mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
Merge pull request #3580 from ZappoMan/editToolsImprovements
better handling of rotated entities
This commit is contained in:
commit
49c02267d3
3 changed files with 102 additions and 70 deletions
|
@ -454,22 +454,28 @@ SelectionDisplay = (function () {
|
|||
var rotateHandleOffset = 0.05;
|
||||
var grabberMoveUpOffset = 0.1;
|
||||
|
||||
var left = properties.position.x - halfDimensions.x;
|
||||
var right = properties.position.x + halfDimensions.x;
|
||||
var bottom = properties.position.y - halfDimensions.y;
|
||||
var top = properties.position.y + halfDimensions.y;
|
||||
var near = properties.position.z - halfDimensions.z;
|
||||
var far = properties.position.z + halfDimensions.z;
|
||||
var center = { x: properties.position.x, y: properties.position.y, z: properties.position.z };
|
||||
var top, far, left, bottom, near, right, boundsCenter, objectCenter, BLN, BRN, BLF, TLN, TRN, TLF, TRF;
|
||||
|
||||
var BLN = { x: left, y: bottom, z: near };
|
||||
var BRN = { x: right, y: bottom, z: near };
|
||||
var BLF = { x: left, y: bottom, z: far };
|
||||
var BRF = { x: right, y: bottom, z: far };
|
||||
var TLN = { x: left, y: top, z: near };
|
||||
var TRN = { x: right, y: top, z: near };
|
||||
var TLF = { x: left, y: top, z: far };
|
||||
var TRF = { x: right, y: top, z: far };
|
||||
objectCenter = { x: properties.position.x, y: properties.position.y, z: properties.position.z };
|
||||
|
||||
top = properties.boundingBox.tfl.y;
|
||||
far = properties.boundingBox.tfl.z;
|
||||
left = properties.boundingBox.tfl.x;
|
||||
|
||||
bottom = properties.boundingBox.brn.y;
|
||||
right = properties.boundingBox.brn.x;
|
||||
near = properties.boundingBox.brn.z;
|
||||
|
||||
boundsCenter = { x: properties.boundingBox.center.x, y: properties.boundingBox.center.y, z: properties.boundingBox.center.z };
|
||||
|
||||
BLN = { x: left, y: bottom, z: near };
|
||||
BRN = { x: right, y: bottom, z: near };
|
||||
BLF = { x: left, y: bottom, z: far };
|
||||
BRF = { x: right, y: bottom, z: far };
|
||||
TLN = { x: left, y: top, z: near };
|
||||
TRN = { x: right, y: top, z: near };
|
||||
TLF = { x: left, y: top, z: far };
|
||||
TRF = { x: right, y: top, z: far };
|
||||
|
||||
var yawCorner;
|
||||
var pitchCorner;
|
||||
|
@ -488,9 +494,10 @@ SelectionDisplay = (function () {
|
|||
|
||||
------------------------------*/
|
||||
|
||||
if (MyAvatar.position.x > center.x) {
|
||||
if (MyAvatar.position.x > objectCenter.x) {
|
||||
// must be BRF or BRN
|
||||
if (MyAvatar.position.z < center.z) {
|
||||
if (MyAvatar.position.z < objectCenter.z) {
|
||||
|
||||
yawHandleRotation = Quat.fromVec3Degrees({ x: 270, y: 90, z: 0 });
|
||||
pitchHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 90, z: 0 });
|
||||
rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 0 });
|
||||
|
@ -499,21 +506,21 @@ SelectionDisplay = (function () {
|
|||
pitchNormal = { x: 1, y: 0, z: 0 };
|
||||
rollNormal = { x: 0, y: 0, z: 1 };
|
||||
|
||||
yawCorner = { x: right + rotateHandleOffset,
|
||||
yawCorner = { x: left + rotateHandleOffset,
|
||||
y: bottom - rotateHandleOffset,
|
||||
z: near - rotateHandleOffset };
|
||||
|
||||
pitchCorner = { x: left - rotateHandleOffset,
|
||||
pitchCorner = { x: right - rotateHandleOffset,
|
||||
y: top + rotateHandleOffset,
|
||||
z: near - rotateHandleOffset};
|
||||
|
||||
rollCorner = { x: right + rotateHandleOffset,
|
||||
rollCorner = { x: left + rotateHandleOffset,
|
||||
y: top + rotateHandleOffset,
|
||||
z: far + rotateHandleOffset };
|
||||
|
||||
yawCenter = { x: center.x, y: bottom, z: center.z };
|
||||
pitchCenter = { x: left, y: center.y, z: center.z};
|
||||
rollCenter = { x: center.x, y: center.y, z: far };
|
||||
yawCenter = { x: boundsCenter.x, y: bottom, z: boundsCenter.z };
|
||||
pitchCenter = { x: right, y: boundsCenter.y, z: boundsCenter.z};
|
||||
rollCenter = { x: boundsCenter.x, y: boundsCenter.y, z: far };
|
||||
|
||||
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-south.png" });
|
||||
|
@ -521,6 +528,7 @@ SelectionDisplay = (function () {
|
|||
|
||||
|
||||
} else {
|
||||
|
||||
yawHandleRotation = Quat.fromVec3Degrees({ x: 270, y: 0, z: 0 });
|
||||
pitchHandleRotation = Quat.fromVec3Degrees({ x: 180, y: 270, z: 0 });
|
||||
rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 90 });
|
||||
|
@ -530,29 +538,31 @@ SelectionDisplay = (function () {
|
|||
rollNormal = { x: 0, y: 0, z: 1 };
|
||||
|
||||
|
||||
yawCorner = { x: right + rotateHandleOffset,
|
||||
yawCorner = { x: left + rotateHandleOffset,
|
||||
y: bottom - rotateHandleOffset,
|
||||
z: far + rotateHandleOffset };
|
||||
|
||||
pitchCorner = { x: left - rotateHandleOffset,
|
||||
pitchCorner = { x: right - rotateHandleOffset,
|
||||
y: top + rotateHandleOffset,
|
||||
z: far + rotateHandleOffset };
|
||||
|
||||
rollCorner = { x: right + rotateHandleOffset,
|
||||
rollCorner = { x: left + rotateHandleOffset,
|
||||
y: top + rotateHandleOffset,
|
||||
z: near - rotateHandleOffset};
|
||||
|
||||
|
||||
yawCenter = { x: center.x, y: bottom, z: center.z };
|
||||
pitchCenter = { x: left, y: center.y, z: center.z };
|
||||
rollCenter = { x: center.x, y: center.y, z: near};
|
||||
yawCenter = { x: boundsCenter.x, y: bottom, z: boundsCenter.z };
|
||||
pitchCenter = { x: right, y: boundsCenter.y, z: boundsCenter.z };
|
||||
rollCenter = { x: boundsCenter.x, y: boundsCenter.y, z: near};
|
||||
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
}
|
||||
} else {
|
||||
|
||||
// must be BLF or BLN
|
||||
if (MyAvatar.position.z < center.z) {
|
||||
if (MyAvatar.position.z < objectCenter.z) {
|
||||
|
||||
yawHandleRotation = Quat.fromVec3Degrees({ x: 270, y: 180, z: 0 });
|
||||
pitchHandleRotation = Quat.fromVec3Degrees({ x: 90, y: 0, z: 90 });
|
||||
rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 180 });
|
||||
|
@ -561,26 +571,27 @@ SelectionDisplay = (function () {
|
|||
pitchNormal = { x: 1, y: 0, z: 0 };
|
||||
rollNormal = { x: 0, y: 0, z: 1 };
|
||||
|
||||
yawCorner = { x: left - rotateHandleOffset,
|
||||
yawCorner = { x: right - rotateHandleOffset,
|
||||
y: bottom - rotateHandleOffset,
|
||||
z: near - rotateHandleOffset };
|
||||
|
||||
pitchCorner = { x: right + rotateHandleOffset,
|
||||
pitchCorner = { x: left + rotateHandleOffset,
|
||||
y: top + rotateHandleOffset,
|
||||
z: near - rotateHandleOffset };
|
||||
|
||||
rollCorner = { x: left - rotateHandleOffset,
|
||||
rollCorner = { x: right - rotateHandleOffset,
|
||||
y: top + rotateHandleOffset,
|
||||
z: far + rotateHandleOffset};
|
||||
|
||||
yawCenter = { x: center.x, y: bottom, z: center.z };
|
||||
pitchCenter = { x: right, y: center.y, z: center.z };
|
||||
rollCenter = { x: center.x, y: center.y, z: far};
|
||||
yawCenter = { x: boundsCenter.x, y: bottom, z: boundsCenter.z };
|
||||
pitchCenter = { x: left, y: boundsCenter.y, z: boundsCenter.z };
|
||||
rollCenter = { x: boundsCenter.x, y: boundsCenter.y, z: far};
|
||||
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
|
||||
} else {
|
||||
|
||||
yawHandleRotation = Quat.fromVec3Degrees({ x: 270, y: 270, z: 0 });
|
||||
rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 180 });
|
||||
pitchHandleRotation = Quat.fromVec3Degrees({ x: 180, y: 270, z: 0 });
|
||||
|
@ -589,21 +600,21 @@ SelectionDisplay = (function () {
|
|||
rollNormal = { x: 0, y: 0, z: 1 };
|
||||
pitchNormal = { x: 1, y: 0, z: 0 };
|
||||
|
||||
yawCorner = { x: left - rotateHandleOffset,
|
||||
yawCorner = { x: right - rotateHandleOffset,
|
||||
y: bottom - rotateHandleOffset,
|
||||
z: far + rotateHandleOffset };
|
||||
|
||||
rollCorner = { x: left - rotateHandleOffset,
|
||||
rollCorner = { x: right - rotateHandleOffset,
|
||||
y: top + rotateHandleOffset,
|
||||
z: near - rotateHandleOffset };
|
||||
|
||||
pitchCorner = { x: right + rotateHandleOffset,
|
||||
pitchCorner = { x: left + rotateHandleOffset,
|
||||
y: top + rotateHandleOffset,
|
||||
z: far + rotateHandleOffset};
|
||||
|
||||
yawCenter = { x: center.x, y: bottom, z: center.z };
|
||||
rollCenter = { x: center.x, y: center.y, z: near };
|
||||
pitchCenter = { x: right, y: center.y, z: center.z};
|
||||
yawCenter = { x: boundsCenter.x, y: bottom, z: boundsCenter.z };
|
||||
rollCenter = { x: boundsCenter.x, y: boundsCenter.y, z: near };
|
||||
pitchCenter = { x: left, y: boundsCenter.y, z: boundsCenter.z};
|
||||
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
|
@ -611,7 +622,6 @@ SelectionDisplay = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
var rotateHandlesVisible = true;
|
||||
var translateHandlesVisible = true;
|
||||
var stretchHandlesVisible = true;
|
||||
|
@ -632,17 +642,11 @@ SelectionDisplay = (function () {
|
|||
|
||||
Overlays.editOverlay(highlightBox, { visible: false });
|
||||
|
||||
print("selectionBoxVisible:" + selectionBoxVisible);
|
||||
Overlays.editOverlay(selectionBox,
|
||||
{
|
||||
visible: selectionBoxVisible,
|
||||
position: center,
|
||||
dimensions: properties.dimensions,
|
||||
rotation: properties.rotation,
|
||||
});
|
||||
Overlays.editOverlay(selectionBox, { visible: selectionBoxVisible, position: objectCenter, dimensions: properties.dimensions,
|
||||
rotation: properties.rotation,});
|
||||
|
||||
|
||||
Overlays.editOverlay(grabberMoveUp, { visible: translateHandlesVisible, position: { x: center.x, y: top + grabberMoveUpOffset, z: center.z } });
|
||||
Overlays.editOverlay(grabberMoveUp, { visible: translateHandlesVisible, position: { x: boundsCenter.x, y: top + grabberMoveUpOffset, z: boundsCenter.z } });
|
||||
|
||||
Overlays.editOverlay(grabberLBN, { visible: stretchHandlesVisible, position: { x: left, y: bottom, z: near } });
|
||||
Overlays.editOverlay(grabberRBN, { visible: stretchHandlesVisible, position: { x: right, y: bottom, z: near } });
|
||||
|
@ -654,25 +658,25 @@ SelectionDisplay = (function () {
|
|||
Overlays.editOverlay(grabberRTF, { visible: stretchHandlesVisible, position: { x: right, y: top, z: far } });
|
||||
|
||||
|
||||
Overlays.editOverlay(grabberTOP, { visible: stretchHandlesVisible, position: { x: center.x, y: top, z: center.z } });
|
||||
Overlays.editOverlay(grabberBOTTOM, { visible: stretchHandlesVisible, position: { x: center.x, y: bottom, z: center.z } });
|
||||
Overlays.editOverlay(grabberLEFT, { visible: stretchHandlesVisible, position: { x: left, y: center.y, z: center.z } });
|
||||
Overlays.editOverlay(grabberRIGHT, { visible: stretchHandlesVisible, position: { x: right, y: center.y, z: center.z } });
|
||||
Overlays.editOverlay(grabberNEAR, { visible: stretchHandlesVisible, position: { x: center.x, y: center.y, z: near } });
|
||||
Overlays.editOverlay(grabberFAR, { visible: stretchHandlesVisible, position: { x: center.x, y: center.y, z: far } });
|
||||
Overlays.editOverlay(grabberTOP, { visible: stretchHandlesVisible, position: { x: boundsCenter.x, y: top, z: boundsCenter.z } });
|
||||
Overlays.editOverlay(grabberBOTTOM, { visible: stretchHandlesVisible, position: { x: boundsCenter.x, y: bottom, z: boundsCenter.z } });
|
||||
Overlays.editOverlay(grabberLEFT, { visible: stretchHandlesVisible, position: { x: left, y: boundsCenter.y, z: boundsCenter.z } });
|
||||
Overlays.editOverlay(grabberRIGHT, { visible: stretchHandlesVisible, position: { x: right, y: boundsCenter.y, z: boundsCenter.z } });
|
||||
Overlays.editOverlay(grabberNEAR, { visible: stretchHandlesVisible, position: { x: boundsCenter.x, y: boundsCenter.y, z: near } });
|
||||
Overlays.editOverlay(grabberFAR, { visible: stretchHandlesVisible, position: { x: boundsCenter.x, y: boundsCenter.y, z: far } });
|
||||
|
||||
Overlays.editOverlay(grabberEdgeTR, { visible: stretchHandlesVisible, position: { x: right, y: top, z: center.z } });
|
||||
Overlays.editOverlay(grabberEdgeTL, { visible: stretchHandlesVisible, position: { x: left, y: top, z: center.z } });
|
||||
Overlays.editOverlay(grabberEdgeTF, { visible: stretchHandlesVisible, position: { x: center.x, y: top, z: far } });
|
||||
Overlays.editOverlay(grabberEdgeTN, { visible: stretchHandlesVisible, position: { x: center.x, y: top, z: near } });
|
||||
Overlays.editOverlay(grabberEdgeBR, { visible: stretchHandlesVisible, position: { x: right, y: bottom, z: center.z } });
|
||||
Overlays.editOverlay(grabberEdgeBL, { visible: stretchHandlesVisible, position: { x: left, y: bottom, z: center.z } });
|
||||
Overlays.editOverlay(grabberEdgeBF, { visible: stretchHandlesVisible, position: { x: center.x, y: bottom, z: far } });
|
||||
Overlays.editOverlay(grabberEdgeBN, { visible: stretchHandlesVisible, position: { x: center.x, y: bottom, z: near } });
|
||||
Overlays.editOverlay(grabberEdgeNR, { visible: stretchHandlesVisible, position: { x: right, y: center.y, z: near } });
|
||||
Overlays.editOverlay(grabberEdgeNL, { visible: stretchHandlesVisible, position: { x: left, y: center.y, z: near } });
|
||||
Overlays.editOverlay(grabberEdgeFR, { visible: stretchHandlesVisible, position: { x: right, y: center.y, z: far } });
|
||||
Overlays.editOverlay(grabberEdgeFL, { visible: stretchHandlesVisible, position: { x: left, y: center.y, z: far } });
|
||||
Overlays.editOverlay(grabberEdgeTR, { visible: stretchHandlesVisible, position: { x: right, y: top, z: boundsCenter.z } });
|
||||
Overlays.editOverlay(grabberEdgeTL, { visible: stretchHandlesVisible, position: { x: left, y: top, z: boundsCenter.z } });
|
||||
Overlays.editOverlay(grabberEdgeTF, { visible: stretchHandlesVisible, position: { x: boundsCenter.x, y: top, z: far } });
|
||||
Overlays.editOverlay(grabberEdgeTN, { visible: stretchHandlesVisible, position: { x: boundsCenter.x, y: top, z: near } });
|
||||
Overlays.editOverlay(grabberEdgeBR, { visible: stretchHandlesVisible, position: { x: right, y: bottom, z: boundsCenter.z } });
|
||||
Overlays.editOverlay(grabberEdgeBL, { visible: stretchHandlesVisible, position: { x: left, y: bottom, z: boundsCenter.z } });
|
||||
Overlays.editOverlay(grabberEdgeBF, { visible: stretchHandlesVisible, position: { x: boundsCenter.x, y: bottom, z: far } });
|
||||
Overlays.editOverlay(grabberEdgeBN, { visible: stretchHandlesVisible, position: { x: boundsCenter.x, y: bottom, z: near } });
|
||||
Overlays.editOverlay(grabberEdgeNR, { visible: stretchHandlesVisible, position: { x: right, y: boundsCenter.y, z: near } });
|
||||
Overlays.editOverlay(grabberEdgeNL, { visible: stretchHandlesVisible, position: { x: left, y: boundsCenter.y, z: near } });
|
||||
Overlays.editOverlay(grabberEdgeFR, { visible: stretchHandlesVisible, position: { x: right, y: boundsCenter.y, z: far } });
|
||||
Overlays.editOverlay(grabberEdgeFL, { visible: stretchHandlesVisible, position: { x: left, y: boundsCenter.y, z: far } });
|
||||
|
||||
|
||||
Overlays.editOverlay(baseOfEntityProjectionOverlay,
|
||||
|
|
|
@ -174,6 +174,16 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
|
|||
sittingPoints.setProperty("length", _sittingPoints.size());
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(sittingPoints, sittingPoints); // gettable, but not settable
|
||||
|
||||
AABox aaBox = getAABoxInMeters();
|
||||
QScriptValue boundingBox = engine->newObject();
|
||||
QScriptValue bottomRightNear = vec3toScriptValue(engine, aaBox.getCorner());
|
||||
QScriptValue topFarLeft = vec3toScriptValue(engine, aaBox.calcTopFarLeft());
|
||||
QScriptValue center = vec3toScriptValue(engine, aaBox.calcCenter());
|
||||
boundingBox.setProperty("brn", bottomRightNear);
|
||||
boundingBox.setProperty("tfl", topFarLeft);
|
||||
boundingBox.setProperty("center", center);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(boundingBox, boundingBox); // gettable, but not settable
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -643,3 +653,20 @@ AACube EntityItemProperties::getMaximumAACubeInMeters() const {
|
|||
|
||||
return AACube(minimumCorner, diameter);
|
||||
}
|
||||
|
||||
// The minimum bounding box for the entity.
|
||||
AABox EntityItemProperties::getAABoxInMeters() const {
|
||||
|
||||
// _position represents the position of the registration point.
|
||||
glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint;
|
||||
|
||||
glm::vec3 unrotatedMinRelativeToEntity = glm::vec3(0.0f, 0.0f, 0.0f) - (_dimensions * _registrationPoint);
|
||||
glm::vec3 unrotatedMaxRelativeToEntity = _dimensions * registrationRemainder;
|
||||
Extents unrotatedExtentsRelativeToRegistrationPoint = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
|
||||
Extents rotatedExtentsRelativeToRegistrationPoint = unrotatedExtentsRelativeToRegistrationPoint.getRotated(getRotation());
|
||||
|
||||
// shift the extents to be relative to the position/registration point
|
||||
rotatedExtentsRelativeToRegistrationPoint.shiftBy(_position);
|
||||
|
||||
return AABox(rotatedExtentsRelativeToRegistrationPoint);
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
|
||||
AACube getMaximumAACubeInTreeUnits() const;
|
||||
AACube getMaximumAACubeInMeters() const;
|
||||
AABox getAABoxInMeters() const;
|
||||
|
||||
void debugDump() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue