mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 05:17:24 +02:00
correctly handle unselect and dont show highlight when other tool is active
This commit is contained in:
parent
f21ff76a38
commit
caac5881bf
2 changed files with 35 additions and 30 deletions
|
@ -2254,8 +2254,9 @@ SelectionDisplay = (function () {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// nothing to do by default
|
// nothing to do by default
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.mouseReleaseEvent = function(event) {
|
that.mouseReleaseEvent = function(event) {
|
||||||
|
@ -2289,9 +2290,9 @@ SelectionDisplay = (function () {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: mousePressEvent from the main script should call us., so we don't
|
// NOTE: mousePressEvent and mouseMoveEvent from the main script should call us., so we don't hook these:
|
||||||
// hook the Controller.mousePressEvent.connect(that.mousePressEvent); ourselves.
|
// Controller.mousePressEvent.connect(that.mousePressEvent);
|
||||||
Controller.mouseMoveEvent.connect(that.mouseMoveEvent);
|
// Controller.mouseMoveEvent.connect(that.mouseMoveEvent);
|
||||||
Controller.mouseReleaseEvent.connect(that.mouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(that.mouseReleaseEvent);
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
|
@ -338,13 +338,15 @@ function rayPlaneIntersection(pickRay, point, normal) {
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
mouseLastPosition = { x: event.x, y: event.y };
|
mouseLastPosition = { x: event.x, y: event.y };
|
||||||
entitySelected = false;
|
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||||
|
|
||||||
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event) || selectionDisplay.mousePressEvent(event)) {
|
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event) || selectionDisplay.mousePressEvent(event)) {
|
||||||
// Event handled; do nothing.
|
// Event handled; do nothing.
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
entitySelected = false;
|
||||||
|
selectionDisplay.unselectAll();
|
||||||
|
|
||||||
// If we aren't active and didn't click on an overlay: quit
|
// If we aren't active and didn't click on an overlay: quit
|
||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
return;
|
return;
|
||||||
|
@ -441,34 +443,36 @@ function mouseMoveEvent(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
// allow the selectionDisplay to handle the event first, if it doesn't handle it, then do our own thing
|
||||||
if (!entitySelected) {
|
if (selectionDisplay.mouseMoveEvent(event)) {
|
||||||
var entityIntersection = Entities.findRayIntersection(pickRay);
|
|
||||||
if (entityIntersection.accurate) {
|
|
||||||
if(highlightedEntityID.isKnownID && highlightedEntityID.id != entityIntersection.entityID.id) {
|
|
||||||
selectionDisplay.unhighlightSelectable(highlightedEntityID);
|
|
||||||
highlightedEntityID = { id: -1, isKnownID: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
var halfDiagonal = Vec3.length(entityIntersection.properties.dimensions) / 2.0;
|
|
||||||
|
|
||||||
var angularSize = 2 * Math.atan(halfDiagonal / Vec3.distance(Camera.getPosition(),
|
|
||||||
entityIntersection.properties.position)) * 180 / 3.14;
|
|
||||||
|
|
||||||
var sizeOK = (allowLargeModels || angularSize < MAX_ANGULAR_SIZE)
|
|
||||||
&& (allowSmallModels || angularSize > MIN_ANGULAR_SIZE);
|
|
||||||
|
|
||||||
if (entityIntersection.entityID.isKnownID && sizeOK) {
|
|
||||||
if (wantEntityGlow) {
|
|
||||||
Entities.editEntity(entityIntersection.entityID, { glowLevel: 0.25 });
|
|
||||||
}
|
|
||||||
highlightedEntityID = entityIntersection.entityID;
|
|
||||||
selectionDisplay.highlightSelectable(entityIntersection.entityID);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
var entityIntersection = Entities.findRayIntersection(pickRay);
|
||||||
|
if (entityIntersection.accurate) {
|
||||||
|
if(highlightedEntityID.isKnownID && highlightedEntityID.id != entityIntersection.entityID.id) {
|
||||||
|
selectionDisplay.unhighlightSelectable(highlightedEntityID);
|
||||||
|
highlightedEntityID = { id: -1, isKnownID: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
var halfDiagonal = Vec3.length(entityIntersection.properties.dimensions) / 2.0;
|
||||||
|
|
||||||
|
var angularSize = 2 * Math.atan(halfDiagonal / Vec3.distance(Camera.getPosition(),
|
||||||
|
entityIntersection.properties.position)) * 180 / 3.14;
|
||||||
|
|
||||||
|
var sizeOK = (allowLargeModels || angularSize < MAX_ANGULAR_SIZE)
|
||||||
|
&& (allowSmallModels || angularSize > MIN_ANGULAR_SIZE);
|
||||||
|
|
||||||
|
if (entityIntersection.entityID.isKnownID && sizeOK) {
|
||||||
|
if (wantEntityGlow) {
|
||||||
|
Entities.editEntity(entityIntersection.entityID, { glowLevel: 0.25 });
|
||||||
|
}
|
||||||
|
highlightedEntityID = entityIntersection.entityID;
|
||||||
|
selectionDisplay.highlightSelectable(entityIntersection.entityID);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue