Ignore:
Timestamp:
01/11/09 13:34:37 (15 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r3265 r3267  
    4040 
    4141int BvhConstructor::SortTriangles(BvhLeaf *leaf,  
    42                                            int axis,  
    43                                            float position 
    44                                            ) 
     42                                                                  int axis,  
     43                                                                  float position 
     44                                                                  ) 
    4545{ 
    4646        int i = leaf->mFirst; 
     
    6969 
    7070 
     71void BvhConstructor::UpdateBoundingBoxes(BvhNode *node) 
     72{ 
     73        if (node->IsLeaf()) 
     74        { 
     75                int numEntities = node->CountPrimitives(); 
     76                SceneEntity **entities = mEntities + node->mFirst; 
     77 
     78                node->mBox = SceneEntity::ComputeBoundingBox(entities, numEntities); 
     79                //cout << "box: " << node->mBox << endl; 
     80        } 
     81        else 
     82        { 
     83                BvhNode *f = static_cast<BvhInterior *>(node)->GetFront(); 
     84                BvhNode *b = static_cast<BvhInterior *>(node)->GetBack(); 
     85 
     86                UpdateBoundingBoxes(f); 
     87                UpdateBoundingBoxes(b); 
     88 
     89                node->mBox = f->mBox; 
     90                node->mBox.Include(b->mBox); 
     91        } 
     92} 
     93 
     94 
    7195int BvhConstructor::SortTrianglesSpatialMedian(BvhLeaf *leaf,  
    7296                                                                                           int axis) 
     
    84108        if (TerminationCriteriaMet(leaf)) 
    85109        { 
    86                 if (leaf->CountPrimitives() <= 0) 
    87                         cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 
     110                //if (leaf->CountPrimitives() <= 0) 
     111                //cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 
    88112                return leaf; 
    89113        } 
     
    157181{ 
    158182        BvhNode *root; 
    159  
    160183        mNumNodes = 1; 
    161184 
     
    168191        l->mArea = l->mBox.SurfaceArea(); 
    169192         
    170         cout << "constructing bvh" << endl; 
     193        cout << "constructing bvh from "  << l->mFirst << " to " << l->mLast << endl; 
    171194 
    172195        root = SubdivideLeaf(l, 0); 
    173196 
     197        UpdateBoundingBoxes(root); 
     198 
    174199        numNodes = mNumNodes; 
    175200 
Note: See TracChangeset for help on using the changeset viewer.