mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-18 23:48:45 +02:00
Merge pull request #12722 from druiz17/fix-entities-outline
fix ContextOverlayInferface highlighing unspecified entities.
This commit is contained in:
commit
5f13df4102
5 changed files with 63 additions and 33 deletions
|
@ -81,26 +81,14 @@ void LaserPointer::editRenderState(const std::string& state, const QVariant& sta
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaserPointer::updateRenderStateOverlay(const OverlayID& id, const QVariant& props) {
|
PickResultPointer LaserPointer::getVisualPickResult(const PickResultPointer& pickResult) {
|
||||||
if (!id.isNull() && props.isValid()) {
|
PickResultPointer visualPickResult = pickResult;
|
||||||
QVariantMap propMap = props.toMap();
|
auto rayPickResult = std::static_pointer_cast<RayPickResult>(visualPickResult);
|
||||||
propMap.remove("visible");
|
IntersectionType type = rayPickResult ? rayPickResult->type : IntersectionType::NONE;
|
||||||
qApp->getOverlays().editOverlay(id, propMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaserPointer::updateRenderState(const RenderState& renderState, const IntersectionType type, float distance, const QUuid& objectID, const PickRay& pickRay, bool defaultState) {
|
if (type != IntersectionType::HUD) {
|
||||||
if (!renderState.getStartID().isNull()) {
|
glm::vec3 endVec;
|
||||||
QVariantMap startProps;
|
PickRay pickRay = rayPickResult ? PickRay(rayPickResult->pickVariant) : PickRay();
|
||||||
startProps.insert("position", vec3toVariant(pickRay.origin));
|
|
||||||
startProps.insert("visible", true);
|
|
||||||
startProps.insert("ignoreRayIntersection", renderState.doesStartIgnoreRays());
|
|
||||||
qApp->getOverlays().editOverlay(renderState.getStartID(), startProps);
|
|
||||||
}
|
|
||||||
glm::vec3 endVec;
|
|
||||||
if (((defaultState || !_lockEnd) && _lockEndObject.id.isNull()) || type == IntersectionType::HUD) {
|
|
||||||
endVec = pickRay.origin + pickRay.direction * distance;
|
|
||||||
} else {
|
|
||||||
if (!_lockEndObject.id.isNull()) {
|
if (!_lockEndObject.id.isNull()) {
|
||||||
glm::vec3 pos;
|
glm::vec3 pos;
|
||||||
glm::quat rot;
|
glm::quat rot;
|
||||||
|
@ -122,17 +110,54 @@ 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 {
|
glm::vec3 direction = endVec - pickRay.origin;
|
||||||
|
float distance = glm::distance(pickRay.origin, endVec);
|
||||||
|
glm::vec3 normalizedDirection = glm::normalize(direction);
|
||||||
|
|
||||||
|
rayPickResult->type = _lockEndObject.isOverlay ? IntersectionType::OVERLAY : IntersectionType::ENTITY;
|
||||||
|
rayPickResult->objectID = _lockEndObject.id;
|
||||||
|
rayPickResult->intersection = endVec;
|
||||||
|
rayPickResult->distance = distance;
|
||||||
|
rayPickResult->surfaceNormal = -normalizedDirection;
|
||||||
|
rayPickResult->pickVariant["direction"] = vec3toVariant(normalizedDirection);
|
||||||
|
} else if (type != IntersectionType::NONE && _lockEnd) {
|
||||||
if (type == IntersectionType::ENTITY) {
|
if (type == IntersectionType::ENTITY) {
|
||||||
endVec = DependencyManager::get<EntityScriptingInterface>()->getEntityTransform(objectID)[3];
|
endVec = DependencyManager::get<EntityScriptingInterface>()->getEntityTransform(rayPickResult->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(rayPickResult->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(rayPickResult->objectID)->getPosition();
|
||||||
}
|
}
|
||||||
|
glm::vec3 direction = endVec - pickRay.origin;
|
||||||
|
float distance = glm::distance(pickRay.origin, endVec);
|
||||||
|
glm::vec3 normalizedDirection = glm::normalize(direction);
|
||||||
|
rayPickResult->intersection = endVec;
|
||||||
|
rayPickResult->distance = distance;
|
||||||
|
rayPickResult->surfaceNormal = -normalizedDirection;
|
||||||
|
rayPickResult->pickVariant["direction"] = vec3toVariant(normalizedDirection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return visualPickResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LaserPointer::updateRenderStateOverlay(const OverlayID& id, const QVariant& props) {
|
||||||
|
if (!id.isNull() && props.isValid()) {
|
||||||
|
QVariantMap propMap = props.toMap();
|
||||||
|
propMap.remove("visible");
|
||||||
|
qApp->getOverlays().editOverlay(id, propMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LaserPointer::updateRenderState(const RenderState& renderState, const IntersectionType type, float distance, const QUuid& objectID, const PickRay& pickRay) {
|
||||||
|
if (!renderState.getStartID().isNull()) {
|
||||||
|
QVariantMap startProps;
|
||||||
|
startProps.insert("position", vec3toVariant(pickRay.origin));
|
||||||
|
startProps.insert("visible", true);
|
||||||
|
startProps.insert("ignoreRayIntersection", renderState.doesStartIgnoreRays());
|
||||||
|
qApp->getOverlays().editOverlay(renderState.getStartID(), startProps);
|
||||||
|
}
|
||||||
|
glm::vec3 endVec = pickRay.origin + pickRay.direction * distance;
|
||||||
|
|
||||||
QVariant end = vec3toVariant(endVec);
|
QVariant end = vec3toVariant(endVec);
|
||||||
if (!renderState.getPathID().isNull()) {
|
if (!renderState.getPathID().isNull()) {
|
||||||
QVariantMap pathProps;
|
QVariantMap pathProps;
|
||||||
|
@ -195,15 +220,15 @@ void LaserPointer::updateVisuals(const PickResultPointer& pickResult) {
|
||||||
IntersectionType type = rayPickResult ? rayPickResult->type : IntersectionType::NONE;
|
IntersectionType type = rayPickResult ? rayPickResult->type : IntersectionType::NONE;
|
||||||
if (_enabled && !_currentRenderState.empty() && _renderStates.find(_currentRenderState) != _renderStates.end() &&
|
if (_enabled && !_currentRenderState.empty() && _renderStates.find(_currentRenderState) != _renderStates.end() &&
|
||||||
(type != IntersectionType::NONE || _laserLength > 0.0f || !_lockEndObject.id.isNull())) {
|
(type != IntersectionType::NONE || _laserLength > 0.0f || !_lockEndObject.id.isNull())) {
|
||||||
PickRay pickRay(rayPickResult->pickVariant);
|
PickRay pickRay = rayPickResult ? PickRay(rayPickResult->pickVariant): PickRay();
|
||||||
QUuid uid = rayPickResult->objectID;
|
QUuid uid = rayPickResult->objectID;
|
||||||
float distance = _laserLength > 0.0f ? _laserLength : rayPickResult->distance;
|
float distance = _laserLength > 0.0f ? _laserLength : rayPickResult->distance;
|
||||||
updateRenderState(_renderStates[_currentRenderState], type, distance, uid, pickRay, false);
|
updateRenderState(_renderStates[_currentRenderState], type, distance, uid, pickRay);
|
||||||
disableRenderState(_defaultRenderStates[_currentRenderState].second);
|
disableRenderState(_defaultRenderStates[_currentRenderState].second);
|
||||||
} else if (_enabled && !_currentRenderState.empty() && _defaultRenderStates.find(_currentRenderState) != _defaultRenderStates.end()) {
|
} else if (_enabled && !_currentRenderState.empty() && _defaultRenderStates.find(_currentRenderState) != _defaultRenderStates.end()) {
|
||||||
disableRenderState(_renderStates[_currentRenderState]);
|
disableRenderState(_renderStates[_currentRenderState]);
|
||||||
PickRay pickRay = rayPickResult ? PickRay(rayPickResult->pickVariant) : PickRay();
|
PickRay pickRay = rayPickResult ? PickRay(rayPickResult->pickVariant) : PickRay();
|
||||||
updateRenderState(_defaultRenderStates[_currentRenderState].second, IntersectionType::NONE, _defaultRenderStates[_currentRenderState].first, QUuid(), pickRay, true);
|
updateRenderState(_defaultRenderStates[_currentRenderState].second, IntersectionType::NONE, _defaultRenderStates[_currentRenderState].first, QUuid(), pickRay);
|
||||||
} else if (!_currentRenderState.empty()) {
|
} else if (!_currentRenderState.empty()) {
|
||||||
disableRenderState(_renderStates[_currentRenderState]);
|
disableRenderState(_renderStates[_currentRenderState]);
|
||||||
disableRenderState(_defaultRenderStates[_currentRenderState].second);
|
disableRenderState(_defaultRenderStates[_currentRenderState].second);
|
||||||
|
@ -386,4 +411,4 @@ glm::vec2 LaserPointer::findPos2D(const PickedObject& pickedObject, const glm::v
|
||||||
default:
|
default:
|
||||||
return glm::vec2(NAN);
|
return glm::vec2(NAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
PointerEvent buildPointerEvent(const PickedObject& target, const PickResultPointer& pickResult, const std::string& button = "", bool hover = true) override;
|
PointerEvent buildPointerEvent(const PickedObject& target, const PickResultPointer& pickResult, const std::string& button = "", bool hover = true) override;
|
||||||
|
|
||||||
|
PickResultPointer getVisualPickResult(const PickResultPointer& pickResult) override;
|
||||||
PickedObject getHoveredObject(const PickResultPointer& pickResult) override;
|
PickedObject getHoveredObject(const PickResultPointer& pickResult) override;
|
||||||
Pointer::Buttons getPressedButtons(const PickResultPointer& pickResult) override;
|
Pointer::Buttons getPressedButtons(const PickResultPointer& pickResult) override;
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ private:
|
||||||
LockEndObject _lockEndObject;
|
LockEndObject _lockEndObject;
|
||||||
|
|
||||||
void updateRenderStateOverlay(const OverlayID& id, const QVariant& props);
|
void updateRenderStateOverlay(const OverlayID& id, const QVariant& props);
|
||||||
void updateRenderState(const RenderState& renderState, const IntersectionType type, float distance, const QUuid& objectID, const PickRay& pickRay, bool defaultState);
|
void updateRenderState(const RenderState& renderState, const IntersectionType type, float distance, const QUuid& objectID, const PickRay& pickRay);
|
||||||
void disableRenderState(const RenderState& renderState);
|
void disableRenderState(const RenderState& renderState);
|
||||||
|
|
||||||
struct TriggerState {
|
struct TriggerState {
|
||||||
|
|
|
@ -68,8 +68,9 @@ void Pointer::update(unsigned int pointerID) {
|
||||||
// This only needs to be a read lock because update won't change any of the properties that can be modified from scripts
|
// This only needs to be a read lock because update won't change any of the properties that can be modified from scripts
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
auto pickResult = getPrevPickResult();
|
auto pickResult = getPrevPickResult();
|
||||||
updateVisuals(pickResult);
|
auto visualPickResult = getVisualPickResult(pickResult);
|
||||||
generatePointerEvents(pointerID, pickResult);
|
updateVisuals(visualPickResult);
|
||||||
|
generatePointerEvents(pointerID, visualPickResult);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ protected:
|
||||||
|
|
||||||
virtual bool shouldHover(const PickResultPointer& pickResult) { return true; }
|
virtual bool shouldHover(const PickResultPointer& pickResult) { return true; }
|
||||||
virtual bool shouldTrigger(const PickResultPointer& pickResult) { return true; }
|
virtual bool shouldTrigger(const PickResultPointer& pickResult) { return true; }
|
||||||
|
virtual PickResultPointer getVisualPickResult(const PickResultPointer& pickResult) { return pickResult; };
|
||||||
|
|
||||||
static const float POINTER_MOVE_DELAY;
|
static const float POINTER_MOVE_DELAY;
|
||||||
static const float TOUCH_PRESS_TO_MOVE_DEADSPOT_SQUARED;
|
static const float TOUCH_PRESS_TO_MOVE_DEADSPOT_SQUARED;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
|
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
|
||||||
DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
|
DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
|
||||||
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
|
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
|
||||||
Picks, makeLaserLockInfo Xform, makeLaserParams, AddressManager, getEntityParents
|
Picks, makeLaserLockInfo Xform, makeLaserParams, AddressManager, getEntityParents, Selection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
@ -467,8 +467,10 @@ Script.include("/~/system/libraries/Xform.js");
|
||||||
Script.clearTimeout(this.contextOverlayTimer);
|
Script.clearTimeout(this.contextOverlayTimer);
|
||||||
}
|
}
|
||||||
this.contextOverlayTimer = false;
|
this.contextOverlayTimer = false;
|
||||||
if (entityID !== this.entityWithContextOverlay) {
|
if (entityID === this.entityWithContextOverlay) {
|
||||||
this.destroyContextOverlay();
|
this.destroyContextOverlay();
|
||||||
|
} else {
|
||||||
|
Selection.removeFromSelectedItemsList("contextOverlayHighlightList", "entity", entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetEntity = this.targetObject.getTargetEntity();
|
var targetEntity = this.targetObject.getTargetEntity();
|
||||||
|
|
Loading…
Reference in a new issue