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
2105bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraData) {2105bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraData) {
2106 VoxelTreeElement* voxel = (VoxelTreeElement*)element;2106 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2107 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;2107 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
2108 2108
2109 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine2109 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine
2110 // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not2110 // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not
2111 // consider that case.2111 // consider that case.
@@ -2141,7 +2141,7 @@ bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraDat · 29 unmodified lines
2141bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraData) {2141bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraData) {
2142 VoxelTreeElement* voxel = (VoxelTreeElement*)element;2142 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2143 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;2143 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
2144 2144
2145 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine2145 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine
2146 // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not2146 // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not
2147 // consider that case.2147 // consider that case.
@@ -2184,7 +2184,7 @@ bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraDat · 36 unmodified lines
2184bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData) {2184bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData) {
2185 VoxelTreeElement* voxel = (VoxelTreeElement*)element;2185 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2186 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;2186 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
2187 2187
2188 // If we're still recursing the tree using this operator, then we don't know if we're inside or outside...2188 // If we're still recursing the tree using this operator, then we don't know if we're inside or outside...
2189 // so before we move forward we need to determine our frustum location2189 // so before we move forward we need to determine our frustum location
2190 ViewFrustum::location inFrustum = voxel->inFrustum(args->thisViewFrustum);2190 ViewFrustum::location inFrustum = voxel->inFrustum(args->thisViewFrustum);
@@ -2201,7 +2201,6 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 10 unmodified lines
2201 // ok, now do some processing for this node...2201 // ok, now do some processing for this node...
2202 switch (inFrustum) {2202 switch (inFrustum) {
2203 case ViewFrustum::OUTSIDE: {2203 case ViewFrustum::OUTSIDE: {
2204
2205 // If this node is outside the current view, then we might want to hide it... unless it was previously OUTSIDE,2204 // If this node is outside the current view, then we might want to hide it... unless it was previously OUTSIDE,
2206 // if it was previously outside, then we can safely assume it's already hidden, and we can also safely assume2205 // if it was previously outside, then we can safely assume it's already hidden, and we can also safely assume
2207 // that all of it's children are outside both of our views, in which case we can just stop recursing...2206 // 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
2215 // we need to hide it. Additionally we know that ALL of it's children are also fully OUTSIDE so we can recurse2214 // we need to hide it. Additionally we know that ALL of it's children are also fully OUTSIDE so we can recurse
2216 // the children and simply mark them as hidden2215 // the children and simply mark them as hidden
2217 args->tree->recurseNodeWithOperation(voxel, hideAllSubTreeOperation, args );2216 args->tree->recurseNodeWithOperation(voxel, hideAllSubTreeOperation, args );
2218
2219 return false;2217 return false;
2220 2218
2221 } break;2219 } break;
2222 case ViewFrustum::INSIDE: {2220 case ViewFrustum::INSIDE: {
2223
2224 // If this node is INSIDE the current view, then we might want to show it... unless it was previously INSIDE,2221 // If this node is INSIDE the current view, then we might want to show it... unless it was previously INSIDE,
2225 // if it was previously INSIDE, then we can safely assume it's already shown, and we can also safely assume2222 // if it was previously INSIDE, then we can safely assume it's already shown, and we can also safely assume
2226 // that all of it's children are INSIDE both of our views, in which case we can just stop recursing...2223 // 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
2234 // we need to show it. Additionally we know that ALL of it's children are also fully INSIDE so we can recurse2231 // we need to show it. Additionally we know that ALL of it's children are also fully INSIDE so we can recurse
2235 // the children and simply mark them as visible (as appropriate based on LOD)2232 // the children and simply mark them as visible (as appropriate based on LOD)
2236 args->tree->recurseNodeWithOperation(voxel, showAllSubTreeOperation, args);2233 args->tree->recurseNodeWithOperation(voxel, showAllSubTreeOperation, args);
2237
2238 return false;2234 return false;
2239 } break;2235 } break;
2240 case ViewFrustum::INTERSECT: {2236 case ViewFrustum::INTERSECT: {
2241 args->nodesScanned++;2237 args->nodesScanned++;
2242
2243 // If this node INTERSECTS the current view, then we might want to show it... unless it was previously INSIDE2238 // If this node INTERSECTS the current view, then we might want to show it... unless it was previously INSIDE
2244 // the last known view, in which case it will already be visible, and we know that all it's children are also2239 // the last known view, in which case it will already be visible, and we know that all it's children are also
2245 // previously INSIDE and visible. So in this case stop recursing2240 // previously INSIDE and visible. So in this case stop recursing
@@ -2253,8 +2248,15 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 7 unmodified lines
2253 // if the child node INTERSECTs the view, then we want to check to see if it thinks it should render2248 // if the child node INTERSECTs the view, then we want to check to see if it thinks it should render
2254 // if it should render but is missing it's VBO index, then we want to flip it on, and we can stop recursing from2249 // if it should render but is missing it's VBO index, then we want to flip it on, and we can stop recursing from
2255 // here because we know will block any children anyway2250 // 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
2256 if (voxel->getShouldRender() && !voxel->isKnownBufferIndex()) {2257 if (voxel->getShouldRender() && !voxel->isKnownBufferIndex()) {
2257 voxel->setDirtyBit(); // will this make it draw?2258 voxel->setDirtyBit(); // will this make it draw?
2259 voxel->markWithChangedTime(); // both are needed to force redraw
2258 args->nodesShown++;2260 args->nodesShown++;
2259 return false;2261 return false;
2260 }2262 }
@@ -2267,7 +2269,6 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 6 unmodified lines
2267 } break;2269 } break;
2268 } // switch2270 } // switch
2269 2271
2270
2271 return true; // keep going!2272 return true; // keep going!
2272}2273}
2273 2274