Changeset 503


Ignore:
Timestamp:
01/05/06 20:41:52 (18 years ago)
Author:
mattausch
Message:

added mesh creation function

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
17 edited

Legend:

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

    r501 r503  
    1313#;../data/vienna/vienna-plane.x3d 
    1414#       filename ../data/vienna/viewcells-25-sel.x3d 
    15 #       filename ../data/atlanta/atlanta2.x3d 
     15        filename ../data/atlanta/atlanta2.x3d 
    1616#       filename ../data/soda/soda.dat 
    17         filename ../data/soda/soda5.dat 
     17#       filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    3030        samplesPerPass  100000 
    3131        initialSamples 500000 
    32         vssSamples 200000 
     32        vssSamples 2000000 
    3333        vssSamplesPerPass 100000 
    3434        useImportanceSampling true 
    3535        loadInitialSamples  false 
    3636        storeInitialSamples false 
    37         useViewSpaceBox true 
    3837} 
    3938 
     
    181180         
    182181        PostProcess { 
    183                 minPvsDif 100 
    184                 minPvs 10 
    185                 maxPvs 150 
    186182                # how much samples are used for post processing 
    187183                samples 100000 
     
    196192                colorCode Random 
    197193                exportRays false 
    198                 exportGeometry true 
     194                exportGeometry false 
    199195        } 
    200196         
     
    223219        Termination { 
    224220                maxDepth                40 
    225                 minPvs                  1 
    226                 minRays                 100 
    227                 minSize                 0.0001 
    228                 maxCostRatio            0.95 
     221                minPvs                  50 
     222                minRays                 300 
     223                minSize                 0.001 
     224                maxCostRatio            0.9 
    229225                missTolerance           4 
    230226                maxRayContribution      0.5 
     
    232228         
    233229        maxTotalMemory  100 
    234         maxStaticMemory 80 
     230        maxStaticMemory 50 
    235231 
    236232        splitType       regular 
     
    283279        Termination { 
    284280                # parameters used for autopartition 
    285                 minRays                 100 
     281                minRays                 200 
    286282                minPolygons             -1 
    287283                maxDepth                30 
    288                 minPvs                  2 
     284                minPvs                  20 
    289285                #minArea                0.0001 
    290286                minArea                 0.000 
    291                 maxRayContribution      0.005 
     287                maxRayContribution      0.05 
    292288                maxCostRatio            0.9 
    293                 missTolerance           4 
     289                missTolerance           5 
    294290                #maxAccRayLength        100 
    295291                 
    296                 maxViewCells            8000 
     292                maxViewCells            20000 
    297293                 
    298294                # used for pvs criterium 
     
    309305        PostProcess { 
    310306                maxCostRatio 0.1 
    311                 minViewCells 200 
     307                minViewCells 500 
    312308                maxPvsSize   1000 
    313                 useRaysForMerge false 
     309                useRaysForMerge true 
    314310        } 
    315311} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp

    r492 r503  
    17861786   
    17871787  Vector3 invDirection; 
    1788   const float eps = 1e-6; 
    1789   const float invEps = 1e6; 
     1788  const float eps = 1e-6f; 
     1789  const float invEps = 1e6f; 
    17901790   
    17911791  // it does change the ray direction very slightly, 
     
    17931793   
    17941794  if (fabs(direction.x) < eps) { 
    1795     if (direction.x < 0.0) 
     1795    if (direction.x < 0.0f) 
    17961796      invDirection.x = -invEps; 
    17971797    else 
     
    17991799  } 
    18001800  else 
    1801     invDirection.x = 1.0 / direction.x; 
     1801    invDirection.x = 1.0f / direction.x; 
    18021802   
    18031803  if (fabs(direction.y) < eps) { 
     
    18081808  } 
    18091809  else 
    1810     invDirection.y = 1.0 / direction.y; 
     1810    invDirection.y = 1.0f / direction.y; 
    18111811   
    18121812  if (fabs(direction.z) < eps) { 
    1813     if (direction.z < 0.0) 
     1813    if (direction.z < 0.0f) 
    18141814      invDirection.z = -invEps; 
    18151815    else 
     
    18171817  } 
    18181818  else 
    1819     invDirection.z = 1.0 / direction.z; 
    1820  
    1821  
    1822    
    1823   if (fabs(direction.x) < 0.001) { 
     1819    invDirection.z = 1.0f / direction.z; 
     1820 
     1821 
     1822   
     1823  if (fabs(direction.x) < 0.001f) { 
    18241824    if (mMin.x < origin.x && mMax.x > origin.x) { 
    18251825      minx = -MAXFLOAT; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Containers.h

    r372 r503  
    1313class Polygon3; 
    1414class Ray; 
     15class Mesh; 
    1516 
    1617/** Container storing polygons used during BSP tree construction. 
     
    4041typedef vector<HierarchyNode *> NodeContainer; 
    4142 
    42  
    4343typedef vector<SceneGraphNode *> SceneGraphNodeContainer; 
    4444 
     45typedef vector<Mesh *> MeshContainer; 
    4546 
    4647 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r501 r503  
    12291229                                 "view_cells_max_pvs=", 
    12301230                                 "300"); 
    1231  
    1232   RegisterOption("ViewCells.PostProcess.minPvsDif", 
    1233                                  optInt, 
    1234                                  "view_cells_post_process_min_pvs_dif=", 
    1235                                  "10"); 
    1236  
    1237   RegisterOption("ViewCells.PostProcess.maxPvs", 
    1238                                  optInt, 
    1239                                  "view_cells_post_process_max_pvs=", 
    1240                                  "300"); 
    1241  
    1242   RegisterOption("ViewCells.PostProcess.minPvs", 
    1243                                  optString, 
    1244                                  "view_cells_post_process_min_pvs", 
    1245                                  "10"); 
    1246    
     1231  
    12471232  RegisterOption("ViewCells.filename", 
    12481233                 optString, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r483 r503  
    11#include "Polygon3.h" 
    2 #include "Mesh.h" 
    32#include "Mesh.h" 
    43#include "AxisAlignedBox3.h" 
    54#include "Ray.h" 
     5#include "Triangle3.h" 
    66 
    77Polygon3::Polygon3():  
     
    471471        return revPoly; 
    472472} 
     473 
     474 
     475void Polygon3::Triangulate(vector<Triangle3> &triangles) 
     476{ 
     477        int i = 1; 
     478        int j = 0; 
     479        int k = mVertices.size() - 1; 
     480        int count = 0; 
     481 
     482        while (i < k) 
     483        { 
     484                triangles.push_back(Triangle3(mVertices[i], mVertices[j], mVertices[k])); 
     485 
     486                if ((count ++) % 2) 
     487                        j = i ++; 
     488                else 
     489                        j = k --; 
     490        } 
     491} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h

    r448 r503  
    9898        int CastRay(const Ray &ray, float &t, const float nearestT); 
    9999 
    100          
     100        /** The polygon is triangulated. 
     101        */ 
     102        void Triangulate(vector<Triangle3> &triangles); 
     103 
    101104        /** The piercing rays of the polygon are inherited by the child fragments 
    102105                @parm front_piece the front fragment inheriting the front rays 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r502 r503  
    692692 
    693693         
    694         totalSamples += rays.size(); 
    695         rssSamples += vssRays.size(); 
     694        totalSamples += (int)rays.size(); 
     695        rssSamples += (int)vssRays.size(); 
    696696 
    697697         
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r485 r503  
    2323} 
    2424 
     25 
    2526const ObjectPvs &ViewCell::GetPvs() const 
    2627{ 
     
    3334} 
    3435 
     36 
    3537int ViewCell::Type() const  
    3638{  
    3739        return VIEW_CELL;  
    3840} 
     41 
    3942 
    4043void ViewCell::AddPassingRay(const Ray &ray, const int contributions) 
     
    5457        mVolume = volume; 
    5558} 
     59 
     60 
     61void ViewCell::SetMesh(Mesh *mesh) 
     62{ 
     63        mMesh = mesh; 
     64} 
     65 
    5666 
    5767void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r479 r503  
    116116        */ 
    117117        void SetArea(float area); 
     118 
     119        /** Updates the view cell statstics for this particular view cell. 
     120        */ 
    118121        virtual void UpdateViewCellsStats(ViewCellsStatistics &vcStat); 
    119122 
     
    123126        /// Rays piercing this view cell. 
    124127        RayContainer mPiercingRays; 
     128 
     129        /** Sets the mesh for this view cell. 
     130        */ 
     131        void SetMesh(Mesh *mesh); 
    125132 
    126133protected: 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r502 r503  
    88#include "Ray.h" 
    99#include "AxisAlignedBox3.h" 
     10#include "Triangle3.h" 
     11 
    1012#include <stack> 
    1113 
     
    423425        app << "#N_INVALIDLEAVES (number of invalid leaves )\n" << invalidLeaves << endl; 
    424426 
     427        app << "#N_RAYS (number of rays / leaf)\n" << AvgRays() << endl; 
    425428        //app << "#N_PVS: " << pvs << endl; 
    426429 
     
    776779 
    777780        // constrruct root node geometry 
    778         BspNodeGeometry *cell = new BspNodeGeometry(); 
    779         ConstructGeometry(mRoot, *cell); 
     781        BspNodeGeometry *geom = new BspNodeGeometry(); 
     782        ConstructGeometry(mRoot, *geom); 
    780783 
    781784        BspTraversalData tData(mRoot, polys, 0, mRootCell, rays,  
    782                                                    ComputePvsSize(*rays), cell->GetArea(), cell); 
     785                                                   ComputePvsSize(*rays), geom->GetArea(), geom); 
    783786 
    784787        tStack.push(tData); 
     
    18091812        // accumulate depth to compute average depth 
    18101813        mStat.accumDepth += data.mDepth; 
    1811          
     1814        // accumulate rays to compute rays /  leaf 
     1815        mStat.accumRays += (int)data.mRays->size(); 
    18121816 
    18131817        if (data.mDepth >= mTermMaxDepth) 
     
    21962200} 
    21972201 
    2198 void BspTree::ConstructGeometry(BspNode *n, BspNodeGeometry &cell) const 
    2199 { 
    2200         PolygonContainer polys; 
    2201         ConstructGeometry(n, polys); 
    2202         cell.mPolys = polys; 
    2203 } 
    2204  
    2205 void BspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const 
     2202void BspTree::ConstructGeometry(BspViewCell *vc, BspNodeGeometry &geom) const 
    22062203{ 
    22072204        vector<BspLeaf *> leaves = vc->mLeaves; 
     
    22102207 
    22112208        for (it = leaves.begin(); it != it_end; ++ it) 
    2212                 ConstructGeometry(*it, cell); 
    2213 } 
    2214  
    2215  
    2216 void BspTree::ConstructGeometry(BspNode *n, PolygonContainer &cell) const 
     2209                ConstructGeometry(*it, geom); 
     2210} 
     2211 
     2212 
     2213void BspTree::ConstructGeometry(BspNode *n, BspNodeGeometry &geom) const 
    22172214{ 
    22182215        vector<Plane3> halfSpaces; 
     
    22912288                 
    22922289                if (candidates[i]) 
    2293                         cell.push_back(candidates[i]); 
     2290                        geom.mPolys.push_back(candidates[i]); 
    22942291        } 
    22952292} 
     
    22992296                                                   const bool onlyUnmailed) const 
    23002297{ 
    2301         PolygonContainer cell; 
    2302  
    2303         ConstructGeometry(n, cell); 
     2298        BspNodeGeometry geom; 
     2299        ConstructGeometry(n, geom); 
    23042300 
    23052301        stack<BspNode *> nodeStack; 
     
    23192315            if (node != n && (!onlyUnmailed || !node->Mailed())) 
    23202316                        { 
    2321                                 // test all planes of current node if candidate really 
    2322                                 // is neighbour 
    2323                                 PolygonContainer neighborCandidate; 
    2324                                 ConstructGeometry(node, neighborCandidate); 
     2317                                // test all planes of current node if neighbour  
     2318                                // candidate really is neighbour 
     2319                                BspNodeGeometry candidateGeom; 
     2320                                ConstructGeometry(node, candidateGeom); 
    23252321                                 
    23262322                                bool isAdjacent = true; 
     
    23282324                                { 
    23292325                                        const int cf =  
    2330                                                 Polygon3::ClassifyPlane(neighborCandidate,  
     2326                                                Polygon3::ClassifyPlane(candidateGeom.mPolys,  
    23312327                                                                                                halfSpaces[i], 
    23322328                                                                                                mEpsilon); 
     
    23382334                                if (isAdjacent) 
    23392335                                        neighbors.push_back(dynamic_cast<BspLeaf *>(node)); 
    2340  
    2341                                 CLEAR_CONTAINER(neighborCandidate); 
    23422336                        } 
    23432337                } 
     
    23462340                        BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    23472341         
    2348                         const int cf = Polygon3::ClassifyPlane(cell,  
     2342                        const int cf = Polygon3::ClassifyPlane(geom.mPolys,  
    23492343                                                                                                   interior->mPlane, 
    23502344                                                                                                   mEpsilon); 
     
    23642358        } 
    23652359         
    2366         CLEAR_CONTAINER(cell); 
    23672360        return (int)neighbors.size(); 
    23682361} 
     2362 
    23692363 
    23702364BspLeaf *BspTree::GetRandomLeaf(const Plane3 &halfspace) 
     
    23872381                { 
    23882382                        BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    2389                          
    23902383                        BspNode *next; 
    23912384         
    2392                         PolygonContainer cell; 
    2393  
     2385                        BspNodeGeometry geom; 
    23942386                        // todo: not very efficient: constructs full cell everytime 
    2395                         ConstructGeometry(interior, cell); 
    2396  
    2397                         const int cf = Polygon3::ClassifyPlane(cell,  
     2387                        ConstructGeometry(interior, geom); 
     2388 
     2389                        const int cf = Polygon3::ClassifyPlane(geom.mPolys,  
    23982390                                                                                                   halfspace,  
    23992391                                                                                                   mEpsilon); 
     
    25342526/*************************************************************/ 
    25352527 
     2528 
    25362529BspNodeGeometry::~BspNodeGeometry() 
    25372530{ 
    25382531        CLEAR_CONTAINER(mPolys); 
    25392532} 
     2533 
    25402534 
    25412535float BspNodeGeometry::GetArea() const  
     
    25432537        return Polygon3::GetArea(mPolys); 
    25442538} 
     2539 
     2540 
     2541void BspNodeGeometry::AddToMesh(Mesh &mesh) 
     2542{ 
     2543        PolygonContainer::const_iterator it, it_end = mPolys.end(); 
     2544        int vcount = 0; 
     2545 
     2546        for (it = mPolys.begin(); it != mPolys.end(); ++ it) 
     2547        { 
     2548                Polygon3 *poly = *it; 
     2549                 
     2550                vector<Triangle3> triangles; 
     2551                poly->Triangulate(triangles); 
     2552                vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 
     2553         
     2554                for (tit = triangles.begin(); tit != tit_end; ++ tit) 
     2555                { 
     2556                        mesh.mVertices.push_back((*tit).mVertices[0]); 
     2557                        mesh.mVertices.push_back((*tit).mVertices[1]); 
     2558                        mesh.mVertices.push_back((*tit).mVertices[2]); 
     2559 
     2560                        Face *face = new Face(vcount ++, vcount ++, vcount ++); 
     2561                        mesh.AddFace(face); 
     2562                } 
     2563        } 
     2564} 
     2565 
    25452566 
    25462567void BspNodeGeometry::SplitGeometry(BspNodeGeometry &front, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r492 r503  
    4444        */ 
    4545        void ComputeBoundingBox(AxisAlignedBox3 &box); 
     46 
    4647        /** Splits the polygon and returns the part of the polygon inside of the node geometry. 
    4748        */ 
    4849        Polygon3 *SplitPolygon(Polygon3 *poly, const float epsilon) const; 
    4950 
     51        /** Adds node geometry to mesh. 
     52                @note the mesh vertices will not be connected 
     53        */ 
     54        void AddToMesh(Mesh &mesh); 
     55 
     56        /** The polygons the geometry consists of. 
     57        */ 
    5058        PolygonContainer mPolys; 
    5159}; 
     
    132140        /// polygon splits  
    133141        int polySplits; 
     142        /// accumulated number of rays refs 
     143        int accumRays; 
    134144 
    135145        // Constructor 
     
    145155        // TODO: computation wrong 
    146156        double AvgDepth() const { return accumDepth / (double)Leaves();};  
    147    
     157        double AvgRays() const { return accumRays / (double)Leaves();};  
     158 
    148159        void Reset()  
    149160        { 
     
    170181                invalidLeaves = 0; 
    171182                polySplits = 0; 
     183                accumRays = 0; 
    172184        } 
    173185 
     
    458470                @returns the number of intersections with objects stored in the tree. 
    459471        */ 
    460   int 
    461   _CastRay(Ray &ray); 
    462  
    463  
    464   int 
    465   CastLineSegment(const Vector3 &origin, 
    466                                   const Vector3 &termination, 
    467                                   ViewCellContainer &viewcells 
    468                                   ); 
    469  
    470   ViewCell * 
    471   GetViewCell(const Vector3 &point); 
     472        int     _CastRay(Ray &ray); 
     473 
     474 
     475        int     CastLineSegment(const Vector3 &origin, 
     476                                                const Vector3 &termination, 
     477                                                ViewCellContainer &viewcells 
     478                                                ); 
     479 
     480        ViewCell *GetViewCell(const Vector3 &point); 
    472481   
    473482        /// bsp tree construction types 
     
    483492                                          const bool onlyUnmailed) const; 
    484493 
    485         /** Constructs geometry associated with the half space intersections  
    486                 leading to this node. 
    487         */ 
    488         void ConstructGeometry(BspNode *n, PolygonContainer &cell) const; 
     494        /** Constructs geometry of view cell returning a BSP node geometry type. 
     495        */ 
     496        void ConstructGeometry(BspNode *n, BspNodeGeometry &cell) const; 
    489497         
    490498        /** Construct geometry of view cell. 
    491499        */ 
    492         void ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const; 
    493  
    494         /** Constructs geometry of view cell returning a BSP node geometry type. 
    495         */ 
    496         void ConstructGeometry(BspNode *n, BspNodeGeometry &cell) const; 
     500        void ConstructGeometry(BspViewCell *vc, BspNodeGeometry &geom) const; 
    497501 
    498502        /** Returns random leaf of BSP tree. 
     
    788792        void AddToPvs(BspLeaf *leaf, 
    789793                                  const BoundedRayContainer &rays,  
    790                                   int &sampleContributions, 
     794                                  int &sampleContributions,      
    791795                                  int &contributingSamples); 
    792796 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r502 r503  
    3737void ViewCellsManager::ParseEnvironment() 
    3838{ 
    39         // post processing stuff 
    40         environment->GetIntValue("ViewCells.PostProcess.minPvsDif", mMinPvsDif); 
    41         environment->GetIntValue("ViewCells.PostProcess.minPvs", mMinPvs); 
    42         environment->GetIntValue("ViewCells.PostProcess.maxPvs", mMaxPvs); 
    43  
     39        // visualization stuff 
    4440        environment->GetBoolValue("ViewCells.Visualization.exportRays", mExportRays); 
    4541        environment->GetBoolValue("ViewCells.Visualization.exportGeometry", mExportGeometry); 
    4642 
    4743        char buf[50]; 
    48          
     44 
    4945        environment->GetStringValue("ViewCells.Visualization.colorCode", buf); 
    50          
     46 
    5147        if (strcmp(buf, "PVS") == 0) 
    5248                mColorCode = 1; 
     
    6561{ 
    6662        DEL_PTR(mRenderer); 
    67  
    6863        CLEAR_CONTAINER(mViewCells); 
     64        CLEAR_CONTAINER(mMeshContainer); 
    6965} 
    7066 
     
    7369{ 
    7470        X3dParser parser; 
    75          
     71 
    7672        environment->GetFloatValue("ViewCells.height", parser.mViewCellHeight); 
    77          
     73 
    7874        bool success = parser.ParseFile(filename, *this); 
    7975        Debug << (int)mViewCells.size() << " view cells loaded" << endl; 
     
    10298        if (!ViewCellsConstructed()) 
    10399                return; 
    104    
     100 
    105101        VssRayContainer::const_iterator it, it_end = rays.end(); 
    106102 
    107         for (it = rays.begin(); it != it_end; ++ it)  
    108         {        
     103        for (it = rays.begin(); it != it_end; ++ it) 
     104        { 
    109105                ComputeSampleContributions(*(*it)); 
    110106        } 
     
    143139 
    144140 
    145 void ViewCellsManager::DeriveViewCells(const ObjectContainer &objects,  
    146                                                                            ViewCellContainer &viewCells,  
     141void ViewCellsManager::DeriveViewCells(const ObjectContainer &objects, 
     142                                                                           ViewCellContainer &viewCells, 
    147143                                                                           const int maxViewCells) const 
    148144{ 
    149145        // maximal max viewcells 
    150         int limit = maxViewCells > 0 ?  
     146        int limit = maxViewCells > 0 ? 
    151147                Min((int)objects.size(), maxViewCells) : (int)objects.size(); 
    152148 
     
    154150        { 
    155151                Intersectable *object = objects[i]; 
    156                  
     152 
    157153                // extract the mesh instances 
    158154                if (object->Type() == Intersectable::MESH_INSTANCE) 
     
    168164 
    169165 
    170 ViewCell *ViewCellsManager::ExtrudeViewCell(const Triangle3 &baseTri,  
     166ViewCell *ViewCellsManager::ExtrudeViewCell(const Triangle3 &baseTri, 
    171167                                                                                        const float height) const 
    172168{ 
    173169        // one mesh per view cell 
    174170        Mesh *mesh = new Mesh(); 
    175          
     171 
    176172        //-- construct prism 
    177173 
    178         // bottom  
     174        // bottom 
    179175        mesh->mFaces.push_back(new Face(2,1,0)); 
    180176        // top 
     
    188184        Vector3 triNorm = baseTri.GetNormal(); 
    189185 
    190         Triangle3 topTri;        
     186        Triangle3 topTri; 
    191187 
    192188        // add base vertices and calculate top vertices 
    193189        for (int i = 0; i < 3; ++ i) 
    194190                mesh->mVertices.push_back(baseTri.mVertices[i]); 
    195          
    196         // add top vertices      
     191 
     192        // add top vertices 
    197193        for (int i = 0; i < 3; ++ i) 
    198194                mesh->mVertices.push_back(baseTri.mVertices[i] + height * triNorm); 
    199          
     195 
    200196        mesh->Preprocess(); 
    201197 
     
    217213 
    218214        std::merge(front.mPiercingRays.begin(), front.mPiercingRays.end(), 
    219                            back.mPiercingRays.begin(), back.mPiercingRays.end(),  
     215                           back.mPiercingRays.begin(), back.mPiercingRays.end(), 
    220216                           vc->mPiercingRays.begin()); 
    221217 
     
    321317{ 
    322318        mViewCells.clear(); 
    323          
     319 
    324320        CollectViewCells(); 
    325321        mViewCellsStats.Reset(); 
     
    336332 
    337333  ViewCellContainer viewcells; 
    338                  
     334 
    339335  ray.mPvsContribution = 0; 
    340336  ray.mRelativePvsContribution = 0.0f; 
     
    343339  Ray hray(ray); 
    344340  float tmin = 0, tmax = 1.0; 
    345    
     341 
    346342  //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 
    347343  if (!GetSceneBbox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
    348344        return; 
    349    
     345 
    350346  Vector3 origin = hray.Extrap(tmin); 
    351347  Vector3 termination = hray.Extrap(tmax); 
    352    
     348 
    353349  CastLineSegment(origin, 
    354350                                  termination, 
    355351                                  viewcells); 
    356    
     352 
    357353  // copy viewcells memory efficiently 
    358354  const bool storeViewcells = false; 
     
    361357        ray.mViewCells = viewcells; 
    362358  } 
    363    
     359 
    364360  ViewCellContainer::const_iterator it = viewcells.begin(); 
    365361 
     
    367363 
    368364  if (addInPlace) { 
    369         for (; it != viewcells.end(); ++it) {    
     365        for (; it != viewcells.end(); ++it) { 
    370366          ViewCell *viewcell = *it; 
    371            
     367 
    372368          // if ray not outside of view space 
    373369          float contribution; 
    374           bool added =  
     370          bool added = 
    375371                viewcell->GetPvs().AddSample(ray.mTerminationObject, 
    376372                                                                         contribution 
     
    378374          if (added) 
    379375                ray.mPvsContribution++; 
    380            
     376 
    381377          ray.mRelativePvsContribution += contribution; 
    382378        } 
    383379  } else { 
    384     for (; it != viewcells.end(); ++it) {        
     380    for (; it != viewcells.end(); ++it) { 
    385381          ViewCell *viewcell = *it; 
    386382          // if ray not outside of view space 
     
    390386                                                                                                   )) 
    391387                ray.mPvsContribution++; 
    392            
     388 
    393389          ray.mRelativePvsContribution += contribution; 
    394390        } 
    395391 
    396         for (it = viewcells.begin(); it != viewcells.end(); ++it) {      
     392        for (it = viewcells.begin(); it != viewcells.end(); ++it) { 
    397393          ViewCell *viewcell = *it; 
    398394          // if ray not outside of view space 
     
    405401void ViewCellsManager::GetRaySets(const VssRayContainer &sourceRays, 
    406402                                                                  const int maxSize, 
    407                                                                   VssRayContainer &usedRays,  
     403                                                                  VssRayContainer &usedRays, 
    408404                                                                  VssRayContainer *savedRays) const 
    409405{ 
     
    461457 
    462458 
     459 
     460void ViewCellsManager::CreateViewCellsMeshes() 
     461{ 
     462        // convert to meshes 
     463        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     464 
     465        for (it = mViewCells.begin(); it != it_end; ++ it) 
     466        { 
     467                CreateMesh(*it); 
     468        } 
     469} 
     470 
    463471/**********************************************************************/ 
    464472/*                   BspViewCellsManager implementation               */ 
     
    466474 
    467475 
    468 BspViewCellsManager::BspViewCellsManager(BspTree *bspTree,  
     476BspViewCellsManager::BspViewCellsManager(BspTree *bspTree, 
    469477                                                                                 int constructionSamples): 
    470 ViewCellsManager(constructionSamples),  
     478ViewCellsManager(constructionSamples), 
    471479mBspTree(bspTree) 
    472480{ 
     
    486494 
    487495 
    488 int BspViewCellsManager::Construct(const ObjectContainer &objects,  
     496int BspViewCellsManager::Construct(const ObjectContainer &objects, 
    489497                                                                   const VssRayContainer &rays) 
    490498{ 
     
    494502 
    495503        int sampleContributions = 0; 
    496          
     504 
    497505        // construct view cells using the collected samples 
    498506        RayContainer constructionRays; 
     
    513521        } 
    514522 
    515     if (mViewCells.empty())  
    516         {  
    517                 // no view cells loaded  
     523    if (mViewCells.empty()) 
     524        { 
     525                // no view cells loaded 
    518526                mBspTree->Construct(objects, constructionRays); 
    519527                // collect final view cells 
    520528                mBspTree->CollectViewCells(mViewCells); 
    521         }  
     529        } 
    522530        else 
    523531        { 
     
    529537 
    530538        Debug << mBspTree->GetStatistics() << endl; 
    531          
    532         EvaluateViewCellsStats(); 
     539 
     540        //EvaluateViewCellsStats(); 
    533541        Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 
    534542 
     
    536544        ComputeSampleContributions(savedRays); 
    537545 
     546 
    538547        return sampleContributions; 
    539548} 
    540549 
     550 
    541551void BspViewCellsManager::CollectViewCells() 
    542552{ 
    543553        mBspTree->CollectViewCells(mViewCells); 
    544554} 
     555 
    545556 
    546557float BspViewCellsManager::GetProbability(ViewCell *viewCell) 
     
    553564#endif 
    554565} 
    555    
     566 
    556567 
    557568float BspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
     
    575586 
    576587 
    577 int BspViewCellsManager::PostProcess(const ObjectContainer &objects,  
     588int BspViewCellsManager::PostProcess(const ObjectContainer &objects, 
    578589                                                                         const VssRayContainer &rays) 
    579590{ 
     
    601612                cout << "exporting initial view cells (=leaves) ... "; 
    602613                Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 
    603          
     614 
    604615                if (exporter) 
    605616                { 
     
    607618                        exporter->SetFilled(); 
    608619                        ExportViewCells(exporter); 
    609                                  
     620 
    610621                        if (mExportGeometry) 
    611622                        { 
     
    624635 
    625636        cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 
    626                  
     637 
    627638        long startTime = GetTime(); 
    628639 
     
    637648        CLEAR_CONTAINER(mBspRays); 
    638649        ConstructBspRays(rays, mPostProcessSamples); 
    639          
     650 
    640651        for (int i = 0; i < (int)mBspRays.size(); ++ i) 
    641         {   
     652        { 
    642653                BspRay *ray = mBspRays[i]; 
    643            
     654 
    644655                // traverse leaves stored in the rays and compare and merge consecutive 
    645656                // leaves (i.e., the neighbors in the tree) 
    646657                if (ray->intersections.size() < 2) 
    647658                        continue; 
    648            
     659 
    649660                iit = ray->intersections.begin(); 
    650661 
    651662                BspLeaf *previousLeaf = (*iit).mLeaf; 
    652663                ++ iit; 
    653                  
     664 
    654665                for (; iit != ray->intersections.end(); ++ iit) 
    655666                { 
     
    657668 
    658669                        if (ShouldMerge(leaf, previousLeaf)) 
    659                         {                        
     670                        { 
    660671                                MergeBspLeafViewCells(leaf, previousLeaf); 
    661672 
    662673                                ++ merged; 
    663674                        } 
    664                  
     675 
    665676                        previousLeaf = leaf; 
    666677                } 
     
    673684 
    674685        Debug << "Postprocessing: Merged " << merged << " view cells in " 
    675                   << TimeDiff(startTime, GetTime()) *1e-3 << " secs"  
     686                  << TimeDiff(startTime, GetTime()) *1e-3 << " secs" 
    676687                  << "using " << (int)mBspRays.size() << " samples" << endl << endl; 
    677          
     688 
    678689        CLEAR_CONTAINER(mBspRays); 
    679690 
     
    704715        CLEAR_CONTAINER(mBspRays); 
    705716        ConstructBspRays(sampleRays, mVisualizationSamples); 
    706          
     717 
    707718        if (1) // export view cells 
    708719        { 
     
    715726                        delete exporter; 
    716727                } 
    717                  
     728 
    718729                cout << "finished" << endl; 
    719         }        
     730        } 
    720731 
    721732        //-- visualization of the BSP splits 
    722733        bool exportSplits = false; 
    723734        environment->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits); 
    724          
     735 
    725736        if (exportSplits) 
    726737        { 
     
    734745 
    735746 
    736 inline bool vc_gt(ViewCell *a, ViewCell *b)  
    737 {  
     747inline bool vc_gt(ViewCell *a, ViewCell *b) 
     748{ 
    738749        return a->GetPvs().GetSize() > b->GetPvs().GetSize(); 
    739750} 
     
    744755        Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d"); 
    745756 
    746         if (exporter)  
    747         {        
    748                 Material m;  
     757        if (exporter) 
     758        { 
     759                Material m; 
    749760                m.mDiffuseColor = RgbColor(1, 0, 0); 
    750761                exporter->SetForcedMaterial(m); 
    751762                exporter->SetWireframe(); 
    752                  
     763 
    753764                exporter->ExportBspSplits(*mBspTree, true); 
    754765 
     
    759770 
    760771                exporter->SetFilled(); 
    761                                  
     772 
    762773                // export rays 
    763774                if (0) 
    764775                { 
    765776                        VssRayContainer outRays; 
    766                  
     777 
    767778                        int raysSize = min((int)mBspRays.size(), mVisualizationSamples); 
    768779 
     
    770781                                // only rays piercing geometry 
    771782                                outRays.push_back(mBspRays[i]->vssRay); 
    772                                                  
    773                         // export rays  
     783 
     784                        // export rays 
    774785                        exporter->ExportRays(outRays, RgbColor(1, 1, 0)); 
    775786                } 
     
    786797{ 
    787798        const int leafOut = 10; 
    788          
     799 
    789800        ViewCell::NewMail(); 
    790801 
    791802        //-- some rays for output 
    792803        const int raysOut = min((int)mBspRays.size(), mVisualizationSamples); 
    793          
     804 
    794805        cout << "visualization using " << mVisualizationSamples << " samples" << endl; 
    795806        Debug << "\nOutput view cells: " << endl; 
    796          
     807 
    797808        // sort view cells to get largest view cells 
    798809#if 0 
    799810        stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
    800811#endif 
    801         int limit = min(leafOut, (int)mViewCells.size());  
    802                  
     812        int limit = min(leafOut, (int)mViewCells.size()); 
     813 
    803814        for (int i = 0; i < limit; ++ i) 
    804815        { 
     
    815826#if 0 
    816827                // check whether we can add the current ray to the output rays 
    817                 for (int k = 0; k < raysOut; ++ k)  
     828                for (int k = 0; k < raysOut; ++ k) 
    818829                { 
    819830                        BspRay *ray = mBspRays[k]; 
     
    821832                        { 
    822833                                BspLeaf *leaf = ray->intersections[j].mLeaf; 
    823                                 if (vc == leaf->GetViewCell())  
     834                                if (vc == leaf->GetViewCell()) 
    824835                                        vcRays.push_back(ray->vssRay); 
    825836                        } 
     
    830841 
    831842                Exporter *exporter = Exporter::GetExporter(s); 
    832                          
     843 
    833844                exporter->SetWireframe(); 
    834845 
     
    841852                else 
    842853                { 
    843                         PolygonContainer vcGeom; 
    844                          
     854                        BspNodeGeometry vcGeom; 
     855 
    845856                        //-- export view cell 
    846857                        mBspTree->ConstructGeometry(vc, vcGeom); 
    847                         exporter->ExportPolygons(vcGeom); 
    848                         CLEAR_CONTAINER(vcGeom); 
    849                 } 
    850                          
    851                 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()  
     858                        exporter->ExportPolygons(vcGeom.mPolys); 
     859                } 
     860 
     861                Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 
    852862                          << ", piercing rays=" << (int)vcRays.size() 
    853863                          << ", leaves=" << (int)vc->mLeaves.size() << endl; 
    854864 
    855                          
     865 
    856866                // export rays piercing this view cell 
    857867#if 0 
     
    871881 
    872882                // output PVS of view cell 
    873                 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it)  
     883                for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 
    874884                { 
    875885                        Intersectable *intersect = (*it).first; 
     
    882892                                exporter->ExportIntersectable(intersect); 
    883893                                intersect->Mail(); 
    884                         }                        
    885                 } 
    886                                  
     894                        } 
     895                } 
     896 
    887897                DEL_PTR(exporter); 
    888898                cout << "finished" << endl; 
     
    895905bool BspViewCellsManager::MergeBspLeafViewCells(BspLeaf *front, BspLeaf *back) const 
    896906{ 
    897         BspViewCell *viewCell =  
    898                 dynamic_cast<BspViewCell *>(MergeViewCells(*front->GetViewCell(),  
     907        BspViewCell *viewCell = 
     908                dynamic_cast<BspViewCell *>(MergeViewCells(*front->GetViewCell(), 
    899909                                                                                                   *back->GetViewCell())); 
    900          
     910 
    901911        if (!viewCell) 
    902912                return false; 
     
    910920 
    911921        vector<BspLeaf *>::const_iterator it; 
    912          
     922 
    913923        for (it = fLeaves.begin(); it != fLeaves.end(); ++ it) 
    914924        { 
     
    921931                viewCell->mLeaves.push_back(*it); 
    922932        } 
    923          
     933 
    924934        DEL_PTR(fVc); 
    925935        DEL_PTR(bVc); 
     
    940950        if (fvc->GetPvs().GetSize() + fdiff < mMaxPvs) 
    941951        { 
    942                 if ((fvc->GetPvs().GetSize() < mMinPvs) ||       
     952                if ((fvc->GetPvs().GetSize() < mMinPvs) || 
    943953                        (bvc->GetPvs().GetSize() < mMinPvs) || 
    944954                        ((fdiff < mMinPvsDif) && (bvc->GetPvs().Diff(fvc->GetPvs()) < mMinPvsDif))) 
     
    947957                } 
    948958        } 
    949          
     959 
    950960        return false; 
    951961} 
     
    979989 
    980990 
    981 void BspViewCellsManager::ExportColor(Exporter *exporter,  
     991void BspViewCellsManager::ExportColor(Exporter *exporter, 
    982992                                                                          ViewCell *vc) const 
    983993{ 
     
    9941004        case 1: // pvs 
    9951005                { 
    996                         importance = (float)vc->GetPvs().GetSize() /  
     1006                        importance = (float)vc->GetPvs().GetSize() / 
    9971007                                (float)mViewCellsStats.maxPvs; 
    9981008                } 
     
    10021012                        BspViewCell *bspVc = dynamic_cast<BspViewCell *>(vc); 
    10031013 
    1004                         importance = (float)bspVc->mLeaves.size() /  
     1014                        importance = (float)bspVc->mLeaves.size() / 
    10051015                                (float)mViewCellsStats.maxLeaves; 
    10061016                } 
     
    10191029        m.mDiffuseColor.r = importance; 
    10201030        m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r; 
    1021          
     1031 
    10221032        exporter->SetForcedMaterial(m); 
    10231033} 
    10241034 
    1025 void BspViewCellsManager::ExportVcGeometry(Exporter *exporter,  
     1035void BspViewCellsManager::ExportVcGeometry(Exporter *exporter, 
    10261036                                                                                 ViewCell *vc) const 
    10271037{ 
     
    10301040        else 
    10311041        { 
    1032                 PolygonContainer cell; 
     1042                BspNodeGeometry geom; 
    10331043                mBspTree->ConstructGeometry( 
    1034                         dynamic_cast<BspViewCell *>(vc), cell); 
    1035                 exporter->ExportPolygons(cell); 
    1036         } 
     1044                        dynamic_cast<BspViewCell *>(vc), geom); 
     1045                exporter->ExportPolygons(geom.mPolys); 
     1046        } 
     1047} 
     1048 
     1049 
     1050void BspViewCellsManager::CreateMesh(ViewCell *vc) 
     1051{ 
    10371052} 
    10381053 
     
    10481063/*                   KdViewCellsManager implementation               */ 
    10491064/**********************************************************************/ 
     1065 
     1066 
    10501067 
    10511068KdViewCellsManager::KdViewCellsManager(KdTree *kdTree): 
     
    10851102} 
    10861103 
    1087 int KdViewCellsManager::Construct(const ObjectContainer &objects,  
     1104int KdViewCellsManager::Construct(const ObjectContainer &objects, 
    10881105                                                                  const VssRayContainer &rays) 
    10891106{ 
     
    10971114        // create the view cells 
    10981115        mKdTree->CreateAndCollectViewCells(mViewCells); 
    1099          
     1116 
    11001117        // cast rays 
    11011118        ComputeSampleContributions(rays); 
     
    11121129} 
    11131130 
    1114 int KdViewCellsManager::PostProcess(const ObjectContainer &objects,  
     1131int KdViewCellsManager::PostProcess(const ObjectContainer &objects, 
    11151132                                                                        const VssRayContainer &rays) 
    11161133{ 
     
    11351152        { 
    11361153                const int leafOut = 10; 
    1137                  
     1154 
    11381155                ViewCell::NewMail(); 
    1139    
     1156 
    11401157                //-- some rays for output 
    11411158                const int raysOut = min((int)sampleRays.size(), mVisualizationSamples); 
     
    11441161                //-- some random view cells and rays for output 
    11451162                vector<KdLeaf *> kdLeaves; 
    1146                  
     1163 
    11471164                for (int i = 0; i < leafOut; ++ i) 
    11481165                        kdLeaves.push_back(dynamic_cast<KdLeaf *>(mKdTree->GetRandomLeaf())); 
    1149                  
     1166 
    11501167                for (int i = 0; i < kdLeaves.size(); ++ i) 
    11511168                { 
    11521169                        KdLeaf *leaf = kdLeaves[i]; 
    11531170                        RayContainer vcRays; 
    1154                          
     1171 
    11551172                        cout << "creating output for view cell " << i << " ... "; 
    1156 #if 0                    
     1173#if 0 
    11571174                        // check whether we can add the current ray to the output rays 
    1158                         for (int k = 0; k < raysOut; ++ k)  
     1175                        for (int k = 0; k < raysOut; ++ k) 
    11591176                        { 
    11601177                                Ray *ray = sampleRays[k]; 
    1161                                  
     1178 
    11621179                                for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
    11631180                                { 
    11641181                                        BspLeaf *leaf2 = ray->bspIntersections[j].mLeaf; 
    1165                                          
    1166                                         if (leaf->GetViewCell() == leaf2->GetViewCell())  
     1182 
     1183                                        if (leaf->GetViewCell() == leaf2->GetViewCell()) 
    11671184                                        { 
    11681185                                                vcRays.push_back(ray); 
     
    11701187                                } 
    11711188                        } 
    1172 #endif                   
     1189#endif 
    11731190                        Intersectable::NewMail(); 
    1174                          
     1191 
    11751192                        ViewCell *vc = leaf->mViewCell; 
    1176                          
     1193 
    11771194                        //bspLeaves[j]->Mail(); 
    11781195                        char s[64]; sprintf(s, "kd-pvs%04d.x3d", i); 
    1179                          
     1196 
    11801197                        Exporter *exporter = Exporter::GetExporter(s); 
    11811198                        exporter->SetFilled(); 
     
    11831200                        exporter->SetWireframe(); 
    11841201                        //exporter->SetFilled(); 
    1185                          
     1202 
    11861203                        Material m;//= RandomMaterial(); 
    11871204                        m.mDiffuseColor = RgbColor(1, 1, 0); 
    11881205                        exporter->SetForcedMaterial(m); 
    1189                          
     1206 
    11901207                        AxisAlignedBox3 box = mKdTree->GetBox(leaf); 
    11911208                        exporter->ExportBox(box); 
    11921209 
    1193                         Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()  
     1210                        Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 
    11941211                                << ", piercing rays=" << (int)vcRays.size() << endl; 
    1195                          
     1212 
    11961213                        // export rays piercing this view cell 
    1197                         exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0));   
    1198                          
     1214                        exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0)); 
     1215 
    11991216                        m.mDiffuseColor = RgbColor(1, 0, 0); 
    12001217                        exporter->SetForcedMaterial(m); 
    1201                          
     1218 
    12021219                        // exporter->SetWireframe(); 
    12031220                        exporter->SetFilled(); 
    1204                          
     1221 
    12051222                        ObjectPvsMap::iterator it, it_end = vc->GetPvs().mEntries.end(); 
    12061223                        // output PVS of view cell 
    1207                         for (it = vc->GetPvs().mEntries.begin(); it !=  it_end; ++ it)  
     1224                        for (it = vc->GetPvs().mEntries.begin(); it !=  it_end; ++ it) 
    12081225                        { 
    12091226                                Intersectable *intersect = (*it).first; 
     
    12121229                                        exporter->ExportIntersectable(intersect); 
    12131230                                        intersect->Mail(); 
    1214                                 }                        
     1231                                } 
    12151232                        } 
    1216                          
     1233 
    12171234                        DEL_PTR(exporter); 
    12181235                        cout << "finished" << endl; 
     
    12261243                { 
    12271244                        VssRay *ray = sampleRays[i]; 
    1228                  
     1245 
    12291246                        // check whether we can add this to the rays 
    1230                         for (int j = 0; j < pvsOut; j++)  
     1247                        for (int j = 0; j < pvsOut; j++) 
    12311248                        { 
    12321249                                if (objects[j] == ray->mTerminationObject) 
     
    12371254                } 
    12381255 
    1239                 if (exportRays)  
     1256                if (exportRays) 
    12401257                { 
    12411258                        Exporter *exporter = NULL; 
     
    12431260                        exporter->SetWireframe(); 
    12441261                        exporter->ExportKdTree(*mKdTree); 
    1245                  
    1246                         for (i=0; i < pvsOut; i++)  
     1262 
     1263                        for (i=0; i < pvsOut; i++) 
    12471264                                exporter->ExportRays(rays[i], RgbColor(1, 0, 0)); 
    12481265 
    12491266                        exporter->SetFilled(); 
    1250                  
     1267 
    12511268                        delete exporter; 
    12521269                } 
    12531270 
    1254                 for (int k=0; k < pvsOut; k++)  
     1271                for (int k=0; k < pvsOut; k++) 
    12551272                { 
    12561273                        Intersectable *object = objects[k]; 
    1257                         char s[64];      
     1274                        char s[64]; 
    12581275                        sprintf(s, "sample-pvs%04d.x3d", k); 
    12591276 
    12601277                        Exporter *exporter = Exporter::GetExporter(s); 
    12611278                        exporter->SetWireframe(); 
    1262                  
     1279 
    12631280                        KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 
    12641281                        Intersectable::NewMail(); 
    1265                          
     1282 
    12661283                        // avoid adding the object to the list 
    12671284                        object->Mail(); 
    12681285                        ObjectContainer visibleObjects; 
    1269              
    1270                         for (; i != object->mKdPvs.mEntries.end(); i++)  
     1286 
     1287                        for (; i != object->mKdPvs.mEntries.end(); i++) 
    12711288                        { 
    12721289                                KdNode *node = (*i).first; 
    12731290                                exporter->ExportBox(mKdTree->GetBox(node)); 
    1274                  
     1291 
    12751292                                mKdTree->CollectObjects(node, visibleObjects); 
    12761293                        } 
    1277                  
     1294 
    12781295                        exporter->ExportRays(rays[k],  RgbColor(0, 1, 0)); 
    12791296                        exporter->SetFilled(); 
    1280                          
     1297 
    12811298                        for (int j = 0; j < visibleObjects.size(); j++) 
    12821299                                exporter->ExportIntersectable(visibleObjects[j]); 
    1283                          
     1300 
    12841301                        Material m; 
    12851302                        m.mDiffuseColor = RgbColor(1, 0, 0); 
    12861303                        exporter->SetForcedMaterial(m); 
    12871304                        exporter->ExportIntersectable(object); 
    1288                  
     1305 
    12891306                        delete exporter; 
    12901307                } 
    1291         }                
     1308        } 
    12921309} 
    12931310 
     
    13001317 
    13011318 
    1302 void KdViewCellsManager::ExportVcGeometry(Exporter *exporter,  
     1319void KdViewCellsManager::ExportVcGeometry(Exporter *exporter, 
    13031320                                                                                  ViewCell *vc) const 
    13041321{ 
     
    13351352 
    13361353 
     1354void KdViewCellsManager::CreateMesh(ViewCell *vc) 
     1355{ 
     1356} 
     1357 
    13371358/**********************************************************************/ 
    13381359/*                   VspKdViewCellsManager implementation             */ 
     
    13401361 
    13411362 
    1342 VspKdViewCellsManager::VspKdViewCellsManager(VspKdTree *vspKdTree,  
     1363VspKdViewCellsManager::VspKdViewCellsManager(VspKdTree *vspKdTree, 
    13431364                                                                                         int constructionSamples): 
    1344 ViewCellsManager(constructionSamples),  
     1365ViewCellsManager(constructionSamples), 
    13451366mVspKdTree(vspKdTree) 
    13461367{ 
     
    13641385} 
    13651386 
     1387 
    13661388void VspKdViewCellsManager::CollectViewCells() 
    13671389{ 
     
    13691391} 
    13701392 
    1371 int VspKdViewCellsManager::Construct(const ObjectContainer &objects,  
     1393int VspKdViewCellsManager::Construct(const ObjectContainer &objects, 
    13721394                                                                         const VssRayContainer &rays) 
    13731395{ 
     
    13751397        if (ViewCellsConstructed()) 
    13761398                return 0; 
    1377                  
     1399 
    13781400        VssRayContainer constructionRays; 
    13791401        VssRayContainer savedRays; 
    13801402 
    1381         GetRaySets(rays,  
    1382                            mConstructionSamples,  
    1383                            constructionRays,  
     1403        GetRaySets(rays, 
     1404                           mConstructionSamples, 
     1405                           constructionRays, 
    13841406                           &savedRays); 
    1385          
    1386         Debug << "constructing vsp kd tree using "  
     1407 
     1408        Debug << "constructing vsp kd tree using " 
    13871409                  << (int)constructionRays.size() << " samples" << endl; 
    13881410 
     
    13971419 
    13981420        // collapse siblings belonging to the same view cell 
     1421        mVspKdTree->RefineViewCells(rays); 
     1422 
     1423                // collapse siblings belonging to the same view cell 
    13991424        mVspKdTree->CollapseTree(); 
    1400  
    1401         // collapse siblings belonging to the same view cell 
    1402         mVspKdTree->RefineViewCells(rays); 
    14031425 
    14041426        // evaluale view cell stats 
     
    14101432        // recast rest of rays 
    14111433        ComputeSampleContributions(savedRays); 
    1412          
    1413         Debug << "Computed remaining ray contribution in " << TimeDiff(startTime, GetTime()) * 1e-3  
     1434 
     1435        Debug << "Computed remaining ray contribution in " << TimeDiff(startTime, GetTime()) * 1e-3 
    14141436                  << " secs" << endl; 
    14151437 
     
    14281450} 
    14291451 
    1430 int VspKdViewCellsManager::PostProcess(const ObjectContainer &objects,  
     1452int VspKdViewCellsManager::PostProcess(const ObjectContainer &objects, 
    14311453                                                                           const VssRayContainer &rays) 
    14321454{ 
     
    14541476 
    14551477        //-- export leaf building blocks 
    1456         Exporter *exporter = Exporter::GetExporter("vspkdtree.x3d");  
     1478        Exporter *exporter = Exporter::GetExporter("vspkdtree.x3d"); 
    14571479        if (!exporter) 
    14581480                return; 
     
    14621484        exporter->ExportVspKdTree(*mVspKdTree); 
    14631485 
    1464         if (mExportGeometry)  
     1486        if (mExportGeometry) 
    14651487                exporter->ExportGeometry(objects); 
    14661488 
    1467         if (mExportRays)  
    1468         { 
    1469                 const float prob = (float)mVisualizationSamples  
     1489        if (mExportRays) 
     1490        { 
     1491                const float prob = (float)mVisualizationSamples 
    14701492                        / ((float)sampleRays.size() + Limits::Small); 
    14711493 
     
    14911513        if (!ViewCellsConstructed()) 
    14921514                return; 
    1493          
     1515 
    14941516        //-- export single view cells 
    14951517        for (int i = 0; i < 10; ++ i) 
     
    14981520                sprintf(s, "vsp_viewcell%04d.x3d", i); 
    14991521                Exporter *exporter = Exporter::GetExporter(s); 
    1500                 const int idx =  
     1522                const int idx = 
    15011523                        (int)RandomValue(0.0, (Real)((int)mViewCells.size() - 1)); 
    15021524 
    1503                 VspKdViewCell *vc = dynamic_cast<VspKdViewCell *>(mViewCells[idx]);  
     1525                VspKdViewCell *vc = dynamic_cast<VspKdViewCell *>(mViewCells[idx]); 
    15041526 
    15051527                cout << "Output view cell " << i << " with pvs size " << vc->GetPvs().GetSize() << endl; 
     
    15081530                Material m; 
    15091531                m.mDiffuseColor = RgbColor(0, 1, 1); 
    1510                                  
     1532 
    15111533                exporter->SetForcedMaterial(m); 
    15121534                exporter->SetWireframe(); 
     
    15171539                if (mExportRays) 
    15181540                { 
    1519                         vector<VspKdLeaf *>::const_iterator it,  
     1541                        vector<VspKdLeaf *>::const_iterator it, 
    15201542                                it_end = vc->mLeaves.end(); 
    15211543 
     
    15401562                                                if ((*it)->mTerminationObject == NULL) 
    15411563                                                        castRays.push_back(*it); 
    1542                                                 else  
     1564                                                else 
    15431565                                                        initRays.push_back(*it); 
    15441566                                } 
     
    15601582                exporter->SetFilled(); 
    15611583 
    1562                 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it)  
     1584                for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 
    15631585                { 
    15641586                        Intersectable *intersect = (*it).first; 
     
    15711593                                exporter->ExportIntersectable(intersect); 
    15721594                                intersect->Mail(); 
    1573                         }                        
     1595                        } 
    15741596                } 
    15751597 
     
    15781600 
    15791601        //-- export final view cells 
    1580         Exporter *exporter = Exporter::GetExporter("vspkdtree_merged.x3d");  
    1581          
     1602        Exporter *exporter = Exporter::GetExporter("vspkdtree_merged.x3d"); 
     1603 
    15821604        //if (exportGeometry) exporter->SetWireframe(); 
    15831605        //else exporter->SetFilled(); 
     
    15851607        ExportViewCells(exporter); 
    15861608 
    1587         if (mExportGeometry)  
     1609        if (mExportGeometry) 
    15881610        { 
    15891611                exporter->SetFilled(); 
     
    15911613        } 
    15921614 
    1593         if (mExportRays)  
    1594         { 
    1595                 const float prob = (float)mVisualizationSamples  
     1615        if (mExportRays) 
     1616        { 
     1617                const float prob = (float)mVisualizationSamples 
    15961618                        / ((float)sampleRays.size() + Limits::Small); 
    1597                  
     1619 
    15981620                exporter->SetWireframe(); 
    1599                          
     1621 
    16001622                VssRayContainer rays; 
    1601                  
     1623 
    16021624                for (int i = 0; i < sampleRays.size(); ++ i) 
    16031625                { 
     
    16051627                        rays.push_back(sampleRays[i]); 
    16061628                } 
    1607                 exporter->ExportRays(rays, RgbColor(1, 0, 0));   
     1629                exporter->ExportRays(rays, RgbColor(1, 0, 0)); 
    16081630        } 
    16091631 
     
    16301652        if (mColorCode == 0) // Random color 
    16311653                return; 
    1632          
     1654 
    16331655        float importance = 0; 
    16341656 
     
    16371659        case 1: // pvs 
    16381660                { 
    1639                         importance = (float)vc->GetPvs().GetSize() /  
     1661                        importance = (float)vc->GetPvs().GetSize() / 
    16401662                                (float)mViewCellsStats.maxPvs; 
    16411663                } 
     
    16451667            VspKdViewCell *vspKdVc = dynamic_cast<VspKdViewCell *>(vc); 
    16461668 
    1647                         importance = (float)vspKdVc->mLeaves.size() /  
     1669                        importance = (float)vspKdVc->mLeaves.size() / 
    16481670                                (float)mViewCellsStats.maxLeaves; 
    16491671                } 
     
    16511673        case 3: // merged tree depth difference 
    16521674                { 
    1653                         //importance = (float)GetMaxTreeDiff(vc) /  
     1675                        //importance = (float)GetMaxTreeDiff(vc) / 
    16541676                        //      (float)(mVspBspTree->GetStatistics().maxDepth * 2); 
    16551677                } 
     
    16681690 
    16691691 
    1670 void VspKdViewCellsManager::ExportVcGeometry(Exporter *exporter,  
     1692void VspKdViewCellsManager::ExportVcGeometry(Exporter *exporter, 
    16711693                                                                                   ViewCell *vc) const 
    16721694{ 
     
    16841706 
    16851707 
    1686 /************************************************************************/ 
    1687 /*                 VspBspViewCellsManager implementation                */ 
    1688 /************************************************************************/ 
    1689  
    1690  
    1691 VspBspViewCellsManager::VspBspViewCellsManager(VspBspTree *vspBspTree,  
     1708void VspKdViewCellsManager::CreateMesh(ViewCell *vc) 
     1709{ 
     1710} 
     1711 
     1712/**************************************************************************/ 
     1713/*                   VspBspViewCellsManager implementation                */ 
     1714/**************************************************************************/ 
     1715 
     1716 
     1717VspBspViewCellsManager::VspBspViewCellsManager(VspBspTree *vspBspTree, 
    16921718                                                                                           int constructionSamples): 
    1693 ViewCellsManager(constructionSamples),  
     1719ViewCellsManager(constructionSamples), 
    16941720mVspBspTree(vspBspTree) 
    16951721{ 
     
    17191745 
    17201746 
    1721 float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell,  
     1747float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell, 
    17221748                                                                                        float objRendercost) const 
    17231749{ 
     
    17431769} 
    17441770 
    1745 int VspBspViewCellsManager::Construct(const ObjectContainer &objects,  
     1771int VspBspViewCellsManager::Construct(const ObjectContainer &objects, 
    17461772                                                                          const VssRayContainer &rays) 
    17471773{ 
    1748   // if view cells were already constructed 
    1749   if (ViewCellsConstructed()) 
    1750         return 0; 
    1751    
    1752   Debug << "Constructing bsp view cells" << endl; 
    1753    
    1754   int sampleContributions = 0; 
    1755    
    1756   VssRayContainer sampleRays; 
    1757    
    1758   int limit = min (mConstructionSamples, (int)rays.size()); 
    1759  
    1760          
     1774        // if view cells were already constructed 
     1775        if (ViewCellsConstructed()) 
     1776                return 0; 
     1777 
     1778        Debug << "Constructing bsp view cells" << endl; 
     1779 
     1780        int sampleContributions = 0; 
     1781 
     1782        VssRayContainer sampleRays; 
     1783 
     1784        int limit = min (mConstructionSamples, (int)rays.size()); 
     1785 
    17611786        VssRayContainer constructionRays; 
    17621787        VssRayContainer savedRays; 
     
    17681793 
    17691794        mVspBspTree->Construct(constructionRays, &mSceneBox); 
    1770          
     1795 
    17711796        Debug << mVspBspTree->GetStatistics() << endl; 
    17721797 
     
    17741799        cout << "collapsing invalid tree regions ... "; 
    17751800        long startTime = GetTime(); 
    1776         int collapsedLeaves = mVspBspTree->CollapseTree();  
     1801        int collapsedLeaves = mVspBspTree->CollapseTree(); 
    17771802        Debug << "collapsed in " << TimeDiff(startTime, GetTime()) * 1e-3 << " seconds" << endl; 
    17781803    cout << "finished" << endl; 
    1779          
     1804 
    17801805        cout << "reseting view cell stats ... "; 
    17811806        ResetViewCells(); 
    17821807        cout << "finished" << endl; 
    1783          
     1808 
    17841809        Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 
    17851810 
     
    17881813                cout << "exporting initial view cells (=leaves) ... "; 
    17891814                Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 
    1790          
     1815 
    17911816                if (exporter) 
    17921817                { 
     
    17971822                        if (0 && mExportRays) 
    17981823                                exporter->ExportRays(rays, RgbColor(1, 1, 1)); 
    1799                          
     1824 
    18001825                        if (mExportGeometry) 
    18011826                                exporter->ExportGeometry(objects); 
    1802                          
     1827 
    18031828                        delete exporter; 
    18041829                } 
     
    18071832 
    18081833        startTime = GetTime(); 
     1834 
     1835        //-- merge the individual view cells: Should be done here because it makes 
     1836        MergeViewCells(rays, objects); 
     1837        //-- refines the merged view cells 
     1838        RefineViewCells(rays); 
     1839        // collapse sibling leaves that share the same view cell 
     1840        mVspBspTree->CollapseTree(); 
     1841 
     1842        // reset view cells and stats 
     1843        ResetViewCells(); 
     1844 
    18091845        cout << "Computing remaining ray contributions ... "; 
    18101846        // recast rest of rays 
     
    18121848        cout << "finished" << endl; 
    18131849 
    1814         Debug << "Computed remaining ray contribution in " << TimeDiff(startTime, GetTime()) * 1e-3  
     1850        Debug << "Computed remaining ray contribution in " << TimeDiff(startTime, GetTime()) * 1e-3 
    18151851                  << " secs" << endl; 
    18161852 
    18171853        cout << "construction finished" << endl; 
     1854 
    18181855        return sampleContributions; 
    18191856} 
    18201857 
    18211858 
    1822 // matt TODO: remove 
    1823 int VspBspViewCellsManager::MergeViewCells(const VssRayContainer &rays) const 
    1824 { 
    1825         vector<BspIntersection>::const_iterator iit; 
    1826         vector<BspRay *>bspRays; 
    1827         int merged = 0; 
    1828  
    1829         mVspBspTree->ConstructBspRays(bspRays, rays); 
    1830  
    1831         for (int i = 0; i < (int)bspRays.size(); ++ i) 
    1832         { 
    1833                 BspRay *ray = bspRays[i]; 
    1834            
    1835                 // traverse leaves stored in the rays and compare and merge consecutive 
    1836                 // leaves (i.e., the neighbors in the tree) 
    1837                 if (ray->intersections.size() < 2) 
    1838                         continue; 
    1839            
    1840                 iit = ray->intersections.begin(); 
    1841  
    1842                 BspLeaf *previousLeaf = (*iit).mLeaf; 
    1843                 ++ iit; 
    1844                  
    1845                 for (; iit != ray->intersections.end(); ++ iit) 
    1846                 { 
    1847                         BspLeaf *leaf = (*iit).mLeaf; 
    1848  
    1849                         if (ShouldMerge(leaf, previousLeaf)) 
    1850                         {                        
    1851                                 mVspBspTree->MergeViewCells(leaf, previousLeaf); 
    1852                                 ++ merged; 
    1853                         } 
    1854                         previousLeaf = leaf; 
    1855                 } 
    1856         } 
    1857         CLEAR_CONTAINER(bspRays); 
    1858  
    1859         return merged; 
    1860 } 
    1861          
    1862  
    1863 int VspBspViewCellsManager::PostProcess(const ObjectContainer &objects,  
    1864                                                                                 const VssRayContainer &rays) 
    1865 { 
    1866         if (!ViewCellsConstructed()) 
    1867         { 
    1868                 Debug << "view cells not constructed" << endl; 
    1869                 return 0; 
    1870         } 
    1871  
     1859void VspBspViewCellsManager::MergeViewCells(const VssRayContainer &rays, 
     1860                                                                                        const ObjectContainer &objects) 
     1861{ 
    18721862        //-- post processing of bsp view cells 
    18731863    int vcSize = 0; 
     
    18881878        //-- merge or subdivide view cells 
    18891879        int merged = 0; 
    1890          
     1880 
    18911881        cout << "starting merge using " << mPostProcessSamples << " samples ... "; 
    18921882        long startTime = GetTime(); 
    18931883 
     1884        // TODO: should be done BEFORE the ray casting 
    18941885        merged = mVspBspTree->MergeViewCells(postProcessRays); 
    18951886 
     
    19011892        Debug << "Postprocessing: Merged " << merged << " view cells in " 
    19021893                  << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl << endl; 
    1903          
     1894 
    19041895        cout << "reseting view cell stats ... "; 
    19051896        ResetViewCells(); 
     
    19341925                cout << "finished" << endl; 
    19351926        } 
    1936  
     1927} 
     1928 
     1929 
     1930void VspBspViewCellsManager::RefineViewCells(const VssRayContainer &rays) 
     1931{ 
    19371932        Debug << "render time before refine:" << endl; 
    19381933        mRenderer->RenderScene(); 
     1934        SimulationStatistics ss; 
    19391935        dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
    19401936    Debug << ss << endl; 
    19411937 
    19421938        cout << "Refining the merged view cells ... "; 
    1943         startTime = GetTime(); 
     1939        long startTime = GetTime(); 
    19441940 
    19451941        // refining the merged view cells 
     
    19531949        Debug << "Postprocessing: refined " << refined << " view cells in " 
    19541950                  << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl << endl; 
    1955          
    1956         // collapse sibling leaves that share the same view cell 
    1957         mVspBspTree->CollapseTree(); 
    1958  
    1959         // reset view cells and stats 
    1960         ResetViewCells(); 
    1961  
    1962         return merged; 
     1951} 
     1952 
     1953int VspBspViewCellsManager::PostProcess(const ObjectContainer &objects, 
     1954                                                                                const VssRayContainer &rays) 
     1955{ 
     1956        if (!ViewCellsConstructed()) 
     1957        { 
     1958                Debug << "view cells not constructed" << endl; 
     1959                return 0; 
     1960        } 
     1961 
     1962        CreateViewCellsMeshes(); 
     1963 
     1964        return 0; 
    19631965} 
    19641966 
     
    19931995bool VspBspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 
    19941996{ 
    1995         return mSceneBox.IsInside(viewPoint) &&  
     1997        return mSceneBox.IsInside(viewPoint) && 
    19961998                   mVspBspTree->ViewPointValid(viewPoint); 
    19971999} 
     
    20262028                        delete exporter; 
    20272029                } 
    2028                  
     2030 
    20292031                cout << "finished" << endl; 
    2030         }        
     2032        } 
    20312033 
    20322034        //-- visualization of the BSP splits 
    20332035        bool exportSplits = false; 
    20342036        environment->GetBoolValue("VspBspTree.Visualization.exportSplits", exportSplits); 
    2035          
     2037 
    20362038        if (exportSplits) 
    20372039        { 
     
    20442046        ExportBspPvs(objects, visRays); 
    20452047} 
    2046          
     2048 
    20472049 
    20482050void VspBspViewCellsManager::ExportSplits(const ObjectContainer &objects, 
     
    20512053        Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d"); 
    20522054 
    2053         if (exporter)  
    2054         {        
    2055                 Material m;  
     2055        if (exporter) 
     2056        { 
     2057                Material m; 
    20562058                m.mDiffuseColor = RgbColor(1, 0, 0); 
    20572059                exporter->SetForcedMaterial(m); 
    20582060                exporter->SetWireframe(); 
    2059                  
     2061 
    20602062                exporter->ExportBspSplits(*mVspBspTree, true); 
    20612063 
     
    20662068 
    20672069                exporter->ResetForcedMaterial(); 
    2068                  
     2070 
    20692071                // export rays 
    20702072                if (mExportRays) 
    20712073                        exporter->ExportRays(rays, RgbColor(1, 1, 0)); 
    2072          
     2074 
    20732075                if (mExportGeometry) 
    20742076                        exporter->ExportGeometry(objects); 
     
    20782080} 
    20792081 
     2082 
    20802083void VspBspViewCellsManager::ExportBspPvs(const ObjectContainer &objects, 
    20812084                                                                                  const VssRayContainer &rays) 
    20822085{ 
    20832086        const int leafOut = 10; 
    2084          
     2087 
    20852088        ViewCell::NewMail(); 
    2086          
     2089 
    20872090        cout << "visualization using " << mVisualizationSamples << " samples" << endl; 
    20882091        Debug << "\nOutput view cells: " << endl; 
    2089          
     2092 
    20902093        // sort view cells to visualize the largest view cells 
    20912094#if 0 
    20922095        stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
    20932096#endif 
    2094         int limit = min(leafOut, (int)mViewCells.size());  
     2097        int limit = min(leafOut, (int)mViewCells.size()); 
    20952098 
    20962099#if 1 
     
    21052108        { 
    21062109                cout << "creating output for view cell " << i << " ... "; 
    2107                  
     2110 
    21082111                VssRayContainer vcRays; 
    21092112                Intersectable::NewMail(); 
     
    21172120#if 1 
    21182121                // check whether we can add the current ray to the output rays 
    2119                 for (int k = 0; k < raysOut; ++ k)  
     2122                for (int k = 0; k < raysOut; ++ k) 
    21202123                { 
    21212124                        BspRay *ray = bspRays[k]; 
     
    21232126                        { 
    21242127                                BspLeaf *leaf = ray->intersections[j].mLeaf; 
    2125                                 if (vc == leaf->GetViewCell())  
     2128                                if (vc == leaf->GetViewCell()) 
    21262129                                        vcRays.push_back(ray->vssRay); 
    21272130                        } 
     
    21372140                exporter->SetForcedMaterial(m); 
    21382141 
    2139                 ExportVcGeometry(exporter, vc);  
    2140                          
    2141                                  
    2142                 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()  
     2142                ExportVcGeometry(exporter, vc); 
     2143 
     2144 
     2145                Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 
    21432146                          << ", piercing rays=" << (int)vcRays.size() 
    21442147                          << ", leaves=" << (int)vc->mLeaves.size() << endl; 
    2145                  
     2148 
    21462149                //-- export rays piercing this view cell 
    21472150#if 1 
     
    21632166 
    21642167                // output PVS of view cell 
    2165                 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it)  
     2168                for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 
    21662169                { 
    21672170                        Intersectable *intersect = (*it).first; 
     
    21742177                                exporter->ExportIntersectable(intersect); 
    21752178                                intersect->Mail(); 
    2176                         }                        
    2177                 } 
    2178                                  
     2179                        } 
     2180                } 
     2181 
    21792182                DEL_PTR(exporter); 
    21802183                cout << "finished" << endl; 
     
    21882191 
    21892192 
    2190 bool VspBspViewCellsManager::ShouldMerge(BspLeaf *front, BspLeaf *back) const 
    2191 { 
    2192         ViewCell *fvc = front->GetViewCell(); 
    2193         ViewCell *bvc = back->GetViewCell(); 
    2194  
    2195         if (fvc == bvc) 
    2196                 return false; 
    2197  
    2198         const int fdiff = fvc->GetPvs().Diff(bvc->GetPvs()); 
    2199  
    2200         if (fvc->GetPvs().GetSize() + fdiff < mMaxPvs) 
    2201         { 
    2202                 if ((fvc->GetPvs().GetSize() < mMinPvs) ||       
    2203                         (bvc->GetPvs().GetSize() < mMinPvs) || 
    2204                         ((fdiff < mMinPvsDif) &&  
    2205                          (bvc->GetPvs().Diff(fvc->GetPvs()) < mMinPvsDif))) 
    2206                 { 
    2207                         return true; 
    2208                 } 
    2209         } 
    2210          
    2211         return false; 
    2212 } 
    2213  
    2214  
    22152193int VspBspViewCellsManager::CastLineSegment(const Vector3 &origin, 
    22162194                                                                                        const Vector3 &termination, 
     
    22212199 
    22222200 
    2223 void VspBspViewCellsManager::ExportColor(Exporter *exporter,  
     2201void VspBspViewCellsManager::ExportColor(Exporter *exporter, 
    22242202                                                                                 ViewCell *vc) const 
    22252203{ 
    22262204        if (mColorCode == 0) // Random color 
    22272205                return; 
    2228          
     2206 
    22292207        float importance = 0; 
    22302208 
     
    22332211        case 1: // pvs 
    22342212                { 
    2235                         importance = (float)vc->GetPvs().GetSize() /  
     2213                        importance = (float)vc->GetPvs().GetSize() / 
    22362214                                (float)mViewCellsStats.maxPvs; 
    22372215                } 
     
    22412219            BspViewCell *bspVc = dynamic_cast<BspViewCell *>(vc); 
    22422220 
    2243                         importance = (float)bspVc->mLeaves.size() /  
     2221                        importance = (float)bspVc->mLeaves.size() / 
    22442222                                (float)mViewCellsStats.maxLeaves; 
    22452223                } 
     
    22472225        case 3: // merge tree differene 
    22482226                { 
    2249                         importance = (float)GetMaxTreeDiff(vc) /  
     2227                        importance = (float)GetMaxTreeDiff(vc) / 
    22502228                                (float)(mVspBspTree->GetStatistics().maxDepth * 2); 
    22512229                } 
     
    22642242 
    22652243 
    2266 void VspBspViewCellsManager::ExportVcGeometry(Exporter *exporter,  
     2244void VspBspViewCellsManager::ExportVcGeometry(Exporter *exporter, 
    22672245                                                                                          ViewCell *vc) const 
    22682246{ 
    22692247#if 1 
     2248    if (vc->GetMesh()) 
     2249        { 
     2250                exporter->ExportMesh(vc->GetMesh()); 
     2251                return; 
     2252        } 
     2253 
    22702254        BspNodeGeometry geom; 
    22712255        mVspBspTree-> 
    2272                 ConstructGeometry(dynamic_cast<BspViewCell *>(vc), geom.mPolys); 
     2256                ConstructGeometry(dynamic_cast<BspViewCell *>(vc), geom); 
    22732257        exporter->ExportPolygons(geom.mPolys); 
    22742258#else 
    2275          
     2259 
    22762260        Material m2; 
    22772261        m2.mDiffuseColor.b = 0.3f + Random(0.7f); 
     
    23242308 
    23252309 
    2326  
    2327  
    2328 ViewCell * 
    2329 VspBspViewCellsManager::GetViewCell(const Vector3 &point) 
     2310ViewCell *VspBspViewCellsManager::GetViewCell(const Vector3 &point) 
    23302311{ 
    23312312  if (!mVspBspTree) 
     
    23332314  return mVspBspTree->GetViewCell(point); 
    23342315} 
     2316 
     2317 
     2318void VspBspViewCellsManager::CreateMesh(ViewCell *vc) 
     2319{ 
     2320        BspNodeGeometry geom; 
     2321        BspViewCell *bspVc = dynamic_cast<BspViewCell *>(vc); 
     2322        mVspBspTree->ConstructGeometry(bspVc, geom); 
     2323 
     2324        Mesh *mesh = new Mesh(); 
     2325        geom.AddToMesh(*mesh); 
     2326        vc->SetMesh(mesh); 
     2327        mMeshContainer.push_back(mesh); 
     2328} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r502 r503  
    2525class ViewCellsStatistics; 
    2626class Exporter; 
     27 
    2728struct BspRay; 
    2829 
     
    171172        virtual void GetPvsStatistics(PvsStatistics &stat); 
    172173 
    173   /** Get a viewcell containing the specified point */ 
    174   virtual ViewCell *GetViewCell(const Vector3 &point) = 0; 
     174        /** Get a viewcell containing the specified point */ 
     175        virtual ViewCell *GetViewCell(const Vector3 &point) = 0; 
    175176   
    176   virtual void 
    177   PrintPvsStatistics(ostream &s); 
     177        virtual void PrintPvsStatistics(ostream &s); 
    178178 
    179179        /** Returns probability that view point lies in one view cell. 
     
    233233        void SetViewSpaceBox(const AxisAlignedBox3 &box); 
    234234 
     235        /** Creates mesh for this view cell. 
     236        */ 
     237        virtual void CreateMesh(ViewCell *vc) = NULL; 
    235238 
    236239protected: 
     
    265268        */ 
    266269        virtual void ExportVcGeometry(Exporter *exporter, ViewCell *vc) const = 0; 
     270 
     271        /** Creates meshes from the view cells. 
     272        */ 
     273        void CreateViewCellsMeshes(); 
    267274 
    268275        /// the view cell corresponding to space ouside the valid view space 
     
    291298        /// the scene bounding box 
    292299        AxisAlignedBox3 mSceneBox; 
     300 
     301        MeshContainer mMeshContainer; 
    293302 
    294303        //-- visualization options 
     
    343352        AxisAlignedBox3 GetSceneBbox() const; 
    344353 
    345   /** Get a viewcell containing the specified point */ 
    346   ViewCell *GetViewCell(const Vector3 &point); 
     354        /** Get a viewcell containing the specified point */ 
     355        ViewCell *GetViewCell(const Vector3 &point); 
     356 
     357        void CreateMesh(ViewCell *vc); 
    347358 
    348359protected: 
     
    411422        /** Prints out statistics of this approach. 
    412423        */ 
    413   //  virtual void PrintStatistics(ostream &s) const; 
    414   ViewCell *GetViewCell(const Vector3 &point) { return NULL; } 
    415  
    416   float GetProbability(ViewCell *viewCell); 
    417   float GetRendercost(ViewCell *viewCell, float objRendercost) const; 
     424        //  virtual void PrintStatistics(ostream &s) const; 
     425        ViewCell *GetViewCell(const Vector3 &point) { return NULL; } 
     426 
     427        float GetProbability(ViewCell *viewCell); 
     428        float GetRendercost(ViewCell *viewCell, float objRendercost) const; 
    418429   
    419   AxisAlignedBox3 GetSceneBbox() const; 
     430        AxisAlignedBox3 GetSceneBbox() const; 
     431 
     432        void CreateMesh(ViewCell *vc); 
    420433 
    421434protected: 
     
    468481                                                ViewCellContainer &viewcells); 
    469482 
    470   ViewCell *GetViewCell(const Vector3 &point) { return NULL; } 
     483        ViewCell *GetViewCell(const Vector3 &point) { return NULL; } 
    471484 
    472485        float GetProbability(ViewCell *viewCell); 
     
    474487 
    475488        AxisAlignedBox3 GetSceneBbox() const; 
     489 
     490        void CreateMesh(ViewCell *vc); 
     491 
    476492protected: 
    477493 
     
    526542         
    527543        AxisAlignedBox3 GetSceneBbox() const; 
    528  
    529   ViewCell *GetViewCell(const Vector3 &point); 
     544         
     545        ViewCell *GetViewCell(const Vector3 &point); 
    530546 
    531547        bool GetViewPoint(Vector3 &viewPoint) const; 
    532548 
    533549        bool ViewPointValid(const Vector3 &viewPoint) const; 
     550 
     551        void CreateMesh(ViewCell *vc); 
     552 
    534553protected: 
    535         /** DEPRECATED 
    536         */ 
    537         int MergeViewCells(const VssRayContainer &rays) const; 
    538  
    539         /** Returns true if front and back leaf should be merged. 
    540         */ 
    541         bool ShouldMerge(BspLeaf *front, BspLeaf *back) const; 
     554 
     555        /** Merges the view cells. 
     556        */ 
     557        void MergeViewCells(const VssRayContainer &rays, const ObjectContainer &objects); 
     558         
     559        void RefineViewCells(const VssRayContainer &rays); 
    542560 
    543561        void CollectViewCells(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r501 r503  
    835835 
    836836 
     837/* 
    837838float VspBspTree::EvalCostRatio(const VspBspTraversalData &tData, 
    838839                                                                const AxisAlignedBox3 &box, 
     
    949950        return  (mCtDivCi + newCost) / oldCost; 
    950951} 
    951  
     952*/ 
    952953 
    953954 
     
    13041305 
    13051306 
    1306 void VspBspTree::CollectLeaves(vector<BspLeaf *> &leaves) const 
     1307void VspBspTree::CollectLeaves(vector<BspLeaf *> &leaves,  
     1308                                                           const bool onlyUnmailed, 
     1309                                                           const int maxPvsSize) const 
    13071310{ 
    13081311        stack<BspNode *> nodeStack; 
     
    13171320                { 
    13181321                        // test if this leaf is in valid view space 
    1319                         if (node->TreeValid()) 
     1322                        BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     1323                        if (leaf->TreeValid() &&  
     1324                                (!onlyUnmailed || leaf->Mailed()) && 
     1325                                ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().GetSize() <= maxPvsSize))) 
    13201326                        { 
    1321                                 BspLeaf *leaf = (BspLeaf *)node; 
    13221327                                leaves.push_back(leaf); 
    13231328                        } 
     
    16411646 
    16421647void VspBspTree::ConstructGeometry(BspNode *n, 
    1643                                                                    BspNodeGeometry &cell) const 
    1644 { 
    1645         ConstructGeometry(n, cell.mPolys); 
    1646 } 
    1647  
    1648  
    1649 void VspBspTree::ConstructGeometry(BspNode *n, 
    1650                                                                    PolygonContainer &cell) const 
     1648                                                                   BspNodeGeometry &geom) const 
    16511649{ 
    16521650        vector<Plane3> halfSpaces; 
     
    17261724 
    17271725                if (candidatePolys[i]) 
    1728                         cell.push_back(candidatePolys[i]); 
     1726                        geom.mPolys.push_back(candidatePolys[i]); 
    17291727        } 
    17301728} 
     
    17321730 
    17331731void VspBspTree::ConstructGeometry(BspViewCell *vc,  
    1734                                                                    PolygonContainer &vcGeom) const 
     1732                                                                   BspNodeGeometry &vcGeom) const 
    17351733{ 
    17361734        vector<BspLeaf *> leaves = vc->mLeaves; 
     
    17451743                                                   const bool onlyUnmailed) const 
    17461744{ 
    1747         PolygonContainer geom; 
     1745        BspNodeGeometry geom; 
    17481746        ConstructGeometry(n, geom); 
    17491747 
     
    17701768                                // test all planes of current node if candidate really 
    17711769                                // is neighbour 
    1772                                 PolygonContainer neighborCandidate; 
     1770                                BspNodeGeometry neighborCandidate; 
    17731771                                ConstructGeometry(node, neighborCandidate); 
    17741772 
     
    17771775                                { 
    17781776                                        const int cf = 
    1779                                                 Polygon3::ClassifyPlane(neighborCandidate, 
     1777                                                Polygon3::ClassifyPlane(neighborCandidate.mPolys, 
    17801778                                                                                                halfSpaces[i], 
    17811779                                                                                                mEpsilon); 
     
    17871785                                if (isAdjacent) 
    17881786                                        neighbors.push_back(dynamic_cast<BspLeaf *>(node)); 
    1789  
    1790                                 CLEAR_CONTAINER(neighborCandidate); 
    17911787                        } 
    17921788                } 
     
    17951791                        BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    17961792 
    1797                         const int cf = Polygon3::ClassifyPlane(geom, 
     1793                        const int cf = Polygon3::ClassifyPlane(geom.mPolys, 
    17981794                                                                                                   interior->GetPlane(), 
    17991795                                                                                                   mEpsilon); 
     
    18131809        } 
    18141810 
    1815         CLEAR_CONTAINER(geom); 
    18161811        return (int)neighbors.size(); 
    18171812} 
     
    18371832                { 
    18381833                        BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    1839  
    18401834                        BspNode *next; 
    1841  
    1842                         PolygonContainer geom; 
     1835                        BspNodeGeometry geom; 
    18431836 
    18441837                        // todo: not very efficient: constructs full cell everytime 
    18451838                        ConstructGeometry(interior, geom); 
    18461839 
    1847                         const int cf = Polygon3::ClassifyPlane(geom, halfspace, mEpsilon); 
     1840                        const int cf =  
     1841                                Polygon3::ClassifyPlane(geom.mPolys, halfspace, mEpsilon); 
    18481842 
    18491843                        if (cf == Polygon3::BACK_SIDE) 
     
    22482242 
    22492243 
    2250 int VspBspTree::CollectMergeCandidates() 
    2251 { 
    2252         vector<BspLeaf *> leaves; 
    2253  
    2254         // collect the leaves, e.g., the "voxels" that will build the view cells 
    2255         CollectLeaves(leaves); 
     2244int VspBspTree::CollectMergeCandidates(const vector<BspLeaf *> leaves) 
     2245{ 
    22562246        BspLeaf::NewMail(); 
    22572247 
     
    22912281        vector<BspRay *> bspRays; 
    22922282 
     2283        long startTime = GetTime(); 
    22932284        ConstructBspRays(bspRays, rays); 
     2285        Debug << (int)bspRays.size() << " bsp rays constructed in " << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 
     2286 
    22942287        map<BspLeaf *, vector<BspLeaf*> > neighborMap; 
    2295  
    22962288        vector<BspIntersection>::const_iterator iit; 
    22972289 
    2298         int leaves = 0; 
     2290        int numLeaves = 0; 
    22992291         
    23002292        BspLeaf::NewMail(); 
     
    23212313                                leaf->mArea * leaf->mPvs->GetSize(); 
    23222314                         
    2323                         ++ leaves; 
     2315                        ++ numLeaves; 
    23242316                } 
    23252317                 
     
    23452337                                        leaf->mArea * leaf->mPvs->GetSize(); 
    23462338 
    2347                                 ++ leaves; 
     2339                                ++ numLeaves; 
    23482340                        } 
    23492341                 
     
    23792371        Debug << "neighbormap size: " << (int)neighborMap.size() << endl; 
    23802372        Debug << "mergequeue: " << (int)mMergeQueue.size() << endl; 
    2381         Debug << "leaves in queue: " << leaves << endl; 
     2373        Debug << "leaves in queue: " << numLeaves << endl; 
    23822374        Debug << "overall cost: " << BspMergeCandidate::sOverallCost << endl; 
    23832375 
    23842376        CLEAR_CONTAINER(bspRays); 
    23852377 
    2386         return leaves; 
     2378        //-- collect the leaves which haven't been found by ray casting 
     2379        vector<BspLeaf *> leaves; 
     2380        CollectLeaves(leaves, true, mMaxPvs); 
     2381        Debug << "found " << (int)leaves.size() << " new leaves" << endl; 
     2382        //CollectMergeCandidates(leaves); 
     2383 
     2384        return numLeaves; 
    23872385} 
    23882386 
     
    24402438                mergeStats.nodes = CollectMergeCandidates(rays); 
    24412439        else 
    2442                 mergeStats.nodes = CollectMergeCandidates(); 
     2440        { 
     2441                vector<BspLeaf *> leaves; 
     2442                CollectLeaves(leaves); 
     2443                mergeStats.nodes = CollectMergeCandidates(leaves); 
     2444        } 
    24432445 
    24442446        mergeStats.collectTime = TimeDiff(startTime, GetTime()); 
     
    27352737} 
    27362738 
     2739#define USE_ASCII 0 
     2740bool VspBspTree::WriteVspBspTree() 
     2741{ 
     2742        char fileName[100]; 
     2743        environment->GetStringValue("VspBspTree.viewCellsFilename", fileName); 
     2744         
     2745        /*VssRayContainer::const_iterator it, it_end = samples.end(); 
     2746         
     2747#if USE_ASCII 
     2748        ofstream samplesOut(fileName); 
     2749        if (!samplesOut.is_open()) 
     2750                return false; 
     2751 
     2752        for (it = samples.begin(); it != it_end; ++ it) 
     2753        { 
     2754                VssRay *ray = *it; 
     2755                int sourceid = ray->mOriginObject ? ray->mOriginObject->mId : -1;                
     2756                int termid = ray->mTerminationObject ? ray->mTerminationObject->mId : -1;        
     2757 
     2758                samplesOut << ray->GetOrigin().x << " " << ray->GetOrigin().y << " " << ray->GetOrigin().z << " "  
     2759                                   << ray->GetTermination().x << " " << ray->GetTermination().y << " " << ray->GetTermination().z << " "  
     2760                                   << sourceid << " " << termid << "\n"; 
     2761        } 
     2762#else 
     2763        ofstream samplesOut(fileName, ios::binary); 
     2764        if (!samplesOut.is_open()) 
     2765                return false; 
     2766 
     2767        for (it = samples.begin(); it != it_end; ++ it) 
     2768        {        
     2769                VssRay *ray = *it; 
     2770                Vector3 origin(ray->GetOrigin()); 
     2771                Vector3 termination(ray->GetTermination()); 
     2772                 
     2773                int sourceid = ray->mOriginObject ? ray->mOriginObject->mId : -1;                
     2774                int termid = ray->mTerminationObject ? ray->mTerminationObject->mId : -1;                
     2775 
     2776                samplesOut.write(reinterpret_cast<char *>(&origin), sizeof(Vector3)); 
     2777                samplesOut.write(reinterpret_cast<char *>(&termination), sizeof(Vector3)); 
     2778                samplesOut.write(reinterpret_cast<char *>(&sourceid), sizeof(int)); 
     2779                samplesOut.write(reinterpret_cast<char *>(&termid), sizeof(int)); 
     2780    } 
     2781#endif 
     2782 
     2783        samplesOut.close(); 
     2784        */ 
     2785        return true; 
     2786} 
     2787 
     2788bool VspBspTree::LoadVspBspTree() 
     2789{ 
     2790        /*std::stable_sort(objects.begin(), objects.end(), ilt); 
     2791        char fileName[100]; 
     2792        environment->GetStringValue("Preprocessor.samplesFilename", fileName); 
     2793         
     2794    Vector3 origin, termination; 
     2795        // HACK: needed only for lower_bound algorithm to find the  
     2796        // intersected objects 
     2797        MeshInstance sObj(NULL); 
     2798        MeshInstance tObj(NULL); 
     2799 
     2800#if USE_ASCII 
     2801        ifstream samplesIn(fileName, ios::binary); 
     2802        if (!samplesIn.is_open()) 
     2803                return false; 
     2804 
     2805        string buf; 
     2806        while (!(getline(samplesIn, buf)).eof()) 
     2807        { 
     2808                sscanf(buf.c_str(), "%f %f %f %f %f %f %d %d",  
     2809                           &origin.x, &origin.y, &origin.z, 
     2810                           &termination.x, &termination.y, &termination.z,  
     2811                           &(sObj.mId), &(tObj.mId)); 
     2812                 
     2813                Intersectable *sourceObj = NULL; 
     2814                Intersectable *termObj = NULL; 
     2815                 
     2816                if (sObj.mId >= 0) 
     2817                { 
     2818                        ObjectContainer::iterator oit = 
     2819                                lower_bound(objects.begin(), objects.end(), &sObj, ilt); 
     2820                        sourceObj = *oit; 
     2821                } 
     2822                 
     2823                if (tObj.mId >= 0) 
     2824                { 
     2825                        ObjectContainer::iterator oit = 
     2826                                lower_bound(objects.begin(), objects.end(), &tObj, ilt); 
     2827                        termObj = *oit; 
     2828                } 
     2829 
     2830                samples.push_back(new VssRay(origin, termination, sourceObj, termObj)); 
     2831        } 
     2832#else 
     2833        ifstream samplesIn(fileName, ios::binary); 
     2834        if (!samplesIn.is_open()) 
     2835                return false; 
     2836 
     2837        while (1) 
     2838        { 
     2839                 samplesIn.read(reinterpret_cast<char *>(&origin), sizeof(Vector3)); 
     2840                 samplesIn.read(reinterpret_cast<char *>(&termination), sizeof(Vector3)); 
     2841                 samplesIn.read(reinterpret_cast<char *>(&(sObj.mId)), sizeof(int)); 
     2842                 samplesIn.read(reinterpret_cast<char *>(&(tObj.mId)), sizeof(int)); 
     2843                 
     2844                 if (samplesIn.eof()) 
     2845                        break; 
     2846 
     2847                Intersectable *sourceObj = NULL; 
     2848                Intersectable *termObj = NULL; 
     2849                 
     2850                if (sObj.mId >= 0) 
     2851                { 
     2852                        ObjectContainer::iterator oit = 
     2853                                lower_bound(objects.begin(), objects.end(), &sObj, ilt); 
     2854                        sourceObj = *oit; 
     2855                } 
     2856                 
     2857                if (tObj.mId >= 0) 
     2858                { 
     2859                        ObjectContainer::iterator oit = 
     2860                                lower_bound(objects.begin(), objects.end(), &tObj, ilt); 
     2861                        termObj = *oit; 
     2862                } 
     2863 
     2864                samples.push_back(new VssRay(origin, termination, sourceObj, termObj)); 
     2865        } 
     2866 
     2867#endif 
     2868        samplesIn.close(); 
     2869*/ 
     2870        return true; 
     2871} 
     2872 
    27372873 
    27382874/************************************************************************/ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r501 r503  
    5656                /// how often this branch has missed the max-cost ratio 
    5757                int mMaxCostMisses; 
    58  
    59  
     58         
    6059                /** Returns average ray contribution. 
    6160                */ 
     
    164163                                   AxisAlignedBox3 *forcedBoundingBox); 
    165164 
    166         /** Returns list of BSP leaves. 
    167         */ 
    168         void CollectLeaves(vector<BspLeaf *> &leaves) const; 
     165        /** Returns list of BSP leaves with pvs smaller than 
     166                a certain threshold. 
     167                @param onlyUnmailed if only the unmailed leaves should be considered 
     168                @param maxPvs the maximal pvs (-1 means unlimited) 
     169        */ 
     170        void CollectLeaves(vector<BspLeaf *> &leaves,  
     171                                           const bool onlyUnmailed = false, 
     172                                           const int maxPvs = -1) const; 
    169173 
    170174        /** Returns box which bounds the whole tree. 
     
    203207                leading to this node. 
    204208        */ 
    205         void ConstructGeometry(BspNode *n, PolygonContainer &cell) const; 
    206  
    207         /** Constructs geometry associated with the half space intersections  
    208                 leading to this node. 
    209         */ 
    210         void ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const; 
    211  
    212         /** Construct geometry and stores it in a geometry node container. 
    213         */ 
    214         void ConstructGeometry(BspNode *n, BspNodeGeometry &cell) const; 
     209        void ConstructGeometry(BspNode *n, BspNodeGeometry &geom) const; 
     210         
     211        /** Construct geometry of view cell. 
     212        */ 
     213        void ConstructGeometry(BspViewCell *vc, BspNodeGeometry &geom) const; 
    215214 
    216215        /** Returns random leaf of BSP tree. 
     
    284283        */ 
    285284        BspViewCell *GetOutOfBoundsCell() const; 
     285 
     286        /** Writes tree to disc. 
     287        */ 
     288        bool WriteVspBspTree(); 
     289 
     290        /** Loads tree from disc. 
     291        */ 
     292        bool LoadVspBspTree(); 
    286293 
    287294protected: 
     
    457464        /** Evaluates cost ratio for axis aligned splits. 
    458465        */ 
    459         float EvalCostRatio(const VspBspTraversalData &tData, 
     466        /*float EvalCostRatio(const VspBspTraversalData &tData, 
    460467                                                const AxisAlignedBox3 &box, 
    461468                                                const int axis, 
     
    464471                                                int &raysFront, 
    465472                                                int &pvsBack, 
    466                                                 int &pvsFront); 
     473                                                int &pvsFront);*/ 
    467474 
    468475        /** Selects an axis aligned split plane. 
     
    542549 
    543550        /** Collects candidates for the merge in the merge queue. 
     551                @param leaves the leaves to be merged 
    544552                @returns number of leaves in queue 
    545553        */ 
    546         int CollectMergeCandidates(); 
     554        int CollectMergeCandidates(const vector<BspLeaf *> leaves); 
    547555        /** Collects candidates for the merge in the merge queue. 
    548556                @returns number of leaves in queue 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp

    r501 r503  
    20072007        } 
    20082008} 
     2009 
    20092010 
    20102011int VspKdTree::FindNeighbors(VspKdLeaf *n, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp

    r492 r503  
    964964        for (it = leaves.begin(); it != it_end; ++ it) 
    965965        { 
    966                 PolygonContainer cell; 
    967                 tree.ConstructGeometry(*it, cell); 
     966                BspNodeGeometry geom; 
     967                tree.ConstructGeometry(*it, geom); 
    968968                 
    969                 ExportPolygons(cell); 
    970  
    971                 CLEAR_CONTAINER(cell); 
     969                ExportPolygons(geom.mPolys); 
    972970        } 
    973971} 
Note: See TracChangeset for help on using the changeset viewer.