Ignore:
Timestamp:
01/17/06 23:28:10 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r544 r547  
    2525mTotalAreaValid(false), 
    2626mTotalArea(0.0f), 
    27 mViewCellsFinished(false) 
     27mViewCellsFinished(false), 
     28mMaxPvsSize(99999) 
    2829{ 
    2930        mViewSpaceBox.Initialize(); 
     
    4950        environment->GetBoolValue("ViewCells.Visualization.exportRays", mExportRays); 
    5051        environment->GetBoolValue("ViewCells.Visualization.exportGeometry", mExportGeometry); 
     52        environment->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio); 
    5153 
    5254        char buf[50]; 
     
    105107        return (int)rays.size(); 
    106108} 
     109 
     110 
     111bool ViewCellsManager::CheckValid(ViewCell *vc) const 
     112{ 
     113        if (vc->GetPvs().GetSize() > mMaxPvsSize) 
     114                return false; 
     115 
     116        return true; 
     117} 
     118 
    107119 
    108120bool ViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) 
     
    347359} 
    348360 
     361 
    349362ViewCellContainer &ViewCellsManager::GetViewCells() 
    350363{ 
     
    375388        // has to be recomputed 
    376389        mTotalAreaValid = false; 
     390} 
     391 
     392 
     393int ViewCellsManager::GetMaxPvsSize() const 
     394{ 
     395        return mMaxPvsSize; 
    377396} 
    378397 
     
    17971816float VspBspViewCellsManager::GetProbability(ViewCell *viewCell) 
    17981817{ 
    1799 #if 0 
    1800         return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 
    1801 #else 
    1802         return GetArea(viewCell) / GetAccVcArea(); 
    1803 #endif 
     1818        if (mVspBspTree->mUseAreaForPvs) 
     1819                return GetArea(viewCell) / GetAccVcArea(); 
     1820        else 
     1821                return GetVolume(viewCell) / mViewSpaceBox.GetVolume(); 
    18041822} 
    18051823 
     
    18071825void VspBspViewCellsManager::CollectViewCells() 
    18081826{ 
    1809         mVspBspTree->CollectViewCells(mViewCells); 
     1827        mVspBspTree->CollectViewCells(mViewCells, false); 
    18101828} 
    18111829 
     
    18521870        Debug << "saved rays: " << (int)savedRays.size() << endl; 
    18531871 
     1872        mMaxPvsSize = (int)(mMaxPvsRatio * (float)objects.size()); 
     1873         
    18541874        mVspBspTree->Construct(constructionRays, &mViewSpaceBox); 
    18551875 
     
    19291949 
    19301950        // TODO: should be done BEFORE the ray casting 
    1931         merged = mVspBspTree->MergeViewCells(rays); 
     1951        merged = mVspBspTree->MergeViewCells(rays, objects); 
    19321952 
    19331953        //-- stats and visualizations 
     
    23002320                                                                                 ViewCell *vc) const 
    23012321{ 
    2302         if (mColorCode == 0) // Random color 
     2322        if (CheckValid(vc) && (mColorCode == 0)) // Random color 
    23032323                return; 
    23042324 
    23052325        float importance = 0; 
    2306  
     2326         
     2327        Material m; 
     2328         
    23072329        switch (mColorCode) 
    23082330        { 
     
    23192341                        importance = (float)bspVc->mLeaves.size() / 
    23202342                                (float)mViewCellsStats.maxLeaves; 
     2343 
     2344                        if (CheckValid(vc)) 
     2345                                m.mDiffuseColor.b = 1.0f; 
     2346                        m.mDiffuseColor.r = importance; 
     2347                        m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r; 
    23212348                } 
    23222349                break; 
     
    23252352                        importance = (float)GetMaxTreeDiff(vc) / 
    23262353                                (float)(mVspBspTree->GetStatistics().maxDepth * 2); 
     2354 
     2355                        if (CheckValid(vc)) 
     2356                                m.mDiffuseColor.b = 1.0f; 
     2357                        m.mDiffuseColor.r = importance; 
     2358                        m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r; 
    23272359                } 
    23282360                break; 
     
    23312363        } 
    23322364 
    2333         Material m; 
    2334         m.mDiffuseColor.b = 1.0f; 
     2365        m.mDiffuseColor.b = CheckValid(vc) ? 1.0f : 0.0f; 
    23352366        m.mDiffuseColor.r = importance; 
    23362367        m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r; 
     2368 
    23372369        //Debug << "importance: " << importance << endl; 
    23382370        exporter->SetForcedMaterial(m); 
Note: See TracChangeset for help on using the changeset viewer.