Changeset 397 for trunk


Ignore:
Timestamp:
11/09/05 18:23:43 (19 years ago)
Author:
mattausch
Message:

worked on bsp view cells, fixed some bugs

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r396 r397  
    126126        #splitPlaneStrategy 130 
    127127         
    128         splitPlaneStrategy 8 
     128        splitPlaneStrategy 1024 
    129129         
    130         maxPolyCandidates 50 
    131         maxRayCandidates 1024 
     130        maxPolyCandidates 200 
     131        maxRayCandidates 0 
    132132         
    133133        Termination { 
    134134                # autopartition 
    135                 maxRays 100 
    136                 maxPolygons 0 
    137                 maxDepth 50 
    138                 minPvs -1 
     135                maxRays 200 
     136                maxPolygons 5 
     137                maxDepth 30 
     138                minPvs 50 
     139                minArea -0.001 
    139140                 
    140141                # axis aligned splits 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r390 r397  
    12201220                 "20"); 
    12211221 
     1222  RegisterOption("BspTree.Termination.minArea", 
     1223                 optFloat, 
     1224                 "-bsp_term_min_area=", 
     1225                 "0.001"); 
     1226 
    12221227   RegisterOption("BspTree.Termination.maxRays", 
    12231228                 optInt, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r396 r397  
    1717int BspTree::sTermMinPvs = 20; 
    1818int BspTree::sTermMaxDepth = 20; 
     19float BspTree::sTermMinArea = 0.001; 
    1920int BspTree::sMaxPolyCandidates = 10; 
    2021int BspTree::sMaxRayCandidates = 10; 
     
    692693} 
    693694 
     695inline bool BspTree::TerminationCriteriaMet(const BspTraversalData &data) const 
     696{ 
     697        return  
     698                (((int)data.mPolygons->size() <= sTermMaxPolygons) ||  
     699                 ((int)data.mRays->size() <= sTermMaxRays) || 
     700                 (data.mPvs <= sTermMinPvs) || 
     701                 (data.mArea <= sTermMinArea) || 
     702                 (data.mDepth >= sTermMaxDepth)); 
     703} 
    694704 
    695705BspNode *BspTree::Subdivide(BspTraversalStack &tStack, BspTraversalData &tData) 
    696706{ 
    697707        //-- terminate traversal   
    698         if (((int)tData.mPolygons->size() <= sTermMaxPolygons) ||  
    699                 ((int)tData.mRays->size() <= sTermMaxRays) || 
    700                 (tData.mPvs <= sTermMinPvs) || 
    701                  (tData.mDepth >= sTermMaxDepth)) 
    702                  
     708        if (TerminationCriteriaMet(tData))               
    703709        { 
    704710                BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
     
    747753 
    748754        //-- continue subdivision 
    749  
    750755        PolygonContainer coincident; 
    751756         
     
    10531058        if (sSplitPlaneStrategy & RANDOM_POLYGON) 
    10541059        { 
    1055                 Polygon3 *nextPoly = (*data.mPolygons)[Random((int)data.mPolygons->size())]; 
    1056                 return nextPoly->GetSupportingPlane(); 
     1060                if (!data.mPolygons->empty()) 
     1061                { 
     1062                        Polygon3 *nextPoly = (*data.mPolygons)[Random((int)data.mPolygons->size())]; 
     1063                        return nextPoly->GetSupportingPlane(); 
     1064                } 
     1065                 
     1066                return Plane3(); 
    10571067        } 
    10581068 
     
    10831093                        SplitPlaneCost(poly->GetSupportingPlane(), data, frontData, backData); 
    10841094 
    1085                 Debug << "cost: " << candidateCost << ", lowest: " << lowestCost << endl; 
    1086  
    10871095                if (candidateCost < lowestCost) 
    10881096                { 
     
    10921100        } 
    10931101         
     1102        Debug << "lowest: " << lowestCost << endl; 
     1103 
    10941104        //limit = maxRaysCandidates > 0 ? Min((int)rays.size(), maxRayCandidates) : (int)rays.size();    
    10951105        const BoundedRayContainer *rays = data.mRays; 
     
    11031113                        Vector3 pt[3]; 
    11041114                        int idx[3]; 
    1105                          
     1115                 
    11061116                        for (int j = 0; j < 3; j ++) 
    11071117                        { 
    11081118                                idx[j] = Random((int)rays->size() * 2); 
    11091119                                 
    1110                                 BoundedRay *bRay = (*rays)[idx[j]]; 
    1111                                 Ray *ray = bRay->mRay; 
    1112  
    11131120                                if (idx[j] < (int)rays->size()) 
    1114                                         pt[j] = ray->Extrap(bRay->mMinT); 
     1121                                        pt[j] = (*rays)[idx[j]]->mRay->Extrap((*rays)[idx[j]]->mMinT); 
    11151122                                else 
    1116                                 { 
     1123                                {        
    11171124                                        idx[j] -= (int)rays->size(); 
    1118                                         pt[j] = ray->Extrap(bRay->mMaxT); 
     1125                                        pt[j] = (*rays)[idx[j]]->mRay->Extrap((*rays)[idx[j]]->mMaxT); 
    11191126                                } 
    11201127                        }        
    1121                  
     1128                         
    11221129                        plane = Plane3(pt[0], pt[1], pt[2]); 
    11231130                } 
     
    11441151                if (candidateCost < lowestCost) 
    11451152                { 
    1146                         Debug << "choose ray plane: " << lowestCost << endl; 
     1153                        Debug << "choose ray plane: " << candidateCost << endl; 
    11471154                        bestPlane = plane; 
    11481155                         
    11491156                        lowestCost = candidateCost; 
    11501157                } 
    1151                 else 
    1152                         Debug << "ray cost: " << candidateCost << ", lowest: " << lowestCost << endl; 
    1153         } 
    1154  
    1155         //Debug << "Plane lowest cost: " << lowestCost << endl; 
     1158        } 
     1159 
     1160        Debug << "Plane lowest cost: " << lowestCost << endl; 
    11561161        return bestPlane; 
    11571162} 
     
    12621267        // all values should be approx. between 0 and 1 so they can be combined 
    12631268        // and scaled with the factors according to their importance 
    1264         if (sSplitPlaneStrategy & BALANCED_POLYS) 
     1269        if ((sSplitPlaneStrategy & BALANCED_POLYS) && (!polys.empty())) 
    12651270                val += sBalancedPolysFactor * fabs(sumBalancedPolys) / (float)polys.size(); 
    12661271         
    1267         if (sSplitPlaneStrategy & LEAST_SPLITS)     
     1272        if ((sSplitPlaneStrategy & LEAST_SPLITS) && (!polys.empty()))   
    12681273                val += sLeastSplitsFactor * sumSplits / (float)polys.size(); 
    12691274 
     
    14111416        if ((sSplitPlaneStrategy & BALANCED_RAYS) && !rays.empty()) 
    14121417                        val += sBalancedRaysFactor * fabs(sumBalancedRays) / (float)rays.size(); 
    1413  
     1418pOverall = 1; pFront = 1; pBack = 1; 
    14141419        if ((sSplitPlaneStrategy & PVS) && area && pvs) 
    14151420                val += sPvsFactor * (frontData.mPvs * pFront + (backData.mPvs * pBack)) / 
     
    15431548        environment->GetIntValue("BspTree.Termination.maxPolygons", sTermMaxPolygons); 
    15441549        environment->GetIntValue("BspTree.Termination.maxRays", sTermMaxRays); 
     1550        environment->GetFloatValue("BspTree.Termination.minArea", sTermMinArea); 
    15451551 
    15461552        //-- termination criteria for axis aligned split 
     
    15691575    Debug << "BSP max depth: " << sTermMaxDepth << endl; 
    15701576        Debug << "BSP min PVS: " << sTermMinPvs << endl; 
     1577        Debug << "BSP min area: " << sTermMinArea << endl; 
    15711578        Debug << "BSP max polys: " << sTermMaxPolygons << endl; 
    15721579        Debug << "BSP max rays: " << sTermMaxRays << endl; 
     
    16521659 
    16531660        // store minimal and maximal pvs 
    1654         /*if (data.mPvs > mStat.pvs) 
    1655                 mStat.pvs = data.mPvs; 
    1656          
    1657         if (data.mPvs < mStat.pvs) 
    1658                 mStat.pvs = data.mPvs;*/ 
     1661        /*if (data.mPvs > mStat.pvs)mStat.pvs = data.mPvs; 
     1662        if (data.mPvs < mStat.pvs)      mStat.pvs = data.mPvs;*/ 
    16591663 
    16601664        // accumulate depth to compute average 
     
    16641668        Debug << "BSP stats: " 
    16651669                  << "Depth: " << data.mDepth << " (max: " << sTermMaxDepth << "), " 
    1666                    << "PVS: " << data.mPvs << " (max: " << sTermMinPvs << "), " 
     1670                  << "PVS: " << data.mPvs << " (min: " << sTermMinPvs << "), " 
     1671                  << "Area: " << data.mArea << " (min: " << sTermMinArea << "), " 
    16671672                  << "#polygons: " << (int)data.mPolygons->size() << " (max: " << sTermMaxPolygons << "), " 
    16681673                  << "#rays: " << (int)data.mRays->size() << " (max: " << sTermMaxRays << "), "  
     
    23922397        } 
    23932398 
    2394         //Debug << "returning new geometry " << mPolys.size() << " CHILD: " << childCell->mPolys.size() << endl; 
    2395         //Debug << "old area " << this->GetArea() << " new: " << childCell->GetArea() << endl; 
     2399        Debug << "returning new geometry " << mPolys.size() << " f: " << front.mPolys.size() << " b: " << back.mPolys.size() << endl; 
     2400        Debug << "old area " << GetArea() << " f: " << front.GetArea() << " b: " << back.GetArea() << endl; 
    23962401} 
    23972402 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r396 r397  
    740740        int ComputePvsSize(const BoundedRayContainer &rays) const; 
    741741 
     742        bool TerminationCriteriaMet(const BspTraversalData &data) const; 
     743 
    742744        /// Pointer to the root of the tree 
    743745        BspNode *mRoot; 
     
    782784        /// maximal possible depth 
    783785        static int sTermMaxDepth; 
    784         /// mininam pvs 
     786        /// mininum area 
     787        static float sTermMinArea; 
     788        /// mininum PVS 
    785789        static int sTermMinPvs; 
    786790        /// strategy to get the best split plane 
Note: See TracChangeset for help on using the changeset viewer.