mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:17:35 +02:00
[Case 6491] Adds some debugging prints.
Changes Committed: modified: scripts/system/libraries/entitySelectionTool.js
This commit is contained in:
parent
912305fd4b
commit
15ff4ebecb
1 changed files with 76 additions and 3 deletions
|
@ -1583,20 +1583,29 @@ SelectionDisplay = (function() {
|
|||
|
||||
// FUNCTION: SET SPACE MODE
|
||||
that.setSpaceMode = function(newSpaceMode) {
|
||||
print("======> SetSpaceMode called. ========");
|
||||
if (spaceMode != newSpaceMode) {
|
||||
print(" Updating SpaceMode From: " + spaceMode + " To: " + newSpaceMode);
|
||||
spaceMode = newSpaceMode;
|
||||
that.updateHandles();
|
||||
} else {
|
||||
print(" Can't update SpaceMode. CurrentMode: " + spaceMode + " DesiredMode: " + newSpaceMode);
|
||||
}
|
||||
print("====== SetSpaceMode called. <========");
|
||||
};
|
||||
|
||||
// FUNCTION: TOGGLE SPACE MODE
|
||||
that.toggleSpaceMode = function() {
|
||||
print("========> ToggleSpaceMode called. =========");
|
||||
if (spaceMode == SPACE_WORLD && SelectionManager.selections.length > 1) {
|
||||
print("Local space editing is not available with multiple selections");
|
||||
return;
|
||||
}
|
||||
print( "PreToggle: " + spaceMode);
|
||||
spaceMode = spaceMode == SPACE_LOCAL ? SPACE_WORLD : SPACE_LOCAL;
|
||||
print( "PostToggle: " + spaceMode);
|
||||
that.updateHandles();
|
||||
print("======== ToggleSpaceMode called. <=========");
|
||||
};
|
||||
|
||||
// FUNCTION: UNSELECT ALL
|
||||
|
@ -1605,6 +1614,9 @@ SelectionDisplay = (function() {
|
|||
|
||||
// FUNCTION: UPDATE HANDLES
|
||||
that.updateHandles = function() {
|
||||
print( "======> Update Handles =======" );
|
||||
print( " Selections Count: " + SelectionManager.selections.length );
|
||||
print( " SpaceMode: " + spaceMode );
|
||||
if (SelectionManager.selections.length === 0) {
|
||||
that.setOverlaysVisible(false);
|
||||
return;
|
||||
|
@ -2334,6 +2346,8 @@ SelectionDisplay = (function() {
|
|||
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
||||
});
|
||||
|
||||
print( "====== Update Handles <=======" );
|
||||
|
||||
};
|
||||
|
||||
// FUNCTION: SET OVERLAYS VISIBLE
|
||||
|
@ -3551,15 +3565,22 @@ SelectionDisplay = (function() {
|
|||
|
||||
// FUNCTION: UPDATE ROTATION DEGREES OVERLAY
|
||||
function updateRotationDegreesOverlay(angleFromZero, handleRotation, centerPosition) {
|
||||
print( "---> updateRotationDegreesOverlay ---" );
|
||||
print(" AngleFromZero: " + angleFromZero );
|
||||
print(" HandleRotation - X: " + handleRotation.x + " Y: " + handleRotation.y + " Z: " + handleRotation.z );
|
||||
print(" CenterPos - " + centerPosition.x + " Y: " + centerPosition.y + " Z: " + centerPosition.z );
|
||||
var angle = angleFromZero * (Math.PI / 180);
|
||||
var position = {
|
||||
x: Math.cos(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER,
|
||||
y: Math.sin(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER,
|
||||
z: 0,
|
||||
};
|
||||
print(" Angle: " + angle );
|
||||
print(" InitialPos: " + position.x + ", " + position.y + ", " + position.z);
|
||||
position = Vec3.multiplyQbyV(handleRotation, position);
|
||||
position = Vec3.sum(centerPosition, position);
|
||||
Overlays.editOverlay(rotationDegreesDisplay, {
|
||||
print(" TranslatedPos: " + position.x + ", " + position.y + ", " + position.z);
|
||||
var overlayProps = {
|
||||
position: position,
|
||||
dimensions: {
|
||||
x: innerRadius * ROTATION_DISPLAY_SIZE_X_MULTIPLIER,
|
||||
|
@ -3567,7 +3588,12 @@ SelectionDisplay = (function() {
|
|||
},
|
||||
lineHeight: innerRadius * ROTATION_DISPLAY_LINE_HEIGHT_MULTIPLIER,
|
||||
text: normalizeDegrees(angleFromZero) + "°",
|
||||
});
|
||||
};
|
||||
print(" OverlayDim - X: " + overlayProps.dimensions.x + " Y: " + overlayProps.dimensions.y + " Z: " + overlayProps.dimensions.z );
|
||||
print(" OverlayLineHeight: " + overlayProps.lineHeight );
|
||||
print(" OverlayText: " + overlayProps.text );
|
||||
Overlays.editOverlay(rotationDegreesDisplay, overlayProps);
|
||||
print( "<--- updateRotationDegreesOverlay ---" );
|
||||
}
|
||||
|
||||
// YAW GRABBER TOOL DEFINITION
|
||||
|
@ -3575,6 +3601,7 @@ SelectionDisplay = (function() {
|
|||
addGrabberTool(yawHandle, {
|
||||
mode: "ROTATE_YAW",
|
||||
onBegin: function(event) {
|
||||
print("================== HANDLE_ROLL(Beg) -> =======================");
|
||||
SelectionManager.saveProperties();
|
||||
initialPosition = SelectionManager.worldPosition;
|
||||
|
||||
|
@ -3616,8 +3643,10 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
|
||||
updateRotationDegreesOverlay(0, yawHandleRotation, yawCenter);
|
||||
print("================== HANDLE_YAW(Beg) <- =======================");
|
||||
},
|
||||
onEnd: function(event, reason) {
|
||||
print("================== HANDLE_YAW(End) -> =======================");
|
||||
Overlays.editOverlay(rotateOverlayInner, {
|
||||
visible: false
|
||||
});
|
||||
|
@ -3632,8 +3661,10 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
|
||||
pushCommandForSelections();
|
||||
print("================== HANDLE_YAW(End) <- =======================");
|
||||
},
|
||||
onMove: function(event) {
|
||||
print("================== HANDLE_YAW(Mve) -> =======================");
|
||||
var pickRay = generalComputePickRay(event.x, event.y);
|
||||
Overlays.editOverlay(selectionBox, {
|
||||
visible: false
|
||||
|
@ -3651,6 +3682,7 @@ SelectionDisplay = (function() {
|
|||
var centerToIntersect = Vec3.subtract(result.intersection, center);
|
||||
// Note: orientedAngle which wants normalized centerToZero and centerToIntersect
|
||||
// handles that internally, so it's to pass unnormalized vectors here.
|
||||
print(" RotNormal - X: " + rotationNormal.x + " Y: " + rotationNormal.y + " Z: " + rotationNormal.z);
|
||||
var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal);
|
||||
var distanceFromCenter = Vec3.distance(center, result.intersection);
|
||||
var snapToInner = distanceFromCenter < innerRadius;
|
||||
|
@ -3736,6 +3768,7 @@ SelectionDisplay = (function() {
|
|||
}
|
||||
|
||||
}
|
||||
print("================== HANDLE_YAW(Mve) <- =======================");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -3743,6 +3776,7 @@ SelectionDisplay = (function() {
|
|||
addGrabberTool(pitchHandle, {
|
||||
mode: "ROTATE_PITCH",
|
||||
onBegin: function(event) {
|
||||
print("================== HANDLE_PITCH(Beg) -> =======================");
|
||||
SelectionManager.saveProperties();
|
||||
initialPosition = SelectionManager.worldPosition;
|
||||
|
||||
|
@ -3784,8 +3818,10 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
|
||||
updateRotationDegreesOverlay(0, pitchHandleRotation, pitchCenter);
|
||||
print("================== HANDLE_PITCH(Beg) <- =======================");
|
||||
},
|
||||
onEnd: function(event, reason) {
|
||||
print("================== HANDLE_PITCH(End) -> =======================");
|
||||
Overlays.editOverlay(rotateOverlayInner, {
|
||||
visible: false
|
||||
});
|
||||
|
@ -3800,8 +3836,10 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
|
||||
pushCommandForSelections();
|
||||
print("================== HANDLE_PITCH(End) <- =======================");
|
||||
},
|
||||
onMove: function(event) {
|
||||
print("================== HANDLE_PITCH(Mve) -> =======================");
|
||||
var pickRay = generalComputePickRay(event.x, event.y);
|
||||
Overlays.editOverlay(selectionBox, {
|
||||
visible: false
|
||||
|
@ -3818,6 +3856,7 @@ SelectionDisplay = (function() {
|
|||
var centerToIntersect = Vec3.subtract(result.intersection, center);
|
||||
// Note: orientedAngle which wants normalized centerToZero & centerToIntersect, handles
|
||||
// this internally, so it's fine to pass non-normalized versions here.
|
||||
print(" RotNormal - X: " + rotationNormal.x + " Y: " + rotationNormal.y + " Z: " + rotationNormal.z);
|
||||
var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal);
|
||||
|
||||
var distanceFromCenter = Vec3.distance(center, result.intersection);
|
||||
|
@ -3894,6 +3933,7 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
}
|
||||
}
|
||||
print("================== HANDLE_PITCH(Mve) <- =======================");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -3901,6 +3941,7 @@ SelectionDisplay = (function() {
|
|||
addGrabberTool(rollHandle, {
|
||||
mode: "ROTATE_ROLL",
|
||||
onBegin: function(event) {
|
||||
print("================== HANDLE_ROLL(Beg) -> =======================");
|
||||
SelectionManager.saveProperties();
|
||||
initialPosition = SelectionManager.worldPosition;
|
||||
|
||||
|
@ -3942,8 +3983,10 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
|
||||
updateRotationDegreesOverlay(0, rollHandleRotation, rollCenter);
|
||||
print("================== HANDLE_ROLL(Beg) <- =======================");
|
||||
},
|
||||
onEnd: function(event, reason) {
|
||||
print("================== HANDLE_ROLL(End) -> =======================");
|
||||
Overlays.editOverlay(rotateOverlayInner, {
|
||||
visible: false
|
||||
});
|
||||
|
@ -3958,8 +4001,10 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
|
||||
pushCommandForSelections();
|
||||
print("================== HANDLE_ROLL(End) <- =======================");
|
||||
},
|
||||
onMove: function(event) {
|
||||
print("================== HANDLE_ROLL(Mve) -> =======================");
|
||||
var pickRay = generalComputePickRay(event.x, event.y);
|
||||
Overlays.editOverlay(selectionBox, {
|
||||
visible: false
|
||||
|
@ -3976,6 +4021,7 @@ SelectionDisplay = (function() {
|
|||
var centerToIntersect = Vec3.subtract(result.intersection, center);
|
||||
// Note: orientedAngle which wants normalized centerToZero & centerToIntersect, handles
|
||||
// this internally, so it's fine to pass non-normalized versions here.
|
||||
print(" RotNormal - X: " + rotationNormal.x + " Y: " + rotationNormal.y + " Z: " + rotationNormal.z);
|
||||
var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal);
|
||||
|
||||
var distanceFromCenter = Vec3.distance(center, result.intersection);
|
||||
|
@ -4051,6 +4097,8 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
}
|
||||
}
|
||||
print("================== HANDLE_ROLL(Mve) <- =======================");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -4086,7 +4134,10 @@ SelectionDisplay = (function() {
|
|||
|
||||
// FUNCTION: MOUSE PRESS EVENT
|
||||
that.mousePressEvent = function(event) {
|
||||
var wantDebug = false;
|
||||
var wantDebug = true;
|
||||
if ( wantDebug ) {
|
||||
print( "=============== eST::MousePressEvent BEG =======================");
|
||||
}
|
||||
if (!event.isLeftButton && !that.triggered) {
|
||||
// if another mouse button than left is pressed ignore it
|
||||
return false;
|
||||
|
@ -4118,6 +4169,7 @@ SelectionDisplay = (function() {
|
|||
|
||||
var tool = grabberTools[result.overlayID];
|
||||
if (tool) {
|
||||
print("Intersected with known table tool.");
|
||||
activeTool = tool;
|
||||
mode = tool.mode;
|
||||
somethingClicked = 'tool';
|
||||
|
@ -4125,8 +4177,10 @@ SelectionDisplay = (function() {
|
|||
activeTool.onBegin(event);
|
||||
}
|
||||
} else {
|
||||
print("Intersected with unregistered tool...");
|
||||
switch (result.overlayID) {
|
||||
case grabberMoveUp:
|
||||
print("grabberMoveUp");
|
||||
mode = "TRANSLATE_UP_DOWN";
|
||||
somethingClicked = mode;
|
||||
|
||||
|
@ -4142,6 +4196,7 @@ SelectionDisplay = (function() {
|
|||
case grabberNEAR:
|
||||
case grabberEdgeTN: // TODO: maybe this should be TOP+NEAR stretching?
|
||||
case grabberEdgeBN: // TODO: maybe this should be BOTTOM+FAR stretching?
|
||||
print("grabberNear variant");
|
||||
mode = "STRETCH_NEAR";
|
||||
somethingClicked = mode;
|
||||
break;
|
||||
|
@ -4149,31 +4204,37 @@ SelectionDisplay = (function() {
|
|||
case grabberFAR:
|
||||
case grabberEdgeTF: // TODO: maybe this should be TOP+FAR stretching?
|
||||
case grabberEdgeBF: // TODO: maybe this should be BOTTOM+FAR stretching?
|
||||
print("grabberFar variant");
|
||||
mode = "STRETCH_FAR";
|
||||
somethingClicked = mode;
|
||||
break;
|
||||
case grabberTOP:
|
||||
print("grabberTOP");
|
||||
mode = "STRETCH_TOP";
|
||||
somethingClicked = mode;
|
||||
break;
|
||||
case grabberBOTTOM:
|
||||
print("grabberBOTTOM");
|
||||
mode = "STRETCH_BOTTOM";
|
||||
somethingClicked = mode;
|
||||
break;
|
||||
case grabberRIGHT:
|
||||
case grabberEdgeTR: // TODO: maybe this should be TOP+RIGHT stretching?
|
||||
case grabberEdgeBR: // TODO: maybe this should be BOTTOM+RIGHT stretching?
|
||||
print("grabberRight variant");
|
||||
mode = "STRETCH_RIGHT";
|
||||
somethingClicked = mode;
|
||||
break;
|
||||
case grabberLEFT:
|
||||
case grabberEdgeTL: // TODO: maybe this should be TOP+LEFT stretching?
|
||||
case grabberEdgeBL: // TODO: maybe this should be BOTTOM+LEFT stretching?
|
||||
print("grabberLeft variant");
|
||||
mode = "STRETCH_LEFT";
|
||||
somethingClicked = mode;
|
||||
break;
|
||||
|
||||
default:
|
||||
print("UNKNOWN( " + result.overlayID + " )");
|
||||
mode = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
|
@ -4183,6 +4244,7 @@ SelectionDisplay = (function() {
|
|||
// if one of the items above was clicked, then we know we are in translate or stretch mode, and we
|
||||
// should hide our rotate handles...
|
||||
if (somethingClicked) {
|
||||
print("Click is triggering hiding of handles, hopefully");
|
||||
Overlays.editOverlay(yawHandle, {
|
||||
visible: false
|
||||
});
|
||||
|
@ -4225,6 +4287,7 @@ SelectionDisplay = (function() {
|
|||
originalRoll = roll;
|
||||
|
||||
if (result.intersects) {
|
||||
print("Intersection detected with handle...");
|
||||
var resultTool = grabberTools[result.overlayID];
|
||||
if (resultTool) {
|
||||
activeTool = resultTool;
|
||||
|
@ -4236,15 +4299,18 @@ SelectionDisplay = (function() {
|
|||
}
|
||||
switch (result.overlayID) {
|
||||
case yawHandle:
|
||||
print("Handle_YAW");
|
||||
mode = "ROTATE_YAW";
|
||||
somethingClicked = mode;
|
||||
overlayOrientation = yawHandleRotation;
|
||||
overlayCenter = yawCenter;
|
||||
yawZero = result.intersection;
|
||||
rotationNormal = yawNormal;
|
||||
print("rotationNormal set to: " + rotationNormal.x + ", " + rotationNormal.y + ", " + rotationNormal.z);
|
||||
break;
|
||||
|
||||
case pitchHandle:
|
||||
print("Handle_PITCH");
|
||||
mode = "ROTATE_PITCH";
|
||||
initialPosition = SelectionManager.worldPosition;
|
||||
somethingClicked = mode;
|
||||
|
@ -4252,15 +4318,18 @@ SelectionDisplay = (function() {
|
|||
overlayCenter = pitchCenter;
|
||||
pitchZero = result.intersection;
|
||||
rotationNormal = pitchNormal;
|
||||
print("rotationNormal set to: " + rotationNormal.x + ", " + rotationNormal.y + ", " + rotationNormal.z);
|
||||
break;
|
||||
|
||||
case rollHandle:
|
||||
print("Handle_ROLL");
|
||||
mode = "ROTATE_ROLL";
|
||||
somethingClicked = mode;
|
||||
overlayOrientation = rollHandleRotation;
|
||||
overlayCenter = rollCenter;
|
||||
rollZero = result.intersection;
|
||||
rotationNormal = rollNormal;
|
||||
print("rotationNormal set to: " + rotationNormal.x + ", " + rotationNormal.y + ", " + rotationNormal.z);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -4463,6 +4532,10 @@ SelectionDisplay = (function() {
|
|||
ignoreRayIntersection: false
|
||||
});
|
||||
|
||||
if ( wantDebug ) {
|
||||
print( "=============== eST::MousePressEvent END =======================");
|
||||
}
|
||||
|
||||
return somethingClicked;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue