Changeset 366


Ignore:
Timestamp:
11/01/05 20:02:22 (19 years ago)
Author:
mattausch
Message:

some ideas abou saving bspleaves with the ray and t

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
12 edited

Legend:

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

    r362 r366  
    5656 
    5757Sampling { 
    58         totalSamples    200000 
     58        totalSamples    20000000 
    5959        samplesPerPass  3 
    6060} 
     
    6868        maxViewCells 0 
    6969         
    70         minPvsDif 10 
     70        minPvsDif 100 
     71#       maxPvsSize 200 
    7172         
    7273#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r339 r366  
    99Preprocessor::Preprocessor(): 
    1010mKdTree(NULL), 
    11 mBspTree(NULL), 
    12 mViewCellsType(BSP_VIEW_CELLS) 
     11mBspTree(NULL) 
    1312{ 
    1413} 
     
    5251        environment->GetStringValue("ViewCells.hierarchy", viewCellsStr); 
    5352 
    54         int vcType = BSP_VIEW_CELLS; 
    55    
    5653        if (strcmp(viewCellsStr, "bspTree") == 0) 
    57                 mViewCellsType = BSP_VIEW_CELLS; 
     54                ViewCell::sHierarchy = ViewCell::BSP; 
    5855        else if (strcmp(viewCellsStr, "kdTree") == 0) 
    59                 mViewCellsType = KD_VIEW_CELLS; 
     56                ViewCell::sHierarchy = ViewCell::KD; 
    6057        else if (strcmp(viewCellsStr, "sceneDependent") == 0) 
    6158        { 
     
    6764                exit(1); 
    6865        } 
    69  
    70         if (mViewCellsType == KD_VIEW_CELLS) 
    71                 Debug << "kdtree" << endl; 
    72         else if (mViewCellsType == BSP_VIEW_CELLS) 
    73                 Debug << "bsptree" << endl; 
    7466 
    7567        return true; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r329 r366  
    115115  /// the view cell corresponding to unbounded space 
    116116  ViewCell mUnbounded; 
    117  
    118   /// view cell hierarchy types 
    119   enum {BSP_VIEW_CELLS, KD_VIEW_CELLS, SCENE_DEPENDENT}; 
    120  
    121   /// type of the view cells 
    122   int mViewCellsType; 
    123117}; 
    124118 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h

    r362 r366  
    148148typedef Pvs<Intersectable *> ViewCellPvs; 
    149149 
     150 
    150151#endif 
    151152 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp

    r362 r366  
    194194} 
    195195 
     196 
     197void Ray::Insert(const BspIntersection &bspi) 
     198{ 
     199        vector<BspIntersection>::iterator it; 
     200 
     201        while (it != 
     202} 
     203 
    196204ostream & 
    197205operator<<(ostream &s, const PassingRaySet &set) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h

    r362 r366  
    5656  }; 
    5757   
     58  struct BspIntersection 
     59  { 
     60          float mT; 
     61          BspLeaf *leaf; 
     62          BspIntersection(float t, BspLeaf *l): mT(t), leaf(l) 
     63          {} 
     64 
     65          bool operator<(const BspIntersection &b) const  
     66          { 
     67                  return mT     < b.mT; 
     68          } 
     69  }; 
     70 
    5871  // I should have some abstract cell data type !!! here 
    5972  // corresponds to the spatial elementary cell 
     
    6275   
    6376  vector<Intersection> intersections; 
     77  vector<BspIntersection> bspIntersections; 
    6478  vector<KdLeaf *> kdLeaves; 
    6579  vector<MeshInstance *> meshes; 
    66   vector<BspLeaf *> bspLeaves; 
    6780   
    6881  // constructors 
     
    197210  int ClassifyPlane(const Plane3 &plane, const float minT, const float maxT) const; 
    198211 
     212  void Insert(const BspIntersection &bspi); 
     213 
    199214private: 
    200215  Vector3 loc, dir;             // Describes ray origin and vector 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r365 r366  
    121121                for (j=1; j < ((int)ray.bspLeaves.size() - 1); ++ j)  
    122122                { 
    123                         if (ray.bspLeaves[j]->GetViewCell() != &mUnbounded) 
    124                                 ray.bspLeaves[j]->GetViewCell()-> 
     123                        BspLeaf *leaf = ray.bspIntersections.leaf; 
     124 
     125                        if (leaf->GetViewCell() != &mUnbounded) 
     126                                leaf->GetViewCell()-> 
    125127                                        AddPassingRay(ray, contributingSamples ? 1 : 0); 
    126128                } 
     
    162164        } 
    163165 
    164         if (mViewCellsType == BSP_VIEW_CELLS) 
     166        if (ViewCell::sHierarchy == ViewCell::BSP) 
    165167        { 
    166168                // cast ray to BSP tree to get intersection with view cells 
     
    376378                int passSamples = 0; 
    377379                int index = 0; 
    378                 Real maxTime = 0; 
    379                 int maxTimeIdx = 0; 
     380                 
    380381                int reverseSamples = 0; 
    381382                bool collectSamplesForBsp =  
    382                         (mViewCellsType == BSP_VIEW_CELLS) && 
     383                        (ViewCell::sHierarchy == ViewCell::BSP) && 
    383384                        (BspTree::sConstructionMethod == BspTree::FROM_RAYS) && 
    384385                        (totalSamples < mBspConstructionSamples); 
    385386                         
    386                 cout << "totalSamples: "  << totalSamples << endl; 
     387                //cout << "totalSamples: "  << totalSamples << endl; 
    387388 
    388389                for (i = 0; i < objects.size(); i++) { 
     
    392393                 
    393394                        int pvsSize = 0; 
    394                         if (mViewCellsType == KD_VIEW_CELLS) 
     395                        if (ViewCell::sHierarchy == ViewCell::KD) 
    395396                                pvsSize = object->mKdPvs.GetSize(); 
    396397                                                 
     
    402403                        int faceIndex = object->GetRandomSurfacePoint(point, normal); 
    403404                         
    404                         long samplesPerObjStart = GetTime(); 
    405  
    406405                        bool viewcellSample = true; 
    407406                        int sampleContributions; 
     
    456455                                        } 
    457456                                        //------------------- 
    458                                         if (mViewCellsType == BSP_VIEW_CELLS)  
     457                                        if (ViewCell::sHierarchy == ViewCell::BSP)  
    459458                                        { 
    460459                                                ProcessBspViewCells(collectSamplesForBsp, 
     
    471470                                //                              object->GetRandomVisibleMesh(Plane3(normal, point)); 
    472471                        } 
    473                                  
    474                         // measure maximal time for samples per object 
    475                         Real t = TimeDiff(samplesPerObjStart, GetTime()); 
    476  
    477                         if (t > maxTime) 
    478                         { 
    479                                 maxTime = t; 
    480                                 maxTimeIdx = i; 
    481                         } 
    482472         
    483473                        // CORR matt: must add all samples 
     
    494484                int pvsSize = 0; 
    495485         
    496                 if (mViewCellsType == BSP_VIEW_CELLS) { 
     486                if (ViewCell::sHierarchy == ViewCell::BSP) { 
    497487                        for (i=0; i < mViewCells.size(); i++) { 
    498488                                ViewCell *vc = mViewCells[i]; 
     
    506496                } 
    507497 
    508                 Debug << "maximal time needed for pass: " << maxTime << " (object " << maxTimeIdx << ")" << endl; 
    509  
    510498                float avgRayContrib = (passContributingSamples > 0) ?  
    511499                        passSampleContributions/(float)passContributingSamples : 0; 
     
    529517        } 
    530518         
    531         if (mViewCellsType == KD_VIEW_CELLS)     
     519        if (ViewCell::sHierarchy == ViewCell::KD)        
    532520                cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    533521   
     
    535523        if (mBspTree) 
    536524        { 
     525                cout << "starting post processing ... "; 
     526 
     527                Debug << "original pvs size: " << mBspTree->CountViewCellPvs() << endl; 
     528 
     529                long startTime = GetTime(); 
    537530                int merged = PostprocessViewCells(mSampleRays); 
    538                 Debug << "merged " << merged << " view cells" << endl; 
    539  
    540                 ViewCellContainer vc; 
    541                 mBspTree->CollectViewCells(vc); 
    542  
    543                 ViewCellContainer::const_iterator it, it_end = vc.end(); 
    544  
    545                 int mergedPvs = 0; 
    546                 for (it = vc.begin(); it != it_end; ++ it) 
    547                         mergedPvs += (*it)->GetPvs().GetSize(); 
    548  
    549                 Debug << "merged pvs size: " << mergedPvs << endl; 
     531                 
     532                cout << "finished" << endl; 
     533                cout << "merged " << merged << " view cells in " 
     534                         << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
     535 
     536                //-- recount pvs 
     537                Debug << "merged pvs size: " << mBspTree->CountViewCellPvs() << endl; 
    550538 
    551539        } 
     
    557545                exporter->ExportKdTree(*mKdTree); 
    558546 
    559                 if (mBspTree && (mViewCellsType == BSP_VIEW_CELLS)) 
     547                if (mBspTree && (ViewCell::sHierarchy == ViewCell::BSP)) 
    560548                        exporter->ExportBspTree(*mBspTree); 
    561549 
     
    580568        //-- several visualizations and statistics 
    581569        if (1) { 
    582         if (mBspTree && (mViewCellsType == BSP_VIEW_CELLS)) 
     570                if (mBspTree && (ViewCell::sHierarchy == ViewCell::BSP)) 
    583571        { 
    584572                bool exportSplits = false; 
     
    672660        RayContainer::const_iterator rit, rit_end = rays.end(); 
    673661        vector<BspLeaf *>::const_iterator lit; 
    674 if (0) 
     662 
    675663        for (rit = rays.begin(); rit != rays.end(); ++ rit) 
    676664        {   
    677665                // traverse leaves stored in the rays and compare and merge consecutive 
    678666                // leaves (i.e., the neighbors in the tree) 
     667                if ((*rit)->bspLeaves.empty()) 
     668                        continue; 
     669 
    679670                lit = (*rit)->bspLeaves.begin(); 
    680671 
     
    693684                } 
    694685        } 
     686 
    695687        return merged; 
    696688} 
     
    775767                        for (int i = 0; i < (int)bspLeaves.size(); ++ i) 
    776768                        { 
    777                                 if (bspLeaves[i] == ray->bspLeaves[j])  
     769                                if (bspLeaves[i]->GetViewCell() == ray->bspLeaves[j]->GetViewCell())  
    778770                                { 
    779771                                        vcRays[i].push_back(*ray); 
     
    799791                ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
    800792 
     793                exporter->SetWireframe(); 
     794 
    801795                Material m;//= RandomMaterial(); 
    802796                m.mDiffuseColor = RgbColor(0, 1, 0); 
    803797                exporter->SetForcedMaterial(m); 
    804798 
    805                 exporter->SetWireframe(); 
    806  
    807799                if (vc->GetMesh()) 
    808800                        exporter->ExportViewCell(vc); 
     
    810802                { 
    811803            PolygonContainer cell; 
    812  
    813                         mBspTree->ConstructGeometry(bspLeaves[i], cell); 
     804                        // export view cell 
     805                        mBspTree->ConstructGeometry(bspLeaves[i]->GetViewCell(), cell); 
    814806                        exporter->ExportPolygons(cell); 
    815807                        CLEAR_CONTAINER(cell); 
    816  
    817                         /*vector<BspLeaf *> neighbors; 
    818                         mBspTree->FindNeighbors(bspLeaves[j], neighbors); 
    819                         for (int j = 0; j < (int)neighbors.size(); ++ j) 
    820                         {       if (neighbors[j]->mViewCell == bspLeaves[j]->mViewCell) 
    821                                 {}}*/ 
    822808                } 
    823809 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r362 r366  
    44#include "MeshKdTree.h" 
    55#include "Triangle3.h" 
     6 
     7ViewCell::HierarchyType ViewCell::sHierarchy = BSP; 
    68 
    79ViewCell::ViewCell(): MeshInstance(NULL), mPiercingRays(0) 
     
    1315} 
    1416 
    15 ViewCellPvs &ViewCell::GetPvs()  
     17ViewCell *ViewCell::Generate(Mesh *mesh) 
     18{ 
     19        switch(sHierarchy) 
     20        { 
     21        case KD: 
     22                return new ViewCell(mesh); 
     23        case BSP: 
     24                return new BspViewCell(mesh); 
     25        default: 
     26                Debug << "should not come here" << endl; 
     27                return NULL; 
     28        } 
     29} 
     30 
     31ViewCellPvs &ViewCell::GetPvs() 
    1632{ 
    1733        return mPvs; 
     
    2844{ 
    2945        // maximal max viewcells 
    30         int limit = maxViewCells > 0 ? Min((int)objects.size(), maxViewCells) : (int)objects.size(); 
     46        int limit = maxViewCells > 0 ?  
     47                Min((int)objects.size(), maxViewCells) : (int)objects.size(); 
    3148 
    3249        for (int i = 0; i < limit; ++ i) 
     
    3956                        MeshInstance *inst = dynamic_cast<MeshInstance *>(object); 
    4057 
    41                         ViewCell *viewCell = new ViewCell(inst->GetMesh()); 
     58                        ViewCell *viewCell = Generate(inst->GetMesh()); 
    4259                        viewCells.push_back(viewCell); 
    4360                } 
     
    7895        mesh->Preprocess(); 
    7996 
    80         return new ViewCell(mesh); 
     97        return Generate(mesh); 
    8198} 
    8299 
    83100ViewCell *ViewCell::Merge(ViewCell &front, ViewCell &back) 
    84101{ 
    85         ViewCell *vc = new ViewCell(); 
     102        ViewCell *vc = Generate(); 
    86103        // merge pvs 
    87104        vc->mPvs.Merge(front.mPvs, back.mPvs); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r362 r366  
    1111class BspPvs; 
    1212struct Triangle3; 
     13class BspLeaf; 
    1314 
    1415/** 
     
    5455        static ViewCell *Merge(ViewCell &front, ViewCell &back); 
    5556 
    56  
    5757        /// Ray set description of the rays passing through this node.   
    5858        PassingRaySet mPassingRays; 
     
    6060        /// Rays piercing this view cell. 
    6161        RayContainer mPiercingRays; 
     62 
     63        /// view cells types 
     64        enum HierarchyType {BSP, KD}; 
     65 
     66        /** Generates view cells of type specified by view cells type. 
     67        */ 
     68        static ViewCell *Generate(Mesh *mesh = NULL); 
     69 
     70        /// type of view cells hierarchy (KD, BSP) 
     71        static HierarchyType sHierarchy; 
    6272 
    6373protected: 
     
    6777}; 
    6878 
    69 //}; // GtpVisibilityPreprocessor 
     79class BspViewCell: public ViewCell 
     80{ 
     81public: 
     82        BspViewCell(): mBspLeaves(0) {} 
     83        BspViewCell(Mesh *mesh):  
     84        ViewCell(mesh), mBspLeaves(0) {} 
     85 
     86        /// Leaves which hold this view cell. 
     87        vector<BspLeaf *> mBspLeaves; 
     88}; 
    7089 
    7190#endif 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r362 r366  
    260260} 
    261261 
    262 BspLeaf::BspLeaf(ViewCell *viewCell):  
     262BspLeaf::BspLeaf(BspViewCell *viewCell):  
    263263mViewCell(viewCell) 
    264264{ 
     
    269269{} 
    270270 
    271 BspLeaf::BspLeaf(BspInterior *parent, ViewCell *viewCell):  
     271BspLeaf::BspLeaf(BspInterior *parent, BspViewCell *viewCell):  
    272272BspNode(parent), mViewCell(viewCell) 
    273273{ 
    274274} 
    275275 
    276 ViewCell *BspLeaf::GetViewCell() 
     276BspViewCell *BspLeaf::GetViewCell() const 
    277277{ 
    278278        return mViewCell; 
    279279} 
    280280 
    281 void BspLeaf::SetViewCell(ViewCell *viewCell) 
     281void BspLeaf::SetViewCell(BspViewCell *viewCell) 
    282282{ 
    283283        mViewCell = viewCell; 
     
    297297        contributingSamples = 0; 
    298298 
    299         mViewCell = new ViewCell(); 
     299        mViewCell = dynamic_cast<BspViewCell *>(ViewCell::Generate()); 
     300        mViewCell->mBspLeaves.push_back(this); 
    300301 
    301302    BoundedRayContainer::const_iterator it, it_end = rays.end(); 
     
    320321                } 
    321322 
    322                 ray->bspLeaves.push_back(this); 
     323                ray->bspIntersections.push_back(BspIntersection(this, (*it)->mMinT); 
    323324 
    324325                if (storeRays) 
     
    711712                { 
    712713                        // add view cell to leaf 
    713                         leaf->SetViewCell(tData.mViewCell); 
     714                        leaf->SetViewCell(dynamic_cast<BspViewCell *>(tData.mViewCell)); 
     715                        leaf->mViewCell->mBspLeaves.push_back(leaf); 
    714716                } 
    715717 
     
    12441246        float sumBalancedRays = 0; 
    12451247        float sumRaySplits = 0; 
     1248        float pvsSize = 0; 
     1249 
     1250        Intersectable::NewMail(); 
    12461251 
    12471252        BoundedRayContainer::const_iterator rit, rit_end = rays.end(); 
     
    12641269                { 
    12651270                        sumRaySplits += sLeastRaySplitsTable[classification]; 
     1271                } 
     1272 
     1273                if (sSplitPlaneStrategy & PVS) 
     1274                { 
     1275                        vector<Ray::Intersection>::const_iterator it,  
     1276                                it_end = ray->intersections.end(); 
     1277 
     1278                        for (it = ray->intersections.begin(); it != it_end; ++ it) 
     1279                        { 
     1280                                if (!(*it).mObject->Mailed()) 
     1281                                { 
     1282                                        (*it).mObject->Mail(); 
     1283                                } 
     1284                        } 
    12661285                } 
    12671286        } 
     
    15971616} 
    15981617 
     1618int BspTree::CountViewCellPvs() const 
     1619{ 
     1620        int count = 0; 
     1621        stack<BspNode *> nodeStack; 
     1622        nodeStack.push(mRoot); 
     1623 
     1624        ViewCell::NewMail(); 
     1625 
     1626        // exclude root cell 
     1627        mRootCell->Mail(); 
     1628 
     1629        while (!nodeStack.empty())  
     1630        { 
     1631                BspNode *node = nodeStack.top(); 
     1632                nodeStack.pop(); 
     1633 
     1634                if (node->IsLeaf())  
     1635                { 
     1636                        ViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->mViewCell; 
     1637 
     1638                        if (!viewCell->Mailed())  
     1639                        { 
     1640                                viewCell->Mail(); 
     1641                                count += viewCell->GetPvs().GetSize(); 
     1642                        } 
     1643                } 
     1644                else  
     1645                { 
     1646                        BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     1647 
     1648                        nodeStack.push(interior->mFront); 
     1649                        nodeStack.push(interior->mBack); 
     1650                } 
     1651        } 
     1652        return count; 
     1653} 
    15991654 
    16001655bool BspTree::MergeViewCells(BspLeaf *front, BspLeaf *back) const 
    16011656{ 
    1602         ViewCell *viewCell = ViewCell::Merge(*front->mViewCell, *back->mViewCell); 
     1657        BspViewCell *viewCell =  
     1658                dynamic_cast<BspViewCell *>(ViewCell::Merge(*front->mViewCell, *back->mViewCell)); 
    16031659         
    16041660        if (!viewCell) 
    16051661                return false; 
    16061662 
    1607         DEL_PTR(front->mViewCell); 
    1608         DEL_PTR(back->mViewCell); 
    1609  
    1610         front->SetViewCell(viewCell); 
    1611         back->SetViewCell(viewCell); 
     1663        // change view cells of all leaves associated with the 
     1664        // previous view cells 
     1665 
     1666        BspViewCell *fVc = front->mViewCell; 
     1667        BspViewCell *bVc = back->mViewCell; 
     1668 
     1669        vector<BspLeaf *> fLeaves = fVc->mBspLeaves; 
     1670        vector<BspLeaf *> bLeaves = bVc->mBspLeaves; 
     1671 
     1672        vector<BspLeaf *>::const_iterator it; 
     1673         
     1674        for (it = fLeaves.begin(); it != fLeaves.end(); ++ it) 
     1675        { 
     1676                (*it)->SetViewCell(viewCell); 
     1677                viewCell->mBspLeaves.push_back(*it); 
     1678        } 
     1679        for (it = bLeaves.begin(); it != bLeaves.end(); ++ it) 
     1680        { 
     1681                (*it)->SetViewCell(viewCell); 
     1682                viewCell->mBspLeaves.push_back(*it); 
     1683        } 
     1684         
     1685        DEL_PTR(fVc); 
     1686        DEL_PTR(bVc); 
    16121687 
    16131688        return true; 
     
    16161691bool BspTree::ShouldMerge(BspLeaf *front, BspLeaf *back) const 
    16171692{ 
    1618         if (front->mViewCell->GetPvs().Diff(back->mViewCell->GetPvs()) <  
    1619                 sMinPvsDif) 
    1620                 return true; 
    1621          
    1622         if (back->mViewCell->GetPvs().Diff(front->mViewCell->GetPvs()) <  
    1623                 sMinPvsDif) 
     1693        ViewCell *fvc = front->mViewCell; 
     1694        ViewCell *bvc = back->mViewCell; 
     1695 
     1696        if ((fvc == mRootCell) || (bvc == mRootCell) || (fvc == bvc)) 
     1697                return false; 
     1698 
     1699        /*Debug << "merge (" << sMinPvsDif << ")" << endl; 
     1700        Debug << "size f: " << fvc->GetPvs().GetSize() << ", " 
     1701                  << "size b: " << bvc->GetPvs().GetSize() << endl; 
     1702         
     1703        Debug << "diff f: " << fvc->GetPvs().Diff(bvc->GetPvs()) << ", " 
     1704                  << "diff b: " << bvc->GetPvs().Diff(fvc->GetPvs()) << endl;*/ 
     1705 
     1706    if ((fvc->GetPvs().Diff(bvc->GetPvs()) < sMinPvsDif) && 
     1707            (bvc->GetPvs().Diff(fvc->GetPvs()) < sMinPvsDif)) 
    16241708                return true; 
    16251709 
     
    19652049} 
    19662050 
     2051void BspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const 
     2052{ 
     2053        vector<BspLeaf *> leaves = vc->mBspLeaves; 
     2054 
     2055        vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); 
     2056 
     2057        for (it = leaves.begin(); it != it_end; ++ it) 
     2058                ConstructGeometry(*it, cell); 
     2059} 
     2060 
    19672061int BspTree::FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors,  
    19682062                                                   const bool onlyUnmailed) const 
     
    21212215        return NULL; 
    21222216} 
     2217 
     2218int BspTree::CountPvs(const BoundedRayContainer &rays) const 
     2219{ 
     2220        int pvsSize = 0; 
     2221 
     2222        BoundedRayContainer::const_iterator rit, rit_end = rays.end(); 
     2223        vector<BspLeaf *>::const_iterator lit; 
     2224 
     2225        ViewCell::NewMail(); 
     2226 
     2227        for (rit = rays.begin(); rit != rit_end; ++ rit) 
     2228        { 
     2229                Ray *ray = (*rit)->mRay; 
     2230                 
     2231                for (lit = ray->bspLeaves.begin(); lit != ray->bspLeaves.end(); ++ lit) 
     2232                { 
     2233                        if ((*lit)->mViewCell->Mailed()) 
     2234                        { 
     2235                                pvsSize += (*lit)->mViewCell->GetPvs().GetSize(); 
     2236                        } 
     2237                } 
     2238        } 
     2239 
     2240        return pvsSize; 
     2241} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r362 r366  
    77 
    88class ViewCell; 
     9class BspViewCell; 
    910class Plane3; 
    1011class BspTree;   
     
    230231public: 
    231232        BspLeaf(); 
    232         BspLeaf(ViewCell *viewCell); 
     233        BspLeaf(BspViewCell *viewCell); 
    233234        BspLeaf(BspInterior *parent); 
    234         BspLeaf(BspInterior *parent, ViewCell *viewCell); 
     235        BspLeaf(BspInterior *parent, BspViewCell *viewCell); 
    235236 
    236237        /** @return true since it is an interior node  
    237238        */ 
    238239        bool IsLeaf() const; 
    239         /** Returns pointer from view cell. 
    240         */ 
    241         ViewCell *GetViewCell(); 
     240         
     241        /** Returns pointer of view cell. 
     242        */ 
     243        BspViewCell *GetViewCell() const; 
     244 
    242245        /** Sets pointer to view cell. 
    243246        */ 
    244         void SetViewCell(ViewCell *viewCell); 
     247        void SetViewCell(BspViewCell *viewCell); 
    245248 
    246249        /** Generates new view cell and adds rays to the PVS. 
     
    257260 
    258261        /// if NULL this does not correspond to feasible viewcell 
    259         ViewCell *mViewCell; 
     262        BspViewCell *mViewCell; 
    260263}; 
    261264 
     
    379382                                          const bool onlyUnmailed) const; 
    380383 
    381         /** Extracts geometry associated with the split plane leading to this node. 
    382         */ 
    383         void ConstructGeometry(BspNode *n, PolygonContainer &polys) const; 
     384        /** Constructs geometry associated with the half space intersections  
     385                leading to this node. 
     386        */ 
     387        void ConstructGeometry(BspNode *n, PolygonContainer &cell) const; 
    384388         
     389        /** Construct geometry of view cell. 
     390        */ 
     391        void ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const; 
     392 
    385393        /** Returns random leaf of BSP tree. 
    386394                @param halfspace defines the halfspace from which the leaf is taken. 
     
    413421        */ 
    414422        bool MergeViewCells(BspLeaf *front, BspLeaf *back) const; 
     423 
     424        /** Traverses tree and counts PVS size of all view cells 
     425        */ 
     426        int CountViewCellPvs() const; 
    415427 
    416428protected: 
     
    644656        void ExtractSplitPlanes(BspNode *n, vector<Plane3 *> &planes, vector<bool> &sides) const; 
    645657 
     658        int CountPvs(const BoundedRayContainer &rays) const; 
    646659        /// Pointer to the root of the tree 
    647660        BspNode *mRoot; 
     
    663676                  BLOCKED_RAYS = 128, 
    664677                  LEAST_RAY_SPLITS = 256, 
    665                   BALANCED_RAYS = 512 
     678                  BALANCED_RAYS = 512, 
     679                  PVS = 1024 
    666680                }; 
    667681 
     
    742756}; 
    743757 
    744 //}; // GtpVisibilityPreprocessor 
    745  
    746758#endif 
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r344 r366  
    4242  // construction method. For "from rays" construction, wait until there is 
    4343  // a certain number of rays collected 
    44   if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS && 
     44  if (ViewCell::sHierarchy == ViewCell::BSP && 
    4545          !(BspTree::sConstructionMethod == BspTree::FROM_RAYS))  
    4646  { 
Note: See TracChangeset for help on using the changeset viewer.