mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #13085 from ctrlaltdavid/21863
Fix intermittent ability to select particle and light entities
This commit is contained in:
commit
99960b3024
4 changed files with 67 additions and 35 deletions
|
@ -52,6 +52,11 @@ Script.include("/~/system/libraries/utils.js");
|
|||
if (controllerData.triggerClicks[this.hand]) {
|
||||
if (!this.triggerClicked) {
|
||||
this.selectedTarget = controllerData.rayPicks[this.hand];
|
||||
if (!this.selectedTarget.intersects) {
|
||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||
method: "clearSelection"
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (this.selectedTarget.type === Picks.INTERSECTED_ENTITY) {
|
||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||
|
|
|
@ -778,7 +778,6 @@ var toolBar = (function () {
|
|||
selectionDisplay.triggerMapping.enable();
|
||||
print("starting tablet in landscape mode");
|
||||
tablet.landscape = true;
|
||||
entityIconOverlayManager.setIconsSelectable(null,false);
|
||||
// Not sure what the following was meant to accomplish, but it currently causes
|
||||
// everybody else to think that Interface has lost focus overall. fogbugzid:558
|
||||
// Window.setFocus();
|
||||
|
|
|
@ -70,29 +70,6 @@ EntityIconOverlayManager = function(entityTypes, getOverlayPropertiesFunc) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
this.setIconsSelectable = function(arrayOfSelectedEntityIDs, isIconsSelectable) {
|
||||
if (arrayOfSelectedEntityIDs === null) {
|
||||
for (var id in entityOverlays) {
|
||||
Overlays.editOverlay(entityOverlays[id], {
|
||||
ignoreRayIntersection: isIconsSelectable
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (var id in entityOverlays) {
|
||||
if (arrayOfSelectedEntityIDs.indexOf(id) !== -1) { // in the entityOverlays array and selectable
|
||||
Overlays.editOverlay(entityOverlays[id], {
|
||||
ignoreRayIntersection: isIconsSelectable
|
||||
});
|
||||
} else {
|
||||
Overlays.editOverlay(entityOverlays[id], {
|
||||
ignoreRayIntersection: !isIconsSelectable
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Allocate or get an unused overlay
|
||||
function getOverlay() {
|
||||
var overlay;
|
||||
|
@ -138,9 +115,6 @@ EntityIconOverlayManager = function(entityTypes, getOverlayPropertiesFunc) {
|
|||
overlayProperties[key] = customProperties[key];
|
||||
}
|
||||
}
|
||||
if(properties.type === 'ParticleEffect' || properties.type === 'Light'){
|
||||
overlayProperties.ignoreRayIntersection = true;
|
||||
}
|
||||
Overlays.editOverlay(overlay, overlayProperties);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ SelectionManager = (function() {
|
|||
print("setting selection to " + messageParsed.entityID);
|
||||
}
|
||||
that.setSelections([messageParsed.entityID]);
|
||||
} else if (messageParsed.method === "clearSelection") {
|
||||
that.clearSelections();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,6 +200,8 @@ SelectionManager = (function() {
|
|||
that.worldPosition = properties.boundingBox.center;
|
||||
that.worldRotation = properties.boundingBox.rotation;
|
||||
|
||||
that.entityType = properties.type;
|
||||
|
||||
SelectionDisplay.setSpaceMode(SPACE_LOCAL);
|
||||
} else {
|
||||
that.localRotation = null;
|
||||
|
@ -206,6 +210,8 @@ SelectionManager = (function() {
|
|||
|
||||
properties = Entities.getEntityProperties(that.selections[0]);
|
||||
|
||||
that.entityType = properties.type;
|
||||
|
||||
var brn = properties.boundingBox.brn;
|
||||
var tfl = properties.boundingBox.tfl;
|
||||
|
||||
|
@ -535,6 +541,17 @@ SelectionDisplay = (function() {
|
|||
dashed: false
|
||||
});
|
||||
|
||||
// Handle for x-z translation of particle effect and light entities while inside the bounding box.
|
||||
// Limitation: If multiple entities are selected, only the first entity's icon translates the selection.
|
||||
var iconSelectionBox = Overlays.addOverlay("cube", {
|
||||
size: 0.3, // Match entity icon size.
|
||||
color: COLOR_RED,
|
||||
alpha: 0,
|
||||
solid: false,
|
||||
visible: false,
|
||||
dashed: false
|
||||
});
|
||||
|
||||
var allOverlays = [
|
||||
handleTranslateXCone,
|
||||
handleTranslateXCylinder,
|
||||
|
@ -574,7 +591,8 @@ SelectionDisplay = (function() {
|
|||
handleScaleFREdge,
|
||||
handleScaleFLEdge,
|
||||
handleCloner,
|
||||
selectionBox
|
||||
selectionBox,
|
||||
iconSelectionBox
|
||||
];
|
||||
|
||||
overlayNames[handleTranslateXCone] = "handleTranslateXCone";
|
||||
|
@ -621,6 +639,7 @@ SelectionDisplay = (function() {
|
|||
|
||||
overlayNames[handleCloner] = "handleCloner";
|
||||
overlayNames[selectionBox] = "selectionBox";
|
||||
overlayNames[iconSelectionBox] = "iconSelectionBox";
|
||||
|
||||
var activeTool = null;
|
||||
var handleTools = {};
|
||||
|
@ -691,6 +710,13 @@ SelectionDisplay = (function() {
|
|||
return intersectObj;
|
||||
}
|
||||
|
||||
function isPointInsideBox(point, box) {
|
||||
var position = Vec3.subtract(point, box.position);
|
||||
position = Vec3.multiplyQbyV(Quat.inverse(box.rotation), position);
|
||||
return Math.abs(position.x) <= box.dimensions.x / 2 && Math.abs(position.y) <= box.dimensions.y / 2
|
||||
&& Math.abs(position.z) <= box.dimensions.z / 2;
|
||||
}
|
||||
|
||||
// FUNCTION: MOUSE PRESS EVENT
|
||||
that.mousePressEvent = function (event) {
|
||||
var wantDebug = false;
|
||||
|
@ -723,8 +749,6 @@ SelectionDisplay = (function() {
|
|||
return false;
|
||||
}
|
||||
|
||||
entityIconOverlayManager.setIconsSelectable(SelectionManager.selections, true);
|
||||
|
||||
var hitTool = handleTools[ hitOverlayID ];
|
||||
if (hitTool) {
|
||||
activeTool = hitTool;
|
||||
|
@ -1309,12 +1333,26 @@ SelectionDisplay = (function() {
|
|||
var inModeRotate = isActiveTool(handleRotatePitchRing) ||
|
||||
isActiveTool(handleRotateYawRing) ||
|
||||
isActiveTool(handleRotateRollRing);
|
||||
Overlays.editOverlay(selectionBox, {
|
||||
var selectionBoxGeometry = {
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
dimensions: dimensions,
|
||||
visible: !inModeRotate
|
||||
});
|
||||
dimensions: dimensions
|
||||
};
|
||||
var isCameraInsideBox = isPointInsideBox(Camera.position, selectionBoxGeometry);
|
||||
selectionBoxGeometry.visible = !inModeRotate && !isCameraInsideBox;
|
||||
Overlays.editOverlay(selectionBox, selectionBoxGeometry);
|
||||
|
||||
// UPDATE ICON TRANSLATE HANDLE
|
||||
if (SelectionManager.entityType === "ParticleEffect" || SelectionManager.entityType === "Light") {
|
||||
var iconSelectionBoxGeometry = {
|
||||
position: position,
|
||||
rotation: rotation
|
||||
};
|
||||
iconSelectionBoxGeometry.visible = !inModeRotate && isCameraInsideBox;
|
||||
Overlays.editOverlay(iconSelectionBox, iconSelectionBoxGeometry);
|
||||
} else {
|
||||
Overlays.editOverlay(iconSelectionBox, { visible: false });
|
||||
}
|
||||
|
||||
// UPDATE CLONER (CURRENTLY HIDDEN FOR NOW)
|
||||
var handleClonerOffset = {
|
||||
|
@ -1386,7 +1424,7 @@ SelectionDisplay = (function() {
|
|||
|
||||
// FUNCTION: SET OVERLAYS VISIBLE
|
||||
that.setOverlaysVisible = function(isVisible) {
|
||||
for (var i = 0; i < allOverlays.length; i++) {
|
||||
for (var i = 0, length = allOverlays.length; i < length; i++) {
|
||||
Overlays.editOverlay(allOverlays[i], { visible: isVisible });
|
||||
}
|
||||
};
|
||||
|
@ -2399,6 +2437,22 @@ SelectionDisplay = (function() {
|
|||
}
|
||||
});
|
||||
|
||||
addHandleTool(iconSelectionBox, {
|
||||
mode: "TRANSLATE_XZ",
|
||||
onBegin: function (event, pickRay, pickResult) {
|
||||
translateXZTool.onBegin(event, pickRay, pickResult, false);
|
||||
},
|
||||
elevation: function (event) {
|
||||
translateXZTool.elevation(event);
|
||||
},
|
||||
onEnd: function (event) {
|
||||
translateXZTool.onEnd(event);
|
||||
},
|
||||
onMove: function (event) {
|
||||
translateXZTool.onMove(event);
|
||||
}
|
||||
});
|
||||
|
||||
addHandleTranslateTool(handleTranslateXCone, "TRANSLATE_X", TRANSLATE_DIRECTION.X);
|
||||
addHandleTranslateTool(handleTranslateXCylinder, "TRANSLATE_X", TRANSLATE_DIRECTION.X);
|
||||
addHandleTranslateTool(handleTranslateYCone, "TRANSLATE_Y", TRANSLATE_DIRECTION.Y);
|
||||
|
|
Loading…
Reference in a new issue