mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +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;
|
||||
default:
|
||||
// nothing to do by default
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
that.mouseReleaseEvent = function(event) {
|
||||
|
@ -2289,9 +2290,9 @@ SelectionDisplay = (function () {
|
|||
|
||||
};
|
||||
|
||||
// NOTE: mousePressEvent from the main script should call us., so we don't
|
||||
// hook the Controller.mousePressEvent.connect(that.mousePressEvent); ourselves.
|
||||
Controller.mouseMoveEvent.connect(that.mouseMoveEvent);
|
||||
// NOTE: mousePressEvent and mouseMoveEvent from the main script should call us., so we don't hook these:
|
||||
// Controller.mousePressEvent.connect(that.mousePressEvent);
|
||||
// Controller.mouseMoveEvent.connect(that.mouseMoveEvent);
|
||||
Controller.mouseReleaseEvent.connect(that.mouseReleaseEvent);
|
||||
|
||||
return that;
|
||||
|
|
|
@ -338,13 +338,15 @@ function rayPlaneIntersection(pickRay, point, normal) {
|
|||
|
||||
function mousePressEvent(event) {
|
||||
mouseLastPosition = { x: event.x, y: event.y };
|
||||
entitySelected = false;
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
|
||||
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event) || selectionDisplay.mousePressEvent(event)) {
|
||||
// Event handled; do nothing.
|
||||
return;
|
||||
} else {
|
||||
entitySelected = false;
|
||||
selectionDisplay.unselectAll();
|
||||
|
||||
// If we aren't active and didn't click on an overlay: quit
|
||||
if (!isActive) {
|
||||
return;
|
||||
|
@ -440,34 +442,36 @@ function mouseMoveEvent(event) {
|
|||
if (!isActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
// allow the selectionDisplay to handle the event first, if it doesn't handle it, then do our own thing
|
||||
if (selectionDisplay.mouseMoveEvent(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||
if (!entitySelected) {
|
||||
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);
|
||||
}
|
||||
|
||||
var entityIntersection = Entities.findRayIntersection(pickRay);
|
||||
if (entityIntersection.accurate) {
|
||||
if(highlightedEntityID.isKnownID && highlightedEntityID.id != entityIntersection.entityID.id) {
|
||||
selectionDisplay.unhighlightSelectable(highlightedEntityID);
|
||||
highlightedEntityID = { id: -1, isKnownID: false };
|
||||
}
|
||||
return;
|
||||
|
||||
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