mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 20:42:12 +02:00
Basic voxel editing for desktop mode
This commit is contained in:
parent
4acdf8502d
commit
51b267a18f
4 changed files with 40 additions and 5 deletions
|
@ -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));
|
||||
|
|
|
@ -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 = [];
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue