Ignore:
Timestamp:
06/20/08 02:26:30 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r2782 r2786  
    366366 
    367367 
    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); 
     368void 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 
     385int 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        } 
    382410 
    383411        return renderedBoxes; 
     
    385413 
    386414 
    387 int Bvh::PrepareBoundingBoxesWithDrawArrays(const BvhNodeContainer &nodes) 
     415int Bvh::PrepareBoundsWithDrawArrays(const BvhNodeContainer &nodes) 
    388416{ 
    389417        ////// 
     
    428456 
    429457 
    430 void Bvh::RenderBoundingBoxesWithDrawArrays(int numNodes, RenderState *state) 
     458void Bvh::RenderBoundsWithDrawArrays(int numNodes, RenderState *state) 
    431459{ 
    432460        ////// 
     
    706734        nodeStack.push(mRoot); 
    707735 
     736        int numVirtualLeaves = 0; 
     737 
    708738        while (!nodeStack.empty())  
    709739        { 
     
    713743                if (node->IsVirtualLeaf())  
    714744                { 
     745                        ++ numVirtualLeaves; 
     746 
    715747                        BvhLeaf *leaf = static_cast<BvhLeaf *>(node); 
    716748 
     
    731763        } 
    732764 
    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; 
    735767} 
    736768 
Note: See TracChangeset for help on using the changeset viewer.