Changeset 3068 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
- Timestamp:
- 10/24/08 16:39:24 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3066 r3068 419 419 if (!mDynamicEntities.empty()) 420 420 { 421 //UpdateDynamicBranch();421 UpdateDynamicBranch(); 422 422 } 423 423 } … … 427 427 { 428 428 // q: should we use distance to center rather than the distance to the near plane? 429 430 // because otherwise problems with big object penetrating the near plane 431 // (e.g., big objects in the distance which are then always visible) 432 // especially annoying is this problem when using the frustum 433 // fitting on the visible objects for shadow mapping 434 // on the other hand, distance to near plane can also be used 435 // for near plane intersection 436 node->mDistance = sNearPlane.Distance(node->GetBox().Center()); 437 //node->mDistance = node->GetBox().GetMinDistance(sNearPlane); 429 // distance to near plane can also be used for checking near plane intersection 430 //node->mDistance = sNearPlane.Distance(node->GetBox().Center()); 431 node->mDistance = node->GetBox().GetMinDistance(sNearPlane); 438 432 } 439 433 … … 441 435 float Bvh::CalcMaxDistance(BvhNode *node) const 442 436 { 437 #if 1 443 438 return node->GetBox().GetMaxDistance(sNearPlane); 444 439 440 #else 441 // use bounding boxes of geometry to determine max dist 445 442 float maxDist = .0f; 446 443 … … 457 454 458 455 return maxDist; 456 #endif 459 457 } 460 458 … … 932 930 933 931 mNumVirtualNodes = 0; 934 935 932 // assign new virtual leaves based on specified #triangles per leaf 936 933 std::stack<BvhNode *> nodeStack; 937 938 934 nodeStack.push(mRoot); 939 935 … … 1273 1269 void Bvh::UpdateDynamicBranch() 1274 1270 { 1275 BvhNode *dynamicRoot = static_cast<BvhInterior *>(mRoot)->mBack;1276 1277 1271 // delete old branch 1278 if (! dynamicRoot->IsLeaf())1272 if (!mDynamicRoot->IsLeaf()) 1279 1273 { 1280 1274 cout << "deleting old branch" << endl; 1281 1275 1282 DEL_PTR(dynamicRoot); 1283 1284 dynamicRoot = new BvhLeaf(mRoot); 1285 dynamicRoot->mBox = mRoot->mBox; 1276 DEL_PTR(mDynamicRoot); 1277 1278 mDynamicRoot = new BvhLeaf(mRoot); 1279 mDynamicRoot->mBox = mRoot->mBox; 1280 1281 mDynamicRoot->mFirst = 0; 1282 mDynamicRoot->mLast = 0; 1283 mDynamicRoot->mArea = mDynamicRoot->mBox.SurfaceArea(); 1286 1284 } 1287 1285 1288 1286 cout << "updating dynamic branch" << endl; 1289 1287 1290 dynamicRoot = SubdivideLeaf(static_cast<BvhLeaf *>(dynamicRoot), 0, mDynamicEntities);1288 mDynamicRoot = SubdivideLeaf(static_cast<BvhLeaf *>(mDynamicRoot), 0, mDynamicEntities); 1291 1289 1292 1290 cout << "finished updating dynamic branch" << endl; … … 1302 1300 bool Bvh::IntersectsNearPlane(BvhNode *node) const 1303 1301 { 1304 float distanceToNearPlane = node->GetBox().GetMinDistance(sNearPlane); 1302 // note: we have problems with large scale object penetrating the near plane 1303 // (e.g., objects in the distance which are always handled to be visible) 1304 // especially annoying is this problem when using the frustum 1305 // fitting on the visible objects for shadow mapping 1306 // but don't see how to solve this issue without using much costlier calculations 1307 1305 1308 // we stored the near plane distance => we can use it also here 1306 //float distanceToNearPlane = node->GetDistance(); 1307 1308 return distanceToNearPlane < sNear; 1309 } 1310 1311 1312 } 1309 float distanceToNearPlane = node->GetDistance(); 1310 //float distanceToNearPlane = node->GetBox().GetMinDistance(sNearPlane); 1311 1312 return (distanceToNearPlane < sNear); 1313 } 1314 1315 1316 }
Note: See TracChangeset
for help on using the changeset viewer.