Changeset 3267


Ignore:
Timestamp:
01/11/09 13:34:37 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
6 edited

Legend:

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

    r3266 r3267  
    504504        if (mDynamicGeometrySize) 
    505505        { 
    506                 UpdateDynamicBranch(mDynamicRoot); 
     506                UpdateBoundingBoxes(mDynamicRoot); 
    507507                UpdateDynamicBounds(state); 
    508508        } 
     
    874874        cout << "created tighter bounds for " << p << " percent of the nodes" << endl; 
    875875 
    876         // recreate indices used for indirect mode rendering 
     876        // recreate indices used for indirect rendering mode 
    877877        if (mIndices) CreateIndices(); 
    878878} 
     
    956956        int numVirtualLeaves = 0; 
    957957        int numGeometry = 0; 
    958 cout<<"here3 computing stats"<<endl; 
     958 
    959959        while (!nodeStack.empty())  
    960960        { 
     
    962962                nodeStack.pop(); 
    963963 
    964                 cout << "x"; 
    965                 if (node->IsLeaf() && !node->IsVirtualLeaf()) 
    966                         cerr << "here34"<<endl; 
    967  
    968964                if (node->IsVirtualLeaf())  
    969965                { 
     
    971967                        numGeometry += node->CountPrimitives(); 
    972968 
    973                         cout << " l " << numGeometry; 
    974969                        BvhLeaf *leaf = static_cast<BvhLeaf *>(node); 
    975970 
     
    980975                else  
    981976                { 
    982                         cout << "i"; 
    983  
    984977                        bvhStats.mInteriorSA += node->mBox.SurfaceArea(); 
    985978                        bvhStats.mInteriorVol += node->mBox.GetVolume(); 
     
    10901083        // assign new virtual leaves based on specified #triangles per leaf 
    10911084        std::stack<BvhNode *> nodeStack; 
    1092         nodeStack.push(mRoot); 
    1093  
    1094         cout << "here9" << endl; 
     1085        nodeStack.push(mStaticRoot); 
     1086        nodeStack.push(mDynamicRoot); 
     1087 
    10951088        while (!nodeStack.empty())  
    10961089        { 
    1097                 cout <<"u"<< endl; 
    10981090                BvhNode *node = nodeStack.top(); 
    10991091                nodeStack.pop(); 
     
    11161108                                (CountTriangles(node) <= numTriangles)) 
    11171109                        { 
    1118                                 cout << " l " << CountTriangles(node) << " " << node->mIsMaxDepthForVirtualLeaf << endl; 
     1110                                //cout << " l " << CountTriangles(node) << " " << node->mIsMaxDepthForVirtualLeaf << endl; 
    11191111                                node->mIsVirtualLeaf = true; 
    11201112                        } 
     
    11451137 
    11461138        std::stack<BvhNode *> nodeStack; 
    1147         nodeStack.push(mRoot); 
    1148  
    1149         cout << "here7 computing depth" << endl; 
     1139 
     1140        nodeStack.push(mStaticRoot); 
     1141        nodeStack.push(mDynamicRoot); 
     1142 
    11501143        while (!nodeStack.empty())  
    11511144        { 
    11521145                BvhNode *node = nodeStack.top(); 
    11531146                nodeStack.pop(); 
    1154 cout << "z"; 
     1147 
    11551148                if (node->IsLeaf())  
    11561149                { 
     
    11661159                        if ((f->mFirst == b->mFirst) && (f->mLast == b->mLast)) 
    11671160                        { 
    1168                                 cout << "f: " << f->mFirst << " " << f->mLast << endl; 
    11691161                                // point reached where beyond there would be no further reduction  
    11701162                                // as both subtrees contain the same objects => stop here 
     
    11801172                } 
    11811173        } 
    1182         cout << "here7" << endl; 
    11831174} 
    11841175 
     
    12051196 
    12061197        BvhStats staticBvhStats; 
    1207         ComputeBvhStats(mRoot, staticBvhStats); 
     1198        ComputeBvhStats(mStaticRoot, staticBvhStats); 
    12081199        cout << "\n============ Static BVH statistics =============" << endl; 
    12091200 
     
    14041395 
    14051396 
    1406 void Bvh::UpdateDynamicBranch(BvhNode *node) 
     1397void Bvh::UpdateBoundingBoxes(BvhNode *node) 
    14071398{ 
    14081399        if (node->IsLeaf()) 
     
    14191410                BvhNode *b = static_cast<BvhInterior *>(node)->GetBack(); 
    14201411 
    1421                 UpdateDynamicBranch(f); 
    1422                 UpdateDynamicBranch(b); 
     1412                UpdateBoundingBoxes(f); 
     1413                UpdateBoundingBoxes(b); 
    14231414 
    14241415                node->mBox = f->mBox; 
     
    14521443} 
    14531444 
    1454 } 
     1445 
     1446 
     1447 
     1448} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h

    r3266 r3267  
    590590        void CreateDynamicBranch(); 
    591591 
    592         void UpdateDynamicBranch(BvhNode *node); 
     592        void UpdateBoundingBoxes(BvhNode *node); 
    593593 
    594594        inline bool TerminationCriteriaMet(BvhLeaf *leaf) const; 
  • 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 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.h

    r3264 r3267  
    3232        inline bool TerminationCriteriaMet(BvhLeaf *leaf) const; 
    3333 
     34        void UpdateBoundingBoxes(BvhNode *node); 
     35 
    3436 
    3537        ///////////////// 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp

    r3266 r3267  
    142142        Bvh *bvh = new Bvh(staticEntities, dynamicEntities, maxDepthForTestingChildren); 
    143143 
     144        cout << "here8 " << (int)bvh->mStaticGeometrySize - 1 << endl; 
    144145        BvhConstructor bvhConstructor(bvh->mGeometry,  
    145146                                          0, 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3266 r3267  
    7777FrameBufferObject *fbo = NULL; 
    7878/// the renderable scene geometry 
    79 SceneEntityContainer sceneEntities; 
     79SceneEntityContainer staticObjects; 
    8080/// the dynamic objects in the scene 
    8181SceneEntityContainer dynamicObjects; 
     
    568568        //-- load the static scene geometry 
    569569 
    570         LoadModel(filename + ".dem", sceneEntities); 
     570        LoadModel(filename + ".dem", staticObjects); 
    571571 
    572572 
     
    645645 
    646646        BvhFactory bvhFactory; 
    647         //bvh = bvhFactory.Create(bvh_filename, sceneEntities, dynamicObjects, maxDepthForTestingChildren); 
    648         bvh = bvhFactory.Create(sceneEntities, dynamicObjects, maxDepthForTestingChildren); 
     647        //bvh = bvhFactory.Create(bvh_filename, staticObjects, dynamicObjects, maxDepthForTestingChildren); 
     648        bvh = bvhFactory.Create(staticObjects, dynamicObjects, maxDepthForTestingChildren); 
    649649 
    650650        if (!bvh) 
     
    671671        //-- setup the skydome model 
    672672 
    673         LoadModel("sky.dem", sceneEntities); 
    674         skyDome = sceneEntities.back(); 
     673        LoadModel("sky.dem", staticObjects); 
     674        skyDome = staticObjects.back(); 
    675675 
    676676        /// the turbitity of the sky (from clear to hazy, use <3 for clear sky) 
Note: See TracChangeset for help on using the changeset viewer.