Ignore:
Timestamp:
08/29/06 17:34:19 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1293 r1294  
    213213        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.minGlobalCostRatio", 
    214214                mTermMinGlobalCostRatio); 
    215         Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
     215        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.globalCostMissTolerance",  
     216                mTermGlobalCostMissTolerance); 
    216217 
    217218        //-- factors for bsp tree split plane heuristics 
     
    285286        // add the new nodes to the tree 
    286287        BvhInterior *node = new BvhInterior(tData.mBoundingBox, leaf->GetParent()); 
    287         //cout << "bbox: " << tData.mBoundingBox << endl; 
    288  
     288         
    289289 
    290290        //-- the front and back traversal data is filled with the new values 
     
    292292        frontData.mDepth = backData.mDepth = tData.mDepth + 1; 
    293293 
    294         frontData.mBoundingBox = ComputeBoundingBox(frontObjects, &(tData.mBoundingBox)); 
    295         backData.mBoundingBox = ComputeBoundingBox(backObjects, &(tData.mBoundingBox)); 
     294        frontData.mBoundingBox = ComputeBoundingBox(frontObjects, &tData.mBoundingBox); 
     295        backData.mBoundingBox = ComputeBoundingBox(backObjects, &tData.mBoundingBox); 
    296296         
    297297        ///////////// 
     
    354354        if (!LocalTerminationCriteriaMet(tData) && !globalCriteriaMet) 
    355355        {        
     356                //-- continue subdivision 
     357 
    356358                BvhTraversalData tFrontData; 
    357359                BvhTraversalData tBackData; 
    358  
    359                 //-- continue subdivision 
    360                  
     360                         
    361361                // create new interior node and two leaf node 
    362362                newNode = SubdivideNode(sc->mFrontObjects, 
     
    392392 
    393393                // delete old leaf node 
    394                 DEL_PTR(tData.mNode); 
     394                //DEL_PTR(tData.mNode); 
    395395        } 
    396396 
     
    409409                        CollectRays(leaf->mObjects, leaf->mVssRays); 
    410410                } 
    411         } 
    412          
    413         tData.Clear(); // cleanup 
     411 
     412                // detach node so it won't get deleted 
     413                tData.mNode = NULL; 
     414        } 
    414415         
    415416        return newNode; 
     
    447448        const float renderCostDecr = oldRenderCost - newRenderCost; 
    448449 
    449         //Debug << "render cost decr: " << renderCostDecr << endl; 
     450        Debug << "\nbvh render cost decr: " << renderCostDecr << endl; 
    450451        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    451452 
    452 #if 0 
    453         const float priority = (float)-data.mDepth; 
     453#if 1 
     454        const float priority = (float)-splitCandidate.mParentData.mDepth; 
    454455#else    
    455456        // take render cost of node into account  
     
    469470        // matt: TODO 
    470471        return ( 0 
    471                 || (data.mNode->mObjects.size() < mTermMinObjects) 
    472                 || (data.mProbability <= mTermMinProbability) 
    473                 || (data.mDepth >= mTermMaxDepth) 
     472                //|| ((int)data.mNode->mObjects.size() < mTermMinObjects) 
     473                //|| (data.mProbability <= mTermMinProbability) 
     474                //|| (data.mDepth >= mTermMaxDepth) 
    474475                 ); 
    475476} 
     
    536537                AxisAlignedBox3 box = obj->GetBox(); 
    537538 
    538                 const float objMid = (box.Max(axis) + box.Min(axis)) * 0.5; 
     539                const float objMid = (box.Max(axis) + box.Min(axis)) * 0.5f; 
    539540 
    540541                // object mailed => belongs to back objects 
     
    936937 
    937938        const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 
    938         Debug << "\n***** eval render cost *********\n"  
     939        /*Debug << "\nbvh render cost\n"  
    939940                  << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol << endl 
    940                   << "new rc: " << newRenderCost / viewSpaceVol << endl; 
     941                  << "new rc: " << newRenderCost / viewSpaceVol << endl;*/ 
    941942                  
    942943 
     
    13191320} 
    13201321 
     1322void BvHierarchy::CreateRoot(const ObjectContainer &objects) 
     1323{ 
     1324        //-- create new root 
     1325        AxisAlignedBox3 box = ComputeBoundingBox(objects); 
     1326        BvhLeaf *bvhleaf = new BvhLeaf(box, NULL, (int)objects.size()); 
     1327        bvhleaf->mObjects = objects; 
     1328 
     1329        mRoot = bvhleaf; 
     1330 
     1331        // associate root with current objects 
     1332        AssociateObjectsWithLeaf(bvhleaf); 
     1333} 
     1334 
    13211335 
    13221336SubdivisionCandidate *BvHierarchy::PrepareConstruction(const VssRayContainer &sampleRays, 
    1323                                                                                                            const ObjectContainer &objects 
    1324                                                                                                            //,AxisAlignedBox3 *forcedObjectSpace 
    1325                                                                                                            ) 
     1337                                                                                                           const ObjectContainer &objects) 
    13261338{ 
    13271339        // note matt: we assume that we have objects sorted by their id 
     
    13321344 
    13331345        // compute bounding box from objects 
    1334         mBoundingBox = ComputeBoundingBox(objects); 
     1346        // we assume that root was already created 
     1347        mBoundingBox = mRoot->GetBoundingBox(); 
     1348        BvhLeaf *bvhleaf = dynamic_cast<BvhLeaf *>(mRoot); 
    13351349 
    13361350        mTermMinProbability *= mBoundingBox.GetVolume(); 
    13371351        mGlobalCostMisses = 0; 
    13381352         
    1339         //-- create new root 
    1340  
    1341         BvhLeaf *bvhleaf = new BvhLeaf(mBoundingBox, NULL, (int)objects.size()); 
    1342         bvhleaf->mObjects = objects; 
    1343         mRoot = bvhleaf; 
    1344  
    13451353        // only rays intersecting objects in node are interesting 
    13461354        AssociateObjectsWithRays(sampleRays); 
    1347         // associate root with current objects 
    1348         AssociateObjectsWithLeaf(bvhleaf); 
    1349  
    1350         //-- add first candidate for object space partition 
    1351          
     1355         
     1356 
    13521357        // probabilty is voume of all "seen" view cells 
    13531358#if 1 
    1354         const float prop = EvalViewCellsVolume(bvhleaf->mObjects); 
     1359        const float prop = EvalViewCellsVolume(objects); 
    13551360#else 
    13561361        const float prop = GetBoundingBox().GetVolume(); 
     
    13601365        BvhTraversalData oData(bvhleaf, 0, mBoundingBox, prop); 
    13611366 
    1362         //-- first split candidate 
     1367        //-- add first candidate for object space partition      
    13631368        BvhSubdivisionCandidate *oSubdivisionCandidate =  
    13641369                new BvhSubdivisionCandidate(oData); 
Note: See TracChangeset for help on using the changeset viewer.