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
This commit is contained in:
ZappoMan 2013-05-25 15:29:23 -07:00
parent 48ca562b10
commit f6863081f9
2 changed files with 25 additions and 3 deletions

View file

@ -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);

View file

@ -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();