History

fix the sometime voxels don't show when you move bug

ZappoMan committed 12 years ago

Commit ab3e1af1 parent fc3cc521 file · +10 −9Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+10−9
@@ -2105,7 +2105,7 @@ void VoxelSystem::hideOutOfView(bool forceFullFrustum) { · 2104 unmodified lines
21052105 bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraData) {
21062106 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
21072107 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
2108−
2108+
21092109 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine
21102110 // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not
21112111 // consider that case.
@@ -2141,7 +2141,7 @@ bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraDat · 29 unmodified lines
21412141 bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraData) {
21422142 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
21432143 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
2144−
2144+
21452145 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine
21462146 // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not
21472147 // consider that case.
@@ -2184,7 +2184,7 @@ bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraDat · 36 unmodified lines
21842184 bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData) {
21852185 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
21862186 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
2187−
2187+
21882188 // If we're still recursing the tree using this operator, then we don't know if we're inside or outside...
21892189 // so before we move forward we need to determine our frustum location
21902190 ViewFrustum::location inFrustum = voxel->inFrustum(args->thisViewFrustum);
@@ -2201,7 +2201,6 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 10 unmodified lines
22012201 // ok, now do some processing for this node...
22022202 switch (inFrustum) {
22032203 case ViewFrustum::OUTSIDE: {
2204−
22052204 // If this node is outside the current view, then we might want to hide it... unless it was previously OUTSIDE,
22062205 // if it was previously outside, then we can safely assume it's already hidden, and we can also safely assume
22072206 // that all of it's children are outside both of our views, in which case we can just stop recursing...
@@ -2215,12 +2214,10 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 7 unmodified lines
22152214 // we need to hide it. Additionally we know that ALL of it's children are also fully OUTSIDE so we can recurse
22162215 // the children and simply mark them as hidden
22172216 args->tree->recurseNodeWithOperation(voxel, hideAllSubTreeOperation, args );
2218−
22192217 return false;
22202218
22212219 } break;
22222220 case ViewFrustum::INSIDE: {
2223−
22242221 // If this node is INSIDE the current view, then we might want to show it... unless it was previously INSIDE,
22252222 // if it was previously INSIDE, then we can safely assume it's already shown, and we can also safely assume
22262223 // that all of it's children are INSIDE both of our views, in which case we can just stop recursing...
@@ -2234,12 +2231,10 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 7 unmodified lines
22342231 // we need to show it. Additionally we know that ALL of it's children are also fully INSIDE so we can recurse
22352232 // the children and simply mark them as visible (as appropriate based on LOD)
22362233 args->tree->recurseNodeWithOperation(voxel, showAllSubTreeOperation, args);
2237−
22382234 return false;
22392235 } break;
22402236 case ViewFrustum::INTERSECT: {
22412237 args->nodesScanned++;
2242−
22432238 // If this node INTERSECTS the current view, then we might want to show it... unless it was previously INSIDE
22442239 // the last known view, in which case it will already be visible, and we know that all it's children are also
22452240 // previously INSIDE and visible. So in this case stop recursing
@@ -2253,8 +2248,15 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 7 unmodified lines
22532248 // if the child node INTERSECTs the view, then we want to check to see if it thinks it should render
22542249 // if it should render but is missing it's VBO index, then we want to flip it on, and we can stop recursing from
22552250 // here because we know will block any children anyway
2251+
2252+ float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();
2253+ int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
2254+ bool shouldRender = voxel->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
2255+ voxel->setShouldRender(shouldRender);
2256+
22562257 if (voxel->getShouldRender() && !voxel->isKnownBufferIndex()) {
22572258 voxel->setDirtyBit(); // will this make it draw?
2259+ voxel->markWithChangedTime(); // both are needed to force redraw
22582260 args->nodesShown++;
22592261 return false;
22602262 }
@@ -2267,7 +2269,6 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 6 unmodified lines
22672269 } break;
22682270 } // switch
22692271
2270−
22712272 return true; // keep going!
22722273 }
22732274