WHYYYY DOESN'T THIS WORK

This commit is contained in:
Zach Fox 2017-07-26 16:12:54 -07:00
parent 1336a59b6c
commit 39cb0bc357
2 changed files with 35 additions and 21 deletions

View file

@ -242,11 +242,15 @@ void ContextOverlayInterface::openMarketplace() {
}
void ContextOverlayInterface::enableEntityHighlight(const EntityItemID& entityItemID) {
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'true' for Entity ID:" << entityItemID;
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(true);
if (!qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->getShouldHighlight()) {
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);
if (qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->getShouldHighlight()) {
qCDebug(context_overlay) << "Setting 'shouldHighlight' to 'false' for Entity ID:" << entityItemID;
qApp->getEntities()->getTree()->findEntityByEntityItemID(entityItemID)->setShouldHighlight(false);
}
}

View file

@ -2236,18 +2236,22 @@ function MyController(hand) {
entityPropertiesCache.addEntity(rayPickInfo.entityID);
}
pointerEvent = {
type: "Move",
id: this.hand + 1, // 0 is reserved for hardware mouse
pos2D: projectOntoEntityXYPlane(rayPickInfo.entityID, rayPickInfo.intersection),
pos3D: rayPickInfo.intersection,
normal: rayPickInfo.normal,
direction: rayPickInfo.searchRay.direction,
button: "None"
};
if (rayPickInfo.entityID) {
print("ZRF: " + hoveredEntityID);
if (hoveredEntityID !== rayPickInfo.entityID) {
pointerEvent = {
type: "Move",
id: this.hand + 1, // 0 is reserved for hardware mouse
pos2D: projectOntoEntityXYPlane(entity, rayPickInfo.intersection),
pos3D: rayPickInfo.intersection,
normal: rayPickInfo.normal,
direction: rayPickInfo.searchRay.direction,
button: "None"
};
if (contextOverlayTimer) {
Script.clearTimeout(contextOverlayTimer);
contextOverlayTimer = false;
}
if (hoveredEntityID) {
Entities.sendHoverLeaveEntity(hoveredEntityID, pointerEvent);
}
@ -2255,17 +2259,14 @@ function MyController(hand) {
Entities.sendHoverEnterEntity(hoveredEntityID, pointerEvent);
}
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) {
if (!entityWithContextOverlay && !contextOverlayTimer) {
contextOverlayTimer = Script.setTimeout(function () {
if (rayPickInfo.entityID === hoveredEntityID &&
!entityWithContextOverlay
&& contextualHand !== -1) {
!entityWithContextOverlay &&
contextualHand !== -1 &&
contextOverlayTimer) {
var pointerEvent = {
type: "Move",
id: contextualHand + 1, // 0 is reserved for hardware mouse
@ -2284,6 +2285,15 @@ function MyController(hand) {
}, 500);
contextualHand = this.hand;
}
} else {
if (hoveredEntityID) {
Entities.sendHoverLeaveEntity(hoveredEntityID, pointerEvent);
hoveredEntityID = false;
}
if (contextOverlayTimer) {
Script.clearTimeout(contextOverlayTimer);
contextOverlayTimer = false;
}
}
var candidateHotSpotEntities = Entities.findEntities(handPosition, MAX_EQUIP_HOTSPOT_RADIUS);