mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Closer still
This commit is contained in:
parent
65c28ca821
commit
3a05219c59
3 changed files with 68 additions and 34 deletions
|
@ -89,8 +89,7 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
|
||||||
entityPosition = entityPosition - (entityProperties.getRotation() * (adjustPos * entityProperties.getDimensions()));
|
entityPosition = entityPosition - (entityProperties.getRotation() * (adjustPos * entityProperties.getDimensions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'true' for Entity ID:" << entityItemID;
|
enableEntityHighlight(entityItemID);
|
||||||
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(true);
|
|
||||||
|
|
||||||
AABox boundingBox = AABox(entityPosition - (entityDimensions / 2.0f), entityDimensions * 2.0f);
|
AABox boundingBox = AABox(entityPosition - (entityDimensions / 2.0f), entityDimensions * 2.0f);
|
||||||
|
|
||||||
|
@ -99,8 +98,7 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
|
||||||
|
|
||||||
|
|
||||||
if (!_currentEntityWithContextOverlay.isNull() && _currentEntityWithContextOverlay != entityItemID) {
|
if (!_currentEntityWithContextOverlay.isNull() && _currentEntityWithContextOverlay != entityItemID) {
|
||||||
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << _currentEntityWithContextOverlay;
|
disableEntityHighlight(_currentEntityWithContextOverlay);
|
||||||
qApp->getEntities()->getTree()->findEntityByEntityItemID(_currentEntityWithContextOverlay)->setShouldHighlight(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the cached "Current Entity with Context Overlay" variable
|
// Update the cached "Current Entity with Context Overlay" variable
|
||||||
|
@ -169,8 +167,7 @@ bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityIt
|
||||||
if (_contextOverlayID != UNKNOWN_OVERLAY_ID) {
|
if (_contextOverlayID != UNKNOWN_OVERLAY_ID) {
|
||||||
qCDebug(context_overlay) << "Destroying Context Overlay on top of entity with ID: " << entityItemID;
|
qCDebug(context_overlay) << "Destroying Context Overlay on top of entity with ID: " << entityItemID;
|
||||||
if (!_currentEntityWithContextOverlay.isNull() && _currentEntityWithContextOverlay != entityItemID) {
|
if (!_currentEntityWithContextOverlay.isNull() && _currentEntityWithContextOverlay != entityItemID) {
|
||||||
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << _currentEntityWithContextOverlay;
|
disableEntityHighlight(_currentEntityWithContextOverlay);
|
||||||
qApp->getEntities()->getTree()->findEntityByEntityItemID(_currentEntityWithContextOverlay)->setShouldHighlight(false);
|
|
||||||
}
|
}
|
||||||
setCurrentEntityWithContextOverlay(QUuid());
|
setCurrentEntityWithContextOverlay(QUuid());
|
||||||
_entityMarketplaceID.clear();
|
_entityMarketplaceID.clear();
|
||||||
|
@ -218,15 +215,13 @@ void ContextOverlayInterface::contextOverlays_hoverLeaveOverlay(const OverlayID&
|
||||||
|
|
||||||
void ContextOverlayInterface::contextOverlays_hoverEnterEntity(const EntityItemID& entityID, const PointerEvent& event) {
|
void ContextOverlayInterface::contextOverlays_hoverEnterEntity(const EntityItemID& entityID, const PointerEvent& event) {
|
||||||
if (contextOverlayFilterPassed(entityID)) {
|
if (contextOverlayFilterPassed(entityID)) {
|
||||||
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'true' for Entity ID:" << entityID;
|
enableEntityHighlight(entityID);
|
||||||
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityID)->setShouldHighlight(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextOverlayInterface::contextOverlays_hoverLeaveEntity(const EntityItemID& entityID, const PointerEvent& event) {
|
void ContextOverlayInterface::contextOverlays_hoverLeaveEntity(const EntityItemID& entityID, const PointerEvent& event) {
|
||||||
if (_currentEntityWithContextOverlay != entityID) {
|
if (_currentEntityWithContextOverlay != entityID) {
|
||||||
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << entityID;
|
disableEntityHighlight(entityID);
|
||||||
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityID)->setShouldHighlight(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,3 +240,13 @@ void ContextOverlayInterface::openMarketplace() {
|
||||||
_isInMarketplaceInspectionMode = true;
|
_isInMarketplaceInspectionMode = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContextOverlayInterface::enableEntityHighlight(const EntityItemID& entityItemID) {
|
||||||
|
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'true' for Entity ID:" << entityItemID;
|
||||||
|
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextOverlayInterface::disableEntityHighlight(const EntityItemID& entityItemID) {
|
||||||
|
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << entityItemID;
|
||||||
|
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(false);
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public slots:
|
||||||
void contextOverlays_hoverLeaveOverlay(const OverlayID& overlayID, const PointerEvent& event);
|
void contextOverlays_hoverLeaveOverlay(const OverlayID& overlayID, const PointerEvent& event);
|
||||||
void contextOverlays_hoverEnterEntity(const EntityItemID& entityID, const PointerEvent& event);
|
void contextOverlays_hoverEnterEntity(const EntityItemID& entityID, const PointerEvent& event);
|
||||||
void contextOverlays_hoverLeaveEntity(const EntityItemID& entityID, const PointerEvent& event);
|
void contextOverlays_hoverLeaveEntity(const EntityItemID& entityID, const PointerEvent& event);
|
||||||
|
bool contextOverlayFilterPassed(const EntityItemID& entityItemID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _verboseLogging { true };
|
bool _verboseLogging { true };
|
||||||
|
@ -74,7 +75,8 @@ private:
|
||||||
void openMarketplace();
|
void openMarketplace();
|
||||||
bool _isInMarketplaceInspectionMode { false };
|
bool _isInMarketplaceInspectionMode { false };
|
||||||
|
|
||||||
bool contextOverlayFilterPassed(const EntityItemID& entityItemID);
|
void enableEntityHighlight(const EntityItemID& entityItemID);
|
||||||
|
void disableEntityHighlight(const EntityItemID& entityItemID);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ContextOverlayInterface_h
|
#endif // hifi_ContextOverlayInterface_h
|
||||||
|
|
|
@ -187,7 +187,8 @@ var DEFAULT_GRABBABLE_DATA = {
|
||||||
var USE_BLACKLIST = true;
|
var USE_BLACKLIST = true;
|
||||||
var blacklist = [];
|
var blacklist = [];
|
||||||
|
|
||||||
var potentialEntityWithContextOverlay = false;
|
var hoveredEntityID = false;
|
||||||
|
var contextOverlayTimer = false;
|
||||||
var entityWithContextOverlay = false;
|
var entityWithContextOverlay = false;
|
||||||
var contextualHand = -1;
|
var contextualHand = -1;
|
||||||
|
|
||||||
|
@ -2231,28 +2232,54 @@ function MyController(hand) {
|
||||||
entityPropertiesCache.addEntity(rayPickInfo.entityID);
|
entityPropertiesCache.addEntity(rayPickInfo.entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rayPickInfo.entityID && !entityWithContextOverlay) {
|
if (rayPickInfo.entityID) {
|
||||||
Script.setTimeout(function () {
|
if (hoveredEntityID !== rayPickInfo.entityID) {
|
||||||
if (rayPickInfo.entityID === potentialEntityWithContextOverlay &&
|
pointerEvent = {
|
||||||
!entityWithContextOverlay
|
type: "Move",
|
||||||
&& contextualHand !== -1) {
|
id: this.hand + 1, // 0 is reserved for hardware mouse
|
||||||
var pointerEvent = {
|
pos2D: projectOntoEntityXYPlane(entity, rayPickInfo.intersection),
|
||||||
type: "Move",
|
pos3D: rayPickInfo.intersection,
|
||||||
id: contextualHand + 1, // 0 is reserved for hardware mouse
|
normal: rayPickInfo.normal,
|
||||||
pos2D: projectOntoEntityXYPlane(rayPickInfo.entityID, rayPickInfo.intersection),
|
direction: rayPickInfo.searchRay.direction,
|
||||||
pos3D: rayPickInfo.intersection,
|
button: "None"
|
||||||
normal: rayPickInfo.normal,
|
};
|
||||||
direction: rayPickInfo.searchRay.direction,
|
|
||||||
button: "Secondary"
|
if (hoveredEntityID) {
|
||||||
};
|
Entities.sendHoverLeaveEntity(hoveredEntityID, pointerEvent);
|
||||||
if (ContextOverlay.createOrDestroyContextOverlay(rayPickInfo.entityID, pointerEvent)) {
|
|
||||||
entityWithContextOverlay = rayPickInfo.entityID;
|
|
||||||
potentialEntityWithContextOverlay = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 500);
|
hoveredEntityID = rayPickInfo.entityID;
|
||||||
contextualHand = this.hand;
|
Entities.sendHoverEnterEntity(hoveredEntityID, pointerEvent);
|
||||||
potentialEntityWithContextOverlay = rayPickInfo.entityID;
|
}
|
||||||
|
|
||||||
|
if (contextOverlayTimer && rayPickInfo.entityID != hoveredEntityID) {
|
||||||
|
Script.clearTimeout(contextOverlayTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we already have a context overlay, we don't want to move it to
|
||||||
|
// another entity while we're searching.
|
||||||
|
if (!entityWithContextOverlay) {
|
||||||
|
contextOverlayTimer = Script.setTimeout(function () {
|
||||||
|
if (rayPickInfo.entityID === hoveredEntityID &&
|
||||||
|
!entityWithContextOverlay
|
||||||
|
&& contextualHand !== -1) {
|
||||||
|
var pointerEvent = {
|
||||||
|
type: "Move",
|
||||||
|
id: contextualHand + 1, // 0 is reserved for hardware mouse
|
||||||
|
pos2D: projectOntoEntityXYPlane(rayPickInfo.entityID, rayPickInfo.intersection),
|
||||||
|
pos3D: rayPickInfo.intersection,
|
||||||
|
normal: rayPickInfo.normal,
|
||||||
|
direction: rayPickInfo.searchRay.direction,
|
||||||
|
button: "Secondary"
|
||||||
|
};
|
||||||
|
if (ContextOverlay.createOrDestroyContextOverlay(rayPickInfo.entityID, pointerEvent)) {
|
||||||
|
entityWithContextOverlay = rayPickInfo.entityID;
|
||||||
|
hoveredEntityID = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contextOverlayTimer = false;
|
||||||
|
}, 500);
|
||||||
|
contextualHand = this.hand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var candidateHotSpotEntities = Entities.findEntities(handPosition, MAX_EQUIP_HOTSPOT_RADIUS);
|
var candidateHotSpotEntities = Entities.findEntities(handPosition, MAX_EQUIP_HOTSPOT_RADIUS);
|
||||||
|
@ -3503,7 +3530,7 @@ function MyController(hand) {
|
||||||
if (entityWithContextOverlay) {
|
if (entityWithContextOverlay) {
|
||||||
ContextOverlay.destroyContextOverlay(entityWithContextOverlay);
|
ContextOverlay.destroyContextOverlay(entityWithContextOverlay);
|
||||||
entityWithContextOverlay = false;
|
entityWithContextOverlay = false;
|
||||||
potentialEntityWithContextOverlay = false;
|
hoveredEntityID = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInEditMode()) {
|
if (isInEditMode()) {
|
||||||
|
|
Loading…
Reference in a new issue