Changeset 2786 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
- Timestamp:
- 06/20/08 02:26:30 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r2782 r2786 366 366 367 367 368 void Bvh::RenderBoundingBox(BvhNode *node, RenderState *state) 369 { 370 //RenderBoundingBoxImmediate(node->GetBox()); 371 static BvhNodeContainer dummy(1); 372 dummy[0] = node; 373 RenderBoundingBoxes(dummy, state); 374 } 375 376 377 378 int Bvh::RenderBoundingBoxes(const BvhNodeContainer &nodes, RenderState *state) 379 { 380 int renderedBoxes = PrepareBoundingBoxesWithDrawArrays(nodes); 381 RenderBoundingBoxesWithDrawArrays(renderedBoxes, state); 368 void Bvh::RenderBounds(BvhNode *node, RenderState *state, bool useTightBounds) 369 { 370 // if not using tight bounds, rendering boxes in immediate mode 371 // is preferable to vertex arrays (less setup time) 372 if (!useTightBounds) 373 { 374 RenderBoundingBoxImmediate(node->GetBox()); 375 } 376 else 377 { 378 static BvhNodeContainer dummy(1); 379 dummy[0] = node; 380 RenderBounds(dummy, state, useTightBounds); 381 } 382 } 383 384 385 int Bvh::RenderBounds(const BvhNodeContainer &nodes, 386 RenderState *state, 387 bool useTightBounds) 388 { 389 // if not using tight bounds, rendering boxes in immediate mode 390 // is preferable to vertex arrays (less setup time) 391 392 int renderedBoxes; 393 394 if (!useTightBounds) 395 { 396 BvhNodeContainer::const_iterator nit, nit_end = nodes.end(); 397 398 for (nit = nodes.begin(); nit != nit_end; ++ nit) 399 { 400 RenderBoundingBoxImmediate((*nit)->GetBox()); 401 } 402 403 renderedBoxes = (int)nodes.size(); 404 } 405 else 406 { 407 renderedBoxes = PrepareBoundsWithDrawArrays(nodes); 408 RenderBoundsWithDrawArrays(renderedBoxes, state); 409 } 382 410 383 411 return renderedBoxes; … … 385 413 386 414 387 int Bvh::PrepareBound ingBoxesWithDrawArrays(const BvhNodeContainer &nodes)415 int Bvh::PrepareBoundsWithDrawArrays(const BvhNodeContainer &nodes) 388 416 { 389 417 ////// … … 428 456 429 457 430 void Bvh::RenderBound ingBoxesWithDrawArrays(int numNodes, RenderState *state)458 void Bvh::RenderBoundsWithDrawArrays(int numNodes, RenderState *state) 431 459 { 432 460 ////// … … 706 734 nodeStack.push(mRoot); 707 735 736 int numVirtualLeaves = 0; 737 708 738 while (!nodeStack.empty()) 709 739 { … … 713 743 if (node->IsVirtualLeaf()) 714 744 { 745 ++ numVirtualLeaves; 746 715 747 BvhLeaf *leaf = static_cast<BvhLeaf *>(node); 716 748 … … 731 763 } 732 764 733 mBvhStats.mGeometryRatio = mGeometrySize / (float) GetNumLeaves();734 mBvhStats.mTriangleRatio = mBvhStats.mTriangles / (float) GetNumLeaves();765 mBvhStats.mGeometryRatio = mGeometrySize / (float)numVirtualLeaves; 766 mBvhStats.mTriangleRatio = mBvhStats.mTriangles / (float)numVirtualLeaves; 735 767 } 736 768
Note: See TracChangeset
for help on using the changeset viewer.