mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:28:37 +02:00
Simplify trigger click usage
This commit is contained in:
parent
a94b2b367b
commit
6d90b6d0fd
1 changed files with 20 additions and 17 deletions
|
@ -302,6 +302,8 @@
|
||||||
highlightedEntityID = null, // Root entity of highlighted entity set.
|
highlightedEntityID = null, // Root entity of highlighted entity set.
|
||||||
wasScaleTool = false,
|
wasScaleTool = false,
|
||||||
isOtherEditorEditingEntityID = false,
|
isOtherEditorEditingEntityID = false,
|
||||||
|
isTriggerClicked = false,
|
||||||
|
wasTriggerClicked = false,
|
||||||
isGripClicked = false,
|
isGripClicked = false,
|
||||||
wasGripClicked = false,
|
wasGripClicked = false,
|
||||||
hoveredOverlayID = null,
|
hoveredOverlayID = null,
|
||||||
|
@ -775,6 +777,7 @@
|
||||||
doUpdateState;
|
doUpdateState;
|
||||||
|
|
||||||
intersection = getIntersection();
|
intersection = getIntersection();
|
||||||
|
isTriggerClicked = hand.triggerClicked();
|
||||||
isGripClicked = hand.gripClicked();
|
isGripClicked = hand.gripClicked();
|
||||||
|
|
||||||
// State update.
|
// State update.
|
||||||
|
@ -788,7 +791,7 @@
|
||||||
break;
|
break;
|
||||||
case EDITOR_SEARCHING:
|
case EDITOR_SEARCHING:
|
||||||
if (hand.valid() && (!intersection.entityID || !intersection.editableEntity)
|
if (hand.valid() && (!intersection.entityID || !intersection.editableEntity)
|
||||||
&& !(intersection.overlayID && hand.triggerClicked() && otherEditor.isHandle(intersection.overlayID))) {
|
&& !(intersection.overlayID && isTriggerClicked && otherEditor.isHandle(intersection.overlayID))) {
|
||||||
// No transition.
|
// No transition.
|
||||||
updateState();
|
updateState();
|
||||||
updateTool();
|
updateTool();
|
||||||
|
@ -796,14 +799,14 @@
|
||||||
}
|
}
|
||||||
if (!hand.valid()) {
|
if (!hand.valid()) {
|
||||||
setState(EDITOR_IDLE);
|
setState(EDITOR_IDLE);
|
||||||
} else if (intersection.overlayID && hand.triggerClicked()
|
} else if (intersection.overlayID && isTriggerClicked
|
||||||
&& otherEditor.isHandle(intersection.overlayID)) {
|
&& otherEditor.isHandle(intersection.overlayID)) {
|
||||||
highlightedEntityID = otherEditor.rootEntityID();
|
highlightedEntityID = otherEditor.rootEntityID();
|
||||||
setState(EDITOR_HANDLE_SCALING);
|
setState(EDITOR_HANDLE_SCALING);
|
||||||
} else if (intersection.entityID && intersection.editableEntity && !hand.triggerClicked()) {
|
} else if (intersection.entityID && intersection.editableEntity && !isTriggerClicked) {
|
||||||
highlightedEntityID = Entities.rootOf(intersection.entityID);
|
highlightedEntityID = Entities.rootOf(intersection.entityID);
|
||||||
setState(EDITOR_HIGHLIGHTING);
|
setState(EDITOR_HIGHLIGHTING);
|
||||||
} else if (intersection.entityID && intersection.editableEntity && hand.triggerClicked()) {
|
} else if (intersection.entityID && intersection.editableEntity && isTriggerClicked) {
|
||||||
highlightedEntityID = Entities.rootOf(intersection.entityID);
|
highlightedEntityID = Entities.rootOf(intersection.entityID);
|
||||||
if (otherEditor.isEditing(highlightedEntityID)) {
|
if (otherEditor.isEditing(highlightedEntityID)) {
|
||||||
if (toolSelected !== TOOL_SCALE) {
|
if (toolSelected !== TOOL_SCALE) {
|
||||||
|
@ -821,9 +824,8 @@
|
||||||
case EDITOR_HIGHLIGHTING:
|
case EDITOR_HIGHLIGHTING:
|
||||||
if (hand.valid()
|
if (hand.valid()
|
||||||
&& intersection.entityID && intersection.editableEntity
|
&& intersection.entityID && intersection.editableEntity
|
||||||
&& !(hand.triggerClicked()
|
&& !(isTriggerClicked && (!otherEditor.isEditing(highlightedEntityID) || toolSelected !== TOOL_SCALE))
|
||||||
&& (!otherEditor.isEditing(highlightedEntityID) || toolSelected !== TOOL_SCALE))
|
&& !(isTriggerClicked && intersection.overlayID && otherEditor.isHandle(intersection.overlayID))) {
|
||||||
&& !(hand.triggerClicked() && intersection.overlayID && otherEditor.isHandle(intersection.overlayID))) {
|
|
||||||
// No transition.
|
// No transition.
|
||||||
doUpdateState = false;
|
doUpdateState = false;
|
||||||
if (otherEditor.isEditing(highlightedEntityID) !== isOtherEditorEditingEntityID) {
|
if (otherEditor.isEditing(highlightedEntityID) !== isOtherEditorEditingEntityID) {
|
||||||
|
@ -845,11 +847,11 @@
|
||||||
}
|
}
|
||||||
if (!hand.valid()) {
|
if (!hand.valid()) {
|
||||||
setState(EDITOR_IDLE);
|
setState(EDITOR_IDLE);
|
||||||
} else if (intersection.overlayID && hand.triggerClicked()
|
} else if (intersection.overlayID && isTriggerClicked
|
||||||
&& otherEditor.isHandle(intersection.overlayID)) {
|
&& otherEditor.isHandle(intersection.overlayID)) {
|
||||||
highlightedEntityID = otherEditor.rootEntityID();
|
highlightedEntityID = otherEditor.rootEntityID();
|
||||||
setState(EDITOR_HANDLE_SCALING);
|
setState(EDITOR_HANDLE_SCALING);
|
||||||
} else if (intersection.entityID && intersection.editableEntity && hand.triggerClicked()) {
|
} else if (intersection.entityID && intersection.editableEntity && isTriggerClicked) {
|
||||||
highlightedEntityID = Entities.rootOf(intersection.entityID); // May be a different entityID.
|
highlightedEntityID = Entities.rootOf(intersection.entityID); // May be a different entityID.
|
||||||
if (otherEditor.isEditing(highlightedEntityID)) {
|
if (otherEditor.isEditing(highlightedEntityID)) {
|
||||||
if (toolSelected !== TOOL_SCALE) {
|
if (toolSelected !== TOOL_SCALE) {
|
||||||
|
@ -869,7 +871,7 @@
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_GRABBING:
|
case EDITOR_GRABBING:
|
||||||
if (hand.valid() && hand.triggerClicked() && !isGripClicked) {
|
if (hand.valid() && isTriggerClicked && !isGripClicked) {
|
||||||
// Don't test for intersection.intersected because when scaling with handles intersection may lag behind.
|
// Don't test for intersection.intersected because when scaling with handles intersection may lag behind.
|
||||||
// No transition.
|
// No transition.
|
||||||
if (toolSelected === TOOL_SCALE !== wasScaleTool) {
|
if (toolSelected === TOOL_SCALE !== wasScaleTool) {
|
||||||
|
@ -881,7 +883,7 @@
|
||||||
}
|
}
|
||||||
if (!hand.valid()) {
|
if (!hand.valid()) {
|
||||||
setState(EDITOR_IDLE);
|
setState(EDITOR_IDLE);
|
||||||
} else if (!hand.triggerClicked()) {
|
} else if (!isTriggerClicked) {
|
||||||
if (intersection.entityID && intersection.editableEntity) {
|
if (intersection.entityID && intersection.editableEntity) {
|
||||||
highlightedEntityID = Entities.rootOf(intersection.entityID);
|
highlightedEntityID = Entities.rootOf(intersection.entityID);
|
||||||
setState(EDITOR_HIGHLIGHTING);
|
setState(EDITOR_HIGHLIGHTING);
|
||||||
|
@ -898,7 +900,7 @@
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_DIRECT_SCALING:
|
case EDITOR_DIRECT_SCALING:
|
||||||
if (hand.valid() && hand.triggerClicked()
|
if (hand.valid() && isTriggerClicked
|
||||||
&& (otherEditor.isEditing(highlightedEntityID) || otherEditor.isHandle(intersection.overlayID))) {
|
&& (otherEditor.isEditing(highlightedEntityID) || otherEditor.isHandle(intersection.overlayID))) {
|
||||||
// Don't test for intersection.intersected because when scaling with handles intersection may lag behind.
|
// Don't test for intersection.intersected because when scaling with handles intersection may lag behind.
|
||||||
// Don't test toolSelected === TOOL_SCALE because this is a UI element and so not able to be changed while
|
// Don't test toolSelected === TOOL_SCALE because this is a UI element and so not able to be changed while
|
||||||
|
@ -910,7 +912,7 @@
|
||||||
}
|
}
|
||||||
if (!hand.valid()) {
|
if (!hand.valid()) {
|
||||||
setState(EDITOR_IDLE);
|
setState(EDITOR_IDLE);
|
||||||
} else if (!hand.triggerClicked()) {
|
} else if (!isTriggerClicked) {
|
||||||
if (!intersection.entityID || !intersection.editableEntity) {
|
if (!intersection.entityID || !intersection.editableEntity) {
|
||||||
setState(EDITOR_SEARCHING);
|
setState(EDITOR_SEARCHING);
|
||||||
} else {
|
} else {
|
||||||
|
@ -923,7 +925,7 @@
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDITOR_HANDLE_SCALING:
|
case EDITOR_HANDLE_SCALING:
|
||||||
if (hand.valid() && hand.triggerClicked() && otherEditor.isEditing(highlightedEntityID)) {
|
if (hand.valid() && isTriggerClicked && otherEditor.isEditing(highlightedEntityID)) {
|
||||||
// Don't test for intersection.intersected because when scaling with handles intersection may lag behind.
|
// Don't test for intersection.intersected because when scaling with handles intersection may lag behind.
|
||||||
// Don't test toolSelected === TOOL_SCALE because this is a UI element and so not able to be changed while
|
// Don't test toolSelected === TOOL_SCALE because this is a UI element and so not able to be changed while
|
||||||
// scaling with two hands.
|
// scaling with two hands.
|
||||||
|
@ -934,7 +936,7 @@
|
||||||
}
|
}
|
||||||
if (!hand.valid()) {
|
if (!hand.valid()) {
|
||||||
setState(EDITOR_IDLE);
|
setState(EDITOR_IDLE);
|
||||||
} else if (!hand.triggerClicked()) {
|
} else if (!isTriggerClicked) {
|
||||||
if (!intersection.entityID || !intersection.editableEntity) {
|
if (!intersection.entityID || !intersection.editableEntity) {
|
||||||
setState(EDITOR_SEARCHING);
|
setState(EDITOR_SEARCHING);
|
||||||
} else {
|
} else {
|
||||||
|
@ -948,11 +950,11 @@
|
||||||
break;
|
break;
|
||||||
case EDITOR_CLONING:
|
case EDITOR_CLONING:
|
||||||
// Immediate transition out of state after cloning entities during state entry.
|
// Immediate transition out of state after cloning entities during state entry.
|
||||||
if (hand.valid() && hand.triggerClicked()) {
|
if (hand.valid() && isTriggerClicked) {
|
||||||
setState(EDITOR_GRABBING);
|
setState(EDITOR_GRABBING);
|
||||||
} else if (!hand.valid()) {
|
} else if (!hand.valid()) {
|
||||||
setState(EDITOR_IDLE);
|
setState(EDITOR_IDLE);
|
||||||
} else if (!hand.triggerClicked()) {
|
} else if (!isTriggerClicked) {
|
||||||
if (intersection.entityID && intersection.editableEntity) {
|
if (intersection.entityID && intersection.editableEntity) {
|
||||||
highlightedEntityID = Entities.rootOf(intersection.entityID);
|
highlightedEntityID = Entities.rootOf(intersection.entityID);
|
||||||
setState(EDITOR_HIGHLIGHTING);
|
setState(EDITOR_HIGHLIGHTING);
|
||||||
|
@ -963,6 +965,7 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wasTriggerClicked = isTriggerClicked;
|
||||||
wasGripClicked = isGripClicked;
|
wasGripClicked = isGripClicked;
|
||||||
|
|
||||||
if (DEBUG && editorState !== previousState) {
|
if (DEBUG && editorState !== previousState) {
|
||||||
|
|
Loading…
Reference in a new issue