Added preview deplacement + fixed locking issue

This commit is contained in:
Atlante45 2014-03-11 18:01:38 -07:00
parent be6e7d0e97
commit 6fcb802a94
3 changed files with 31 additions and 20 deletions

View file

@ -15,16 +15,16 @@ function mousePressEvent(event) {
var pickRay = Camera.computePickRay(event.x, event.y);
var intersection = Voxels.findRayIntersection(pickRay);
if (intersection.intersects) {
// 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);
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);
print("clicked on face=" + intersection.face);
print("clicked on distance=" + intersection.distance);
var newVoxel = {
var newVoxel = {
x: intersection.voxel.x,
y: intersection.voxel.y,
z: intersection.voxel.z,
@ -32,7 +32,7 @@ function mousePressEvent(event) {
red: 255,
green: 0,
blue: 255 };
if (intersection.face == "MIN_X_FACE") {
newVoxel.x -= newVoxel.s;
} else if (intersection.face == "MAX_X_FACE") {
@ -46,11 +46,11 @@ function mousePressEvent(event) {
} else if (intersection.face == "MAX_Z_FACE") {
newVoxel.z += newVoxel.s;
}
print("Voxels.setVoxel("+newVoxel.x + ", "
+ newVoxel.y + ", " + newVoxel.z + ", " + newVoxel.s + ", "
print("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);
}
}

View file

@ -972,7 +972,6 @@ function mousePressEvent(event) {
print("placing import...");
placeImport();
showImport(false);
pasteMode = false;
moveTools();
return;
}
@ -1177,7 +1176,6 @@ function menuItemEvent(menuItem) {
print("importing...");
if (importVoxels()) {
showImport(true);
pasteMode = true;
}
moveTools();
}
@ -1512,14 +1510,27 @@ function checkControllers() {
}
function update(deltaTime) {
var newWindowDimensions = Controller.getViewportDimensions();
if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) {
windowDimensions = newWindowDimensions;
moveTools();
}
if (editToolsOn) {
var newWindowDimensions = Controller.getViewportDimensions();
if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) {
windowDimensions = newWindowDimensions;
moveTools();
}
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);
}
}
}

View file

@ -40,12 +40,12 @@ void LocalVoxelsOverlay::update(float deltatime) {
_voxelSystem->init();
}
_tree->lockForWrite();
if (_visible && _voxelCount != _tree->getOctreeElementsCount()) {
_voxelCount = _tree->getOctreeElementsCount();
_tree->lockForWrite();
_voxelSystem->forceRedrawEntireTree();
_tree->unlock();
}
_tree->unlock();
}
void LocalVoxelsOverlay::render() {