Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -160,13 +160,15 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 159 unmodified lines | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | double sinceLastViewCulling = (start - _lastViewCulling) / 1000.0; | 162 | double sinceLastViewCulling = (start - _lastViewCulling) / 1000.0; |
| 163 | // If the view frustum has changed, since last time, then remove nodes that are out of view | 163 | // If the view frustum is no longer changing, but has changed, since last time, then remove nodes that are out of view |
| 164 | if ((sinceLastViewCulling >= std::max(_lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) && hasViewChanged()) { | 164 | if ((sinceLastViewCulling >= std::max(_lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) |
| 165 | && !isViewChanging() && hasViewChanged()) { | ||
| 165 | _lastViewCulling = start; | 166 | _lastViewCulling = start; |
| 166 | 167 | ||
| 167 | // When we call removeOutOfView() voxels, we don't actually remove the voxels from the VBOs, but we do remove | 168 | // When we call removeOutOfView() voxels, we don't actually remove the voxels from the VBOs, but we do remove |
| 168 | // them from tree, this makes our tree caclulations faster, but doesn't require us to fully rebuild the VBOs (which | 169 | // them from tree, this makes our tree caclulations faster, but doesn't require us to fully rebuild the VBOs (which |
| 169 | // can be expensive). | 170 | // can be expensive). |
| 171 | printLog("CALLING---removeOutOfView(); sinceLastViewCulling=%lf \n",sinceLastViewCulling); | ||
| 170 | removeOutOfView(); | 172 | removeOutOfView(); |
| 171 | 173 | ||
| 172 | // Once we call cleanupRemovedVoxels() we do need to rebuild our VBOs (if anything was actually removed). So, | 174 | // Once we call cleanupRemovedVoxels() we do need to rebuild our VBOs (if anything was actually removed). So, |
| @@ -883,8 +885,10 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) { · 710 unmodified lines | |||
| 883 | return true; // keep going! | 885 | return true; // keep going! |
| 884 | } | 886 | } |
| 885 | 887 | ||
| 886 | bool VoxelSystem::hasViewChanged() { | 888 | |
| 889 | bool VoxelSystem::isViewChanging() { | ||
| 887 | bool result = false; // assume the best | 890 | bool result = false; // assume the best |
| 891 | // If our viewFrustum has changed since our _lastKnowViewFrustum | ||
| 888 | if (_viewFrustum && !_lastKnowViewFrustum.matches(_viewFrustum)) { | 892 | if (_viewFrustum && !_lastKnowViewFrustum.matches(_viewFrustum)) { |
| 889 | result = true; | 893 | result = true; |
| 890 | _lastKnowViewFrustum = *_viewFrustum; // save last known | 894 | _lastKnowViewFrustum = *_viewFrustum; // save last known |
| @@ -892,6 +896,22 @@ bool VoxelSystem::hasViewChanged() { · 1 unmodified line | |||
| 892 | return result; | 896 | return result; |
| 893 | } | 897 | } |
| 894 | 898 | ||
| 899 | bool VoxelSystem::hasViewChanged() { | ||
| 900 | bool result = false; // assume the best | ||
| 901 | |||
| 902 | // If we're still changing, report no change yet. | ||
| 903 | if (isViewChanging()) { | ||
| 904 | return false; | ||
| 905 | } | ||
| 906 | |||
| 907 | // If our viewFrustum has changed since our _lastKnowViewFrustum | ||
| 908 | if (_viewFrustum && !_lastStableViewFrustum.matches(_viewFrustum)) { | ||
| 909 | result = true; | ||
| 910 | _lastStableViewFrustum = *_viewFrustum; // save last stable | ||
| 911 | } | ||
| 912 | return result; | ||
| 913 | } | ||
| 914 | |||
| 895 | void VoxelSystem::removeOutOfView() { | 915 | void VoxelSystem::removeOutOfView() { |
| 896 | PerformanceWarning warn(_renderWarningsOn, "removeOutOfView()"); | 916 | PerformanceWarning warn(_renderWarningsOn, "removeOutOfView()"); |
| 897 | removeOutOfViewArgs args(this); | 917 | removeOutOfViewArgs args(this); |