mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 13:33:27 +02:00
Corrections
This commit is contained in:
parent
6fb47eef85
commit
ee3900be4f
8 changed files with 30 additions and 24 deletions
|
@ -7,7 +7,7 @@
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
////
|
//
|
||||||
#include "LaserPointer.h"
|
#include "LaserPointer.h"
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
#include "RayPickScriptingInterface.h"
|
#include "RayPickScriptingInterface.h"
|
||||||
|
|
||||||
LaserPointer::LaserPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates,
|
LaserPointer::LaserPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates,
|
||||||
const bool faceAvatar, const bool centerEndY, const bool lockEnd, const bool distanceScaleEnd, const bool scaleWithAvatar, const bool enabled) :
|
const bool faceAvatar, const bool centerEndY, const bool lockEnd, const bool distanceScaleEnd, const bool scaleWithAvatar, const bool enabled) :
|
||||||
_renderingEnabled(enabled),
|
_renderingEnabled(enabled),
|
||||||
_renderStates(renderStates),
|
_renderStates(renderStates),
|
||||||
_defaultRenderStates(defaultRenderStates),
|
_defaultRenderStates(defaultRenderStates),
|
||||||
|
@ -121,7 +121,8 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
|
||||||
glm::vec3 endVec;
|
glm::vec3 endVec;
|
||||||
if (((defaultState || !_lockEnd) && _lockEndObject.id.isNull()) || type == IntersectionType::HUD) {
|
if (((defaultState || !_lockEnd) && _lockEndObject.id.isNull()) || type == IntersectionType::HUD) {
|
||||||
endVec = pickRay.origin + pickRay.direction * distance;
|
endVec = pickRay.origin + pickRay.direction * distance;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (!_lockEndObject.id.isNull()) {
|
if (!_lockEndObject.id.isNull()) {
|
||||||
glm::vec3 pos;
|
glm::vec3 pos;
|
||||||
glm::quat rot;
|
glm::quat rot;
|
||||||
|
@ -132,7 +133,8 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
|
||||||
rot = quatFromVariant(qApp->getOverlays().getProperty(_lockEndObject.id, "rotation").value);
|
rot = quatFromVariant(qApp->getOverlays().getProperty(_lockEndObject.id, "rotation").value);
|
||||||
dim = vec3FromVariant(qApp->getOverlays().getProperty(_lockEndObject.id, "dimensions").value);
|
dim = vec3FromVariant(qApp->getOverlays().getProperty(_lockEndObject.id, "dimensions").value);
|
||||||
registrationPoint = glm::vec3(0.5f);
|
registrationPoint = glm::vec3(0.5f);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
EntityItemProperties props = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(_lockEndObject.id);
|
EntityItemProperties props = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(_lockEndObject.id);
|
||||||
glm::mat4 entityMat = createMatFromQuatAndPos(props.getRotation(), props.getPosition());
|
glm::mat4 entityMat = createMatFromQuatAndPos(props.getRotation(), props.getPosition());
|
||||||
glm::mat4 finalPosAndRotMat = entityMat * _lockEndObject.offsetMat;
|
glm::mat4 finalPosAndRotMat = entityMat * _lockEndObject.offsetMat;
|
||||||
|
@ -143,17 +145,20 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
|
||||||
}
|
}
|
||||||
const glm::vec3 DEFAULT_REGISTRATION_POINT = glm::vec3(0.5f);
|
const glm::vec3 DEFAULT_REGISTRATION_POINT = glm::vec3(0.5f);
|
||||||
endVec = pos + rot * (dim * (DEFAULT_REGISTRATION_POINT - registrationPoint));
|
endVec = pos + rot * (dim * (DEFAULT_REGISTRATION_POINT - registrationPoint));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (type == IntersectionType::ENTITY) {
|
if (type == IntersectionType::ENTITY) {
|
||||||
endVec = DependencyManager::get<EntityScriptingInterface>()->getEntityTransform(objectID)[3];
|
endVec = DependencyManager::get<EntityScriptingInterface>()->getEntityTransform(objectID)[3];
|
||||||
} else if (type == IntersectionType::OVERLAY) {
|
}
|
||||||
|
else if (type == IntersectionType::OVERLAY) {
|
||||||
endVec = vec3FromVariant(qApp->getOverlays().getProperty(objectID, "position").value);
|
endVec = vec3FromVariant(qApp->getOverlays().getProperty(objectID, "position").value);
|
||||||
} else if (type == IntersectionType::AVATAR) {
|
}
|
||||||
|
else if (type == IntersectionType::AVATAR) {
|
||||||
endVec = DependencyManager::get<AvatarHashMap>()->getAvatar(objectID)->getPosition();
|
endVec = DependencyManager::get<AvatarHashMap>()->getAvatar(objectID)->getPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float avatarScale = DependencyManager::get<AvatarManager>()->getMyAvatar()->getAvatarScale();
|
float avatarScale = DependencyManager::get<AvatarManager>()->getMyAvatar()->getAvatarScale();
|
||||||
|
|
||||||
QVariant end = vec3toVariant(endVec);
|
QVariant end = vec3toVariant(endVec);
|
||||||
|
@ -180,7 +185,8 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
|
||||||
}
|
}
|
||||||
if (_centerEndY) {
|
if (_centerEndY) {
|
||||||
endProps.insert("position", end);
|
endProps.insert("position", end);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
glm::vec3 currentUpVector = faceAvatarRotation * Vectors::UP;
|
glm::vec3 currentUpVector = faceAvatarRotation * Vectors::UP;
|
||||||
endProps.insert("position", vec3toVariant(endVec + glm::vec3(currentUpVector.x * 0.5f * dim.y, currentUpVector.y * 0.5f * dim.y, currentUpVector.z * 0.5f * dim.y)));
|
endProps.insert("position", vec3toVariant(endVec + glm::vec3(currentUpVector.x * 0.5f * dim.y, currentUpVector.y * 0.5f * dim.y, currentUpVector.z * 0.5f * dim.y)));
|
||||||
}
|
}
|
||||||
|
@ -221,13 +227,14 @@ void LaserPointer::update() {
|
||||||
if (_renderingEnabled && !_currentRenderState.empty() && _renderStates.find(_currentRenderState) != _renderStates.end() &&
|
if (_renderingEnabled && !_currentRenderState.empty() && _renderStates.find(_currentRenderState) != _renderStates.end() &&
|
||||||
(prevRayPickResult.type != IntersectionType::NONE || _laserLength > 0.0f || !_lockEndObject.id.isNull())) {
|
(prevRayPickResult.type != IntersectionType::NONE || _laserLength > 0.0f || !_lockEndObject.id.isNull())) {
|
||||||
float distance = _laserLength > 0.0f ? _laserLength : prevRayPickResult.distance;
|
float distance = _laserLength > 0.0f ? _laserLength : prevRayPickResult.distance;
|
||||||
qDebug() << &_currentRenderState;
|
|
||||||
updateRenderState(_renderStates[_currentRenderState], prevRayPickResult.type, distance, prevRayPickResult.objectID, prevRayPickResult.searchRay, false);
|
updateRenderState(_renderStates[_currentRenderState], prevRayPickResult.type, distance, prevRayPickResult.objectID, prevRayPickResult.searchRay, false);
|
||||||
disableRenderState(_defaultRenderStates[_currentRenderState].second);
|
disableRenderState(_defaultRenderStates[_currentRenderState].second);
|
||||||
} else if (_renderingEnabled && !_currentRenderState.empty() && _defaultRenderStates.find(_currentRenderState) != _defaultRenderStates.end()) {
|
}
|
||||||
|
else if (_renderingEnabled && !_currentRenderState.empty() && _defaultRenderStates.find(_currentRenderState) != _defaultRenderStates.end()) {
|
||||||
disableRenderState(_renderStates[_currentRenderState]);
|
disableRenderState(_renderStates[_currentRenderState]);
|
||||||
updateRenderState(_defaultRenderStates[_currentRenderState].second, IntersectionType::NONE, _defaultRenderStates[_currentRenderState].first, QUuid(), prevRayPickResult.searchRay, true);
|
updateRenderState(_defaultRenderStates[_currentRenderState].second, IntersectionType::NONE, _defaultRenderStates[_currentRenderState].first, QUuid(), prevRayPickResult.searchRay, true);
|
||||||
} else if (!_currentRenderState.empty()) {
|
}
|
||||||
|
else if (!_currentRenderState.empty()) {
|
||||||
disableRenderState(_renderStates[_currentRenderState]);
|
disableRenderState(_renderStates[_currentRenderState]);
|
||||||
disableRenderState(_defaultRenderStates[_currentRenderState].second);
|
disableRenderState(_defaultRenderStates[_currentRenderState].second);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
class RayPickResult;
|
class RayPickResult;
|
||||||
|
|
||||||
struct LockEndObject {
|
struct LockEndObject {
|
||||||
QUuid id { QUuid() };
|
QUuid id{ QUuid() };
|
||||||
bool isOverlay { false };
|
bool isOverlay{ false };
|
||||||
glm::mat4 offsetMat { glm::mat4() };
|
glm::mat4 offsetMat{ glm::mat4() };
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderState {
|
class RenderState {
|
||||||
|
@ -89,8 +89,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _renderingEnabled;
|
bool _renderingEnabled;
|
||||||
float _laserLength { 0.0f };
|
float _laserLength{ 0.0f };
|
||||||
std::string _currentRenderState { "" };
|
std::string _currentRenderState{ "" };
|
||||||
RenderStateMap _renderStates;
|
RenderStateMap _renderStates;
|
||||||
DefaultRenderStateMap _defaultRenderStates;
|
DefaultRenderStateMap _defaultRenderStates;
|
||||||
bool _faceAvatar;
|
bool _faceAvatar;
|
||||||
|
|
|
@ -113,9 +113,9 @@ void LaserPointerManager::setIncludeItems(const QUuid& uid, const QVector<QUuid>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaserPointerManager::setLockEndUUID(const QUuid& uid, const QUuid& objectID, const bool isOverlay, const glm::mat4& offsetMat) const {
|
void LaserPointerManager::setLockEndUUID(const QUuid& uid, const QUuid& objectID, const bool isOverlay) const {
|
||||||
auto laserPointer = find(uid);
|
auto laserPointer = find(uid);
|
||||||
if (laserPointer) {
|
if (laserPointer) {
|
||||||
laserPointer->setLockEndUUID(objectID, isOverlay, offsetMat);
|
laserPointer->setLockEndUUID(objectID, isOverlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
void setIgnoreItems(const QUuid& uid, const QVector<QUuid>& ignoreEntities) const;
|
void setIgnoreItems(const QUuid& uid, const QVector<QUuid>& ignoreEntities) const;
|
||||||
void setIncludeItems(const QUuid& uid, const QVector<QUuid>& includeEntities) const;
|
void setIncludeItems(const QUuid& uid, const QVector<QUuid>& includeEntities) const;
|
||||||
|
|
||||||
void setLockEndUUID(const QUuid& uid, const QUuid& objectID, const bool isOverlay, const glm::mat4& offsetMat = glm::mat4()) const;
|
void setLockEndUUID(const QUuid& uid, const QUuid& objectID, const bool isOverlay) const;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
////
|
//
|
||||||
|
|
||||||
#include "LaserPointerScriptingInterface.h"
|
#include "LaserPointerScriptingInterface.h"
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ private:
|
||||||
|
|
||||||
float _glow { 0.0 };
|
float _glow { 0.0 };
|
||||||
float _glowWidth { 0.0 };
|
float _glowWidth { 0.0 };
|
||||||
float _glowScale{ 1.0 };
|
float _glowScale { 1.0 };
|
||||||
int _geometryCacheID;
|
int _geometryCacheID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ public:
|
||||||
renderWireCubeInstance(args, batch, glm::vec4(color, 1.0f), pipeline);
|
renderWireCubeInstance(args, batch, glm::vec4(color, 1.0f), pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
// //Dynamic geometry
|
// Dynamic geometry
|
||||||
void renderShape(gpu::Batch& batch, Shape shape);
|
void renderShape(gpu::Batch& batch, Shape shape);
|
||||||
void renderWireShape(gpu::Batch& batch, Shape shape);
|
void renderWireShape(gpu::Batch& batch, Shape shape);
|
||||||
size_t getShapeTriangleCount(Shape shape);
|
size_t getShapeTriangleCount(Shape shape);
|
||||||
|
|
|
@ -150,7 +150,6 @@ Laser = function (side) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(hand) {
|
function update(hand) {
|
||||||
return;
|
|
||||||
var handPosition,
|
var handPosition,
|
||||||
handOrientation,
|
handOrientation,
|
||||||
deltaOrigin,
|
deltaOrigin,
|
||||||
|
|
Loading…
Reference in a new issue