diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index de572c221e..cc6f5d84e7 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -136,6 +136,7 @@ var editTools = new EditTools({ var editVoxels = new EditVoxels(); editTools.addListener(editVoxels.updateEditSettings); +editTools.addListener(selectionManager.updateEditSettings); var entityShapeVisualizerSessionName = "SHAPE_VISUALIZER_" + Uuid.generate(); @@ -781,7 +782,7 @@ var toolBar = (function () { xTextureURL: result.xTextureURL, yTextureURL: result.yTextureURL, zTextureURL: result.zTextureURL, - voxelSurfaceStyle: 3, + voxelSurfaceStyle: voxelSurfaceStyle, collisionless: !(result.collisions), grab: { grabbable: result.grabbable @@ -1103,6 +1104,8 @@ var toolBar = (function () { isActive = active; activeButton.editProperties({isActive: isActive}); undoHistory.setEnabled(isActive); + + editVoxels.setActive(active); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); @@ -1456,7 +1459,7 @@ function mouseClickEvent(event) { var sizeOK = (allowLargeModels || angularSize < MAX_ANGULAR_SIZE) && (allowSmallModels || angularSize > MIN_ANGULAR_SIZE); - if (0 < x && sizeOK) { + if (0 < x && sizeOK && selectionManager.editEnabled) { selectedEntityID = foundEntity; orientation = MyAvatar.orientation; intersection = rayPlaneIntersection(pickRay, P, Quat.getForward(orientation)); diff --git a/scripts/system/create/editModes/editModes.js b/scripts/system/create/editModes/editModes.js index d3a6b9d202..835029f878 100644 --- a/scripts/system/create/editModes/editModes.js +++ b/scripts/system/create/editModes/editModes.js @@ -24,7 +24,7 @@ EditTools = function(options) { var voxelSphereSize = 0.3; var voxelEditDynamics = "click"; var voxelRemove = false; - var voxelPointerMode = "single"; + var voxelPointerMode = "laser"; var voxelBrushLength = 0.5; var listeners = []; diff --git a/scripts/system/create/editModes/editVoxels.js b/scripts/system/create/editModes/editVoxels.js index a9ee82e946..0d27246848 100644 --- a/scripts/system/create/editModes/editVoxels.js +++ b/scripts/system/create/editModes/editVoxels.js @@ -19,6 +19,7 @@ Script.include([ ]); EditVoxels = function() { + var self = this; var that = {}; var controlHeld = false; @@ -33,10 +34,15 @@ EditVoxels = function() { var deletingCubes = false; var continuousPaint = false; var brushPointer = false; + var isActive = true; var editSphereRadius = 0.15; var brushLength = 0.5; + that.setActive = function(active) { + isActive = (active === true); + } + that.updateEditSettings = function(data) { if (data.createAppMode) { @@ -114,7 +120,7 @@ EditVoxels = function() { return false; } - if (!editEnabled) { + if (!editEnabled || !isActive) { return false; } @@ -224,7 +230,9 @@ EditVoxels = function() { } function cleanup() { - toolBar.cleanup(); + Controller.mousePressEvent.disconnect(self.mousePressEvent); + Controller.keyPressEvent.disconnect(self.keyPressEvent); + Controller.keyReleaseEvent.disconnect(self.keyReleaseEvent); } Controller.mousePressEvent.connect(mousePressEvent); diff --git a/scripts/system/create/entitySelectionTool/entitySelectionTool.js b/scripts/system/create/entitySelectionTool/entitySelectionTool.js index 257d4fb407..4eb6f65663 100644 --- a/scripts/system/create/entitySelectionTool/entitySelectionTool.js +++ b/scripts/system/create/entitySelectionTool/entitySelectionTool.js @@ -187,6 +187,21 @@ SelectionManager = (function() { that.pointingAtDesktopWindowRight = false; that.pointingAtTabletLeft = false; that.pointingAtTabletRight = false; + that.editEnabled = true; + + that.updateEditSettings = function(data) { + + if (data.createAppMode) { + if (data.createAppMode === "object"){ + that.editEnabled = true; + } else { + that.editEnabled = false; + if(that.hasSelection()){ + that.clearSelections(); + } + } + } + } that.saveProperties = function() { that.savedProperties = {}; @@ -1303,6 +1318,9 @@ SelectionDisplay = (function() { } function makeClickHandler(hand) { return function (clicked) { + if (!SelectionManager.editEnabled) { + return; + } // Don't allow both hands to trigger at the same time if (that.triggered() && hand !== that.triggeredHand) { return; @@ -1318,6 +1336,9 @@ SelectionDisplay = (function() { } function makePressHandler(hand) { return function (value) { + if (!SelectionManager.editEnabled) { + return; + } if (value >= TRIGGER_ON_VALUE && !that.triggered() && !pointingAtDesktopWindowOrTablet(hand)) { that.pressedHand = hand; that.updateHighlight({}); @@ -1413,6 +1434,9 @@ SelectionDisplay = (function() { if (wantDebug) { print("=============== eST::MousePressEvent BEG ======================="); } + if (!SelectionManager.editEnabled) { + return; + } if (!event.isLeftButton && !that.triggered()) { // EARLY EXIT-(if another mouse button than left is pressed ignore it) return false;