Showing the changes to interface/src/VoxelSystem.cpp (1 of 3 files). Show all
Unified · Split
| @@ -232,7 +232,7 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 231 unmodified lines | |||
| 232 | bool inChildBoundary = (distanceToNode <= childBoundary); | 232 | bool inChildBoundary = (distanceToNode <= childBoundary); |
| 233 | shouldRender = (node->isLeaf() && inChildBoundary) || (inBoundary && !inChildBoundary); | 233 | shouldRender = (node->isLeaf() && inChildBoundary) || (inBoundary && !inChildBoundary); |
| 234 | } | 234 | } |
| 235 | node->setShouldRender(shouldRender); | 235 | node->setShouldRender(shouldRender && !node->deleteMe()); |
| 236 | // let children figure out their renderness | 236 | // let children figure out their renderness |
| 237 | for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { | 237 | for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { |
| 238 | if (node->getChildAtIndex(i)) { | 238 | if (node->getChildAtIndex(i)) { |
| @@ -244,6 +244,15 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 5 unmodified lines | |||
| 244 | } else { | 244 | } else { |
| 245 | voxelsUpdated += updateNodeInArraysAsPartialVBO(node); | 245 | voxelsUpdated += updateNodeInArraysAsPartialVBO(node); |
| 246 | } | 246 | } |
| 247 | |||
| 248 | // If the node has been asked to be deleted, but we've gotten to here, after updateNodeInArraysXXX() | ||
| 249 | // then it means our VBOs are "clean" and our vertices have been removed or not added. So we can now | ||
| 250 | // safely remove the node from the tree and actually delete it. | ||
| 251 | // otherwise honor our calculated shouldRender | ||
| 252 | if (node->deleteMe()) { | ||
| 253 | _tree->deleteVoxelCodeFromTree(node->getOctalCode()); | ||
| 254 | } | ||
| 255 | |||
| 247 | node->clearDirtyBit(); // always clear the dirty bit, even if it doesn't need to be rendered | 256 | node->clearDirtyBit(); // always clear the dirty bit, even if it doesn't need to be rendered |
| 248 | return voxelsUpdated; | 257 | return voxelsUpdated; |
| 249 | } | 258 | } |
| @@ -901,9 +910,19 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { · 651 unmodified lines | |||
| 901 | 910 | ||
| 902 | 911 | ||
| 903 | void VoxelSystem::deleteVoxelAt(float x, float y, float z, float s) { | 912 | void VoxelSystem::deleteVoxelAt(float x, float y, float z, float s) { |
| 904 | //printLog("VoxelSystem::deleteVoxelAt(%f,%f,%f,%f)\n",x,y,z,s); | 913 | printLog("VoxelSystem::deleteVoxelAt(%f,%f,%f,%f)\n",x,y,z,s); |
| 905 | _tree->deleteVoxelAt(x, y, z, s); | 914 | |
| 906 | setupNewVoxelsForDrawing(); | 915 | VoxelNode* node = _tree->getVoxelAt(x, y, z, s); |
| 916 | if (node) { | ||
| 917 | // tell the node we want it deleted | ||
| 918 | node->pleaseDeleteMe(); | ||
| 919 | |||
| 920 | // tree is now dirty | ||
| 921 | _tree->setDirtyBit(); | ||
| 922 | |||
| 923 | // redraw! | ||
| 924 | setupNewVoxelsForDrawing(); // do we even need to do this? Or will the next network receive kick in? | ||
| 925 | } | ||
| 907 | }; | 926 | }; |
| 908 | 927 | ||
| 909 | VoxelNode* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const { | 928 | VoxelNode* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const { |