From f6863081f9be1d46baa1fbf2f10ad1ab5def2424 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 25 May 2013 15:29:23 -0700 Subject: [PATCH] Fix Delta Sending mode by not culling out of view voxels until we STOP moving - added isViewChanging() which determines if the view is currently changing - made hasViewChanged() report false UNTIL we've stopped moving - changed setupNewVoxelsForDrawing() to only call removeOutOfView() if we're not moving --- interface/src/VoxelSystem.cpp | 26 +++++++++++++++++++++++--- interface/src/VoxelSystem.h | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 026f1dd4ee..7ff8649e43 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -160,13 +160,15 @@ void VoxelSystem::setupNewVoxelsForDrawing() { } double sinceLastViewCulling = (start - _lastViewCulling) / 1000.0; - // If the view frustum has changed, since last time, then remove nodes that are out of view - if ((sinceLastViewCulling >= std::max(_lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) && hasViewChanged()) { + // If the view frustum is no longer changing, but has changed, since last time, then remove nodes that are out of view + if ((sinceLastViewCulling >= std::max(_lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) + && !isViewChanging() && hasViewChanged()) { _lastViewCulling = start; // When we call removeOutOfView() voxels, we don't actually remove the voxels from the VBOs, but we do remove // them from tree, this makes our tree caclulations faster, but doesn't require us to fully rebuild the VBOs (which // can be expensive). +printLog("CALLING---removeOutOfView(); sinceLastViewCulling=%lf \n",sinceLastViewCulling); removeOutOfView(); // 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) { return true; // keep going! } -bool VoxelSystem::hasViewChanged() { + +bool VoxelSystem::isViewChanging() { bool result = false; // assume the best + // If our viewFrustum has changed since our _lastKnowViewFrustum if (_viewFrustum && !_lastKnowViewFrustum.matches(_viewFrustum)) { result = true; _lastKnowViewFrustum = *_viewFrustum; // save last known @@ -892,6 +896,22 @@ bool VoxelSystem::hasViewChanged() { return result; } +bool VoxelSystem::hasViewChanged() { + bool result = false; // assume the best + + // If we're still changing, report no change yet. + if (isViewChanging()) { + return false; + } + + // If our viewFrustum has changed since our _lastKnowViewFrustum + if (_viewFrustum && !_lastStableViewFrustum.matches(_viewFrustum)) { + result = true; + _lastStableViewFrustum = *_viewFrustum; // save last stable + } + return result; +} + void VoxelSystem::removeOutOfView() { PerformanceWarning warn(_renderWarningsOn, "removeOutOfView()"); removeOutOfViewArgs args(this); diff --git a/interface/src/VoxelSystem.h b/interface/src/VoxelSystem.h index 21c1ec38ee..7bffb1d33c 100644 --- a/interface/src/VoxelSystem.h +++ b/interface/src/VoxelSystem.h @@ -66,6 +66,7 @@ public: void removeOutOfView(); bool hasViewChanged(); + bool isViewChanging(); bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, VoxelDetail& detail, float& distance, BoxFace& face); @@ -147,6 +148,7 @@ private: ViewFrustum* _viewFrustum; ViewFrustum _lastKnowViewFrustum; + ViewFrustum _lastStableViewFrustum; int newTreeToArrays(VoxelNode *currentNode); void cleanupRemovedVoxels();