mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
[Case 6491] Cleanup of mousePressEvent/tool(s) onBegin (details below).
* Removes unregister tools switch which was never reached. * Rolls all code rotation handle related code within mousePressEvent to the respective rotation handler onBegin functions. * onBegin call site updated accordingly to provide intersection data that code depends upon. * Moves all translateXZTool code explicitly within mousePressEvent to the tool's onBegin function. * onBegin signature updated accordingly to provide intersect results that the tool relies upon. * Found and fixed a bug with translateXZTool where its startingElevation and startingDistance properties were _only_ set when local _debug_ var was set. * This appears to have been responsible for being able to move the object farther than was visible. Re-tested with fix and wasn't able to get that behavior any longer. * Wrap intersect tests within more reader friendly functions. NOTE(s): * Tested GrabberMoveUp and Rotation Handles. They work as they did previously as expected. * Tested selection behavior and it currently maintains as expected. * Tested translationXZTool and it maintains its prior behavior with the improvement noted above. Reviewed-by: Leander Hasty <leander@1stplayable.com> Changes Committed: modified: scripts/system/libraries/entitySelectionTool.js
This commit is contained in:
parent
ae8ae6f6cc
commit
196b665e22
1 changed files with 244 additions and 271 deletions
|
@ -2392,13 +2392,30 @@ SelectionDisplay = (function() {
|
||||||
greatestDimension: 0.0,
|
greatestDimension: 0.0,
|
||||||
startingDistance: 0.0,
|
startingDistance: 0.0,
|
||||||
startingElevation: 0.0,
|
startingElevation: 0.0,
|
||||||
onBegin: function(event,isAltFromGrab) {
|
onBegin: function(event,isAltFromGrab, intersectInfo) {
|
||||||
|
var wantDebug = true;
|
||||||
|
if(wantDebug){
|
||||||
|
print("================== TRANSLATE_XZ(Beg) -> =======================");
|
||||||
|
Vec3.print(" intersectInfo.queryRay", intersectInfo.queryRay);
|
||||||
|
Vec3.print(" intersectInfo.queryRay.origin", intersectInfo.queryRay.origin);
|
||||||
|
Vec3.print(" intersectInfo.results.intersection", intersectInfo.results.intersection);
|
||||||
|
}
|
||||||
|
|
||||||
SelectionManager.saveProperties();
|
SelectionManager.saveProperties();
|
||||||
startPosition = SelectionManager.worldPosition;
|
startPosition = SelectionManager.worldPosition;
|
||||||
var dimensions = SelectionManager.worldDimensions;
|
mode = translateXZTool.mode;
|
||||||
|
|
||||||
var pickRay = generalComputePickRay(event.x, event.y);
|
translateXZTool.pickPlanePosition = intersectInfo.results.intersection;
|
||||||
initialXZPick = rayPlaneIntersection(pickRay, translateXZTool.pickPlanePosition, {
|
translateXZTool.greatestDimension = Math.max(Math.max(SelectionManager.worldDimensions.x, SelectionManager.worldDimensions.y), SelectionManager.worldDimensions.z);
|
||||||
|
translateXZTool.startingDistance = Vec3.distance(intersectInfo.queryRay.origin, SelectionManager.position);
|
||||||
|
translateXZTool.startingElevation = translateXZTool.elevation(intersectInfo.queryRay.origin, translateXZTool.pickPlanePosition);
|
||||||
|
if (wantDebug) {
|
||||||
|
print(" longest dimension: " + translateXZTool.greatestDimension);
|
||||||
|
print(" starting distance: " + translateXZTool.startingDistance);
|
||||||
|
print(" starting elevation: " + translateXZTool.startingElevation);
|
||||||
|
}
|
||||||
|
|
||||||
|
initialXZPick = rayPlaneIntersection(intersectInfo.queryRay, translateXZTool.pickPlanePosition, {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 1,
|
y: 1,
|
||||||
z: 0
|
z: 0
|
||||||
|
@ -2424,6 +2441,9 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
isConstrained = false;
|
isConstrained = false;
|
||||||
|
if(wantDebug){
|
||||||
|
print("================== TRANSLATE_XZ(End) <- =======================");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onEnd: function(event, reason) {
|
onEnd: function(event, reason) {
|
||||||
pushCommandForSelections(duplicatedEntityIDs);
|
pushCommandForSelections(duplicatedEntityIDs);
|
||||||
|
@ -2452,8 +2472,10 @@ SelectionDisplay = (function() {
|
||||||
// this will happen when someone drags across the horizon from the side they started on.
|
// this will happen when someone drags across the horizon from the side they started on.
|
||||||
if (!pick) {
|
if (!pick) {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("Pick ray does not intersect XZ plane.");
|
print(" "+ translateXZTool.mode + "Pick ray does not intersect XZ plane.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--EARLY EXIT--( Invalid ray detected. )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2468,8 +2490,10 @@ SelectionDisplay = (function() {
|
||||||
if ((translateXZTool.startingElevation > 0.0 && elevation < MIN_ELEVATION) ||
|
if ((translateXZTool.startingElevation > 0.0 && elevation < MIN_ELEVATION) ||
|
||||||
(translateXZTool.startingElevation < 0.0 && elevation > -MIN_ELEVATION)) {
|
(translateXZTool.startingElevation < 0.0 && elevation > -MIN_ELEVATION)) {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("too close to horizon!");
|
print(" "+ translateXZTool.mode + " - too close to horizon!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--EARLY EXIT--( Don't proceed past the reached limit. )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3610,9 +3634,24 @@ SelectionDisplay = (function() {
|
||||||
addGrabberTool(yawHandle, {
|
addGrabberTool(yawHandle, {
|
||||||
mode: "ROTATE_YAW",
|
mode: "ROTATE_YAW",
|
||||||
onBegin: function(event) {
|
onBegin: function(event) {
|
||||||
print("================== HANDLE_ROLL(Beg) -> =======================");
|
var wantDebug = true;
|
||||||
|
if (wantDebug) {
|
||||||
|
print("================== HANDLE_YAW(Beg) -> =======================");
|
||||||
|
}
|
||||||
SelectionManager.saveProperties();
|
SelectionManager.saveProperties();
|
||||||
initialPosition = SelectionManager.worldPosition;
|
initialPosition = SelectionManager.worldPosition;
|
||||||
|
mode = "ROTATE_YAW";
|
||||||
|
rotationNormal = yawNormal;
|
||||||
|
//note: It's expected that the intersection is passed when this is called.
|
||||||
|
if (arguments.length >= 2 ) {
|
||||||
|
yawZero = arguments[ 1 ];
|
||||||
|
} else {
|
||||||
|
print("ERROR( yawHandle.onBegin ) - Intersection wasn't passed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wantDebug) {
|
||||||
|
Vec3.print(" yawZero: ", yawZero);
|
||||||
|
}
|
||||||
|
|
||||||
// Size the overlays to the current selection size
|
// Size the overlays to the current selection size
|
||||||
var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1;
|
var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1;
|
||||||
|
@ -3623,15 +3662,19 @@ SelectionDisplay = (function() {
|
||||||
var outerAlpha = 0.2;
|
var outerAlpha = 0.2;
|
||||||
Overlays.editOverlay(rotateOverlayInner, {
|
Overlays.editOverlay(rotateOverlayInner, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: yawHandleRotation,
|
||||||
|
position: yawCenter,
|
||||||
size: innerRadius,
|
size: innerRadius,
|
||||||
innerRadius: 0.9,
|
innerRadius: 0.9,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
endAt: 360,
|
endAt: 360,
|
||||||
alpha: innerAlpha
|
alpha: innerAlpha,
|
||||||
});
|
});
|
||||||
|
|
||||||
Overlays.editOverlay(rotateOverlayOuter, {
|
Overlays.editOverlay(rotateOverlayOuter, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: yawHandleRotation,
|
||||||
|
position: yawCenter,
|
||||||
size: outerRadius,
|
size: outerRadius,
|
||||||
innerRadius: 0.9,
|
innerRadius: 0.9,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
|
@ -3641,18 +3684,28 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
Overlays.editOverlay(rotateOverlayCurrent, {
|
Overlays.editOverlay(rotateOverlayCurrent, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: yawHandleRotation,
|
||||||
|
position: yawCenter,
|
||||||
size: outerRadius,
|
size: outerRadius,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
endAt: 0,
|
endAt: 0,
|
||||||
innerRadius: 0.9,
|
innerRadius: 0.9,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Overlays.editOverlay(rotateOverlayTarget, {
|
||||||
|
visible: true,
|
||||||
|
rotation: yawHandleRotation,
|
||||||
|
position: yawCenter
|
||||||
|
});
|
||||||
|
|
||||||
Overlays.editOverlay(rotationDegreesDisplay, {
|
Overlays.editOverlay(rotationDegreesDisplay, {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
updateRotationDegreesOverlay(0, yawHandleRotation, yawCenter);
|
updateRotationDegreesOverlay(0, yawHandleRotation, yawCenter);
|
||||||
print("================== HANDLE_YAW(Beg) <- =======================");
|
if(wantDebug){
|
||||||
|
print("================== HANDLE_YAW(Beg) <- =======================");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onEnd: function(event, reason) {
|
onEnd: function(event, reason) {
|
||||||
print("================== HANDLE_YAW(End) -> =======================");
|
print("================== HANDLE_YAW(End) -> =======================");
|
||||||
|
@ -3784,10 +3837,25 @@ SelectionDisplay = (function() {
|
||||||
// PITCH GRABBER TOOL DEFINITION
|
// PITCH GRABBER TOOL DEFINITION
|
||||||
addGrabberTool(pitchHandle, {
|
addGrabberTool(pitchHandle, {
|
||||||
mode: "ROTATE_PITCH",
|
mode: "ROTATE_PITCH",
|
||||||
onBegin: function(event) {
|
onBegin: function (event) {
|
||||||
print("================== HANDLE_PITCH(Beg) -> =======================");
|
var wantDebug = true;
|
||||||
|
if (wantDebug){
|
||||||
|
print("================== HANDLE_PITCH(Beg) -> =======================");
|
||||||
|
}
|
||||||
SelectionManager.saveProperties();
|
SelectionManager.saveProperties();
|
||||||
initialPosition = SelectionManager.worldPosition;
|
initialPosition = SelectionManager.worldPosition;
|
||||||
|
mode = "ROTATE_PITCH";
|
||||||
|
rotationNormal = pitchNormal;
|
||||||
|
//note: It's expected that the intersection is passed when this is called.
|
||||||
|
if (arguments.length >= 2 ) {
|
||||||
|
pitchZero = arguments[ 1 ];
|
||||||
|
} else {
|
||||||
|
print("ERROR( pitchHandle.onBegin ) - Intersection wasn't passed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wantDebug) {
|
||||||
|
Vec3.print(" pitchZero: ", pitchZero);
|
||||||
|
}
|
||||||
|
|
||||||
// Size the overlays to the current selection size
|
// Size the overlays to the current selection size
|
||||||
var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1;
|
var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1;
|
||||||
|
@ -3798,6 +3866,8 @@ SelectionDisplay = (function() {
|
||||||
var outerAlpha = 0.2;
|
var outerAlpha = 0.2;
|
||||||
Overlays.editOverlay(rotateOverlayInner, {
|
Overlays.editOverlay(rotateOverlayInner, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: pitchHandleRotation,
|
||||||
|
position: pitchCenter,
|
||||||
size: innerRadius,
|
size: innerRadius,
|
||||||
innerRadius: 0.9,
|
innerRadius: 0.9,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
|
@ -3807,6 +3877,8 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
Overlays.editOverlay(rotateOverlayOuter, {
|
Overlays.editOverlay(rotateOverlayOuter, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: pitchHandleRotation,
|
||||||
|
position: pitchCenter,
|
||||||
size: outerRadius,
|
size: outerRadius,
|
||||||
innerRadius: 0.9,
|
innerRadius: 0.9,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
|
@ -3816,6 +3888,8 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
Overlays.editOverlay(rotateOverlayCurrent, {
|
Overlays.editOverlay(rotateOverlayCurrent, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: pitchHandleRotation,
|
||||||
|
position: pitchCenter,
|
||||||
size: outerRadius,
|
size: outerRadius,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
endAt: 0,
|
endAt: 0,
|
||||||
|
@ -3826,8 +3900,16 @@ SelectionDisplay = (function() {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Overlays.editOverlay(rotateOverlayTarget, {
|
||||||
|
visible: true,
|
||||||
|
rotation: pitchHandleRotation,
|
||||||
|
position: pitchCenter
|
||||||
|
});
|
||||||
|
|
||||||
updateRotationDegreesOverlay(0, pitchHandleRotation, pitchCenter);
|
updateRotationDegreesOverlay(0, pitchHandleRotation, pitchCenter);
|
||||||
print("================== HANDLE_PITCH(Beg) <- =======================");
|
if(wantDebug){
|
||||||
|
print("================== HANDLE_PITCH(Beg) <- =======================");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onEnd: function(event, reason) {
|
onEnd: function(event, reason) {
|
||||||
print("================== HANDLE_PITCH(End) -> =======================");
|
print("================== HANDLE_PITCH(End) -> =======================");
|
||||||
|
@ -3847,7 +3929,7 @@ SelectionDisplay = (function() {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
print("================== HANDLE_PITCH(End) <- =======================");
|
print("================== HANDLE_PITCH(End) <- =======================");
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function (event) {
|
||||||
print("================== HANDLE_PITCH(Mve) -> =======================");
|
print("================== HANDLE_PITCH(Mve) -> =======================");
|
||||||
var pickRay = generalComputePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
Overlays.editOverlay(selectionBox, {
|
Overlays.editOverlay(selectionBox, {
|
||||||
|
@ -3949,10 +4031,25 @@ SelectionDisplay = (function() {
|
||||||
// ROLL GRABBER TOOL DEFINITION
|
// ROLL GRABBER TOOL DEFINITION
|
||||||
addGrabberTool(rollHandle, {
|
addGrabberTool(rollHandle, {
|
||||||
mode: "ROTATE_ROLL",
|
mode: "ROTATE_ROLL",
|
||||||
onBegin: function(event) {
|
onBegin: function (event) {
|
||||||
print("================== HANDLE_ROLL(Beg) -> =======================");
|
var wantDebug = true;
|
||||||
|
if(wantDebug){
|
||||||
|
print("================== HANDLE_ROLL(Beg) -> =======================");
|
||||||
|
}
|
||||||
SelectionManager.saveProperties();
|
SelectionManager.saveProperties();
|
||||||
initialPosition = SelectionManager.worldPosition;
|
initialPosition = SelectionManager.worldPosition;
|
||||||
|
mode = "ROTATE_ROLL";
|
||||||
|
rotationNormal = rollNormal;
|
||||||
|
//note: It's expected that the intersection is passed when this is called.
|
||||||
|
if (arguments.length >= 2 ) {
|
||||||
|
rollZero = arguments[ 1 ];
|
||||||
|
} else {
|
||||||
|
print("ERROR( rollHandle.onBegin ) - Intersection wasn't passed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wantDebug) {
|
||||||
|
Vec3.print(" rollZero: ", rollZero);
|
||||||
|
}
|
||||||
|
|
||||||
// Size the overlays to the current selection size
|
// Size the overlays to the current selection size
|
||||||
var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1;
|
var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1;
|
||||||
|
@ -3963,6 +4060,8 @@ SelectionDisplay = (function() {
|
||||||
var outerAlpha = 0.2;
|
var outerAlpha = 0.2;
|
||||||
Overlays.editOverlay(rotateOverlayInner, {
|
Overlays.editOverlay(rotateOverlayInner, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: rollHandleRotation,
|
||||||
|
position: rollCenter,
|
||||||
size: innerRadius,
|
size: innerRadius,
|
||||||
innerRadius: 0.9,
|
innerRadius: 0.9,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
|
@ -3972,6 +4071,8 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
Overlays.editOverlay(rotateOverlayOuter, {
|
Overlays.editOverlay(rotateOverlayOuter, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: rollHandleRotation,
|
||||||
|
position: rollCenter,
|
||||||
size: outerRadius,
|
size: outerRadius,
|
||||||
innerRadius: 0.9,
|
innerRadius: 0.9,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
|
@ -3981,6 +4082,8 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
Overlays.editOverlay(rotateOverlayCurrent, {
|
Overlays.editOverlay(rotateOverlayCurrent, {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
rotation: rollHandleRotation,
|
||||||
|
position: rollCenter,
|
||||||
size: outerRadius,
|
size: outerRadius,
|
||||||
startAt: 0,
|
startAt: 0,
|
||||||
endAt: 0,
|
endAt: 0,
|
||||||
|
@ -3991,10 +4094,18 @@ SelectionDisplay = (function() {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Overlays.editOverlay(rotateOverlayTarget, {
|
||||||
|
visible: true,
|
||||||
|
rotation: rollHandleRotation,
|
||||||
|
position: rollCenter
|
||||||
|
});
|
||||||
|
|
||||||
updateRotationDegreesOverlay(0, rollHandleRotation, rollCenter);
|
updateRotationDegreesOverlay(0, rollHandleRotation, rollCenter);
|
||||||
print("================== HANDLE_ROLL(Beg) <- =======================");
|
if(wantDebug){
|
||||||
|
print("================== HANDLE_ROLL(Beg) <- =======================");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onEnd: function(event, reason) {
|
onEnd: function (event, reason) {
|
||||||
print("================== HANDLE_ROLL(End) -> =======================");
|
print("================== HANDLE_ROLL(End) -> =======================");
|
||||||
Overlays.editOverlay(rotateOverlayInner, {
|
Overlays.editOverlay(rotateOverlayInner, {
|
||||||
visible: false
|
visible: false
|
||||||
|
@ -4141,11 +4252,68 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// FUNCTION DEF(s): Intersection Check Helpers
|
||||||
|
function testRayIntersect(queryRay, overlayIncludes, overlayExcludes) {
|
||||||
|
var wantDebug = true;
|
||||||
|
if ((queryRay === undefined) || (queryRay === null)) {
|
||||||
|
if (wantDebug) {
|
||||||
|
print("testRayIntersect - EARLY EXIT -> queryRay is undefined OR null!");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var intersectObj = Overlays.findRayIntersection(queryRay, true, overlayIncludes, overlayExcludes);
|
||||||
|
|
||||||
|
if (wantDebug) {
|
||||||
|
if ( ! overlayIncludes ){
|
||||||
|
print("testRayIntersect - no overlayIncludes provided.");
|
||||||
|
}
|
||||||
|
if ( ! overlayExcludes ){
|
||||||
|
print("testRayIntersect - no overlayExcludes provided.");
|
||||||
|
}
|
||||||
|
print("testRayIntersect - Hit: " + intersectObj.intersects);
|
||||||
|
print(" intersectObj.overlayID:" + intersectObj.overlayID + "[" + overlayNames[intersectObj.overlayID] + "]");
|
||||||
|
print(" OverlayName: " + overlayNames[intersectObj.overlayID]);
|
||||||
|
print(" intersectObj.distance:" + intersectObj.distance);
|
||||||
|
print(" intersectObj.face:" + intersectObj.face);
|
||||||
|
Vec3.print(" intersectObj.intersection:", intersectObj.intersection);
|
||||||
|
}
|
||||||
|
|
||||||
|
return intersectObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkIntersectWithHUD(queryRay) {
|
||||||
|
var intersectObj = testRayIntersect(queryRay, [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID]);
|
||||||
|
|
||||||
|
return intersectObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkIntersectWithNonSelectionItems(queryRay) {
|
||||||
|
var intersectObj = testRayIntersect(queryRay, null, [yawHandle, pitchHandle, rollHandle, selectionBox]);
|
||||||
|
|
||||||
|
return intersectObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkIntersectWithRotationHandles(queryRay) {
|
||||||
|
var intersectObj = testRayIntersect(queryRay, [yawHandle, pitchHandle, rollHandle]);
|
||||||
|
|
||||||
|
return intersectObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkIntersectWithSelectionBox(queryRay) {
|
||||||
|
var intersectObj = testRayIntersect(queryRay, [selectionBox]);
|
||||||
|
|
||||||
|
return intersectObj;
|
||||||
|
}
|
||||||
|
//--------------------
|
||||||
|
|
||||||
|
//---------------------------------------
|
||||||
// FUNCTION: MOUSE PRESS EVENT
|
// FUNCTION: MOUSE PRESS EVENT
|
||||||
that.mousePressEvent = function(event) {
|
that.mousePressEvent = function (event) {
|
||||||
var wantDebug = false;
|
var wantDebug = true;
|
||||||
if ( wantDebug ) {
|
if (wantDebug) {
|
||||||
print( "=============== eST::MousePressEvent BEG =======================");
|
print("=============== eST::MousePressEvent BEG =======================");
|
||||||
}
|
}
|
||||||
if (!event.isLeftButton && !that.triggered) {
|
if (!event.isLeftButton && !that.triggered) {
|
||||||
// if another mouse button than left is pressed ignore it
|
// if another mouse button than left is pressed ignore it
|
||||||
|
@ -4155,28 +4323,18 @@ SelectionDisplay = (function() {
|
||||||
var somethingClicked = false;
|
var somethingClicked = false;
|
||||||
var pickRay = generalComputePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
|
|
||||||
var result = Overlays.findRayIntersection(pickRay, true, [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID]);
|
var results_checkHUD = checkIntersectWithHUD(pickRay);
|
||||||
if (result.intersects) {
|
if (results_checkHUD.intersects) {
|
||||||
// mouse clicks on the tablet should override the edit affordances
|
// mouse clicks on the tablet should override the edit affordances
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entityIconOverlayManager.setIconsSelectable(selectionManager.selections,true);
|
entityIconOverlayManager.setIconsSelectable(selectionManager.selections, true);
|
||||||
|
|
||||||
// ignore ray intersection for our selection box and yaw/pitch/roll
|
// ignore ray intersection for our selection box and yaw/pitch/roll
|
||||||
result = Overlays.findRayIntersection(pickRay, true, null, [ yawHandle, pitchHandle, rollHandle, selectionBox ] );
|
var results_checkNonSelection = checkIntersectWithNonSelectionItems(pickRay);
|
||||||
if (result.intersects) {
|
if (results_checkNonSelection.intersects) {
|
||||||
if (wantDebug) {
|
var tool = grabberTools[results_checkNonSelection.overlayID];
|
||||||
print("something intersects... ");
|
|
||||||
print(" result.overlayID:" + result.overlayID + "[" + overlayNames[result.overlayID] + "]");
|
|
||||||
print(" result.intersects:" + result.intersects);
|
|
||||||
print(" result.overlayID:" + result.overlayID);
|
|
||||||
print(" result.distance:" + result.distance);
|
|
||||||
print(" result.face:" + result.face);
|
|
||||||
Vec3.print(" result.intersection:", result.intersection);
|
|
||||||
}
|
|
||||||
|
|
||||||
var tool = grabberTools[result.overlayID];
|
|
||||||
if (tool) {
|
if (tool) {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("Intersected with known table tool( mode: " + tool.mode + " )");
|
print("Intersected with known table tool( mode: " + tool.mode + " )");
|
||||||
|
@ -4184,99 +4342,20 @@ SelectionDisplay = (function() {
|
||||||
activeTool = tool;
|
activeTool = tool;
|
||||||
mode = tool.mode;
|
mode = tool.mode;
|
||||||
somethingClicked = 'tool';
|
somethingClicked = 'tool';
|
||||||
if (activeTool && activeTool.onBegin) {
|
if (activeTool.onBegin) {
|
||||||
activeTool.onBegin(event);
|
activeTool.onBegin(event);
|
||||||
|
} else if (wantDebug) {
|
||||||
|
print(" ActiveTool( " + activeTool.mode + " ) missing onBegin");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (wantDebug) {
|
mode = "UNKNOWN";
|
||||||
print("Intersected with unregistered tool...");
|
}//--End_if(tool)
|
||||||
}
|
}//--End_if(results_checkNonSelection.intersects)
|
||||||
switch (result.overlayID) {
|
|
||||||
case grabberMoveUp:
|
|
||||||
if (wantDebug){
|
|
||||||
print("grabberMoveUp");
|
|
||||||
}
|
|
||||||
mode = "TRANSLATE_UP_DOWN";
|
|
||||||
somethingClicked = mode;
|
|
||||||
|
|
||||||
// in translate mode, we hide our stretch handles...
|
|
||||||
for (var i = 0; i < stretchHandles.length; i++) {
|
|
||||||
Overlays.editOverlay(stretchHandles[i], {
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case grabberNEAR:
|
|
||||||
case grabberEdgeTN: // TODO: maybe this should be TOP+NEAR stretching?
|
|
||||||
case grabberEdgeBN: // TODO: maybe this should be BOTTOM+FAR stretching?
|
|
||||||
if(wantDebug){
|
|
||||||
print("grabberNear variant");
|
|
||||||
}
|
|
||||||
mode = "STRETCH_NEAR";
|
|
||||||
somethingClicked = mode;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case grabberFAR:
|
|
||||||
case grabberEdgeTF: // TODO: maybe this should be TOP+FAR stretching?
|
|
||||||
case grabberEdgeBF: // TODO: maybe this should be BOTTOM+FAR stretching?
|
|
||||||
if(wantDebug){
|
|
||||||
print("grabberFar variant");
|
|
||||||
}
|
|
||||||
mode = "STRETCH_FAR";
|
|
||||||
somethingClicked = mode;
|
|
||||||
break;
|
|
||||||
case grabberTOP:
|
|
||||||
if(wantDebug){
|
|
||||||
print("grabberTOP");
|
|
||||||
}
|
|
||||||
mode = "STRETCH_TOP";
|
|
||||||
somethingClicked = mode;
|
|
||||||
break;
|
|
||||||
case grabberBOTTOM:
|
|
||||||
if(wantDebug){
|
|
||||||
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?
|
|
||||||
if(wantDebug){
|
|
||||||
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?
|
|
||||||
if(wantDebug){
|
|
||||||
print("grabberLeft variant");
|
|
||||||
}
|
|
||||||
mode = "STRETCH_LEFT";
|
|
||||||
somethingClicked = mode;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if(wantDebug){
|
|
||||||
print("UNKNOWN( " + result.overlayID + " )");
|
|
||||||
}
|
|
||||||
mode = "UNKNOWN";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(wantDebug){
|
|
||||||
print(" Unregistered Tool Mode: " + mode );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if one of the items above was clicked, then we know we are in translate or stretch mode, and we
|
// 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...
|
// should hide our rotate handles...
|
||||||
if (somethingClicked) {
|
if (somethingClicked) {
|
||||||
if(wantDebug){
|
if (wantDebug) {
|
||||||
print(" Trying to hide PitchYawRoll Handles");
|
print(" Trying to hide PitchYawRoll Handles");
|
||||||
}
|
}
|
||||||
Overlays.editOverlay(yawHandle, {
|
Overlays.editOverlay(yawHandle, {
|
||||||
|
@ -4307,133 +4386,45 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
|
|
||||||
// Only intersect versus yaw/pitch/roll.
|
// Only intersect versus yaw/pitch/roll.
|
||||||
result = Overlays.findRayIntersection(pickRay, true, [ yawHandle, pitchHandle, rollHandle ] );
|
var results_checkRotationHandles = checkIntersectWithRotationHandles(pickRay);
|
||||||
|
|
||||||
var overlayOrientation;
|
|
||||||
var overlayCenter;
|
|
||||||
|
|
||||||
var properties = Entities.getEntityProperties(selectionManager.selections[0]);
|
var properties = Entities.getEntityProperties(selectionManager.selections[0]);
|
||||||
var angles = Quat.safeEulerAngles(properties.rotation);
|
var angles = Quat.safeEulerAngles(properties.rotation);
|
||||||
var pitch = angles.x;
|
var pitch = angles.x;
|
||||||
var yaw = angles.y;
|
var yaw = angles.y;
|
||||||
var roll = angles.z;
|
var roll = angles.z;
|
||||||
|
|
||||||
|
//TODO_Case6491: Should these only be updated when we actually touched
|
||||||
|
// a handle. (The answer is most likley: Yes) Potentially move chunk
|
||||||
|
// to either tool's onBegin or before rayCast here when refactored.
|
||||||
originalRotation = properties.rotation;
|
originalRotation = properties.rotation;
|
||||||
originalPitch = pitch;
|
originalPitch = pitch;
|
||||||
originalYaw = yaw;
|
originalYaw = yaw;
|
||||||
originalRoll = roll;
|
originalRoll = roll;
|
||||||
|
|
||||||
if (result.intersects) {
|
if (results_checkRotationHandles.intersects) {
|
||||||
var resultTool = grabberTools[result.overlayID];
|
var resultTool = grabberTools[results_checkRotationHandles.overlayID];
|
||||||
if(wantDebug){
|
if (wantDebug) {
|
||||||
print("Intersection detected with handle...");
|
print("Intersection detected with handle...");
|
||||||
}
|
}
|
||||||
if (resultTool) {
|
if (resultTool) {
|
||||||
if(wantDebug){
|
if (wantDebug) {
|
||||||
print(" " + resultTool.mode);
|
print(" " + resultTool.mode);
|
||||||
}
|
}
|
||||||
activeTool = resultTool;
|
activeTool = resultTool;
|
||||||
mode = resultTool.mode;
|
somethingClicked = resultTool.mode;
|
||||||
somethingClicked = 'tool';
|
if(activeTool.onBegin) {
|
||||||
if (activeTool && activeTool.onBegin) {
|
activeTool.onBegin(event, results_checkRotationHandles.intersection);
|
||||||
if(wantDebug){
|
} else if (wantDebug) {
|
||||||
print(" Triggering Tool's onBegin");
|
print(" ActiveTool( " + activeTool.mode + " ) missing onBegin");
|
||||||
}
|
|
||||||
activeTool.onBegin(event);
|
|
||||||
} else if(wantDebug) {
|
|
||||||
print(" Tool's missing onBegin");
|
|
||||||
}
|
}
|
||||||
}
|
}//--End_If(resultTool)
|
||||||
switch (result.overlayID) {
|
}//--End_If(results_checkRotationHandles.intersects)
|
||||||
case yawHandle:
|
|
||||||
if(wantDebug){
|
|
||||||
print("Handle_YAW");
|
|
||||||
}
|
|
||||||
mode = "ROTATE_YAW";
|
|
||||||
somethingClicked = mode;
|
|
||||||
overlayOrientation = yawHandleRotation;
|
|
||||||
overlayCenter = yawCenter;
|
|
||||||
yawZero = result.intersection;
|
|
||||||
rotationNormal = yawNormal;
|
|
||||||
if(wantDebug){
|
|
||||||
print("rotationNormal set to: " + rotationNormal.x + ", " + rotationNormal.y + ", " + rotationNormal.z);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case pitchHandle:
|
if (somethingClicked) {
|
||||||
if(wantDebug){
|
|
||||||
print("Handle_PITCH");
|
|
||||||
}
|
|
||||||
mode = "ROTATE_PITCH";
|
|
||||||
initialPosition = SelectionManager.worldPosition;
|
|
||||||
somethingClicked = mode;
|
|
||||||
overlayOrientation = pitchHandleRotation;
|
|
||||||
overlayCenter = pitchCenter;
|
|
||||||
pitchZero = result.intersection;
|
|
||||||
rotationNormal = pitchNormal;
|
|
||||||
if(wantDebug){
|
|
||||||
print("rotationNormal set to: " + rotationNormal.x + ", " + rotationNormal.y + ", " + rotationNormal.z);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case rollHandle:
|
if (wantDebug) {
|
||||||
if(wantDebug){
|
print(" somethingClicked:" + somethingClicked);
|
||||||
print("Handle_ROLL");
|
print(" mode:" + mode);
|
||||||
}
|
|
||||||
mode = "ROTATE_ROLL";
|
|
||||||
somethingClicked = mode;
|
|
||||||
overlayOrientation = rollHandleRotation;
|
|
||||||
overlayCenter = rollCenter;
|
|
||||||
rollZero = result.intersection;
|
|
||||||
rotationNormal = rollNormal;
|
|
||||||
if(wantDebug){
|
|
||||||
print("rotationNormal set to: " + rotationNormal.x + ", " + rotationNormal.y + ", " + rotationNormal.z);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (wantDebug) {
|
|
||||||
print("mousePressEvent()...... " + overlayNames[result.overlayID]);
|
|
||||||
}
|
|
||||||
mode = "UNKNOWN";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (wantDebug) {
|
|
||||||
print(" somethingClicked:" + somethingClicked);
|
|
||||||
print(" mode:" + mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (somethingClicked) {
|
|
||||||
|
|
||||||
if(wantDebug){
|
|
||||||
print(" Trying to show rotateOverlay Handles");
|
|
||||||
}
|
|
||||||
Overlays.editOverlay(rotateOverlayTarget, {
|
|
||||||
visible: true,
|
|
||||||
rotation: overlayOrientation,
|
|
||||||
position: overlayCenter
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(rotateOverlayInner, {
|
|
||||||
visible: true,
|
|
||||||
rotation: overlayOrientation,
|
|
||||||
position: overlayCenter
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(rotateOverlayOuter, {
|
|
||||||
visible: true,
|
|
||||||
rotation: overlayOrientation,
|
|
||||||
position: overlayCenter,
|
|
||||||
startAt: 0,
|
|
||||||
endAt: 360
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(rotateOverlayCurrent, {
|
|
||||||
visible: true,
|
|
||||||
rotation: overlayOrientation,
|
|
||||||
position: overlayCenter,
|
|
||||||
startAt: 0,
|
|
||||||
endAt: 0
|
|
||||||
});
|
|
||||||
if(wantDebug){
|
|
||||||
print(" Trying to hide PitchYawRoll Handles");
|
print(" Trying to hide PitchYawRoll Handles");
|
||||||
}
|
}
|
||||||
Overlays.editOverlay(yawHandle, {
|
Overlays.editOverlay(yawHandle, {
|
||||||
|
@ -4541,49 +4532,31 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
if (!somethingClicked) {
|
if (!somethingClicked) {
|
||||||
// Only intersect versus selectionBox.
|
// Only intersect versus selectionBox.
|
||||||
result = Overlays.findRayIntersection(pickRay, true, [selectionBox]);
|
var results_checkSelectionBox = checkIntersectWithSelectionBox( pickRay );
|
||||||
if (result.intersects) {
|
if (results_checkSelectionBox.intersects) {
|
||||||
switch (result.overlayID) {
|
activeTool = translateXZTool;
|
||||||
case selectionBox:
|
if(wantDebug){
|
||||||
activeTool = translateXZTool;
|
print("Clicked selectionBox, Activating Tool: " + activeTool.mode );
|
||||||
if(wantDebug){
|
|
||||||
print("Clicked selectionBox, Activating Tool: " + activeTool.mode );
|
|
||||||
}
|
|
||||||
translateXZTool.pickPlanePosition = result.intersection;
|
|
||||||
translateXZTool.greatestDimension = Math.max(Math.max(SelectionManager.worldDimensions.x, SelectionManager.worldDimensions.y),
|
|
||||||
SelectionManager.worldDimensions.z);
|
|
||||||
if (wantDebug) {
|
|
||||||
print("longest dimension: " + translateXZTool.greatestDimension);
|
|
||||||
translateXZTool.startingDistance = Vec3.distance(pickRay.origin, SelectionManager.position);
|
|
||||||
print("starting distance: " + translateXZTool.startingDistance);
|
|
||||||
translateXZTool.startingElevation = translateXZTool.elevation(pickRay.origin, translateXZTool.pickPlanePosition);
|
|
||||||
print(" starting elevation: " + translateXZTool.startingElevation);
|
|
||||||
}
|
|
||||||
|
|
||||||
mode = translateXZTool.mode;
|
|
||||||
activeTool.onBegin(event);
|
|
||||||
somethingClicked = 'selectionBox';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (wantDebug) {
|
|
||||||
print("mousePressEvent()...... " + overlayNames[result.overlayID]);
|
|
||||||
}
|
|
||||||
mode = "UNKNOWN";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
var intersectInfo = {
|
||||||
|
queryRay: pickRay,
|
||||||
|
results: results_checkSelectionBox
|
||||||
|
};
|
||||||
|
activeTool.onBegin(event, null, intersectInfo);
|
||||||
|
somethingClicked = 'selectionBox';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (somethingClicked) {
|
if (somethingClicked) {
|
||||||
pickRay = generalComputePickRay(event.x, event.y);
|
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("mousePressEvent()...... " + overlayNames[result.overlayID]);
|
print("mousePressEvent()...... " + somethingClicked);
|
||||||
|
print(" mode: " + mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset everything as intersectable...
|
// reset everything as intersectable...
|
||||||
// TODO: we could optimize this since some of these were already flipped back(i.e: just get rid of this)
|
// TODO: we could optimize this since some of these were already flipped back(i.e: just get rid of this)
|
||||||
if(wantDebug){
|
if (wantDebug) {
|
||||||
print("Trying to set SelectionBox & PitchYawRoll Handles to NOT_IGNORE Rays");
|
print("Trying to set SelectionBox & PitchYawRoll Handles to NOT_IGNORE Rays");
|
||||||
}
|
}
|
||||||
Overlays.editOverlay(selectionBox, {
|
Overlays.editOverlay(selectionBox, {
|
||||||
|
@ -4599,8 +4572,8 @@ SelectionDisplay = (function() {
|
||||||
ignoreRayIntersection: false
|
ignoreRayIntersection: false
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( wantDebug ) {
|
if (wantDebug) {
|
||||||
print( "=============== eST::MousePressEvent END =======================");
|
print("=============== eST::MousePressEvent END =======================");
|
||||||
}
|
}
|
||||||
|
|
||||||
return somethingClicked;
|
return somethingClicked;
|
||||||
|
@ -4613,18 +4586,18 @@ SelectionDisplay = (function() {
|
||||||
print( "=============== eST::MouseMoveEvent BEG =======================");
|
print( "=============== eST::MouseMoveEvent BEG =======================");
|
||||||
}
|
}
|
||||||
if (activeTool) {
|
if (activeTool) {
|
||||||
if(wantDebug){
|
if (wantDebug) {
|
||||||
print(" Trigger ActiveTool( " + activeTool.mode + " )'s onMove");
|
print(" Trigger ActiveTool( " + activeTool.mode + " )'s onMove");
|
||||||
}
|
}
|
||||||
activeTool.onMove(event);
|
activeTool.onMove(event);
|
||||||
|
|
||||||
if(wantDebug){
|
if (wantDebug) {
|
||||||
print(" Trigger SelectionManager::update");
|
print(" Trigger SelectionManager::update");
|
||||||
}
|
}
|
||||||
SelectionManager._update();
|
SelectionManager._update();
|
||||||
|
|
||||||
if(wantDebug){
|
if (wantDebug) {
|
||||||
print( "=============== eST::MouseMoveEvent END =======================");
|
print("=============== eST::MouseMoveEvent END =======================");
|
||||||
}
|
}
|
||||||
//--EARLY EXIT--( Move handled via active tool)
|
//--EARLY EXIT--( Move handled via active tool)
|
||||||
return true;
|
return true;
|
||||||
|
@ -4710,7 +4683,7 @@ SelectionDisplay = (function() {
|
||||||
pickedAlpha = grabberAlpha;
|
pickedAlpha = grabberAlpha;
|
||||||
highlightNeeded = true;
|
highlightNeeded = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (previousHandle) {
|
if (previousHandle) {
|
||||||
Overlays.editOverlay(previousHandle, {
|
Overlays.editOverlay(previousHandle, {
|
||||||
|
|
Loading…
Reference in a new issue