Merge pull request #191 from overte-org/fix/create_app_intersections

Fixed create app entity intersections in VR, increased default voxel resolution
This commit is contained in:
ksuprynowicz 2022-09-18 22:16:11 +02:00 committed by GitHub
commit a89ddf2d26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 17 deletions

View file

@ -22,8 +22,8 @@
//
Script.include([
"./libraries/utils.js",
"entitySelectionTool/entitySelectionTool.js"
"../../libraries/utils.js",
"../entitySelectionTool/entitySelectionTool.js"
]);
var selectionManager = SelectionManager;
@ -337,6 +337,7 @@ EditVoxels = function() {
var pickRay = generalComputePickRay(event.x, event.y);
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
var overlaysIntersection = Overlays.findRayIntersection(pickRay, true); // accurate picking
if (wantDebug) {
print("Pick ray: " + JSON.stringify(pickRay));
@ -344,6 +345,17 @@ EditVoxels = function() {
}
if (intersection.intersects) {
if (overlaysIntersection.intersects) {
var overlaysIntersectionDistance = Vec3.distance(overlaysIntersection.intersection, pickRay.origin);
var intersectionDistance = Vec3.distance(intersection.intersection, pickRay.origin);
if (wantDebug) {
print("overlaysIntersectionDistance: " + overlaysIntersectionDistance);
print("intersectionDistance: " + intersectionDistance);
}
if (overlaysIntersectionDistance < intersectionDistance) {
return;
}
}
if (attemptVoxelChangeForEntity(intersection.entityID, pickRay.direction, intersection.intersection)) {
Script.update.connect(onUpdateHandler);
isOnUpdateConnected = true;
@ -409,16 +421,6 @@ EditVoxels = function() {
return that.triggeredHand !== NO_HAND;
};
function pointingAtDesktopWindowOrTablet(hand) {
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
SelectionManager.pointingAtDesktopWindowRight) ||
(hand === Controller.Standard.LeftHand &&
SelectionManager.pointingAtDesktopWindowLeft);
var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) ||
(hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft);
return pointingAtDesktopWindow || pointingAtTablet;
}
function makeClickHandler(hand) {
return function (clicked) {
if (!editEnabled) {
@ -428,7 +430,7 @@ EditVoxels = function() {
if (triggered() && hand !== that.triggeredHand) {
return;
}
if (!triggered() && clicked && !pointingAtDesktopWindowOrTablet(hand)) {
if (!triggered() && clicked) {
that.triggeredHand = hand;
mousePressEvent({});
} else if (triggered() && !clicked) {
@ -443,7 +445,7 @@ EditVoxels = function() {
if (!editEnabled) {
return;
}
if (value >= TRIGGER_ON_VALUE && !triggered() && !pointingAtDesktopWindowOrTablet(hand)) {
if (value >= TRIGGER_ON_VALUE && !triggered()) {
that.pressedHand = hand;
} else {
that.pressedHand = NO_HAND;

View file

@ -130,6 +130,11 @@ SelectionManager = (function() {
audioFeedback.action();
}
} else {
var pickRay = SelectionDisplay.controllerComputePickRay();
var intersectObj = SelectionDisplay.testRayIntersect(pickRay, SelectionDisplay.allToolEntities);
if (intersectObj.intersects) {
return;
}
if (hmdMultiSelectMode) {
that.addEntity(messageParsed.entityID, true, that);
} else {
@ -1253,6 +1258,8 @@ SelectionDisplay = (function() {
zRailToolEntity
];
that.allToolEntities = allToolEntities;
const nonLayeredToolEntities = [selectionBox, iconSelectionBox];
var maximumHandleInAllToolEntities = handleDuplicator;
@ -1419,6 +1426,8 @@ SelectionDisplay = (function() {
return intersectObj;
}
that.testRayIntersect = testRayIntersect;
function isPointInsideBox(point, box) {
var position = Vec3.subtract(point, box.position);
position = Vec3.multiplyQbyV(Quat.inverse(box.rotation), position);
@ -1784,6 +1793,8 @@ SelectionDisplay = (function() {
}
}
that.controllerComputePickRay = controllerComputePickRay;
function generalComputePickRay(x, y) {
return controllerComputePickRay() || Camera.computePickRay(x, y);
}

View file

@ -302,7 +302,7 @@ Rectangle {
width: 50
anchors.left: textVolumeSizeX.right
anchors.leftMargin: 3
text: qsTr("16")
text: qsTr("20")
color: "white"
font.pixelSize: 12
validator: IntValidator{bottom: 8; top: 64;}
@ -344,7 +344,7 @@ Rectangle {
width: 50
anchors.left: textVolumeSizeY.right
anchors.leftMargin: 3
text: qsTr("16")
text: qsTr("20")
color: "white"
font.pixelSize: 12
validator: IntValidator{bottom: 8; top: 64;}
@ -385,7 +385,7 @@ Rectangle {
width: 50
anchors.left: textVolumeSizeZ.right
anchors.leftMargin: 3
text: qsTr("16")
text: qsTr("20")
color: "white"
font.pixelSize: 12
validator: IntValidator{bottom: 8; top: 64;}