mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:36:56 +02:00
Don't highlight entity you're inside unless you laser it
This commit is contained in:
parent
d64e3aca55
commit
9b7197cf3f
1 changed files with 19 additions and 12 deletions
|
@ -452,9 +452,8 @@
|
||||||
return rootEntityID;
|
return rootEntityID;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCameraOutsideEntity(entityID) {
|
function isCameraOutsideEntity(entityID, entityPosition) {
|
||||||
var cameraPosition,
|
var cameraPosition,
|
||||||
grabPosition,
|
|
||||||
pickRay,
|
pickRay,
|
||||||
PRECISION_PICKING = true,
|
PRECISION_PICKING = true,
|
||||||
NO_EXCLUDE_IDS = [],
|
NO_EXCLUDE_IDS = [],
|
||||||
|
@ -462,11 +461,10 @@
|
||||||
intersection;
|
intersection;
|
||||||
|
|
||||||
cameraPosition = Camera.position;
|
cameraPosition = Camera.position;
|
||||||
grabPosition = side === LEFT_HAND ? MyAvatar.getLeftPalmPosition() : MyAvatar.getRightPalmPosition();
|
|
||||||
pickRay = {
|
pickRay = {
|
||||||
origin: cameraPosition,
|
origin: cameraPosition,
|
||||||
direction: Vec3.normalize(Vec3.subtract(grabPosition, cameraPosition)),
|
direction: Vec3.normalize(Vec3.subtract(entityPosition, cameraPosition)),
|
||||||
length: Vec3.distance(grabPosition, cameraPosition)
|
length: Vec3.distance(entityPosition, cameraPosition)
|
||||||
};
|
};
|
||||||
intersection = Entities.findRayIntersection(pickRay, PRECISION_PICKING, [entityID], NO_EXCLUDE_IDS, VISIBLE_ONLY);
|
intersection = Entities.findRayIntersection(pickRay, PRECISION_PICKING, [entityID], NO_EXCLUDE_IDS, VISIBLE_ONLY);
|
||||||
|
|
||||||
|
@ -894,7 +892,8 @@
|
||||||
|
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
var showUI,
|
var isTriggerPressed,
|
||||||
|
showUI,
|
||||||
previousState = editorState,
|
previousState = editorState,
|
||||||
doUpdateState,
|
doUpdateState,
|
||||||
color;
|
color;
|
||||||
|
@ -902,11 +901,12 @@
|
||||||
intersection = getIntersection();
|
intersection = getIntersection();
|
||||||
isTriggerClicked = hand.triggerClicked();
|
isTriggerClicked = hand.triggerClicked();
|
||||||
isGripClicked = hand.gripClicked();
|
isGripClicked = hand.gripClicked();
|
||||||
|
isTriggerPressed = hand.triggerPressed();
|
||||||
|
|
||||||
// Hide UI if hand is intersecting entity and camera is outside entity, or it hand is intersecting stretch handle.
|
// Hide UI if hand is intersecting entity and camera is outside entity, or it hand is intersecting stretch handle.
|
||||||
if (dominantHand !== side) {
|
if (dominantHand !== side) {
|
||||||
showUI = !intersection.handIntersected
|
showUI = !intersection.handIntersected || (intersection.entityID !== null
|
||||||
|| (intersection.entityID !== null && !isCameraOutsideEntity(intersection.entityID));
|
&& !isCameraOutsideEntity(intersection.entityID, intersection.intersection));
|
||||||
if (showUI !== isUIVisible) {
|
if (showUI !== isUIVisible) {
|
||||||
isUIVisible = !isUIVisible;
|
isUIVisible = !isUIVisible;
|
||||||
ui.setVisible(isUIVisible);
|
ui.setVisible(isUIVisible);
|
||||||
|
@ -924,9 +924,13 @@
|
||||||
break;
|
break;
|
||||||
case EDITOR_SEARCHING:
|
case EDITOR_SEARCHING:
|
||||||
if (hand.valid()
|
if (hand.valid()
|
||||||
&& (!intersection.entityID || !(intersection.editableEntity || toolSelected === TOOL_PICK_COLOR))
|
|
||||||
&& !(intersection.overlayID && !wasTriggerClicked && isTriggerClicked
|
&& !(intersection.overlayID && !wasTriggerClicked && isTriggerClicked
|
||||||
&& otherEditor.isHandle(intersection.overlayID))) {
|
&& otherEditor.isHandle(intersection.overlayID))
|
||||||
|
&& !(intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR)
|
||||||
|
&& (wasTriggerClicked || !isTriggerClicked) && !isAutoGrab
|
||||||
|
&& (isCameraOutsideEntity(intersection.entityID, intersection.intersection) || isTriggerPressed))
|
||||||
|
&& !(intersection.entityID && (intersection.editableEntity || toolSelected === TOOL_PICK_COLOR)
|
||||||
|
&& (!wasTriggerClicked || isAutoGrab) && isTriggerClicked)) {
|
||||||
// No transition.
|
// No transition.
|
||||||
updateState();
|
updateState();
|
||||||
updateTool();
|
updateTool();
|
||||||
|
@ -940,7 +944,8 @@
|
||||||
rootEntityID = otherEditor.rootEntityID();
|
rootEntityID = otherEditor.rootEntityID();
|
||||||
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
|
||||||
|
&& (isCameraOutsideEntity(intersection.entityID, intersection.intersection) || isTriggerPressed)) {
|
||||||
intersectedEntityID = intersection.entityID;
|
intersectedEntityID = intersection.entityID;
|
||||||
rootEntityID = Entities.rootOf(intersectedEntityID);
|
rootEntityID = Entities.rootOf(intersectedEntityID);
|
||||||
setState(EDITOR_HIGHLIGHTING);
|
setState(EDITOR_HIGHLIGHTING);
|
||||||
|
@ -991,6 +996,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)
|
||||||
|
&& (isCameraOutsideEntity(intersection.entityID, intersection.intersection) || isTriggerPressed)
|
||||||
&& !(!wasTriggerClicked && isTriggerClicked
|
&& !(!wasTriggerClicked && isTriggerClicked
|
||||||
&& (!otherEditor.isEditing(rootEntityID) || toolSelected !== TOOL_SCALE))
|
&& (!otherEditor.isEditing(rootEntityID) || toolSelected !== TOOL_SCALE))
|
||||||
&& !(!wasTriggerClicked && isTriggerClicked && intersection.overlayID
|
&& !(!wasTriggerClicked && isTriggerClicked && intersection.overlayID
|
||||||
|
@ -1070,7 +1076,8 @@
|
||||||
} else {
|
} else {
|
||||||
setState(EDITOR_GRABBING);
|
setState(EDITOR_GRABBING);
|
||||||
}
|
}
|
||||||
} else if (!intersection.entityID || !intersection.editableEntity) {
|
} else if (!intersection.entityID || !intersection.editableEntity
|
||||||
|
|| (!isCameraOutsideEntity(intersection.entityID, intersection.intersection) && !isTriggerPressed)) {
|
||||||
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!");
|
||||||
|
|
Loading…
Reference in a new issue