Ignore:
Timestamp:
01/20/06 11:44:19 (18 years ago)
Author:
mattausch
Message:

added flexible checkvalitity function for view cells

File:
1 edited

Legend:

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

    r558 r561  
    2626mTotalArea(0.0f), 
    2727mViewCellsFinished(false), 
    28 mMaxPvsSize(99999) 
     28mMaxPvsSize(99999), 
     29mMaxPvsRatio(1.0) 
    2930{ 
    3031        mViewSpaceBox.Initialize(); 
     
    109110 
    110111 
    111 bool ViewCellsManager::CheckValid(ViewCell *vc) const 
    112 { 
    113         if (vc->GetPvs().GetSize() > mMaxPvsSize) 
     112bool ViewCellsManager::CheckValidity(ViewCell *vc,  
     113                                                                         float minPvsRatio,  
     114                                                                         float maxPvsRatio) const 
     115{ 
     116        if ((vc->GetPvs().GetSize() > mMaxPvsSize * maxPvsRatio) || 
     117                (vc->GetPvs().GetSize() < mMaxPvsSize * minPvsRatio)) 
     118        {        
    114119                return false; 
     120        } 
    115121 
    116122        return true; 
     
    421427 
    422428 
     429float ViewCellsManager::GetMaxPvsRatio() const 
     430{ 
     431        return mMaxPvsRatio; 
     432} 
     433 
     434 
    423435void ViewCellsManager::ComputeSampleContributions(VssRay &ray) 
    424436{ 
     
    778790                if (ray->intersections.size() < 2) 
    779791                        continue; 
    780  
     792#if 0 
    781793                iit = ray->intersections.begin(); 
    782794 
     
    797809                        previousLeaf = leaf; 
    798810                } 
     811#endif 
    799812        } 
    800813 
     
    10241037} 
    10251038 
    1026  
    1027 bool BspViewCellsManager::MergeBspLeafViewCells(BspLeaf *front, BspLeaf *back) const 
    1028 { 
    1029         BspViewCell *viewCell = 
    1030                 dynamic_cast<BspViewCell *>(MergeViewCells(*front->GetViewCell(), 
    1031                                                                                                    *back->GetViewCell())); 
    1032  
    1033         if (!viewCell) 
    1034                 return false; 
    1035  
    1036         //-- change pointer to view cells of all leaves associated with the previous view cells 
    1037         BspViewCell *fVc = front->GetViewCell(); 
    1038         BspViewCell *bVc = back->GetViewCell(); 
    1039  
    1040         vector<BspLeaf *> fLeaves = fVc->mLeaves; 
    1041         vector<BspLeaf *> bLeaves = bVc->mLeaves; 
    1042  
    1043         vector<BspLeaf *>::const_iterator it; 
    1044  
    1045         for (it = fLeaves.begin(); it != fLeaves.end(); ++ it) 
    1046         { 
    1047                 (*it)->SetViewCell(viewCell); 
    1048                 viewCell->mLeaves.push_back(*it); 
    1049         } 
    1050         for (it = bLeaves.begin(); it != bLeaves.end(); ++ it) 
    1051         { 
    1052                 (*it)->SetViewCell(viewCell); 
    1053                 viewCell->mLeaves.push_back(*it); 
    1054         } 
    1055  
    1056         DEL_PTR(fVc); 
    1057         DEL_PTR(bVc); 
    1058  
    1059         return true; 
    1060 } 
    1061  
    1062 bool BspViewCellsManager::ShouldMerge(BspLeaf *front, BspLeaf *back) const 
    1063 { 
    1064         ViewCell *fvc = front->GetViewCell(); 
    1065         ViewCell *bvc = back->GetViewCell(); 
    1066  
    1067         if ((fvc == mBspTree->GetRootCell()) || (bvc == mBspTree->GetRootCell()) || (fvc == bvc)) 
    1068                 return false; 
    1069  
    1070         int fdiff = fvc->GetPvs().Diff(bvc->GetPvs()); 
    1071  
    1072         if (fvc->GetPvs().GetSize() + fdiff < mMaxPvs) 
    1073         { 
    1074                 if ((fvc->GetPvs().GetSize() < mMinPvs) || 
    1075                         (bvc->GetPvs().GetSize() < mMinPvs) || 
    1076                         ((fdiff < mMinPvsDif) && (bvc->GetPvs().Diff(fvc->GetPvs()) < mMinPvsDif))) 
    1077                 { 
    1078                         return true; 
    1079                 } 
    1080         } 
    1081  
    1082         return false; 
    1083 } 
    10841039 
    10851040 
     
    19761931        int merged = 0; 
    19771932 
    1978         cout << "starting merge using " << mPostProcessSamples << " samples ... "; 
     1933        cout << "starting merge using " << mPostProcessSamples << " samples ... " << endl; 
    19791934        long startTime = GetTime(); 
    19801935 
     
    19831938 
    19841939        //-- stats and visualizations 
    1985         cout << "finished" << endl; 
     1940        cout << "finished merging" << endl; 
    19861941        cout << "merged " << merged << " view cells in " 
    19871942                 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
     
    20992054 
    21002055        // real meshes are only contructed only at this stage 
    2101         //CreateViewCellMeshes(); 
    21022056        FinalizeViewCells(true); 
    21032057 
     
    24192373                                                                                 ViewCell *vc) const 
    24202374{ 
    2421         if (CheckValid(vc) && (mColorCode == 0)) // Random color 
     2375        if (CheckValidity(vc, 0.0, mMaxPvsRatio) && (mColorCode == 0)) // Random color 
    24222376                return; 
    24232377 
    24242378        float importance = 0; 
    2425          
    24262379        Material m; 
    24272380         
     
    24532406        } 
    24542407 
    2455         m.mDiffuseColor.b = CheckValid(vc) ? 1.0f : 0.0f; 
     2408        m.mDiffuseColor.b = CheckValidity(vc, 0.0, mMaxPvsRatio) ? 1.0f : 0.0f; 
    24562409        m.mDiffuseColor.r = importance; 
    24572410        m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r; 
Note: See TracChangeset for help on using the changeset viewer.