From f41533fee6580a052f9169c7b978c716a3afc38d Mon Sep 17 00:00:00 2001 From: LionTurtle Date: Mon, 9 Sep 2013 18:23:37 -0700 Subject: [PATCH] Add nudgeVoxel shading in grid. Fix erase bug. --- interface/src/Application.cpp | 7 +++++-- interface/src/Util.cpp | 9 +++++++++ libraries/voxels/src/VoxelTree.cpp | 3 +-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e2d857e94e..e14bfa7714 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1672,7 +1672,6 @@ void Application::update(float deltaTime) { _mouseVoxel.z += faceVector.z * _mouseVoxel.s; } } - _nudgeVoxel.s = _mouseVoxel.s; } else { _mouseVoxel.s = 0.0f; } @@ -2322,7 +2321,11 @@ void Application::displaySide(Camera& whichCamera) { _mouseVoxel.z + _mouseVoxel.s*0.5f); glLineWidth(4.0f); if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelNudgeMode)) { - glutWireCube(_nudgeVoxel.s); + if (_nudgeVoxel.s) { + glutWireCube(_nudgeVoxel.s); + } else { + glutWireCube(_mouseVoxel.s); + } } else { glutWireCube(_mouseVoxel.s); } diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index c259379e15..05a68cc5a5 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -438,6 +438,15 @@ void renderNudgeGrid(const float& voxelX, const float& voxelY, const float& voxe glVertex3f(origin.x + xz * voxelPrecision, 0, origin.z - (GRID_DIMENSIONS - 1) * voxelS); } glEnd(); + + glColor3f(1.0f,1.0f,1.0f); + + glBegin(GL_POLYGON);//begin drawing of square + glVertex3f(voxelX, 0.0f, voxelZ);//first vertex + glVertex3f(voxelX + voxelS, 0.0f, voxelZ);//second vertex + glVertex3f(voxelX + voxelS, 0.0f, voxelZ + voxelS);//third vertex + glVertex3f(voxelX, 0.0f, voxelZ + voxelS);//fourth vertex + glEnd();//end drawing of polygon } void renderNudgeGuide(const float& voxelX, const float& voxelY, const float& voxelZ, const float& voxelS) { diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index cec46998e7..3ca3ff90e6 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -1907,7 +1907,6 @@ bool VoxelTree::nudgeCheck(VoxelNode* node, void* extraData) { // find necessary leaf size float newLeafSize = findNewLeafSize(args->nudgeVec, unNudgedDetails.s); - args->ancestorSize = unNudgedDetails.s; // check to see if this unNudged node can be nudged if (unNudgedDetails.s <= newLeafSize) { @@ -1957,7 +1956,7 @@ void VoxelTree::nudgeLeaf(VoxelNode* node, void* extraData) { // delete the old node // if the nudge replaces the node in an area outside of the ancestor node - if (fabs(nudge.x) >= args->ancestorSize || fabs(nudge.y) >= args->ancestorSize || fabs(nudge.z) >= args->ancestorSize) { + if ((fabs(nudge.x) >= args->ancestorSize || fabs(nudge.y) >= args->ancestorSize || fabs(nudge.z) >= args->ancestorSize)) { args->voxelEditSenderPtr->sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, voxelDetails); }