History

added support for forceFullFrustum in hideOutOfView() this fixes inconcistancies with voxel hiding showing

ZappoMan committed 13 years ago

Commit 5d18b681 parent 6e31f744 files · +65 −30Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 4 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+59−26
@@ -753,25 +753,54 @@ void VoxelSystem::checkForCulling() { · 752 unmodified lines
753753 && !isViewChanging()
754754 )
755755 ) {
756− _lastViewCulling = start;
757−
758756 // When we call removeOutOfView() voxels, we don't actually remove the voxels from the VBOs, but we do remove
759757 // them from tree, this makes our tree caclulations faster, but doesn't require us to fully rebuild the VBOs (which
760758 // can be expensive).
761759 if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableHideOutOfView)) {
762− hideOutOfView();
763− }
764− if (Menu::getInstance()->isOptionChecked(MenuOption::RemoveOutOfView)) {
760+
761+ // track how long its been since we were last moving. If we have recently moved then only use delta frustums, if
762+ // it's been a long time since we last moved, then go ahead and do a full frustum cull.
763+ if (isViewChanging()) {
764+ _lastViewIsChanging = start;
765+ }
766+ uint64_t sinceLastMoving = (start - _lastViewIsChanging) / 1000;
767+
768+ bool enoughTime = (sinceLastMoving >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS));
769+
770+ // These has changed events will occur before we stop. So we need to remember this for when we finally have stopped
771+ // moving long enough to be enoughTime
772+ if (hasViewChanged()) {
773+ _hasRecentlyChanged = true;
774+ }
775+
776+ // If we have recently changed, but it's been enough time since we last moved, then we will do a full frustum
777+ // hide/show culling pass
778+ bool forceFullFrustum = enoughTime && _hasRecentlyChanged;
779+
780+ // in hide mode, we only track the full frustum culls, because we don't care about the partials.
781+ if (forceFullFrustum) {
782+ _lastViewCulling = start;
783+ _hasRecentlyChanged = false;
784+ }
785+
786+ hideOutOfView(forceFullFrustum);
787+
788+ if (forceFullFrustum) {
789+ uint64_t endViewCulling = usecTimestampNow();
790+ _lastViewCullingElapsed = (endViewCulling - start) / 1000;
791+ }
792+
793+ } else if (Menu::getInstance()->isOptionChecked(MenuOption::RemoveOutOfView)) {
794+ _lastViewCulling = start;
765795 removeOutOfView();
796+ uint64_t endViewCulling = usecTimestampNow();
797+ _lastViewCullingElapsed = (endViewCulling - start) / 1000;
766798 }
767799
768800 // Once we call cleanupRemovedVoxels() we do need to rebuild our VBOs (if anything was actually removed). So,
769801 // we should consider putting this someplace else... as this might be able to occur less frequently, and save us on
770802 // VBO reubuilding. Possibly we should do this only if our actual VBO usage crosses some lower boundary.
771803 cleanupRemovedVoxels();
772−
773− uint64_t endViewCulling = usecTimestampNow();
774− _lastViewCullingElapsed = (endViewCulling - start) / 1000;
775804 }
776805
777806 uint64_t sinceLastAudit = (start - _lastAudit) / 1000;
@@ -1047,7 +1076,8 @@ void VoxelSystem::init() { · 269 unmodified lines
10471076 _callsToTreesToArrays = 0;
10481077 _setupNewVoxelsForDrawingLastFinished = 0;
10491078 _setupNewVoxelsForDrawingLastElapsed = 0;
1050− _lastViewCullingElapsed = _lastViewCulling = _lastAudit = 0;
1079+ _lastViewCullingElapsed = _lastViewCulling = _lastAudit = _lastViewIsChanging = 0;
1080+ _hasRecentlyChanged = false;
10511081
10521082 _voxelsDirty = false;
10531083 _voxelsInWriteArrays = 0;
@@ -1807,11 +1837,27 @@ public: · 753 unmodified lines
18071837 }
18081838 };
18091839
1810−void VoxelSystem::hideOutOfView() {
1840+void VoxelSystem::hideOutOfView(bool forceFullFrustum) {
1841+ printf("VoxelSystem::hideOutOfView(bool forceFullFrustum=%s)\n",debug::valueOf(forceFullFrustum));
18111842 bool showDebugDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
18121843 PerformanceWarning warn(showDebugDetails, "hideOutOfView()", showDebugDetails);
18131844 bool widenFrustum = true;
1814− bool wantDeltaFrustums = !Menu::getInstance()->isOptionChecked(MenuOption::UseFullFrustumInHide);
1845+
1846+ // When using "delta" view frustums and only hide/show items that are in the difference
1847+ // between the two view frustums. There are some potential problems with this mode.
1848+ //
1849+ // 1) This work well for rotating, but what about moving forward?
1850+ // In the move forward case, you'll get new voxel details, but those
1851+ // new voxels will be in the last view.
1852+ //
1853+ // 2) Also, voxels will arrive from the network that are OUTSIDE of the view
1854+ // frustum... these won't get hidden... and so we can't assume they are correctly
1855+ // hidden...
1856+ //
1857+ // Both these problems are solved by intermittently calling this with forceFullFrustum set
1858+ // to true. This will essentially clean up the improperly hidden or shown voxels.
1859+ //
1860+ bool wantDeltaFrustums = !forceFullFrustum && !Menu::getInstance()->isOptionChecked(MenuOption::UseFullFrustumInHide);
18151861 hideOutOfViewArgs args(this, this->_tree, _culledOnce, widenFrustum, wantDeltaFrustums);
18161862
18171863 const bool wantViewFrustumDebugging = false; // change to true for additional debugging
@@ -1822,24 +1868,11 @@ void VoxelSystem::hideOutOfView() { · 4 unmodified lines
18221868 }
18231869 }
18241870
1825− if (_culledOnce && args.lastViewFrustum.matches(args.thisViewFrustum)) {
1826− //printf("view frustum hasn't changed BAIL!!!\n");
1871+ if (!forceFullFrustum && _culledOnce && args.lastViewFrustum.matches(args.thisViewFrustum)) {
1872+ printf("view frustum hasn't changed BAIL!!!\n");
18271873 return;
18281874 }
18291875
1830− // Changed hideOutOfView() to support "delta" view frustums and only hide/show items that are in the difference
1831− // between the two view frustums. There are some potential problems with this idea...
1832− //
1833− // 1) This might work well for rotating, but what about moving forward?
1834− // in the move forward case, you'll get new voxel details, but those
1835− // new voxels will be in the last view... does that work? This works
1836− // ok for now because voxel server resends them and so they get redisplayed,
1837− // but this will not work if we update the voxel server to send less data.
1838− //
1839− // 2) what about voxels coming in from the network that are OUTSIDE of the view
1840− // frustum... they don't get hidden... and so we can't assume they are correctly
1841− // hidden... we could solve this with checking in view on voxelUpdated...
1842− //
18431876 _tree->recurseTreeWithOperation(hideOutOfViewOperation,(void*)&args);
18441877 _lastCulledViewFrustum = args.thisViewFrustum; // save last stable
18451878 _culledOnce = true;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t