mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 10:13:15 +02:00
Added preview deplacement + fixed locking issue
This commit is contained in:
parent
be6e7d0e97
commit
6fcb802a94
3 changed files with 31 additions and 20 deletions
|
@ -15,16 +15,16 @@ function mousePressEvent(event) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
var intersection = Voxels.findRayIntersection(pickRay);
|
var intersection = Voxels.findRayIntersection(pickRay);
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
|
|
||||||
// Note: due to the current C++ "click on voxel" behavior, these values may be the animated color for the voxel
|
// Note: due to the current C++ "click on voxel" behavior, these values may be the animated color for the voxel
|
||||||
print("clicked on voxel.red/green/blue=" + intersection.voxel.red + ", "
|
print("clicked on voxel.red/green/blue=" + intersection.voxel.red + ", "
|
||||||
+ intersection.voxel.green + ", " + intersection.voxel.blue);
|
+ intersection.voxel.green + ", " + intersection.voxel.blue);
|
||||||
print("clicked on voxel.x/y/z/s=" + intersection.voxel.x + ", "
|
print("clicked on voxel.x/y/z/s=" + intersection.voxel.x + ", "
|
||||||
+ intersection.voxel.y + ", " + intersection.voxel.z+ ": " + intersection.voxel.s);
|
+ intersection.voxel.y + ", " + intersection.voxel.z+ ": " + intersection.voxel.s);
|
||||||
print("clicked on face=" + intersection.face);
|
print("clicked on face=" + intersection.face);
|
||||||
print("clicked on distance=" + intersection.distance);
|
print("clicked on distance=" + intersection.distance);
|
||||||
|
|
||||||
var newVoxel = {
|
var newVoxel = {
|
||||||
x: intersection.voxel.x,
|
x: intersection.voxel.x,
|
||||||
y: intersection.voxel.y,
|
y: intersection.voxel.y,
|
||||||
z: intersection.voxel.z,
|
z: intersection.voxel.z,
|
||||||
|
@ -32,7 +32,7 @@ function mousePressEvent(event) {
|
||||||
red: 255,
|
red: 255,
|
||||||
green: 0,
|
green: 0,
|
||||||
blue: 255 };
|
blue: 255 };
|
||||||
|
|
||||||
if (intersection.face == "MIN_X_FACE") {
|
if (intersection.face == "MIN_X_FACE") {
|
||||||
newVoxel.x -= newVoxel.s;
|
newVoxel.x -= newVoxel.s;
|
||||||
} else if (intersection.face == "MAX_X_FACE") {
|
} else if (intersection.face == "MAX_X_FACE") {
|
||||||
|
@ -46,11 +46,11 @@ function mousePressEvent(event) {
|
||||||
} else if (intersection.face == "MAX_Z_FACE") {
|
} else if (intersection.face == "MAX_Z_FACE") {
|
||||||
newVoxel.z += newVoxel.s;
|
newVoxel.z += newVoxel.s;
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Voxels.setVoxel("+newVoxel.x + ", "
|
print("Voxels.setVoxel("+newVoxel.x + ", "
|
||||||
+ newVoxel.y + ", " + newVoxel.z + ", " + newVoxel.s + ", "
|
+ newVoxel.y + ", " + newVoxel.z + ", " + newVoxel.s + ", "
|
||||||
+ newVoxel.red + ", " + newVoxel.green + ", " + newVoxel.blue + ")" );
|
+ newVoxel.red + ", " + newVoxel.green + ", " + newVoxel.blue + ")" );
|
||||||
|
|
||||||
Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue);
|
Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -972,7 +972,6 @@ function mousePressEvent(event) {
|
||||||
print("placing import...");
|
print("placing import...");
|
||||||
placeImport();
|
placeImport();
|
||||||
showImport(false);
|
showImport(false);
|
||||||
pasteMode = false;
|
|
||||||
moveTools();
|
moveTools();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1176,6 @@ function menuItemEvent(menuItem) {
|
||||||
print("importing...");
|
print("importing...");
|
||||||
if (importVoxels()) {
|
if (importVoxels()) {
|
||||||
showImport(true);
|
showImport(true);
|
||||||
pasteMode = true;
|
|
||||||
}
|
}
|
||||||
moveTools();
|
moveTools();
|
||||||
}
|
}
|
||||||
|
@ -1512,14 +1510,27 @@ function checkControllers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(deltaTime) {
|
function update(deltaTime) {
|
||||||
var newWindowDimensions = Controller.getViewportDimensions();
|
|
||||||
if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) {
|
|
||||||
windowDimensions = newWindowDimensions;
|
|
||||||
moveTools();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editToolsOn) {
|
if (editToolsOn) {
|
||||||
|
var newWindowDimensions = Controller.getViewportDimensions();
|
||||||
|
if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) {
|
||||||
|
windowDimensions = newWindowDimensions;
|
||||||
|
moveTools();
|
||||||
|
}
|
||||||
|
|
||||||
checkControllers();
|
checkControllers();
|
||||||
|
|
||||||
|
// Move Import Preview
|
||||||
|
if (isImporting) {
|
||||||
|
var position = MyAvatar.position;
|
||||||
|
var forwardVector = Quat.getFront(MyAvatar.orientation);
|
||||||
|
var targetPosition = Vec3.sum(position, Vec3.multiply(forwardVector, importScale));
|
||||||
|
var newPosition = {
|
||||||
|
x: Math.floor(targetPosition.x / importScale) * importScale,
|
||||||
|
y: Math.floor(targetPosition.y / importScale) * importScale,
|
||||||
|
z: Math.floor(targetPosition.z / importScale) * importScale
|
||||||
|
}
|
||||||
|
moveImport(newPosition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,12 @@ void LocalVoxelsOverlay::update(float deltatime) {
|
||||||
_voxelSystem->init();
|
_voxelSystem->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_tree->lockForWrite();
|
||||||
if (_visible && _voxelCount != _tree->getOctreeElementsCount()) {
|
if (_visible && _voxelCount != _tree->getOctreeElementsCount()) {
|
||||||
_voxelCount = _tree->getOctreeElementsCount();
|
_voxelCount = _tree->getOctreeElementsCount();
|
||||||
_tree->lockForWrite();
|
|
||||||
_voxelSystem->forceRedrawEntireTree();
|
_voxelSystem->forceRedrawEntireTree();
|
||||||
_tree->unlock();
|
|
||||||
}
|
}
|
||||||
|
_tree->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalVoxelsOverlay::render() {
|
void LocalVoxelsOverlay::render() {
|
||||||
|
|
Loading…
Reference in a new issue