Changeset 267 for trunk/VUT


Ignore:
Timestamp:
09/14/05 01:59:22 (19 years ago)
Author:
mattausch
Message:

added viewcell stuff

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
3 edited

Legend:

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

    r265 r267  
    1313#       viewcells ../data/atlanta/atlanta_viewcells_large.x3d 
    1414#viewcells ../data/atlanta/atlanta_viewcells_large2.x3d 
    15         viewcells ../data/vienna/viewcells-25-sel.x3d 
    16 #       viewcells ../data/vienna/viewcells-25.x3d 
     15#       viewcells ../data/vienna/viewcells-25-sel.x3d 
     16        viewcells ../data/vienna/viewcells-25.x3d 
    1717#       viewcells ../data/vienna/viewcells-large-sel.x3d 
    1818} 
     
    6464BspTree { 
    6565#       splitPlaneStrategy leastSplits 
    66         splitPlaneStrategy balancedTree 
     66#       splitPlaneStrategy balancedTree 
    6767#       splitPlaneStrategy nextPolygon 
    68 #       splitPlaneStrategy combined 
     68        splitPlaneStrategy combined 
    6969#       constructionMethod rays 
    7070        constructionMethod viewCells 
     
    7474        Termination { 
    7575                maxPolygons 0 
    76                 maxDepth 999 
     76                maxDepth 3000 
    7777        } 
    7878} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r265 r267  
    3030int BspTree::sBalancedTreeTable[4] = {-1, 1, 0, 0}; 
    3131 
     32const int FACTOR_BALANCE = 1; 
     33const int FACTOR_LEAST_SPLITS = 1; 
     34 
    3235/****************************************************************/ 
    3336/*                  class BspNode implementation                */ 
     
    144147                                                                int &splits, bool storePolys) 
    145148{ 
    146 //#ifdef _Debug 
     149#ifdef _Debug 
    147150        Debug << "Splitting polygons of node " << this << " with plane " << mPlane << endl; 
    148 //#endif 
     151#endif 
    149152        bool inside = false; 
    150153 
     
    157160                int classification = poly->ClassifyPlane(mPlane); 
    158161 
    159                 //Debug << "polygon plane: " << poly->GetSupportingPlane() << endl; 
    160162                Polygon3 *front_piece = NULL; 
    161163                Polygon3 *back_piece = NULL; 
     
    169171                                        inside = (DotProd(mPlane.mNormal, poly->GetSupportingPlane().mNormal) > 0); 
    170172                                         
    171                                 Debug << "coincident" << endl; 
     173                                //Debug << "coincident" << endl; 
    172174                                // discard polygons or saves them in node 
    173175                                ProcessPolygon(poly, storePolys); 
    174176                                break; 
    175177                        case Polygon3::FRONT_SIDE: 
    176                                 Debug << "front" << endl; 
     178                                //Debug << "front" << endl; 
    177179                                frontPolys->push_back(poly); 
    178180                                break; 
    179181                        case Polygon3::BACK_SIDE: 
    180182                                inside = true; 
    181                                 Debug << "back" << endl; 
     183                                //Debug << "back" << endl; 
    182184                                backPolys->push_back(poly); 
    183185                                break; 
    184186                        case Polygon3::SPLIT: 
    185187                                inside = true; 
    186                                 Debug << "split " << poly << endl; 
     188                                //Debug << "split " << poly << endl; 
    187189 
    188190                                front_piece = new Polygon3(); 
     
    279281        app << "#N_NODES ( Number of nodes )\n" << nodes << "\n"; 
    280282 
    281         app << "#N_LEAVES ( Number of interior nodes )\n" << Interior() << "\n"; 
     283        app << "#N_INTERIORS ( Number of interior nodes )\n" << Interior() << "\n"; 
    282284 
    283285        app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 
     
    313315        app << "#N_PMINDEPTH ( Minimal reached depth )\n" << minDepth << endl; 
    314316 
    315         app << "#AVGEPTH ( average depth )\n" << AvgDepth() << endl; 
     317        app << "#AVGDEPTH ( average depth )\n" << AvgDepth() << endl; 
    316318 
    317319        app << "#N_ADDED_RAYREFS  ( Number of dynamically added ray references )\n"<< 
     
    389391                                int splits = 0; 
    390392                 
    391                                 Debug << "Splitting poly, YEAHH\n"; 
    392393                                // split viecell polygons with respect to split plane 
    393394                                bool inside = interior->SplitPolygons(tData.mPolygons, frontPolys, backPolys, splits, mStorePolys); 
    394                                 //Debug << "Reached level " << tData.mDepth << " bk: " << backPolys->size() << " frnt: " << frontPolys->size() << endl; 
     395                                //Debug << "split node on level " << tData.mDepth << " bk: " << backPolys->size() << " frnt: " << frontPolys->size() << endl; 
    395396                                mStat.splits += splits; 
    396397 
     
    408409                { 
    409410                        if (tData.mPolygons->size() > 0) 
    410                                 Debug << "WARNING (should not come here): polygon size: " << tData.mPolygons->size() << " inside: " << tData.mIsInside  << endl; 
     411                                Debug << "WARNING (should not come here): polygon size: " << (int)tData.mPolygons->size() << " inside: " << tData.mIsInside  << endl; 
    411412 
    412413                        BspNode *root = Subdivide(tStack, tData, viewCell);              
    413414 
    414                         //if (!root->IsLeaf()) 
    415                         //      Debug << "WARNING should NOT have subdivided further\n"; 
    416           
    417415                        if (!mRoot) // tree empty => new root 
    418416                                mRoot = root; 
     
    514512                // copy view cell meshes into one big polygon soup 
    515513                PolygonContainer *polys = new PolygonContainer(); 
    516                 Copy2PolygonSoup(viewCells, *polys, sMaxCandidates); 
     514                Copy2PolygonSoup(viewCells, *polys); 
    517515 
    518516                // polygons are stored only during view cell insertion 
     
    524522        } 
    525523         
    526         //-- insert all viewcells 
     524        //-- insert all viewcells one after another 
    527525        ViewCellContainer::const_iterator it; 
    528526 
     
    530528        mStat.polys = 0; 
    531529        mStat.splits = 0; 
    532         //int counter = 0; 
    533          
     530        mStat.accumDepth = 0; 
     531 
    534532        long startTime = GetTime(); 
     533 
     534        int counter = 0; 
    535535        Debug << "**** Starting view cell insertion ****" << endl; 
    536536        for (it = viewCells.begin(); it != viewCells.end(); ++ it) 
    537537        { 
    538                 //Debug << "*** Inserting view cell " << counter ++ << " ***" << endl; 
     538                Debug << "** inserting view cell " << counter ++ << " **" << endl; 
    539539                InsertViewCell(*it); 
    540540        } 
     541 
    541542        Debug << "**** Finished view cell insertion ****" << endl; 
    542543        Debug << "insertion time: "<< TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
     
    552553         
    553554        // copy mesh instance polygons into one big polygon soup 
    554         mStat.polys = Copy2PolygonSoup(objects, *polys, sMaxCandidates); 
     555        mStat.polys = Copy2PolygonSoup(objects, *polys); 
    555556 
    556557        // construct tree from polygon soup 
    557         Construct(polys); 
    558  
    559         // TODO: generate view cells 
     558        Construct(polys, viewCells); 
    560559} 
    561560 
     
    609608                //&& !(viewCell && tData.mIsInside && dynamic_cast<BspLeaf *>(tData.mNode)->GetViewCell()))   
    610609        { 
    611 #ifdef _DEBUG 
     610//#ifdef _DEBUG 
    612611                Debug << "subdivision terminated at depth " << tData.mDepth << ", #polys: " << (int)tData.mPolygons->size() << endl; 
    613 #endif 
     612//#endif 
    614613 
    615614                EvaluateLeafStats(tData); 
     
    623622                                Debug << "ERROR: leaf already has view cell" << endl; 
    624623 
     624                        Debug << "insert view cell" << endl; 
    625625                        leaf->SetViewCell(viewCell); 
    626626                } 
     
    638638        bool inside = false; 
    639639 
    640         Debug << "Subdividing node at depth " << tData.mDepth << endl; 
    641640        BspInterior *interior = SubdivideNode(dynamic_cast<BspLeaf *>(tData.mNode), 
    642641                                                                                  tData.mPolygons, 
     
    732731                } 
    733732        } 
    734          
    735         if (lowestCost > 0) 
    736                 Debug << "Split plane cost: " << lowestCost << " plane: " << (*polygons)[bestPlaneIdx]->GetSupportingPlane() << endl; 
    737         else 
    738                 Debug << "no splits for plane: " << (*polygons)[bestPlaneIdx]->GetSupportingPlane() << endl; 
     733        //Debug << "Plane lowest cost: " << lowestCost << endl; 
     734         
    739735        return (*polygons)[bestPlaneIdx]->GetSupportingPlane(); 
    740736} 
     
    758754                { 
    759755                        sumLeastSplits += sLeastSplitsTable[classification]; 
    760                         Debug << "Adding " <<  sLeastSplitsTable[classification] << " for poly " << *it << "!"; 
    761                 } 
    762         } 
    763  
    764         Debug << "\n" << candidatePlane << " evaluation: " << abs(sumBalanced) + abs(sumLeastSplits) << endl; 
     756                } 
     757        } 
    765758 
    766759        // return linear combination of both sums 
    767         return abs(sumBalanced) + abs(sumLeastSplits); 
     760        return FACTOR_BALANCE * abs(sumBalanced) + FACTOR_LEAST_SPLITS *abs(sumLeastSplits); 
    768761} 
    769762 
     
    791784        else if (strcmp(splitPlaneStrategyStr, "balancedTree") == 0) 
    792785                sSplitPlaneStrategy = BspTree::BALANCED_TREE; 
     786        else if (strcmp(splitPlaneStrategyStr, "combined") == 0) 
     787                sSplitPlaneStrategy = BspTree::COMBINED; 
    793788        else  
    794789        { 
     
    927922                mStat.minDepth = data.mDepth; 
    928923 
     924        // accumulate depth to compute average 
    929925        mStat.accumDepth += data.mDepth; 
    930926 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r265 r267  
    8282  int Interior() const { return nodes / 2; } 
    8383  int Leaves() const { return (nodes / 2) + 1; } 
    84   int AvgDepth() const { return accumDepth / Leaves();}; 
     84  float AvgDepth() const { return accumDepth / (double)Leaves();}; // TODO: computation wrong 
    8585   
    8686  void Reset()  
     
    394394                @returns the number of polygons 
    395395        */ 
    396         int Copy2PolygonSoup(const ObjectContainer &objects, PolygonContainer &polys, int maxObjects); 
     396        int Copy2PolygonSoup(const ObjectContainer &objects, PolygonContainer &polys, int maxObjects = 0); 
    397397        /** Extracts the meshes of the view cells and copies them into the mesh.  
    398398                Adds view cell aabb to the aabb of the tree. 
     
    400400                @returns the number of polygons 
    401401        */ 
    402         int Copy2PolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects); 
     402        int Copy2PolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects = 0); 
    403403 
    404404        /** Extract polygons of this mesh and add to polygon container. 
Note: See TracChangeset for help on using the changeset viewer.