Simplify scale-with-handles state handling

This commit is contained in:
David Rowe 2017-07-14 12:22:21 +12:00
parent 7933280d03
commit ee21797fcd

View file

@ -20,7 +20,7 @@
// Application state // Application state
isAppActive = false, isAppActive = false,
isScaleWithHandles = false, isAppScaleWithHandles = false,
VR_EDIT_SETTING = "io.highfidelity.isVREditing", // Note: This constant is duplicated in utils.js. VR_EDIT_SETTING = "io.highfidelity.isVREditing", // Note: This constant is duplicated in utils.js.
@ -768,8 +768,6 @@
handPose, handPose,
intersection = {}, intersection = {},
isScaleWithHandles = false,
isLaserOn = false, isLaserOn = false,
hoveredEntityID = null, hoveredEntityID = null,
@ -822,10 +820,6 @@
otherHand = hand; otherHand = hand;
} }
function setScaleWithHandles(value) {
isScaleWithHandles = value;
}
function getIsEditing(rootEntityID) { function getIsEditing(rootEntityID) {
return isEditing && rootEntityID === selection.rootEntityID(); return isEditing && rootEntityID === selection.rootEntityID();
} }
@ -1089,7 +1083,7 @@
if (isEditing) { if (isEditing) {
// Perform edit. // Perform edit.
doEdit = true; doEdit = true;
} else if (intersection.intersects && intersection.entityID && (!isScaleWithHandles } else if (intersection.intersects && intersection.entityID && (!isAppScaleWithHandles
|| !otherHand.isEditing(Entities.rootOf(intersection.entityID)))) { || !otherHand.isEditing(Entities.rootOf(intersection.entityID)))) {
// Start editing. // Start editing.
if (intersection.entityID !== hoveredEntityID) { if (intersection.entityID !== hoveredEntityID) {
@ -1101,7 +1095,7 @@
laserEditingDistance = laserLength; laserEditingDistance = laserLength;
} }
startEditing(); startEditing();
if (isScaleWithHandles) { if (isAppScaleWithHandles) {
handles.display(selection.rootEntityID(), selection.boundingBox(), selection.count() > 1); handles.display(selection.rootEntityID(), selection.boundingBox(), selection.count() > 1);
} }
} }
@ -1111,7 +1105,7 @@
// Stop editing. // Stop editing.
stopEditing(); stopEditing();
} }
if (isScaleWithHandles) { if (isAppScaleWithHandles) {
otherHand.hoverHandle(intersection.overlayID); otherHand.hoverHandle(intersection.overlayID);
} }
if (intersection.intersects && intersection.entityID) { if (intersection.intersects && intersection.entityID) {
@ -1136,16 +1130,16 @@
function apply() { function apply() {
if (doEdit) { if (doEdit) {
if (otherHand.isEditing(selection.rootEntityID())) { if (otherHand.isEditing(selection.rootEntityID())) {
if (isScaling && !isScaleWithHandles) { if (isScaling && !isAppScaleWithHandles) {
applyScale(); applyScale();
} }
} else { } else {
applyGrab(); applyGrab();
} }
} else if (doHighlight) { } else if (doHighlight) {
if (!isScaleWithHandles || !otherHand.isEditing(selection.rootEntityID())) { if (!isAppScaleWithHandles || !otherHand.isEditing(selection.rootEntityID())) {
highlights.display(intersection.handSelected, selection.selection(), highlights.display(intersection.handSelected, selection.selection(),
otherHand.isEditing(selection.rootEntityID()) || isScaleWithHandles); otherHand.isEditing(selection.rootEntityID()) || isAppScaleWithHandles);
} }
} }
} }
@ -1187,7 +1181,6 @@
return { return {
setOtherHand: setOtherHand, setOtherHand: setOtherHand,
setScaleWithHandles: setScaleWithHandles,
isEditing: getIsEditing, isEditing: getIsEditing,
hoverHandle: hoverHandle, hoverHandle: hoverHandle,
getTargetPosition: getTargetPosition, getTargetPosition: getTargetPosition,
@ -1234,9 +1227,7 @@
} }
function onGripClicked() { function onGripClicked() {
isScaleWithHandles = !isScaleWithHandles; isAppScaleWithHandles = !isAppScaleWithHandles;
hands[LEFT_HAND].setScaleWithHandles(isScaleWithHandles);
hands[RIGHT_HAND].setScaleWithHandles(isScaleWithHandles);
} }
function setUp() { function setUp() {