mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
LaserPointer: made _objectLockEnd into a struct
This commit is contained in:
parent
3b15897b12
commit
41c6261b74
2 changed files with 19 additions and 12 deletions
|
@ -119,23 +119,23 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
|
||||||
qApp->getOverlays().editOverlay(renderState.getStartID(), startProps);
|
qApp->getOverlays().editOverlay(renderState.getStartID(), startProps);
|
||||||
}
|
}
|
||||||
glm::vec3 endVec;
|
glm::vec3 endVec;
|
||||||
if (((defaultState || !_lockEnd) && _objectLockEnd.first.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 (!_objectLockEnd.first.isNull()) {
|
if (!_lockEndObject.id.isNull()) {
|
||||||
glm::vec3 pos;
|
glm::vec3 pos;
|
||||||
glm::quat rot;
|
glm::quat rot;
|
||||||
glm::vec3 dim;
|
glm::vec3 dim;
|
||||||
glm::vec3 registrationPoint;
|
glm::vec3 registrationPoint;
|
||||||
if (_objectLockEnd.second) {
|
if (_lockEndObject.isOverlay) {
|
||||||
pos = vec3FromVariant(qApp->getOverlays().getProperty(_objectLockEnd.first, "position").value);
|
pos = vec3FromVariant(qApp->getOverlays().getProperty(_lockEndObject.id, "position").value);
|
||||||
rot = quatFromVariant(qApp->getOverlays().getProperty(_objectLockEnd.first, "rotation").value);
|
rot = quatFromVariant(qApp->getOverlays().getProperty(_lockEndObject.id, "rotation").value);
|
||||||
dim = vec3FromVariant(qApp->getOverlays().getProperty(_objectLockEnd.first, "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(_objectLockEnd.first);
|
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 * _offsetMat;
|
glm::mat4 finalPosAndRotMat = entityMat * _lockEndObject.offsetMat;
|
||||||
pos = extractTranslation(finalPosAndRotMat);
|
pos = extractTranslation(finalPosAndRotMat);
|
||||||
rot = glmExtractRotation(finalPosAndRotMat);
|
rot = glmExtractRotation(finalPosAndRotMat);
|
||||||
dim = props.getDimensions();
|
dim = props.getDimensions();
|
||||||
|
@ -211,7 +211,7 @@ void LaserPointer::update() {
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
RayPickResult prevRayPickResult = qApp->getRayPickManager().getPrevRayPickResult(_rayPickUID);
|
RayPickResult prevRayPickResult = qApp->getRayPickManager().getPrevRayPickResult(_rayPickUID);
|
||||||
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 || !_objectLockEnd.first.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;
|
||||||
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);
|
||||||
|
@ -237,8 +237,9 @@ void LaserPointer::setLaserLength(const float laserLength) {
|
||||||
|
|
||||||
void LaserPointer::setLockEndUUID(QUuid objectID, const bool isOverlay, const glm::mat4& offsetMat) {
|
void LaserPointer::setLockEndUUID(QUuid objectID, const bool isOverlay, const glm::mat4& offsetMat) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_objectLockEnd = std::pair<QUuid, bool>(objectID, isOverlay);
|
_lockEndObject.id = objectID;
|
||||||
_offsetMat = offsetMat;
|
_lockEndObject.isOverlay;
|
||||||
|
_lockEndObject.offsetMat = offsetMat;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
|
|
||||||
class RayPickResult;
|
class RayPickResult;
|
||||||
|
|
||||||
|
struct LockEndObject {
|
||||||
|
QUuid id {QUuid()};
|
||||||
|
bool isOverlay {false};
|
||||||
|
glm::mat4 offsetMat {glm::mat4()};
|
||||||
|
};
|
||||||
|
|
||||||
class RenderState {
|
class RenderState {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -91,8 +97,8 @@ private:
|
||||||
bool _centerEndY;
|
bool _centerEndY;
|
||||||
bool _lockEnd;
|
bool _lockEnd;
|
||||||
bool _distanceScaleEnd;
|
bool _distanceScaleEnd;
|
||||||
|
LockEndObject _lockEndObject;
|
||||||
glm::mat4 _offsetMat;
|
glm::mat4 _offsetMat;
|
||||||
std::pair<QUuid, bool> _objectLockEnd { std::pair<QUuid, bool>(QUuid(), false)};
|
|
||||||
|
|
||||||
const QUuid _rayPickUID;
|
const QUuid _rayPickUID;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue