Changeset 305


Ignore:
Timestamp:
10/03/05 18:57:58 (19 years ago)
Author:
mattausch
Message:

avoiding duplicate random planes

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
4 edited

Legend:

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

    r304 r305  
    7373        # vertical axis        = 64 
    7474         
    75         splitPlaneStrategy 4 
     75        splitPlaneStrategy 64 
    7676        # least splits + balanced polygons 
    7777        #splitPlaneStrategy 12 
     
    9292        constructionMethod viewCells 
    9393#       constructionMethod sceneGeometry 
    94         maxCandidates 0 
     94        maxCandidates 25 
    9595        maxViewCells 999999 
    9696        Termination { 
    9797                maxPolysForAxisAligned 50 
    98                 maxPolygons 5 
     98                maxPolygons 0 
    9999                maxDepth 100 
    100100        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r304 r305  
    260260mRoot(NULL),  
    261261mViewCell(viewCell), 
    262 mStoreSplitPolys(true) 
    263 //mStoreSplitPolys(false) 
     262//mStoreSplitPolys(true) 
     263mStoreSplitPolys(false) 
    264264{ 
    265265        Randomize(); // initialise random generator for heuristics 
     
    622622                } 
    623623                //-- add viewcell stored in split polygon 
    624                 else if (leaf->GetViewCell()) 
     624                else if (!leaf->GetViewCell()) 
    625625                        leaf->SetViewCell(tData.mViewCell); 
    626626                //else Debug << "Leaf already has view cell " << endl; 
     
    843843} 
    844844 
    845 Plane3 BspTree::SelectPlane(BspLeaf *leaf, const PolygonContainer &polys)  const 
     845Plane3 BspTree::SelectPlane(BspLeaf *leaf, PolygonContainer &polys) 
    846846{ 
    847847        if (polys.size() == 0) 
     
    899899} 
    900900 
    901 Plane3 BspTree::SelectPlaneHeuristics(const PolygonContainer &polys, int maxTests) const 
     901Plane3 BspTree::SelectPlaneHeuristics(PolygonContainer &polys, int maxTests) 
    902902{ 
    903903        float lowestCost = MAX_FLOAT; 
     
    907907         
    908908        int candidateIdx = limit; 
    909  
     909        PolygonContainer debugPolys;bool dist = true; 
    910910        for (int i = 0; i < limit; ++ i) 
    911911        { 
    912                 candidateIdx = GetNextCandidateIdx(candidateIdx, polys, (int)polys.size() - i - i); 
     912                candidateIdx = GetNextCandidateIdx(candidateIdx, polys); 
    913913 
    914914                Plane3 candidatePlane = polys[candidateIdx]->GetSupportingPlane(); 
    915                  
    916915                 
    917916                // evaluate current candidate 
     
    923922                        lowestCost = candidateCost; 
    924923                } 
    925         } 
     924                for (int i=0; i < debugPolys.size(); ++i) 
     925                        if (polys[candidateIdx] == debugPolys[i]) 
     926                        { 
     927                                Debug << "FATAL ERROR" << endl; 
     928                                dist = false; 
     929                        } 
     930                debugPolys.push_back(polys[candidateIdx]); 
     931        } 
     932         
    926933        //Debug << "Plane lowest cost: " << lowestCost << endl; 
    927          
     934        if (!dist) 
     935                Debug << "FATAL ERROR DUPLICATE TESTS!!" << endl; 
    928936        return polys[bestPlaneIdx]->GetSupportingPlane(); 
    929937} 
    930938 
    931 int BspTree::GetNextCandidateIdx(int currentIdx, PolygonContainer &polys, int max) const 
    932 { 
    933 #if 0 
    934         int candidateIdx = Random(max); // TODO: avoid testing same plane 2 times 
    935  
    936         // swap candidates 
    937         Polygon *p = polys[candidateIdx]; 
    938         polys[candidateIdx] = polys[max]; 
    939         polys[max] = p; 
    940  
    941         return max; 
    942 #else 
    943         return ++ currentIdx; 
    944 #endif 
    945 } 
    946  
    947 float BspTree::EvalSplitPlane(const PolygonContainer &polys, const Plane3 &candidatePlane) const 
     939int BspTree::GetNextCandidateIdx(int currentIdx, PolygonContainer &polys) 
     940{ 
     941        int candidateIdx = Random(currentIdx--); 
     942         
     943        // swap candidates to avoid testing same plane 2 times 
     944        Polygon3 *p = polys[candidateIdx]; 
     945        polys[candidateIdx] = polys[currentIdx]; 
     946        polys[currentIdx] = p; 
     947         
     948        return currentIdx; 
     949} 
     950 
     951float BspTree::EvalSplitPlane(PolygonContainer &polys, const Plane3 &candidatePlane) 
    948952{ 
    949953        float val = 0; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r304 r305  
    359359                @returns the cost of the candidate split plane 
    360360        */ 
    361         float EvalSplitPlane(const PolygonContainer &polys, const Plane3 &candidatePlane) const; 
     361        float EvalSplitPlane(PolygonContainer &polys, const Plane3 &candidatePlane); 
    362362 
    363363        /** Evaluates tree stats in the BSP tree leafs. 
     
    377377                @param polys the polygon list on which the split decition is based 
    378378        */ 
    379         Plane3 SelectPlane(BspLeaf *leaf, const PolygonContainer &polys) const; 
     379        Plane3 SelectPlane(BspLeaf *leaf, PolygonContainer &polys); 
    380380 
    381381        /** Filters next view cell down the tree and inserts it into the appropriate leaves 
     
    416416                @param maxTests the maximal number of candidate tests 
    417417        */ 
    418         Plane3 SelectPlaneHeuristics(const PolygonContainer &polys, const int maxTests) const; 
     418        Plane3 SelectPlaneHeuristics(PolygonContainer &polys, const int maxTests); 
    419419 
    420420        /** Extracts the meshes of the objects and copies them into the mesh.  
     
    444444        int CastRay(Ray &ray); 
    445445 
    446         /** returns next candidate index 
     446        /** returns next candidate index and reorders polygons so no candidate is chosen two times 
    447447                @param the current candidate index 
    448448                @param max the range of candidates 
    449449        */ 
    450         inline int GetNextCandidateIdx(int currentIdx, const int max) const; 
     450        int GetNextCandidateIdx(int currentIdx, PolygonContainer &polys); 
    451451 
    452452        /** Helper function which extracts a view cell on the front and the back 
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r304 r305  
    4040 
    4141  // if BSP tree construction method needs predefined view cells 
    42  
    4342  if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS) 
    4443  { 
     
    7271  if (exporter)  
    7372  {      
    74           Debug << Exporting complementary view cells" << endl; 
     73          Debug << "Exporting complementary view cells" << endl; 
    7574          exporter->ExportViewCells(&vc_compl); // export view cells 
    7675          delete exporter; 
Note: See TracChangeset for help on using the changeset viewer.