Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -170,7 +170,6 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 169 unmodified lines | ||
| 170 | 170 | } else { |
| 171 | 171 | _voxelsUpdated = 0; |
| 172 | 172 | } |
| 173 | − //printLog("setupNewVoxelsForDrawing() AFTER treeToArray _voxelsUpdated=%ld _voxelsDirty=%s\n", _voxelsUpdated, (_voxelsDirty ? "yes" : "no")); | |
| 174 | 173 | if (_voxelsUpdated) { |
| 175 | 174 | _voxelsDirty=true; |
| 176 | 175 | } |
| @@ -200,10 +199,8 @@ void VoxelSystem::copyWrittenDataToReadArrays() { · 23 unmodified lines | ||
| 200 | 199 | |
| 201 | 200 | int VoxelSystem::newTreeToArrays(VoxelNode* node) { |
| 202 | 201 | assert(_viewFrustum); // you must set up _viewFrustum before calling this |
| 203 | − | |
| 204 | 202 | int voxelsUpdated = 0; |
| 205 | 203 | bool shouldRender = false; // assume we don't need to render it |
| 206 | − | |
| 207 | 204 | // if it's colored, we might need to render it! |
| 208 | 205 | if (node->isColored()) { |
| 209 | 206 | float distanceToNode = node->distanceToCamera(*_viewFrustum); |
| @@ -211,11 +208,8 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 1 unmodified line | ||
| 211 | 208 | float childBoundary = boundaryDistanceForRenderLevel(node->getLevel() + 1); |
| 212 | 209 | bool inBoundary = (distanceToNode <= boundary); |
| 213 | 210 | bool inChildBoundary = (distanceToNode <= childBoundary); |
| 214 | − | |
| 215 | 211 | shouldRender = (node->isLeaf() && inChildBoundary) || (inBoundary && !inChildBoundary); |
| 216 | 212 | } |
| 217 | − | |
| 218 | − | |
| 219 | 213 | node->setShouldRender(shouldRender); |
| 220 | 214 | // let children figure out their renderness |
| 221 | 215 | for (int i = 0; i < 8; i++) { |
| @@ -223,7 +217,6 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 1 unmodified line | ||
| 223 | 217 | voxelsUpdated += newTreeToArrays(node->getChildAtIndex(i)); |
| 224 | 218 | } |
| 225 | 219 | } |
| 226 | − | |
| 227 | 220 | if (_alwaysRenderFullVBO) { |
| 228 | 221 | voxelsUpdated += newway__updateNodeInArray(node); |
| 229 | 222 | } else { |
| @@ -438,7 +431,6 @@ void VoxelSystem::updateVBOs() { · 208 unmodified lines | ||
| 438 | 431 | void VoxelSystem::render() { |
| 439 | 432 | PerformanceWarning warn(_renderWarningsOn, "render()"); |
| 440 | 433 | glPushMatrix(); |
| 441 | − //cleanupRemovedVoxels(); | |
| 442 | 434 | updateVBOs(); |
| 443 | 435 | // tell OpenGL where to find vertex and color information |
| 444 | 436 | glEnableClientState(GL_VERTEX_ARRAY); |
| @@ -635,25 +627,3 @@ void VoxelSystem::removeOutOfView() { · 190 unmodified lines | ||
| 635 | 627 | _tree->recurseTreeWithOperation(removeOutOfViewOperation,(void*)this); |
| 636 | 628 | pthread_mutex_unlock(&_voxelCleanupLock); |
| 637 | 629 | } |
| 638 | − | |
| 639 | −// Deletes the VoxelNodes from the _removedVoxels bag, but also cleans up those items from the vertex arrays | |
| 640 | −void VoxelSystem::cleanupRemovedVoxels() { | |
| 641 | − if (!pthread_mutex_trylock(&_voxelCleanupLock)) { | |
| 642 | − while (!_removedVoxels.isEmpty()){ | |
| 643 | − VoxelNode* node = _removedVoxels.extract(); | |
| 644 | − // If the voxel is in the vertex, and it was previously rendered, then set it's vertices to "hidden" | |
| 645 | − if (node->isKnownBufferIndex() && node->getShouldRender()) { | |
| 646 | − unsigned long nodeIndex = node->getBufferIndex(); | |
| 647 | − _voxelDirtyArray[nodeIndex] = true; | |
| 648 | − for (int j = 0; j < VERTEX_POINTS_PER_VOXEL; j++ ) { | |
| 649 | − GLfloat* writeVerticesAt = _writeVerticesArray + (nodeIndex * VERTEX_POINTS_PER_VOXEL); | |
| 650 | − *(writeVerticesAt+j) = FLT_MAX; | |
| 651 | − } | |
| 652 | − _voxelsDirty = true; // yep | |
| 653 | − } | |
| 654 | − _unusedArraySpace++; // track this so we can blow away our arrays if they get too much | |
| 655 | − delete node; // actually delete the node | |
| 656 | − } | |
| 657 | − pthread_mutex_unlock(&_voxelCleanupLock); | |
| 658 | − } | |
| 659 | −} | |