Changeset 3265 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
- Timestamp:
- 01/11/09 02:43:59 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3264 r3265 266 266 267 267 mVboId = -1; 268 // bound the maximal depth of the dynamic branch269 mMaxDepthForDynamicBranch = 1 ;268 // bounds the maximal depth of the dynamic branch 269 mMaxDepthForDynamicBranch = 10; 270 270 } 271 271 … … 1357 1357 while (1) 1358 1358 { 1359 while (mGeometry[i]->GetWorldCenter()[axis] < position) ++ i; 1360 //while ((j > 0) && (position < mGeometry[j]->GetWorldCenter()[axis])) -- j; 1361 while (position < mGeometry[j]->GetWorldCenter()[axis]) -- j; 1359 //while (mGeometry[i]->GetWorldCenter()[axis] < position) ++ i; 1360 //while (position < mGeometry[j]->GetWorldCenter()[axis]) -- j; 1361 1362 while ((i < leaf->mLast) && (mGeometry[i]->GetWorldCenter()[axis] < position)) ++ i; 1363 while ((j > leaf->mFirst) && (position < mGeometry[j]->GetWorldCenter()[axis])) -- j; 1362 1364 1363 1365 // sorting finished … … 1391 1393 if (TerminationCriteriaMet(leaf)) 1392 1394 { 1393 //cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 1395 if (leaf->CountPrimitives() == 0) 1396 cout << "error: leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 1397 1394 1398 return leaf; 1395 1399 } … … 1409 1413 pos = leaf->mBox.Center()[axis]; 1410 1414 1415 //if ((split >= leaf->mLast) || (split < leaf->mFirst)) 1411 1416 if (split == leaf->mLast) 1412 1417 { 1413 1418 // no split could be achieved => just halve number of objects 1414 split = (leaf->mLast -leaf->mFirst) / 2;1415 cerr << "no reduction " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << endl;1419 split = (leaf->mLast + leaf->mFirst) / 2; 1420 cerr << "no reduction " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << " " << split << endl; 1416 1421 } 1417 1422 … … 1436 1441 front->mDepth = leaf->mDepth + 1; 1437 1442 1443 if (leaf->mFirst > leaf->mLast) 1444 cerr << "erorr!!! " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << " " << split << endl; 1445 1438 1446 leaf->mLast = split; 1439 1447 leaf->mDepth = front->mDepth; … … 1455 1463 const bool criteriaMet = 1456 1464 (leaf->mDepth > mMaxDepthForDynamicBranch) || 1457 (leaf->CountPrimitives() == 1);1465 (leaf->CountPrimitives() <= 1); 1458 1466 1459 1467 return criteriaMet; … … 1501 1509 -- mNumNodes; 1502 1510 1503 #if 01511 #if 1 1504 1512 BvhConstructor bvhConstructor(mGeometry, (int)mStaticGeometrySize, (int)mGeometrySize - 1); 1505 1513 … … 1510 1518 1511 1519 #else 1520 1512 1521 BvhLeaf *l = new BvhLeaf(mRoot); 1513 1522 mDynamicRoot = l;
Note: See TracChangeset
for help on using the changeset viewer.