Skip to content

Commit

Permalink
Merge pull request #198 from overte-org/fix/2022.09.1_edit
Browse files Browse the repository at this point in the history
Fix/2022.09.1 edit
  • Loading branch information
ksuprynowicz authored Sep 20, 2022
2 parents 66b72c7 + 666ac42 commit 5b88619
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
30 changes: 16 additions & 14 deletions scripts/system/create/editModes/editVoxels.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
//

Script.include([
"./libraries/utils.js",
"entitySelectionTool/entitySelectionTool.js"
"../../libraries/utils.js",
"../entitySelectionTool/entitySelectionTool.js"
]);

var selectionManager = SelectionManager;
Expand Down Expand Up @@ -337,13 +337,25 @@ 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));
print("Intersection: " + JSON.stringify(intersection));
}

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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions scripts/system/create/entitySelectionTool/entitySelectionTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1253,6 +1258,8 @@ SelectionDisplay = (function() {
zRailToolEntity
];

that.allToolEntities = allToolEntities;

const nonLayeredToolEntities = [selectionBox, iconSelectionBox];

var maximumHandleInAllToolEntities = handleDuplicator;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1784,6 +1793,8 @@ SelectionDisplay = (function() {
}
}

that.controllerComputePickRay = controllerComputePickRay;

function generalComputePickRay(x, y) {
return controllerComputePickRay() || Camera.computePickRay(x, y);
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/system/create/qml/NewPolyVoxDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down Expand Up @@ -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;}
Expand Down Expand Up @@ -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;}
Expand Down

0 comments on commit 5b88619

Please sign in to comment.