Changeset 561


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

added flexible checkvalitity function for view cells

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
4 edited

Legend:

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

    r556 r561  
    925925        //glFrustum(-1, 1, -1, 1, 1, 20000); 
    926926 
    927     const Vector3 center = viewPoint + beam.GetMainDirection() * (zfar - znear) * 0.3; 
     927    const Vector3 center = viewPoint + beam.GetMainDirection() * (zfar - znear) * 0.3f; 
    928928        const Vector3 up =  
    929929                Normalize(CrossProd(beam.mPlanes[0].mNormal, beam.mPlanes[4].mNormal)); 
  • 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; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r557 r561  
    253253        /** Checks if view cell is considered as valid. 
    254254        */ 
    255         virtual bool CheckValid(ViewCell *vc) const; 
     255        virtual bool CheckValidity(ViewCell *vc,  
     256                                                           float minPvsRatio,  
     257                                                           float maxPvsRatio) const; 
    256258 
    257259        /** Returns maximal allowed pvs size. 
    258260        */ 
    259261        int GetMaxPvsSize() const; 
     262 
     263        /** Returns maximal ratio. i.e., currentPVs / maxPvs, 
     264                where pvs is still considered valid. 
     265        */ 
     266        float GetMaxPvsRatio() const; 
    260267 
    261268        /** Exports view cell geometry. 
     
    327334        int mVisualizationSamples; 
    328335 
    329         //-- thresholds used for view cells merge 
    330         int mMinPvsDif; 
    331         int mMinPvs; 
    332         int mMaxPvs; 
    333  
    334336        float mTotalAreaValid; 
    335337        float mTotalArea; 
    336338 
    337339        int mMaxPvsSize; 
    338  
    339340        float mMaxPvsRatio; 
    340341 
     
    410411        void CollectViewCells(); 
    411412 
    412         /** Merges view cells front and back leaf view cell. 
    413         */ 
    414         bool MergeBspLeafViewCells(BspLeaf *front, BspLeaf *back) const; 
    415  
    416         /** Returns true if front and back leaf should be merged. 
    417         */ 
    418         bool ShouldMerge(BspLeaf *front, BspLeaf *back) const; 
    419  
    420413        void ConstructBspRays(const VssRayContainer &rays, 
    421414                                                  const int numSamples); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r560 r561  
    510510                } 
    511511                 
    512                 if (!mViewCellsManager->CheckValid(viewCell)) 
     512                if (!mViewCellsManager->CheckValidity(viewCell, 0.0, mViewCellsManager->GetMaxPvsRatio())) 
    513513                { 
    514514                        viewCell->SetValid(false); 
    515  
    516515                        leaf->SetTreeValid(false); 
    517516                        PropagateUpValidity(leaf); 
     
    16451644                                BspViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 
    16461645                         
    1647                                 if (!mViewCellsManager->CheckValid(viewCell)) 
     1646                                if (!mViewCellsManager->CheckValidity(viewCell, 0.0, mViewCellsManager->GetMaxPvsRatio())) 
    16481647                                { 
    16491648                                        vector<BspLeaf *>::const_iterator it, it_end = viewCell->mLeaves.end(); 
Note: See TracChangeset for help on using the changeset viewer.