Changeset 2895 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
- Timestamp:
- 09/02/08 15:29:20 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r2894 r2895 24 24 using namespace std; 25 25 26 27 int BvhNode::sCurrentState = 0; 26 28 27 29 … … 75 77 mAxis(-1), 76 78 mDepth(0), 77 mPlaneMask(0),78 mPreferredPlane(0),79 79 mLastRenderedFrame(-999), 80 80 mFirst(-1), … … 87 87 mIsVirtualLeaf(false) 88 88 { 89 for (int i = 0; i < NUM_STATES; ++ i) 90 { 91 mPlaneMask[i] = 0; 92 mPreferredPlane[i]= 0; 93 } 89 94 } 90 95 … … 97 102 void BvhNode::ResetVisibility() 98 103 { 99 mVisibility.Reset(); 104 for (int i = 0; i < NUM_STATES; ++ i) 105 { 106 mVisibility[i].Reset(); 107 } 108 100 109 mLastRenderedFrame = -999; 101 110 } … … 301 310 { 302 311 // do the test only if necessary 303 if (!(node->mPlaneMask & (1 << i)))312 if (!(node->mPlaneMask[BvhNode::sCurrentState] & (1 << i))) 304 313 return true; 305 314 … … 310 319 { 311 320 // outside 312 node->mPreferredPlane = i;321 node->mPreferredPlane[BvhNode::sCurrentState] = i; 313 322 return false; 314 323 } … … 320 329 { 321 330 // completely inside: children don't need to check against this plane no more 322 node->mPlaneMask ^= 1 << i;331 node->mPlaneMask[BvhNode::sCurrentState] ^= 1 << i; 323 332 } 324 333 else … … 336 345 337 346 if (node->GetParent()) 338 node->mPlaneMask = node->GetParent()->mPlaneMask; 339 340 341 //for (int i = 0; i < 6; ++ i) 342 // if (!TestPlane(node, i, bIntersect)) return 0; 343 347 node->mPlaneMask[BvhNode::sCurrentState] = node->GetParent()->mPlaneMask[BvhNode::sCurrentState]; 344 348 345 349 //////// 346 350 //-- apply frustum culling for the planes [mPreferredPlane - 5] 347 351 348 for (int i = node->mPreferredPlane ; i < 6; ++ i)352 for (int i = node->mPreferredPlane[BvhNode::sCurrentState]; i < 6; ++ i) 349 353 if (!TestPlane(node, i, bIntersect)) return 0; 350 354 355 351 356 ////////// 352 357 //-- do the view frustum culling for the planes [0 - m_iPreferredPlane) 353 358 354 for (int i = 0; i < node->mPreferredPlane ; ++ i)359 for (int i = 0; i < node->mPreferredPlane[BvhNode::sCurrentState]; ++ i) 355 360 if (!TestPlane(node, i, bIntersect)) return 0; 356 361 … … 362 367 { 363 368 // = 0011 1111 which means that at the beginning, all six planes have to frustum culled 364 mRoot->mPlaneMask = 0x3f;369 mRoot->mPlaneMask[BvhNode::sCurrentState] = 0x3f; 365 370 366 371 mCamera->CalcFrustum(sFrustum);
Note: See TracChangeset
for help on using the changeset viewer.