[Case 6491] Propagates rotation reposition fix from YawHandle (details below).

This wraps the selections rotation update handling into common helper
function utilized by all rotation handle tools (yaw,pitch,roll).

This function is the generalized fix previously exclusive to yawHandle.
This functions is now called within onMove for yaw, pitch, & rollHandle
tools.

NOTE(s):
* Tested yaw, pitch, & roll rotation didn't see any aberrant behavior.
** Tested overlapping shapes and selecting the overlapping portions followed
   by a rotation handle.  Only one took hold as a selection.
** Tested multiple selection and objects rotated & repositioned about the
   encapsulating bounding box's center point as expected.
* Tested translation with multiple items selected and it behaved as
  expected.

Reviewed-by: Leander Hasty <leander@1stplayable.com>

Changes Committed:
	modified:   scripts/system/libraries/entitySelectionTool.js
This commit is contained in:
LaShonda Hopper 2017-08-08 18:47:01 -04:00 committed by LaShonda Hopper
parent 18cc632df5
commit 926789437c

View file

@ -3629,6 +3629,38 @@ SelectionDisplay = (function() {
print( "<--- updateRotationDegreesOverlay ---" );
}
// FUNCTION DEF: updateSelectionsRotation
// Helper func used by rotation grabber tools
function updateSelectionsRotation( rotationChange ) {
if ( ! rotationChange ) {
print("ERROR( updateSelectionsRotation ) - Invalid arg specified!!");
//--EARLY EXIT--
return;
}
// Entities should only reposition if we are rotating multiple selections around
// the selections center point. Otherwise, the rotation will be around the entities
// registration point which does not need repositioning.
var reposition = (SelectionManager.selections.length > 1);
for (var i = 0; i < SelectionManager.selections.length; i++) {
var entityID = SelectionManager.selections[i];
var initialProperties = SelectionManager.savedProperties[entityID];
var newProperties = {
rotation: Quat.multiply(rotationChange, initialProperties.rotation),
};
if (reposition) {
var dPos = Vec3.subtract(initialProperties.position, initialPosition);
dPos = Vec3.multiplyQbyV(rotationChange, dPos);
newProperties.position = Vec3.sum(initialPosition, dPos);
}
Entities.editEntity(entityID, newProperties);
}
}
// YAW GRABBER TOOL DEFINITION
var initialPosition = SelectionManager.worldPosition;
addGrabberTool(yawHandle, {
@ -3756,27 +3788,7 @@ SelectionDisplay = (function() {
z: 0
});
// Entities should only reposition if we are rotating multiple selections around
// the selections center point. Otherwise, the rotation will be around the entities
// registration point which does not need repositioning.
var reposition = SelectionManager.selections.length > 1;
for (var i = 0; i < SelectionManager.selections.length; i++) {
var entityID = SelectionManager.selections[i];
var properties = Entities.getEntityProperties(entityID);
var initialProperties = SelectionManager.savedProperties[entityID];
var newProperties = {
rotation: Quat.multiply(yawChange, initialProperties.rotation),
};
if (reposition) {
var dPos = Vec3.subtract(initialProperties.position, initialPosition);
dPos = Vec3.multiplyQbyV(yawChange, dPos);
newProperties.position = Vec3.sum(initialPosition, dPos);
}
Entities.editEntity(entityID, newProperties);
}
updateSelectionsRotation( yawChange );
updateRotationDegreesOverlay(angleFromZero, yawHandleRotation, yawCenter);
@ -3961,17 +3973,7 @@ SelectionDisplay = (function() {
z: 0
});
for (var i = 0; i < SelectionManager.selections.length; i++) {
var entityID = SelectionManager.selections[i];
var initialProperties = SelectionManager.savedProperties[entityID];
var dPos = Vec3.subtract(initialProperties.position, initialPosition);
dPos = Vec3.multiplyQbyV(pitchChange, dPos);
Entities.editEntity(entityID, {
position: Vec3.sum(initialPosition, dPos),
rotation: Quat.multiply(pitchChange, initialProperties.rotation),
});
}
updateSelectionsRotation( pitchChange );
updateRotationDegreesOverlay(angleFromZero, pitchHandleRotation, pitchCenter);
@ -4154,17 +4156,8 @@ SelectionDisplay = (function() {
y: 0,
z: angleFromZero
});
for (var i = 0; i < SelectionManager.selections.length; i++) {
var entityID = SelectionManager.selections[i];
var initialProperties = SelectionManager.savedProperties[entityID];
var dPos = Vec3.subtract(initialProperties.position, initialPosition);
dPos = Vec3.multiplyQbyV(rollChange, dPos);
Entities.editEntity(entityID, {
position: Vec3.sum(initialPosition, dPos),
rotation: Quat.multiply(rollChange, initialProperties.rotation),
});
}
updateSelectionsRotation( rollChange );
updateRotationDegreesOverlay(angleFromZero, rollHandleRotation, rollCenter);