Changeset 1142


Ignore:
Timestamp:
07/19/06 00:26:49 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
7 edited

Legend:

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

    r1141 r1142  
    12881288                                        "perobject"); 
    12891289 
    1290         RegisterOption("ViewCells.Evaluation.countKdPvs", 
    1291                                         optBool, 
    1292                                         "view_cells_evaluation_count_kd_pvs=", 
    1293                                         "false"); 
    1294  
    12951290        RegisterOption("ViewCells.active", 
    12961291                                        optInt, 
     
    22192214        RegisterOption("VspTree.storeKdPvs", 
    22202215                                        optBool, 
    2221                                         "vsp_storeKdPvs=", 
     2216                                        "vsp_store_kd_pvs=", 
    22222217                                        "true"); 
    22232218         
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1141 r1142  
    16771677 
    16781678 
    1679 int ViewCellsTree::CountKdPvs(const ViewCellLeaf *vc) const 
    1680 { 
    1681         ObjectPvsMap::const_iterator oit, oit_end = vc->GetPvs().mEntries.end(); 
    1682  
     1679int ViewCellsTree::GetPvsSize(ViewCell *vc) const 
     1680{ 
    16831681        int pvsSize = 0; 
    16841682 
    16851683        Intersectable::NewMail(); 
    16861684 
    1687         for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
    1688         { 
    1689                 Intersectable *obj = (*oit).first; 
    1690  
    1691 /*              KdLeaf *leaf = ; 
    1692  
    1693                         pvsSize += ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size()); 
    1694  
    1695                         //-- handle objects of several kd leaves separately 
    1696                         ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
    1697  
    1698                         for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 
    1699                         { 
    1700                                 Intersectable *object = *oit; 
    1701  
    1702                                 // object not previously in left pvs 
    1703                                 if (!object->Mailed()) 
    1704                                 { 
    1705                                         object->Mail(); 
    1706                                         ++ pvsSize; 
    1707                                 } 
    1708                         }                
    1709                 }*/ 
    1710         } 
    1711  
    1712         return pvsSize; 
    1713 } 
    1714  
    1715  
    1716 int ViewCellsTree::GetPvsSize(ViewCell *vc, const bool countKdPvs) const 
    1717 { 
    1718         int pvsSize = 0; 
    1719  
    1720         Intersectable::NewMail(); 
    1721  
    1722         ////////////////////////// 
    1723         // for interiors, pvs can be stored using different methods 
     1685        //////////////////////////////////////////////// 
     1686        //-- for interiors, pvs can be stored using different methods 
     1687        /////////////////////////////////////////////// 
    17241688 
    17251689        switch (mViewCellsStorage) 
     
    17301694                        if (vc->IsLeaf()) 
    17311695                        { 
    1732                                 if (countKdPvs) 
    1733                                         pvsSize = vc->GetPvs().CountPvs(); 
    1734                                 else 
    1735                                         pvsSize = CountKdPvs(dynamic_cast<ViewCellLeaf *>(vc)); 
    1736                                 break; 
     1696                                pvsSize = vc->GetPvs().CountPvs(); 
    17371697                        } 
    17381698         
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1141 r1142  
    439439        void GetPvs(ViewCell *vc, ObjectPvs &pvs) const; 
    440440 
    441         /** Returns pvs size of view cell. 
    442         */ 
    443         //int GetPvsSize(ViewCell *vc) const; 
    444         int GetPvsSize(ViewCell *vc, const bool countKdPvs = false) const; 
     441        /** Returns pvs size (i.e. the number of entries weighted by their "importance". 
     442        */ 
     443        int GetPvsSize(ViewCell *vc) const; 
    445444 
    446445        /** Returns actual number of object in this pvs and the children. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1141 r1142  
    100100        Environment::GetSingleton()->GetBoolValue("ViewCells.exportBboxesForPvs", mExportBboxesForPvs); 
    101101        Environment::GetSingleton()->GetBoolValue("ViewCells.exportPvs", mExportPvs); 
    102         Environment::GetSingleton()->GetBoolValue("ViewCells.Evaluation.countKdPvs", mCountKdPvs); 
     102         
    103103 
    104104        char buf[100]; 
     
    214214        Debug << "export bounding boxes: " << mExportBboxesForPvs << endl; 
    215215        Debug << "export pvs for view cells: " << mExportPvs << endl; 
    216         Debug << "count kd pvs: " << mCountKdPvs << endl; 
     216         
    217217         
    218218        Debug << endl; 
     
    788788        sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 
    789789 
    790         maxPvs = mViewCellsTree->GetPvsSize(viewCells.back(), mCountKdPvs); 
     790        maxPvs = mViewCellsTree->GetPvsSize(viewCells.back()); 
    791791        minVal = 0; 
    792792 
     
    832832 
    833833                while ((i < (int)viewCells.size()) &&  
    834                            (mViewCellsTree->GetPvsSize(viewCells[i], mCountKdPvs) < currentPvs)) 
     834                           (mViewCellsTree->GetPvsSize(viewCells[i]) < currentPvs)) 
    835835                { 
    836836                        volDif += viewCells[i]->GetVolume(); 
     
    843843                 
    844844                if (0 && (i < (int)viewCells.size())) 
    845                         Debug << "new pvs size increase: " << mViewCellsTree->GetPvsSize(viewCells[i], mCountKdPvs)  
     845                        Debug << "new pvs size increase: " << mViewCellsTree->GetPvsSize(viewCells[i])  
    846846                        << " " << currentPvs << endl; 
    847847         
     
    17061706                ViewCell *viewcell = *it; 
    17071707 
    1708                 const int pvsSize = mViewCellsTree->GetPvsSize(viewcell, mCountKdPvs); 
     1708                const int pvsSize = mViewCellsTree->GetPvsSize(viewcell); 
    17091709 
    17101710                if (pvsSize < stat.minPvs) 
     
    19571957float ViewCellsManager::GetRendercost(ViewCell *viewCell) const 
    19581958{ 
    1959         return mViewCellsTree->GetPvsSize(viewCell, mCountKdPvs); 
     1959        return mViewCellsTree->GetPvsSize(viewCell); 
    19601960} 
    19611961 
     
    24092409                        { 
    24102410                                importance =  
    2411                                         (float)mViewCellsTree->GetPvsSize(vc, mCountKdPvs) /  
     2411                                        (float)mViewCellsTree->GetPvsSize(vc) /  
    24122412                                        (float)mCurrentViewCellsStats.maxPvs; 
    24132413                        } 
     
    43904390                Exporter *exporter = Exporter::GetExporter(s); 
    43914391                 
    4392                 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc, mCountKdPvs) << endl; 
     4392                Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 
    43934393 
    43944394                //-- export the sample rays 
     
    49044904        long startTime; 
    49054905 
    4906         mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 
    49074906        //mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 
    4908          
     4907        //mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 
     4908        mHierarchyManager->Construct3(constructionRays, objects, &mViewSpaceBox); 
     4909 
    49094910        //-- stats 
    49104911        Debug << mVspTree->GetStatistics() << endl; 
     
    53015302        } 
    53025303 
    5303         if (1)  
     5304        if (1 && mOspTree->GetRoot())  
    53045305        {        
    53055306                //-- export final object partition 
     
    53835384                Exporter *exporter = Exporter::GetExporter(s); 
    53845385                 
    5385                 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc, mCountKdPvs) << endl; 
     5386                Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 
    53865387 
    53875388                //-- export the sample rays 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1141 r1142  
    655655        /// if pvs should be exported with view cells 
    656656        bool mExportPvs; 
    657 // matt§§: need this? 
    658         bool mCountKdPvs; 
    659657}; 
    660658 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1141 r1142  
    523523 
    524524 
    525 void VspTree::CreateViewCell(VspTraversalData &tData) 
     525void VspTree::CreateViewCell(VspTraversalData &tData, const bool updatePvs) 
    526526{ 
    527527        //-- create new view cell 
     
    530530        VspViewCell *viewCell = new VspViewCell(); 
    531531    leaf->SetViewCell(viewCell); 
    532                  
    533         //-- update pvs 
     532         
    534533        int conSamp = 0; 
    535534        float sampCon = 0.0f; 
    536         AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); 
    537  
    538         // update scalar pvs size value 
    539         mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().CountPvs()); 
    540  
    541         mVspStats.contributingSamples += conSamp; 
    542         mVspStats.sampleContributions +=(int) sampCon; 
     535 
     536        //-- update pvs 
     537        if (updatePvs) 
     538        { 
     539                AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); 
     540 
     541                // update scalar pvs size value 
     542                mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().CountPvs()); 
     543 
     544                mVspStats.contributingSamples += conSamp; 
     545                mVspStats.sampleContributions += (int)sampCon; 
     546        } 
     547 
    543548 
    544549        //-- store additional info 
     
    766771 
    767772        // explicitely create front and back view cell 
    768         CreateViewCell(frontData); 
    769         CreateViewCell(backData); 
     773        CreateViewCell(frontData, true); 
     774        CreateViewCell(backData, true); 
    770775 
    771776         
     
    773778        // add front and back view cell to "Potentially Visbilie View Cells"  
    774779        // of the objects in front and back pvs 
    775         AddViewCellReferences(frontLeaf->GetViewCell()); 
    776         AddViewCellReferences(backLeaf->GetViewCell()); 
     780 
     781        //AddViewCellReferences(frontLeaf->GetViewCell()); 
     782        //AddViewCellReferences(backLeaf->GetViewCell()); 
    777783 
    778784        interior->mTimeStamp = mTimeStamp ++; 
     
    40044010        mVspTree.mVspStats.nodes = 1; 
    40054011 
    4006         // prepare bounding box 
     4012        // compute view space bounding box 
    40074013        mVspTree.ComputeBoundingBox(rays, forcedViewSpace); 
    40084014 
     
    40324038 
    40334039        // create first view cell 
    4034         mVspTree.CreateViewCell(vData); 
     4040        mVspTree.CreateViewCell(vData, true); 
    40354041                 
    40364042        // add first view cell to all the objects view cell pvs 
     
    41794185        mVspTree.mVspStats.Stop(); 
    41804186         
     4187         
     4188        /////////////////////////////////////////////////////////////// 
     4189        //-- object space partition 
     4190        ///////////////////////////////////////////////////////////// 
     4191 
     4192 
     4193        cout << "starting osp contruction ... " << endl; 
    41814194        startTime = GetTime(); 
    4182         cout << "starting osp contruction ... " << endl; 
    4183  
    4184         //-- object space partition 
     4195 
    41854196        SplitCandidate *osc = 
    41864197                PrepareOsp(sampleRays, objects, forcedViewSpace, *objectSpaceRays); 
     
    42224233        mVspTree.mStoreKdPvs = savedStoreMethod; 
    42234234} 
     4235 
     4236 
     4237void HierarchyManager::Construct3(const VssRayContainer &sampleRays, 
     4238                                                                  const ObjectContainer &objects, 
     4239                                                                  AxisAlignedBox3 *forcedViewSpace) 
     4240{ 
     4241        RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
     4242 
     4243        SplitCandidate *sc = PrepareVsp(sampleRays, forcedViewSpace, *viewSpaceRays); 
     4244        mTQueue.Push(sc); 
     4245 
     4246        cout << "starting vsp contruction ... " << endl; 
     4247 
     4248        long startTime = GetTime(); 
     4249        int i = 0; 
     4250 
     4251        while (!FinishedConstruction()) 
     4252        { 
     4253                SplitCandidate *splitCandidate = NextSplitCandidate(); 
     4254             
     4255                const bool globalTerminationCriteriaMet =  
     4256                        GlobalTerminationCriteriaMet(splitCandidate); 
     4257 
     4258                cout << "vsp nodes: " << i ++ << endl; 
     4259 
     4260                // cost ratio of cost decrease / totalCost 
     4261                const float costRatio = splitCandidate->GetPriority() / mTotalCost; 
     4262                //cout << "cost ratio: " << costRatio << endl; 
     4263 
     4264                if (costRatio < mTermMinGlobalCostRatio) 
     4265                        ++ mGlobalCostMisses; 
     4266 
     4267                //-- subdivide leaf node 
     4268 
     4269                // we have either a object space or view space split 
     4270                VspTree::VspSplitCandidate *sc =  
     4271                        dynamic_cast<VspTree::VspSplitCandidate *>(splitCandidate); 
     4272 
     4273         
     4274                VspNode *r = mVspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 
     4275 
     4276                DEL_PTR(splitCandidate); 
     4277        } 
     4278 
     4279        cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
     4280        mVspTree.mVspStats.Stop(); 
     4281} 
     4282 
    42244283 
    42254284 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1141 r1142  
    10121012                ViewCell *back) const; 
    10131013 
    1014         void CreateViewCell(VspTraversalData &tData); 
     1014        void CreateViewCell(VspTraversalData &tData, const bool updatePvs); 
    10151015 
    10161016        void CollectDirtyCandidates(VspSplitCandidate *sc,  
     
    17481748                                        AxisAlignedBox3 *forcedViewSpace); 
    17491749 
     1750        /** Constructs only vsp tree. 
     1751        */ 
     1752        void Construct3(const VssRayContainer &sampleRays, 
     1753                                        const ObjectContainer &objects, 
     1754                                        AxisAlignedBox3 *forcedViewSpace); 
     1755 
    17501756public: 
    17511757        VspTree &mVspTree; 
Note: See TracChangeset for help on using the changeset viewer.