mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
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:
parent
48ca562b10
commit
f6863081f9
2 changed files with 25 additions and 3 deletions
|
@ -160,13 +160,15 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
double sinceLastViewCulling = (start - _lastViewCulling) / 1000.0;
|
double sinceLastViewCulling = (start - _lastViewCulling) / 1000.0;
|
||||||
// If the view frustum has changed, since last time, then remove nodes that are out of view
|
// 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)) && hasViewChanged()) {
|
if ((sinceLastViewCulling >= std::max(_lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS))
|
||||||
|
&& !isViewChanging() && hasViewChanged()) {
|
||||||
_lastViewCulling = start;
|
_lastViewCulling = start;
|
||||||
|
|
||||||
// When we call removeOutOfView() voxels, we don't actually remove the voxels from the VBOs, but we do remove
|
// 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
|
// them from tree, this makes our tree caclulations faster, but doesn't require us to fully rebuild the VBOs (which
|
||||||
// can be expensive).
|
// can be expensive).
|
||||||
|
printLog("CALLING---removeOutOfView(); sinceLastViewCulling=%lf \n",sinceLastViewCulling);
|
||||||
removeOutOfView();
|
removeOutOfView();
|
||||||
|
|
||||||
// Once we call cleanupRemovedVoxels() we do need to rebuild our VBOs (if anything was actually removed). So,
|
// 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!
|
return true; // keep going!
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoxelSystem::hasViewChanged() {
|
|
||||||
|
bool VoxelSystem::isViewChanging() {
|
||||||
bool result = false; // assume the best
|
bool result = false; // assume the best
|
||||||
|
// If our viewFrustum has changed since our _lastKnowViewFrustum
|
||||||
if (_viewFrustum && !_lastKnowViewFrustum.matches(_viewFrustum)) {
|
if (_viewFrustum && !_lastKnowViewFrustum.matches(_viewFrustum)) {
|
||||||
result = true;
|
result = true;
|
||||||
_lastKnowViewFrustum = *_viewFrustum; // save last known
|
_lastKnowViewFrustum = *_viewFrustum; // save last known
|
||||||
|
@ -892,6 +896,22 @@ bool VoxelSystem::hasViewChanged() {
|
||||||
return result;
|
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() {
|
void VoxelSystem::removeOutOfView() {
|
||||||
PerformanceWarning warn(_renderWarningsOn, "removeOutOfView()");
|
PerformanceWarning warn(_renderWarningsOn, "removeOutOfView()");
|
||||||
removeOutOfViewArgs args(this);
|
removeOutOfViewArgs args(this);
|
||||||
|
|
|
@ -66,6 +66,7 @@ public:
|
||||||
|
|
||||||
void removeOutOfView();
|
void removeOutOfView();
|
||||||
bool hasViewChanged();
|
bool hasViewChanged();
|
||||||
|
bool isViewChanging();
|
||||||
|
|
||||||
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
VoxelDetail& detail, float& distance, BoxFace& face);
|
VoxelDetail& detail, float& distance, BoxFace& face);
|
||||||
|
@ -147,6 +148,7 @@ private:
|
||||||
|
|
||||||
ViewFrustum* _viewFrustum;
|
ViewFrustum* _viewFrustum;
|
||||||
ViewFrustum _lastKnowViewFrustum;
|
ViewFrustum _lastKnowViewFrustum;
|
||||||
|
ViewFrustum _lastStableViewFrustum;
|
||||||
|
|
||||||
int newTreeToArrays(VoxelNode *currentNode);
|
int newTreeToArrays(VoxelNode *currentNode);
|
||||||
void cleanupRemovedVoxels();
|
void cleanupRemovedVoxels();
|
||||||
|
|
Loading…
Reference in a new issue