Changeset 3265
- Timestamp:
- 01/11/09 02:43:59 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter2.cpp
r3262 r3265 510 510 511 511 512 int entityCount = 1;512 int entityCount = mNumShapes; 513 513 ofile.write(reinterpret_cast<char *>(&entityCount), sizeof(int)); 514 514 515 515 516 516 ////////// 517 //-- write single scene entity 518 519 // no transformation 520 bool hasTrafo = false; 521 ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 522 523 // a dummy lod 524 int numLODs = 1; 525 ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int)); 526 527 float dist = 0; 528 ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 529 530 ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 517 //-- write scene entities 531 518 532 519 // all shapes belong to this scene entity 533 520 for (int i = 0; i < mNumShapes; ++ i) 534 521 { 522 // no transformation 523 bool hasTrafo = false; 524 ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 525 526 // a dummy lod 527 int numLODs = 1; 528 ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int)); 529 530 float dist = 0; 531 ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 532 533 int numShapes = 1; 534 ofile.write(reinterpret_cast<char *>(&numShapes), sizeof(int)); 535 535 536 int shapeId = i; 536 537 ofile.write(reinterpret_cast<char *>(&shapeId), sizeof(int)); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp
r3262 r3265 32 32 33 33 //const int numFiles = 879; 34 const int numFiles = 300;34 const int numFiles = 10; 35 35 36 36 vector<string> filenames; -
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; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp
r3262 r3265 40 40 41 41 int BvhConstructor::SortTriangles(BvhLeaf *leaf, 42 int axis, 43 float position) 42 int axis, 43 float position 44 ) 44 45 { 45 46 int i = leaf->mFirst; … … 48 49 while (1) 49 50 { 50 while (mEntities[i]->GetWorldCenter()[axis] < position) ++ i; 51 //while ((j > 0) && (position < mGeometry[j]->GetWorldCenter()[axis])) -- j; 52 while (position < mEntities[j]->GetWorldCenter()[axis]) -- j; 51 //while (mEntities[i]->GetWorldCenter()[axis] < position) ++ i; 52 //while (position < mEntities[j]->GetWorldCenter()[axis]) -- j; 53 54 while ((i < leaf->mLast) && (mEntities[i]->GetWorldCenter()[axis] < position)) ++ i; 55 while ((j > leaf->mFirst) && (position < mEntities[j]->GetWorldCenter()[axis])) -- j; 53 56 54 57 // sorting finished … … 81 84 if (TerminationCriteriaMet(leaf)) 82 85 { 83 cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 86 if (leaf->CountPrimitives() <= 0) 87 cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 84 88 return leaf; 85 89 } … … 101 105 { 102 106 // no split could be achieved => just halve number of objects 103 split = (leaf->mLast -leaf->mFirst) / 2;107 split = (leaf->mLast + leaf->mFirst) / 2; 104 108 cerr << "no reduction " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << endl; 105 109 }
Note: See TracChangeset
for help on using the changeset viewer.