mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:36:38 +02:00
Corrections
This commit is contained in:
parent
ee3900be4f
commit
536bf6f81d
2 changed files with 14 additions and 22 deletions
|
@ -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,8 +121,7 @@ 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;
|
||||||
|
@ -133,8 +132,7 @@ 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;
|
||||||
|
@ -145,15 +143,12 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,8 +180,7 @@ 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)));
|
||||||
}
|
}
|
||||||
|
@ -229,12 +223,10 @@ void LaserPointer::update() {
|
||||||
float distance = _laserLength > 0.0f ? _laserLength : prevRayPickResult.distance;
|
float distance = _laserLength > 0.0f ? _laserLength : prevRayPickResult.distance;
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue