From d62438d852448fe465fbc0ec8c86b7a6dbb322b5 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sat, 16 Jul 2022 20:19:50 +0200 Subject: [PATCH] Voxel UI cleanup and help text improvement --- .../src/RenderablePolyVoxEntityItem.cpp | 7 +------ scripts/system/create/editModes/editModes.js | 1 + scripts/system/create/editModes/editVoxels.js | 18 ------------------ scripts/system/html/gridControls.html | 13 ++----------- 4 files changed, 4 insertions(+), 35 deletions(-) diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index e961da0722..ad0b5123ec 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -273,7 +273,6 @@ QByteArray RenderablePolyVoxEntityItem::volDataToArray(quint16 voxelXSize, quint withReadLock([&] { if (isEdged()) { low += 1; - //voxelSize += 2; } loop3(ivec3(0), voxelSize, [&](const ivec3& v){ @@ -1027,11 +1026,7 @@ void RenderablePolyVoxEntityItem::uncompressVolumeData() { return; } - quint16 voxelXDataSize = voxelXSize; - quint16 voxelYDataSize = voxelYSize; - quint16 voxelZDataSize = voxelZSize; - - int rawSize = voxelXDataSize * voxelYDataSize * voxelZDataSize; + int rawSize = voxelXSize * voxelYSize * voxelZSize; QByteArray compressedData; reader >> compressedData; diff --git a/scripts/system/create/editModes/editModes.js b/scripts/system/create/editModes/editModes.js index 4f293bbae6..c61dda33a8 100644 --- a/scripts/system/create/editModes/editModes.js +++ b/scripts/system/create/editModes/editModes.js @@ -150,6 +150,7 @@ EditTools = function(options) { try { data = JSON.parse(data); } catch (e) { + console.log("editModes.js, EditTools.webEventReceived: Cannot parse received JSON data"); return; } diff --git a/scripts/system/create/editModes/editVoxels.js b/scripts/system/create/editModes/editVoxels.js index aeaad845fb..0e5e63caac 100644 --- a/scripts/system/create/editModes/editVoxels.js +++ b/scripts/system/create/editModes/editVoxels.js @@ -21,8 +21,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -//const { TRIGGER_ON_VALUE } = require("../../libraries/controllerDispatcherUtils"); - Script.include([ "./libraries/utils.js", "entitySelectionTool/entitySelectionTool.js" @@ -249,14 +247,11 @@ EditVoxels = function() { print("floorVector(toDrawPosition): " + JSON.stringify(floorVector(toDrawPosition))); } oldEditPosition = floorVector(toDrawPosition); - // TODO? Convert sphere radius from world to local - //var cubeDimension = Math.round(editSphereRadius); var cubeSizeWorld = {x : editSphereRadius * 2, y : editSphereRadius * 2, z : editSphereRadius * 2}; var zeroVecWorld = {x : 0, y: 0, z: 0}; var zeroVecLocal = Entities.worldCoordsToVoxelCoords(entityID, zeroVecWorld); var cubeSizeVecLocal = Entities.worldCoordsToVoxelCoords(entityID, cubeSizeWorld); cubeSize = ceilVector(Vec3.subtract(cubeSizeVecLocal, zeroVecLocal)); - //cubeDimension += (cubeDimension > 0) ? 0 : 1; var lowPosition = Vec3.subtract(oldEditPosition, Vec3.multiply(cubeSize, 0.5)); if (Entities.setVoxelsInCuboid(entityID, lowPosition, cubeSize, lastEditValue)){ Audio.playSystemSound((lastEditValue === 255) ? soundAdd : soundDelete); @@ -322,10 +317,6 @@ EditVoxels = function() { return; } - /*if (triggered() && selectionManager.pointingAtDesktopWindowOrTablet(that.triggeredHand)) { - return; - }*/ - if (event.isLeftButton || event.isMiddleButton){ if (event.isMiddleButton){ inverseOperation = true; @@ -566,11 +557,7 @@ EditVoxels = function() { function onUpdateHandler(delta){ var wantDebug = false; - //if (wantDebug) { - //print("=============== eV::onUpdateHandler BEG ======================="); - //} - if (isEditing === false || editedVoxelEntity === null){ return; } @@ -602,14 +589,12 @@ EditVoxels = function() { var globalOriginInVoxelSpace = Entities.worldCoordsToVoxelCoords(editedVoxelEntity, { x: 0, y: 0, z: 0 }); var pickRayDirInVoxelSpace = Vec3.subtract(Entities.worldCoordsToVoxelCoords(editedVoxelEntity, pickRay.direction), globalOriginInVoxelSpace); var voxelPickRayOrigin = Entities.worldCoordsToVoxelCoords(editedVoxelEntity, pickRay.origin); - //var pickRayDirInVoxelSpace = Vec3.subtract(voxelPickRayOrigin, voxelPickRayDirection); pickRayDirInVoxelSpace = Vec3.normalize(pickRayDirInVoxelSpace); var directionMultiplier = 1.0; var offsetVector = { x: 0, y: 0, z: 0 }; switch (editPlane) { // 0 - plane parallel to YZ plane case 0: - //var dirSign = (pickRayDirInVoxelSpace.x > 0) ? 1 : -1; offsetVector.x = 0.5; offsetVector.y = (offsetVector.x / pickRayDirInVoxelSpace.x) * pickRayDirInVoxelSpace.y; offsetVector.z = (offsetVector.x / pickRayDirInVoxelSpace.x) * pickRayDirInVoxelSpace.z; @@ -617,7 +602,6 @@ EditVoxels = function() { break; // 1 - plane parallel to XZ plane case 1: - //var dirSign = (pickRayDirInVoxelSpace.x > 0) ? 1 : -1; offsetVector.y = 0.5; offsetVector.x = (offsetVector.y / pickRayDirInVoxelSpace.y) * pickRayDirInVoxelSpace.x; offsetVector.z = (offsetVector.y / pickRayDirInVoxelSpace.y) * pickRayDirInVoxelSpace.z; @@ -625,7 +609,6 @@ EditVoxels = function() { break; // 2 - plane parallel to XY plane case 2: - //var dirSign = (pickRayDirInVoxelSpace.x > 0) ? 1 : -1; offsetVector.z = 0.5; offsetVector.x = (offsetVector.z / pickRayDirInVoxelSpace.z) * pickRayDirInVoxelSpace.x; offsetVector.y = (offsetVector.z / pickRayDirInVoxelSpace.z) * pickRayDirInVoxelSpace.y; @@ -634,7 +617,6 @@ EditVoxels = function() { default: return; } - //directionMultiplier = 0.1; intersectionPoint = Vec3.sum(Vec3.multiply(pickRayDirInVoxelSpace, directionMultiplier), voxelPickRayOrigin); newEditPosition = floorVector(Vec3.sum(intersectionPoint, offsetVector)); diff --git a/scripts/system/html/gridControls.html b/scripts/system/html/gridControls.html index fc3aa3dfca..7dad236847 100644 --- a/scripts/system/html/gridControls.html +++ b/scripts/system/html/gridControls.html @@ -24,10 +24,6 @@
-
@@ -51,11 +47,6 @@

Voxel edit settings

-
@@ -97,9 +88,9 @@

To edit voxels, Voxel Edit Mode needs to be selected.

Desktop mode:

-

Click left mouse button to add voxel. Click middle mouse button to remove voxel. Hold mouse button and move mouse to add/remove voxels in a single plane. Plane is determined by the direction where you are looking when first voxel is added/removed (for example look downwards for horizontal plane.

+

Click the left mouse button to add voxel. Click the middle mouse button to remove voxel. Hold the mouse button and move mouse to add/remove voxels in a single plane. Plane is determined by the direction in which you are looking when first voxel is added/removed (for example look downwards to draw in horizontal plane).

VR mode:

-

Pressing trigger adds a voxel. Pressing trigger while holding grip removes it. Hold trigger to add multiple voxels in a single plane. Initial direction of controller ray determies the plane. Hold both grips and move your hands together or apart to change size of edit sphere.

+

Press the trigger to add a voxel. Press the trigger while holding grip to remove voxel. Hold the trigger and move controller to add/remove voxels in a single plane. Plane is determined by the direction in which the controller ray points when first voxel is added/removed (for example point downwards to draw in horizontal plane). Hold both grips and move your hands together or apart to change size of edit sphere.