Changeset 352


Ignore:
Timestamp:
10/27/05 18:50:39 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
6 edited

Legend:

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

    r350 r352  
    99#       filename vienna.x3d 
    1010#       filename ../data/vienna/vienna-simple.x3d 
    11 #       filename ../data/vienna/vienna-buildings.x3d 
     11        filename ../data/vienna/vienna-buildings.x3d 
    1212#       filename ../data/vienna/viewcells-25-sel.x3d 
    13         filename ../data/atlanta/atlanta2.x3d 
     13#       filename ../data/atlanta/atlanta2.x3d 
    1414#       filename ../data/soda/soda.dat 
    1515#       filename ../data/soda/soda5.dat 
     
    7676BspTree { 
    7777        Construction { 
    78                 input fromRays 
     78        #       input fromRays 
    7979        #       input fromViewCells 
    80         #       input fromSceneGeometry 
     80                input fromSceneGeometry 
    8181                samples 150000 
    8282                sideTolerance 0.005 
     
    114114         
    115115        #splitPlaneStrategy 384 
    116         splitPlaneStrategy 130 
     116        #splitPlaneStrategy 130 
     117         
     118        splitPlaneStrategy 66 
    117119         
    118120        maxCandidates 80 
     
    120122        Termination { 
    121123                # autopartition 
    122                 maxRays 30 
    123                 maxPolygons 0 
     124                maxRays -1 
     125                maxPolygons 250 
    124126                maxDepth 100 
    125127                 
    126                 #axis aligned split 
    127                 maxPolysForAxisAligned 200 
     128                # axis aligned splits 
     129                maxPolysForAxisAligned 400 
    128130                maxCostRatio 0.9 
    129131                ct_div_ci 0.5 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r350 r352  
    742742 
    743743                // export scene geometry 
    744                 if (1) 
     744                if (0) 
    745745                { 
    746746                        Material m;//= RandomMaterial(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r338 r352  
    55#include "Triangle3.h" 
    66 
    7 ViewCell::ViewCell(): MeshInstance(NULL) 
     7ViewCell::ViewCell(): MeshInstance(NULL), mPiercingRays(0) 
    88{ 
    99} 
    1010 
    11 ViewCell::ViewCell(Mesh *mesh): MeshInstance(mesh) 
     11ViewCell::ViewCell(Mesh *mesh): MeshInstance(mesh), mPiercingRays(0) 
    1212{ 
    1313} 
     
    8080} 
    8181 
     82ViewCell *ViewCell::MergeViewCells(const ViewCell &front, const ViewCell &back) 
     83{ 
     84        /*stable_sort(front.mPiercingRays.begin(), front.mPiercingRays.end()); 
     85        stable_sort(back.mPiercingRays.begin(), back.mPiercingRays.end()); 
     86 
     87        ViewCell *vc = front.Merge(back); 
     88 
     89        if (vc) 
     90                return vc; 
     91 
     92        return back.Merge(front);*/return NULL; 
     93} 
     94 
     95ViewCell *ViewCell::Merge(const ViewCell &other) const 
     96{ 
     97        //-- compute set differences 
     98        const float minDif = 10; 
     99 
     100        RayContainer diff; 
     101 
     102        set_difference(mPiercingRays.begin(), mPiercingRays.end(),  
     103                                   other.mPiercingRays.begin(), other.mPiercingRays.end(), 
     104                                   diff.begin()); 
     105 
     106        if (diff.size() < minDif) 
     107        { 
     108                ViewCell *vc = new ViewCell(); 
     109 
     110                RayContainer::const_iterator it, it_end = other.mPiercingRays.end(); 
     111 
     112                for (it = other.mPiercingRays.begin(); it != it_end; ++ it) 
     113                        vc->mPiercingRays.push_back(*it); 
     114 
     115                while (!diff.empty()) 
     116                { 
     117                        vc->mPiercingRays.push_back(diff.back()); 
     118                        diff.pop_back(); 
     119                } 
     120 
     121                return vc; 
     122        } 
     123 
     124        return NULL; 
     125} 
     126 
     127 
    82128void ViewCell::AddPassingRay(const Ray &ray, const int contributions) 
    83129{ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r311 r352  
    3737                                                                const int maxViewCells); 
    3838 
     39         
     40        /** Adds a passing ray to the passing ray container. 
     41        */ 
     42        void AddPassingRay(const Ray &ray, const int contributions);     
     43 
    3944        /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector. 
    4045                @param the base triangle 
     
    4348        static ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height); 
    4449 
    45         void AddPassingRay(const Ray &ray, const int contributions);     
     50        /** Merges two view cells based on some criteria 
     51                @returns new view cell if merge was success. NULL if merge failed. 
     52        */ 
     53        static ViewCell *MergeViewCells(const ViewCell &front, const ViewCell &back); 
    4654 
    47         static bool ParseEnvironment(); 
    4855 
    49         /** Ray set description of the rays passing through this node */ 
     56        /// Ray set description of the rays passing through this node.   
    5057        PassingRaySet mPassingRays; 
    5158 
     59        /// Rays piercing this view cell. 
     60        RayContainer mPiercingRays; 
     61 
    5262protected: 
     63         
     64        /** Merges view cell with other view cell if certain criteria are met. 
     65                @note because of performance issues the precondition is that the piercing rays are ordered. 
     66        */ 
     67        ViewCell *Merge(const ViewCell &other) const; 
    5368 
    5469        /// the potentially visible objects 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r351 r352  
    220220                                //-- inherit rays from parent polygon 
    221221                                poly->InheritRays(*front_piece, *back_piece); 
    222                                 Debug << "p: " << poly->mPiercingRays.size() << " f: " << front_piece->mPiercingRays.size() << " b: " << back_piece->mPiercingRays.size() << endl; 
     222                                //Debug << "p: " << poly->mPiercingRays.size() << " f: " << front_piece->mPiercingRays.size() << " b: " << back_piece->mPiercingRays.size() << endl; 
    223223                                 
    224224                                // check if polygons still valid  
     
    250250/*                  class BspLeaf implementation                */ 
    251251/****************************************************************/ 
    252 BspLeaf::BspLeaf(): mViewCell(NULL), mPiercingRays(0) 
     252BspLeaf::BspLeaf(): mViewCell(NULL) 
    253253{ 
    254254} 
    255255 
    256256BspLeaf::BspLeaf(ViewCell *viewCell):  
    257 mViewCell(viewCell), mPiercingRays(0) 
     257mViewCell(viewCell) 
    258258{ 
    259259} 
    260260 
    261261BspLeaf::BspLeaf(BspInterior *parent):  
    262 BspNode(parent), mViewCell(NULL), mPiercingRays(0) 
     262BspNode(parent), mViewCell(NULL) 
    263263{} 
    264264 
    265265BspLeaf::BspLeaf(BspInterior *parent, ViewCell *viewCell):  
    266 BspNode(parent), mViewCell(viewCell), mPiercingRays(0) 
     266BspNode(parent), mViewCell(viewCell) 
    267267{ 
    268268} 
     
    285285void BspLeaf::GenerateViewCell(const RayContainer &rays,  
    286286                                                           int &sampleContributions, 
    287                                                            int &contributingSamples) 
     287                                                           int &contributingSamples, 
     288                                                           const bool storeRays) 
    288289{ 
    289290        sampleContributions = 0; 
     
    311312                        ++ contributingSamples; 
    312313                } 
     314 
     315                if (storeRays) 
     316                        mViewCell->mPiercingRays.push_back(*it); 
    313317        } 
    314318} 
     
    694698                leaf->ProcessPolygons(tData.mPolygons, sStoreSplitPolys); 
    695699                DEL_PTR(tData.mPolygons); 
    696                  
    697                 if (mStorePiercingRays) 
    698                 { 
    699                         RayContainer::const_iterator it, it_end = tData.mRays->end(); 
    700                         for (it = tData.mRays->begin(); it != it_end; ++ it) 
    701                         { 
    702                                 leaf->mPiercingRays.push_back(*it); 
    703                         } 
    704                 } 
    705700                DEL_PTR(tData.mRays); 
    706701 
     
    15801575        nodeStack.push(mRoot); 
    15811576 
    1582         BspLeaf *rightLeaf = NULL; 
     1577        BspLeaf *storedLeaf = NULL; 
    15831578 
    15841579        while (!nodeStack.empty())  
     
    15911586                        BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
    15921587 
    1593                         if (rightLeaf && MergeNecessary(leaf, rightLeaf)) 
    1594                                 MergeLeafs(leaf, rightLeaf); 
     1588                        if (storedLeaf) 
     1589                                MergeLeafs(leaf, storedLeaf); 
     1590 
     1591                        // store current leaf 
     1592                        storedLeaf = leaf; 
    15951593                } 
    15961594                else  
     
    16051603} 
    16061604 
    1607 bool BspTree::MergeNecessary(BspLeaf *front, BspLeaf *back) const 
    1608 { 
    1609         if ((front->mPiercingRays.size() < 2) || 
    1610                 (back->mPiercingRays.size() < 2)) 
    1611                 return true; 
    1612         //else if ((Raydiff(front, back) > 100) || 
    1613         //                 (Raydiff(back, front) > 100))return true; 
    1614  
    1615         return false; 
    1616 } 
    1617  
    1618 void BspTree::MergeLeafs(BspLeaf *front, BspLeaf *back) 
     1605void BspTree::MergeLeafs(BspLeaf *front, BspLeaf *back) const 
    16191606{ 
    16201607        //std::merge(front->mPvs.mEntries.begin(), back->mPvs.mEntries.begin()); 
    1621         ViewCell *viewCell = new ViewCell(); 
    1622         viewCell->GetPvs().Merge(front->mViewCell->GetPvs(), back->mViewCell->GetPvs()); 
    1623  
    1624         DEL_PTR(front->mViewCell); 
    1625         DEL_PTR(back->mViewCell); 
    1626  
    1627         front->SetViewCell(viewCell); 
    1628         back->SetViewCell(viewCell); 
     1608        ViewCell *viewCell = ViewCell::MergeViewCells(*front->mViewCell, *back->mViewCell); 
     1609        //viewCell->GetPvs().Merge(front->mViewCell->GetPvs(), back->mViewCell->GetPvs()); 
     1610 
     1611        if (viewCell) 
     1612        { 
     1613                DEL_PTR(front->mViewCell); 
     1614                DEL_PTR(back->mViewCell); 
     1615 
     1616                front->SetViewCell(viewCell); 
     1617                back->SetViewCell(viewCell); 
     1618        } 
    16291619} 
    16301620 
     
    16881678        return splits; 
    16891679} 
     1680 
     1681int BspTree::FindNeighbors(KdNode *n, vector<BspNode *> &neighbors, bool onlyUnmailed) 
     1682{ 
     1683        stack<BspNode *> nodeStack; 
     1684        nodeStack.push(mRoot); 
     1685 
     1686        AxisAlignedBox3 box = GetBox(n); 
     1687 
     1688        while (!nodeStack.empty())  
     1689        { 
     1690                BspNode *node = nodeStack.top(); 
     1691                nodeStack.pop(); 
     1692 
     1693                if (node->IsLeaf())  
     1694                { 
     1695                        if (node != n && (!onlyUnmailed || !node->Mailed()))  
     1696                                neighbors.push_back(node); 
     1697                }  
     1698                else  
     1699                { 
     1700                        KdInterior *interior = (KdInterior *)node; 
     1701                         
     1702                        if (interior->mPosition > box.Max(interior->mAxis)) 
     1703                                nodeStack.push(interior->mBack); 
     1704                        else 
     1705                                if (interior->mPosition < box.Min(interior->mAxis)) 
     1706                                        nodeStack.push(interior->mFront); 
     1707                                else  
     1708                                { 
     1709                                        // random decision 
     1710                                        nodeStack.push(interior->mBack); 
     1711                                        nodeStack.push(interior->mFront); 
     1712                                } 
     1713                } 
     1714         
     1715        } 
     1716        return neighbors.size(); 
     1717} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r350 r352  
    221221                @param sampleContributions the number contributions of the sampels 
    222222                @param contributingSampels the number of contributing rays 
     223                @param storeRays if ray set should be stored in view cell 
    223224        */ 
    224225        void BspLeaf::GenerateViewCell(const RayContainer &rays,  
    225226                                                           int &sampleContributions, 
    226                                                            int &contributingSamples); 
     227                                                           int &contributingSamples, 
     228                                                           const bool storeRays = false); 
    227229 
    228230protected: 
     
    230232        /// if NULL this does not correspond to feasible viewcell 
    231233        ViewCell *mViewCell; 
    232         RayContainer mPiercingRays; 
    233234}; 
    234235 
     
    377378        }; 
    378379 
    379         BspNode *MergeNodes(BspInterior *node); 
    380  
    381         bool MergeNecessary(BspLeaf *front, BspLeaf *back) const; 
     380        /** Merges view cells of leafs. 
     381        */ 
     382        void MergeLeafs(BspLeaf *front, BspLeaf *back) const; 
    382383 
    383384        /** Evaluates tree stats in the BSP tree leafs. 
     
    584585                                  RayContainer &backRays); 
    585586 
    586         void MergeLeafs(BspLeaf *front, BspLeaf *back); 
    587  
    588587        /// Pointer to the root of the tree 
    589588        BspNode *mRoot; 
Note: See TracChangeset for help on using the changeset viewer.