From ab57e191a55b41e5d71f37f9fd00c05311e2d6a9 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Tue, 5 Jul 2022 22:25:46 +0200 Subject: [PATCH] Remove voxels with middle mouse button --- scripts/system/create/editModes/editVoxels.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/system/create/editModes/editVoxels.js b/scripts/system/create/editModes/editVoxels.js index 24710549e3..2f2f3ee488 100644 --- a/scripts/system/create/editModes/editVoxels.js +++ b/scripts/system/create/editModes/editVoxels.js @@ -38,6 +38,7 @@ EditVoxels = function() { var editSingleVoxels = false; var editSpheres = false; var editAdd = true; // Remove voxels if false + var inverseOperation = false; // True when middle mouse button or grip is pressed var brushPointer = false; var isActive = true; @@ -159,12 +160,17 @@ EditVoxels = function() { } lastEditValue = 0; - if(editAdd){ + if((editAdd && !inverseOperation) || (!editAdd && inverseOperation)){ lastEditValue = 255; } if (editSingleVoxels) { - var toDrawPosition = Vec3.subtract(voxelPosition, Vec3.multiply(pickRayDirInVoxelSpace, 0.1)); + var toDrawPosition = null; + if(lastEditValue === 255){ + toDrawPosition = Vec3.subtract(voxelPosition, Vec3.multiply(pickRayDirInVoxelSpace, 0.1)); + }else{ + toDrawPosition = Vec3.subtract(voxelPosition, Vec3.multiply(pickRayDirInVoxelSpace, -0.1)); + } if (wantDebug) { print("Calling setVoxel"); print("entityID: " + JSON.stringify(entityID)); @@ -237,9 +243,15 @@ EditVoxels = function() { print("=============== eV::mousePressEvent BEG ======================="); } - if (!event.isLeftButton && !triggered()) { + if (!(event.isLeftButton || event.isMiddleButton) && !triggered()) { return; } + + if (event.isMiddleButton){ + inverseOperation = true; + }else{ + inverseOperation = false; + } var pickRay = generalComputePickRay(event.x, event.y); var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking