Fix UI sometimes turning off/on/off as hand enters entity

This commit is contained in:
David Rowe 2017-10-02 19:27:26 +13:00
parent 829cc8e5e6
commit 0bd67d494d
2 changed files with 11 additions and 5 deletions

View file

@ -204,6 +204,10 @@ Hand = function (side) {
} }
if (entityID) { if (entityID) {
intersectionPosition = Entities.getEntityProperties(entityID, "position").position; intersectionPosition = Entities.getEntityProperties(entityID, "position").position;
if (Vec3.distance(palmPosition, intersectionPosition) > NEAR_GRAB_RADIUS) {
intersectionPosition = Vec3.sum(palmPosition,
Vec3.multiply(NEAR_GRAB_RADIUS, Vec3.normalize(Vec3.subtract(intersectionPosition, palmPosition))));
}
} }
} }

View file

@ -930,7 +930,7 @@
// Hide UI if hand is intersecting entity and camera is outside entity, or if hand is intersecting stretch handle. // Hide UI if hand is intersecting entity and camera is outside entity, or if hand is intersecting stretch handle.
if (side !== dominantHand) { if (side !== dominantHand) {
showUI = !intersection.handIntersected || (intersection.entityID !== null showUI = !intersection.handIntersected || (intersection.entityID !== null
&& !isCameraOutsideEntity(intersection.entityID, hand.palmPosition())); && !isCameraOutsideEntity(intersection.entityID, intersection.intersection));
if (showUI !== isUIVisible) { if (showUI !== isUIVisible) {
isUIVisible = !isUIVisible; isUIVisible = !isUIVisible;
ui.setVisible(isUIVisible); ui.setVisible(isUIVisible);
@ -952,7 +952,8 @@
&& otherEditor.isHandle(intersection.overlayID)) && otherEditor.isHandle(intersection.overlayID))
&& !(intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR) && !(intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR)
&& (wasTriggerClicked || !isTriggerClicked) && !isAutoGrab && (wasTriggerClicked || !isTriggerClicked) && !isAutoGrab
&& (isTriggerPressed || isCameraOutsideEntity(intersection.entityID, hand.palmPosition()))) && (isTriggerPressed
|| isCameraOutsideEntity(intersection.entityID, intersection.intersection)))
&& !(intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR) && !(intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR)
&& (!wasTriggerClicked || isAutoGrab) && isTriggerClicked)) { && (!wasTriggerClicked || isAutoGrab) && isTriggerClicked)) {
// No transition. // No transition.
@ -969,7 +970,7 @@
setState(EDITOR_HANDLE_SCALING); setState(EDITOR_HANDLE_SCALING);
} else if (intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR) } else if (intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR)
&& (wasTriggerClicked || !isTriggerClicked) && !isAutoGrab && (wasTriggerClicked || !isTriggerClicked) && !isAutoGrab
&& (isTriggerPressed || isCameraOutsideEntity(intersection.entityID, hand.palmPosition()))) { && (isTriggerPressed || isCameraOutsideEntity(intersection.entityID, intersection.intersection))) {
intersectedEntityID = intersection.entityID; intersectedEntityID = intersection.entityID;
rootEntityID = Entities.rootOf(intersectedEntityID); rootEntityID = Entities.rootOf(intersectedEntityID);
setState(EDITOR_HIGHLIGHTING); setState(EDITOR_HIGHLIGHTING);
@ -1020,7 +1021,7 @@
case EDITOR_HIGHLIGHTING: case EDITOR_HIGHLIGHTING:
if (hand.valid() if (hand.valid()
&& intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR) && intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR)
&& (isTriggerPressed || isCameraOutsideEntity(intersection.entityID, hand.palmPosition())) && (isTriggerPressed || isCameraOutsideEntity(intersection.entityID, intersection.intersection))
&& !(!wasTriggerClicked && isTriggerClicked && !(!wasTriggerClicked && isTriggerClicked
&& (!otherEditor.isEditing(rootEntityID) || toolSelected !== TOOL_SCALE)) && (!otherEditor.isEditing(rootEntityID) || toolSelected !== TOOL_SCALE))
&& !(!wasTriggerClicked && isTriggerClicked && intersection.overlayID && !(!wasTriggerClicked && isTriggerClicked && intersection.overlayID
@ -1100,8 +1101,9 @@
} else { } else {
setState(EDITOR_GRABBING); setState(EDITOR_GRABBING);
} }
} else if (!intersection.entityID || !intersection.editableEntity } else if (!intersection.entityID || !intersection.editableEntity
|| (!isTriggerPressed && !isCameraOutsideEntity(intersection.entityID, hand.palmPosition()))) { || (!isTriggerPressed && !isCameraOutsideEntity(intersection.entityID, intersection.intersection))) {
setState(EDITOR_SEARCHING); setState(EDITOR_SEARCHING);
} else { } else {
log(side, "ERROR: Editor: Unexpected condition B in EDITOR_HIGHLIGHTING!"); log(side, "ERROR: Editor: Unexpected condition B in EDITOR_HIGHLIGHTING!");