mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 15:13:41 +02:00
fix entity selection tool
This commit is contained in:
parent
2db45b3ec9
commit
445608e163
3 changed files with 52 additions and 91 deletions
interface/src/ui/overlays
libraries/entities/src
scripts/system/libraries
|
@ -315,7 +315,15 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
|
|||
}
|
||||
|
||||
RENAME_PROP_CONVERT(drawInFront, renderLayer, [](const QVariant& v) { return v.toBool() ? "front" : "world"; });
|
||||
RENAME_PROP_CONVERT(drawHUDLayer, renderLayer, [](const QVariant& v) { return v.toBool() ? "hud" : "world"; });
|
||||
RENAME_PROP_CONVERT(drawHUDLayer, renderLayer, [=](const QVariant& v) {
|
||||
bool f = v.toBool();
|
||||
if (f) {
|
||||
return QVariant("hud");
|
||||
} else if (overlayProps.contains("renderLayer")) {
|
||||
return overlayProps["renderLayer"];
|
||||
}
|
||||
return QVariant("world");
|
||||
});
|
||||
|
||||
OVERLAY_TO_GROUP_ENTITY_PROP_DEFAULT(grabbable, grab, grabbable, false);
|
||||
|
||||
|
@ -380,14 +388,13 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
|
|||
{
|
||||
auto iter = overlayProps.find("rotation");
|
||||
if (iter != overlayProps.end()) {
|
||||
rotation = vec3FromVariant(iter.value());
|
||||
rotation = quatFromVariant(iter.value());
|
||||
} else if (!add) {
|
||||
EntityPropertyFlags desiredProperties;
|
||||
desiredProperties += PROP_ROTATION;
|
||||
rotation = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(id, desiredProperties).getRotation();
|
||||
}
|
||||
}
|
||||
// FIXME:
|
||||
overlayProps["rotation"] = quatToVariant(glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation);
|
||||
}
|
||||
|
||||
|
@ -584,7 +591,6 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie
|
|||
|
||||
RENAME_PROP_CONVERT(rotation, rotation, [](const QVariant& v) {
|
||||
glm::quat rot = quatFromVariant(v);
|
||||
// FIXME:
|
||||
return quatToVariant(glm::angleAxis((float)M_PI_2, rot * Vectors::RIGHT) * rot);
|
||||
});
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "EntityItemProperties.h"
|
||||
|
||||
#include <qmath.h>
|
||||
|
||||
EntityItemPointer GizmoEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
Pointer entity(new GizmoEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
|
@ -109,15 +111,14 @@ bool GizmoEntityItem::supportsDetailedIntersection() const {
|
|||
return _gizmoType == GizmoType::RING;
|
||||
}
|
||||
|
||||
#include <qmath.h>
|
||||
|
||||
bool GizmoEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
OctreeElementPointer& element,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal,
|
||||
QVariantMap& extraInfo, bool precisionPicking) const {
|
||||
glm::vec3 dimensions = getScaledDimensions();
|
||||
glm::vec2 xyDimensions(dimensions.x, dimensions.z);
|
||||
glm::quat rotation = glm::angleAxis((float)M_PI_2, Vectors::RIGHT) * getWorldOrientation();
|
||||
glm::quat rotation = getWorldOrientation();
|
||||
rotation = glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation;
|
||||
glm::vec3 position = getWorldPosition() + rotation * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()));
|
||||
|
||||
if (findRayRectangleIntersection(origin, direction, rotation, position, xyDimensions, distance)) {
|
||||
|
@ -150,7 +151,8 @@ bool GizmoEntityItem::findDetailedParabolaIntersection(const glm::vec3& origin,
|
|||
//// Scale the dimensions by the diameter
|
||||
glm::vec3 dimensions = getScaledDimensions();
|
||||
glm::vec2 xyDimensions(dimensions.x, dimensions.z);
|
||||
glm::quat rotation = glm::angleAxis((float)M_PI_2, Vectors::RIGHT) * getWorldOrientation();
|
||||
glm::quat rotation = getWorldOrientation();
|
||||
rotation = glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation;
|
||||
glm::vec3 position = getWorldPosition();
|
||||
|
||||
glm::quat inverseRot = glm::inverse(rotation);
|
||||
|
|
|
@ -796,26 +796,14 @@ SelectionDisplay = (function() {
|
|||
borderSize: 1.4
|
||||
});
|
||||
|
||||
var handlePropertiesBoundingEdge = {
|
||||
var handleBoundingBox = Overlays.addOverlay("cube", {
|
||||
alpha: 1,
|
||||
color: COLOR_BOUNDING_EDGE,
|
||||
visible: false,
|
||||
ignoreRayIntersection: true,
|
||||
ignorePickIntersection: true,
|
||||
drawInFront: true,
|
||||
lineWidth: 0.2
|
||||
};
|
||||
var handleBoundingTREdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingTLEdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingTFEdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingTNEdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingBREdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingBLEdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingBFEdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingBNEdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingNREdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingNLEdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingFREdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
var handleBoundingFLEdge = Overlays.addOverlay("line3d", handlePropertiesBoundingEdge);
|
||||
isSolid: false
|
||||
});
|
||||
|
||||
var handleDuplicator = Overlays.addOverlay("cube", {
|
||||
alpha: 1,
|
||||
|
@ -903,25 +891,13 @@ SelectionDisplay = (function() {
|
|||
handleStretchYPanel,
|
||||
handleStretchZPanel,
|
||||
handleScaleCube,
|
||||
handleBoundingTREdge,
|
||||
handleBoundingTLEdge,
|
||||
handleBoundingTFEdge,
|
||||
handleBoundingTNEdge,
|
||||
handleBoundingBREdge,
|
||||
handleBoundingBLEdge,
|
||||
handleBoundingBFEdge,
|
||||
handleBoundingBNEdge,
|
||||
handleBoundingNREdge,
|
||||
handleBoundingNLEdge,
|
||||
handleBoundingFREdge,
|
||||
handleBoundingFLEdge,
|
||||
handleBoundingBox,
|
||||
handleDuplicator,
|
||||
selectionBox,
|
||||
iconSelectionBox,
|
||||
xRailOverlay,
|
||||
yRailOverlay,
|
||||
zRailOverlay
|
||||
|
||||
];
|
||||
var maximumHandleInAllOverlays = handleDuplicator;
|
||||
|
||||
|
@ -947,18 +923,7 @@ SelectionDisplay = (function() {
|
|||
|
||||
overlayNames[handleScaleCube] = "handleScaleCube";
|
||||
|
||||
overlayNames[handleBoundingTREdge] = "handleBoundingTREdge";
|
||||
overlayNames[handleBoundingTLEdge] = "handleBoundingTLEdge";
|
||||
overlayNames[handleBoundingTFEdge] = "handleBoundingTFEdge";
|
||||
overlayNames[handleBoundingTNEdge] = "handleBoundingTNEdge";
|
||||
overlayNames[handleBoundingBREdge] = "handleBoundingBREdge";
|
||||
overlayNames[handleBoundingBLEdge] = "handleBoundingBLEdge";
|
||||
overlayNames[handleBoundingBFEdge] = "handleBoundingBFEdge";
|
||||
overlayNames[handleBoundingBNEdge] = "handleBoundingBNEdge";
|
||||
overlayNames[handleBoundingNREdge] = "handleBoundingNREdge";
|
||||
overlayNames[handleBoundingNLEdge] = "handleBoundingNLEdge";
|
||||
overlayNames[handleBoundingFREdge] = "handleBoundingFREdge";
|
||||
overlayNames[handleBoundingFLEdge] = "handleBoundingFLEdge";
|
||||
overlayNames[handleBoundingBox] = "handleBoundingBox";
|
||||
|
||||
overlayNames[handleDuplicator] = "handleDuplicator";
|
||||
overlayNames[selectionBox] = "selectionBox";
|
||||
|
@ -1048,7 +1013,19 @@ SelectionDisplay = (function() {
|
|||
return null;
|
||||
}
|
||||
|
||||
var intersectObj = Overlays.findRayIntersection(queryRay, true, overlayIncludes, overlayExcludes);
|
||||
var overlayIncludesLayered = overlayIncludes.filter(function (value, index, arr) {
|
||||
return value != selectionBox && value != iconSelectionBox;
|
||||
});
|
||||
var intersectObj = Overlays.findRayIntersection(queryRay, true, overlayIncludesLayered, overlayExcludes);
|
||||
|
||||
if (!intersectObj.intersects) {
|
||||
var overlayIncludesNonLayered = overlayIncludes.filter(function (value, index, arr) {
|
||||
return value == selectionBox || value == iconSelectionBox;
|
||||
});
|
||||
if (overlayIncludesNonLayered.length > 0) {
|
||||
intersectObj = Overlays.findRayIntersection(queryRay, true, [], overlayExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
if (wantDebug) {
|
||||
if (!overlayIncludes) {
|
||||
|
@ -1174,9 +1151,10 @@ SelectionDisplay = (function() {
|
|||
that.updateHighlight = function(event) {
|
||||
// if no tool is active, then just look for handles to highlight...
|
||||
var pickRay = generalComputePickRay(event.x, event.y);
|
||||
var result = Overlays.findRayIntersection(pickRay);
|
||||
var result = testRayIntersect(pickRay, allOverlays);
|
||||
var pickedColor;
|
||||
var highlightNeeded = false;
|
||||
print(JSON.stringify(result));
|
||||
|
||||
if (result.intersects) {
|
||||
switch (result.overlayID) {
|
||||
|
@ -1677,40 +1655,26 @@ SelectionDisplay = (function() {
|
|||
dimensions: scaleCubeDimensions
|
||||
});
|
||||
|
||||
// UPDATE BOUNDING BOX EDGES
|
||||
// UPDATE BOUNDING BOX
|
||||
Overlays.editOverlay(handleBoundingBox, {
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
dimensions: dimensions
|
||||
});
|
||||
|
||||
// UPDATE STRETCH HIGHLIGHT PANELS
|
||||
var edgeOffsetX = BOUNDING_EDGE_OFFSET * dimensions.x;
|
||||
var edgeOffsetY = BOUNDING_EDGE_OFFSET * dimensions.y;
|
||||
var edgeOffsetZ = BOUNDING_EDGE_OFFSET * dimensions.z;
|
||||
var LBNPosition = { x: -edgeOffsetX, y: -edgeOffsetY, z: -edgeOffsetZ };
|
||||
LBNPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, LBNPosition));
|
||||
var RBNPosition = { x: edgeOffsetX, y: -edgeOffsetY, z: -edgeOffsetZ };
|
||||
RBNPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, RBNPosition));
|
||||
var LBFPosition = { x: -edgeOffsetX, y: -edgeOffsetY, z: edgeOffsetZ };
|
||||
LBFPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, LBFPosition));
|
||||
var RBFPosition = { x: edgeOffsetX, y: -edgeOffsetY, z: edgeOffsetZ };
|
||||
RBFPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, RBFPosition));
|
||||
var RTFPosition = { x: edgeOffsetX, y: edgeOffsetY, z: edgeOffsetZ };
|
||||
RTFPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, RTFPosition));
|
||||
var LTNPosition = { x: -edgeOffsetX, y: edgeOffsetY, z: -edgeOffsetZ };
|
||||
LTNPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, LTNPosition));
|
||||
var RTNPosition = { x: edgeOffsetX, y: edgeOffsetY, z: -edgeOffsetZ };
|
||||
RTNPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, RTNPosition));
|
||||
var LTFPosition = { x: -edgeOffsetX, y: edgeOffsetY, z: edgeOffsetZ };
|
||||
LTFPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, LTFPosition));
|
||||
var RTFPosition = { x: edgeOffsetX, y: edgeOffsetY, z: edgeOffsetZ };
|
||||
RTFPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, RTFPosition));
|
||||
Overlays.editOverlay(handleBoundingTREdge, { start: RTNPosition, end: RTFPosition });
|
||||
Overlays.editOverlay(handleBoundingTLEdge, { start: LTNPosition, end: LTFPosition });
|
||||
Overlays.editOverlay(handleBoundingTFEdge, { start: LTFPosition, end: RTFPosition });
|
||||
Overlays.editOverlay(handleBoundingTNEdge, { start: LTNPosition, end: RTNPosition });
|
||||
Overlays.editOverlay(handleBoundingBREdge, { start: RBNPosition, end: RBFPosition });
|
||||
Overlays.editOverlay(handleBoundingBLEdge, { start: LBNPosition, end: LBFPosition });
|
||||
Overlays.editOverlay(handleBoundingBFEdge, { start: LBFPosition, end: RBFPosition });
|
||||
Overlays.editOverlay(handleBoundingBNEdge, { start: LBNPosition, end: RBNPosition });
|
||||
Overlays.editOverlay(handleBoundingNREdge, { start: RTNPosition, end: RBNPosition });
|
||||
Overlays.editOverlay(handleBoundingNLEdge, { start: LTNPosition, end: LBNPosition });
|
||||
Overlays.editOverlay(handleBoundingFREdge, { start: RTFPosition, end: RBFPosition });
|
||||
Overlays.editOverlay(handleBoundingFLEdge, { start: LTFPosition, end: LBFPosition });
|
||||
|
||||
// UPDATE STRETCH HIGHLIGHT PANELS
|
||||
|
||||
var RBFPositionRotated = Vec3.multiplyQbyV(rotationInverse, RBFPosition);
|
||||
var RTFPositionRotated = Vec3.multiplyQbyV(rotationInverse, RTFPosition);
|
||||
var LTNPositionRotated = Vec3.multiplyQbyV(rotationInverse, LTNPosition);
|
||||
|
@ -1841,7 +1805,7 @@ SelectionDisplay = (function() {
|
|||
var showOutlineForZone = (SelectionManager.selections.length === 1 &&
|
||||
typeof SelectionManager.savedProperties[SelectionManager.selections[0]] !== "undefined" &&
|
||||
SelectionManager.savedProperties[SelectionManager.selections[0]].type === "Zone");
|
||||
that.setHandleBoundingEdgeVisible(showOutlineForZone || (!isActiveTool(handleRotatePitchRing) &&
|
||||
that.setHandleBoundingBoxVisible(showOutlineForZone || (!isActiveTool(handleRotatePitchRing) &&
|
||||
!isActiveTool(handleRotateYawRing) &&
|
||||
!isActiveTool(handleRotateRollRing)));
|
||||
|
||||
|
@ -1941,26 +1905,15 @@ SelectionDisplay = (function() {
|
|||
// FUNCTION: SET HANDLE SCALE VISIBLE
|
||||
that.setHandleScaleVisible = function(isVisible) {
|
||||
that.setHandleScaleVisible(isVisible);
|
||||
that.setHandleBoundingEdgeVisible(isVisible);
|
||||
that.setHandleBoundingBoxVisible(isVisible);
|
||||
};
|
||||
|
||||
that.setHandleScaleVisible = function(isVisible) {
|
||||
Overlays.editOverlay(handleScaleCube, { visible: isVisible });
|
||||
};
|
||||
|
||||
that.setHandleBoundingEdgeVisible = function(isVisible) {
|
||||
Overlays.editOverlay(handleBoundingTREdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingTLEdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingTFEdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingTNEdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingBREdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingBLEdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingBFEdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingBNEdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingNREdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingNLEdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingFREdge, { visible: isVisible });
|
||||
Overlays.editOverlay(handleBoundingFLEdge, { visible: isVisible });
|
||||
that.setHandleBoundingBoxVisible = function(isVisible) {
|
||||
Overlays.editOverlay(handleBoundingBox, { visible: isVisible });
|
||||
};
|
||||
|
||||
// FUNCTION: SET HANDLE DUPLICATOR VISIBLE
|
||||
|
|
Loading…
Reference in a new issue