mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:13:28 +02:00
make changes to local tree in Voxels JS interface
This commit is contained in:
parent
9831fb5797
commit
f1577d12a0
2 changed files with 21 additions and 3 deletions
|
@ -923,7 +923,6 @@ print("clickedOverlay="+clickedOverlay);
|
|||
}
|
||||
|
||||
voxelDetails = calculateVoxelFromIntersection(intersection,"add");
|
||||
Voxels.eraseVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s);
|
||||
Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s,
|
||||
newColor.red, newColor.green, newColor.blue);
|
||||
lastVoxelPosition = { x: voxelDetails.x, y: voxelDetails.y, z: voxelDetails.z };
|
||||
|
@ -965,7 +964,6 @@ function keyPressEvent(event) {
|
|||
red: colors[color].red,
|
||||
green: colors[color].green,
|
||||
blue: colors[color].blue };
|
||||
Voxels.eraseVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s);
|
||||
Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue);
|
||||
setAudioPosition();
|
||||
Audio.playSound(addSound, audioOptions);
|
||||
|
@ -1054,7 +1052,6 @@ function mouseMoveEvent(event) {
|
|||
var dy = event.y - mouseY;
|
||||
if (Math.sqrt(dx*dx + dy*dy) > PIXELS_PER_EXTRUDE_VOXEL) {
|
||||
lastVoxelPosition = Vec3.sum(lastVoxelPosition, extrudeDirection);
|
||||
Voxels.eraseVoxel(lastVoxelPosition.x, lastVoxelPosition.y, lastVoxelPosition.z,extrudeScale);
|
||||
Voxels.setVoxel(lastVoxelPosition.x, lastVoxelPosition.y, lastVoxelPosition.z,
|
||||
extrudeScale, lastVoxelColor.red, lastVoxelColor.green, lastVoxelColor.blue);
|
||||
mouseX = event.x;
|
||||
|
|
|
@ -20,6 +20,13 @@ void VoxelsScriptingInterface::setVoxelNonDestructive(float x, float y, float z,
|
|||
|
||||
// queue the packet
|
||||
queueVoxelAdd(PacketTypeVoxelSet, addVoxelDetail);
|
||||
|
||||
// handle the local tree also...
|
||||
if (_tree) {
|
||||
_tree->lockForWrite();
|
||||
_tree->createVoxel(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s, red, green, blue, false);
|
||||
_tree->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelsScriptingInterface::setVoxel(float x, float y, float z, float scale,
|
||||
|
@ -30,6 +37,13 @@ void VoxelsScriptingInterface::setVoxel(float x, float y, float z, float scale,
|
|||
|
||||
// queue the destructive add
|
||||
queueVoxelAdd(PacketTypeVoxelSetDestructive, addVoxelDetail);
|
||||
|
||||
// handle the local tree also...
|
||||
if (_tree) {
|
||||
_tree->lockForWrite();
|
||||
_tree->createVoxel(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s, red, green, blue, true);
|
||||
_tree->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelsScriptingInterface::eraseVoxel(float x, float y, float z, float scale) {
|
||||
|
@ -39,6 +53,13 @@ void VoxelsScriptingInterface::eraseVoxel(float x, float y, float z, float scale
|
|||
scale / (float)TREE_SCALE, 0, 0, 0};
|
||||
|
||||
getVoxelPacketSender()->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &deleteVoxelDetail);
|
||||
|
||||
// handle the local tree also...
|
||||
if (_tree) {
|
||||
_tree->lockForWrite();
|
||||
_tree->deleteVoxelAt(deleteVoxelDetail.x, deleteVoxelDetail.y, deleteVoxelDetail.z, deleteVoxelDetail.s);
|
||||
_tree->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue