Changeset 483


Ignore:
Timestamp:
12/27/05 19:32:16 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
9 edited

Legend:

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

    r482 r483  
    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 
     
    146146        loadFromFile false 
    147147        #type kdTree 
    148         type vspKdTree 
     148        #type vspKdTree 
    149149        #type bspTree 
    150         #type vspBspTree 
     150        type vspBspTree 
    151151         
    152152        #type sceneDependent 
     
    196196        Termination { 
    197197                maxDepth                40 
    198                 minPvs                  50 
     198                minPvs                  1 
    199199                minRays                 300 
    200200                minSize                 0.1 
    201                 maxCostRatio            1.8 
    202                 missTolerance           2 
    203                 maxRayContribution      0.5 
     201                maxCostRatio            0.9 
     202                missTolerance           6 
     203                maxRayContribution      0.3 
    204204        } 
    205205         
     
    214214        PostProcess { 
    215215                maxCostRatio 0.005 
    216                 minViewCells 300 
     216                minViewCells 50 
    217217                maxPvsSize   50000 
    218218        } 
     
    220220         
    221221        Visualization { 
    222                 exportRays false 
    223                 exportGeometry false 
     222                exportRays true 
     223                exportGeometry true 
    224224        } 
    225225} 
     
    276276                exportSplits true 
    277277                exportRays true 
    278                 exportGeometry false 
     278                exportGeometry true 
    279279        } 
    280280         
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r448 r483  
    11#include "Polygon3.h" 
    22#include "Mesh.h" 
    3 #include "ViewCellBsp.h" // TODO: erase this 
    43#include "Mesh.h" 
    54#include "AxisAlignedBox3.h" 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r482 r483  
    19121912                                                         vector<ViewCell *> &viewcells) 
    19131913{ 
    1914   int hits = 0; 
    1915   stack<BspRayTraversalData> tStack; 
    1916    
    1917   float mint = 0.0f, maxt = 1.0f; 
    1918    
    1919   Intersectable::NewMail(); 
    1920    
    1921   Vector3 entp = origin; 
    1922   Vector3 extp = termination; 
    1923    
    1924   BspNode *node = mRoot; 
    1925   BspNode *farChild = NULL; 
    1926    
    1927   while (1) { 
    1928         if (!node->IsLeaf())  { 
    1929           BspInterior *in = dynamic_cast<BspInterior *>(node); 
    1930            
    1931           Plane3 splitPlane = in->GetPlane(); 
    1932           const int entSide = splitPlane.Side(entp); 
    1933           const int extSide = splitPlane.Side(extp); 
    1934            
    1935           if (entSide < 0) { 
    1936                 node = in->GetBack(); 
    1937                  
    1938                 if(extSide <= 0) // plane does not split ray => no far child 
    1939                   continue; 
    1940                  
    1941                 farChild = in->GetFront(); // plane splits ray 
    1942                  
    1943           } else 
    1944                 if (entSide > 0) { 
    1945                   node = in->GetFront(); 
    1946                    
    1947                   if (extSide >= 0) // plane does not split ray => no far child 
    1948                         continue; 
    1949                    
    1950                   farChild = in->GetBack(); // plane splits ray                  
    1951                 } 
    1952                 else // ray and plane are coincident 
    1953                   { 
    1954                         // WHAT TO DO IN THIS CASE ? 
    1955                         //break; 
    1956                         node = in->GetFront(); 
    1957                         continue; 
    1958                   } 
    1959            
    1960           // push data for far child 
    1961           tStack.push(BspRayTraversalData(farChild, extp, maxt)); 
    1962            
    1963           // find intersection of ray segment with plane 
    1964           float t; 
    1965           extp = splitPlane.FindIntersection(origin, extp, &t); 
    1966           maxt *= t; 
    1967            
    1968         } else { 
    1969           // reached leaf => intersection with view cell 
    1970           BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
    1971            
    1972           if (!leaf->mViewCell->Mailed()) { 
    1973                 viewcells.push_back(leaf->mViewCell); 
    1974                 leaf->mViewCell->Mail(); 
    1975                 hits++; 
    1976           } 
    1977            
    1978           //-- fetch the next far child from the stack 
    1979           if (tStack.empty()) 
    1980                 break; 
    1981        
    1982           entp = extp; 
    1983           mint = maxt; // NOTE: need this? 
    1984            
    1985           BspRayTraversalData &s = tStack.top(); 
    1986            
    1987           node = s.mNode; 
    1988           extp = s.mExitPoint; 
    1989           maxt = s.mMaxT; 
    1990            
    1991           tStack.pop(); 
    1992         } 
    1993   } 
    1994   return hits; 
     1914        int hits = 0; 
     1915        stack<BspRayTraversalData> tStack; 
     1916 
     1917        float mint = 0.0f, maxt = 1.0f; 
     1918 
     1919        Intersectable::NewMail(); 
     1920 
     1921        Vector3 entp = origin; 
     1922        Vector3 extp = termination; 
     1923 
     1924        BspNode *node = mRoot; 
     1925        BspNode *farChild = NULL; 
     1926 
     1927        while (1)  
     1928        { 
     1929                if (!node->IsLeaf())   
     1930                { 
     1931                        BspInterior *in = dynamic_cast<BspInterior *>(node); 
     1932                 
     1933                        Plane3 splitPlane = in->GetPlane(); 
     1934                         
     1935                        const int entSide = splitPlane.Side(entp); 
     1936                        const int extSide = splitPlane.Side(extp); 
     1937 
     1938                        if (entSide < 0)  
     1939                        { 
     1940                                node = in->GetBack(); 
     1941                 
     1942                                if(extSide <= 0) // plane does not split ray => no far child 
     1943                                        continue; 
     1944                 
     1945                                farChild = in->GetFront(); // plane splits ray 
     1946                 
     1947                        }  
     1948                        else if (entSide > 0)  
     1949                        { 
     1950                                node = in->GetFront(); 
     1951                         
     1952                                if (extSide >= 0) // plane does not split ray => no far child 
     1953                                        continue; 
     1954                         
     1955                                farChild = in->GetBack(); // plane splits ray                    
     1956                        } 
     1957                        else // ray and plane are coincident 
     1958                        { 
     1959                                // WHAT TO DO IN THIS CASE ? 
     1960                                //break; 
     1961                                node = in->GetFront(); 
     1962                                continue; 
     1963                        } 
     1964                 
     1965                        // push data for far child 
     1966                        tStack.push(BspRayTraversalData(farChild, extp, maxt)); 
     1967                 
     1968                        // find intersection of ray segment with plane 
     1969                        float t; 
     1970                        extp = splitPlane.FindIntersection(origin, extp, &t); 
     1971                        maxt *= t;   
     1972                }  
     1973                else  
     1974                { 
     1975                        // reached leaf => intersection with view cell 
     1976                        BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     1977                 
     1978                        if (!leaf->mViewCell->Mailed())  
     1979                        { 
     1980                                viewcells.push_back(leaf->mViewCell); 
     1981                                leaf->mViewCell->Mail(); 
     1982                                hits++; 
     1983                        } 
     1984                 
     1985                        //-- fetch the next far child from the stack 
     1986                        if (tStack.empty()) 
     1987                                break; 
     1988             
     1989                        entp = extp; 
     1990                        mint = maxt; // NOTE: need this? 
     1991                 
     1992                        BspRayTraversalData &s = tStack.top(); 
     1993                 
     1994                        node = s.mNode; 
     1995                        extp = s.mExitPoint; 
     1996                        maxt = s.mMaxT; 
     1997                 
     1998                        tStack.pop(); 
     1999                } 
     2000        } 
     2001        return hits; 
    19952002} 
    19962003 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r482 r483  
    286286        ViewCellContainer viewcells; 
    287287         
     288        /*Vector3 origin = ray.mOrigin; 
     289        Vector3 termination = ray.mTermination; 
     290        static Ray hray; 
     291        float tmin = 0, tmax = 1.0; 
     292        hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 
     293        GetSceneBbox().ComputeMinMaxT(hray, &tmin, &tmax); 
     294        if (tmin >= tmax) 
     295                return; 
     296 
     297        if (tmin > 0.0f) 
     298                origin = ray.Extrap(tmin); 
     299         
     300        if (tmax < 1.0f) 
     301                termination = ray.Extrap(tmax);*/ 
     302         
    288303        CastLineSegment(ray.mOrigin, 
    289304                                        ray.mTermination, 
     
    490505                                                                         const VssRayContainer &rays) 
    491506{ 
    492         if (mBspRays.empty()) 
    493                 ConstructBspRays(rays, mConstructionSamples); 
    494          
    495507        if (!ViewCellsConstructed()) 
    496508        { 
     
    551563        vector<BspIntersection>::const_iterator iit; 
    552564 
     565        if (mBspRays.empty()) 
     566                ConstructBspRays(rays, mPostProcessSamples); 
     567         
    553568        for (int i = 0; i < (int)mBspRays.size(); ++ i) 
    554569        {   
     
    614629 
    615630        if (mBspRays.empty()) 
    616                 ConstructBspRays(sampleRays, mConstructionSamples); 
     631                ConstructBspRays(sampleRays, mVisualizationSamples); 
    617632         
    618633        if (1) // export view cells 
     
    881896                ViewCellContainer viewCells; 
    882897 
     898                // cast line segment to get intersections with bsp leaves 
    883899                CastLineSegment(vssRay->mTermination, vssRay->mOrigin, viewCells); 
    884900 
    885901                ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    886                  
    887902                for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    888903                { 
     
    12971312        ExportLeaves(objects, rays); 
    12981313 
     1314        mVspKdTree->CollectMergeCandidates(); 
    12991315        // finally merge kd leaf building blocks to view cells 
    13001316        const int merged = mVspKdTree->MergeLeaves(); 
     
    14081424                VspKdViewCell *vc = dynamic_cast<VspKdViewCell *>(mViewCells[idx]);  
    14091425 
     1426                cout << "Output view cell " << i << " with pvs size " << vc->GetPvs().GetSize() << endl; 
     1427                Debug << "Output view cell " << i << " with pvs size " << vc->GetPvs().GetSize() << endl; 
    14101428                //-- export geometry 
    14111429                Material m; 
     
    14291447 
    14301448                                VssRayContainer vssRays; 
     1449 
     1450                                VssRayContainer castRays; 
     1451                                VssRayContainer initRays; 
     1452 
    14311453                                leaf->GetRays(vssRays); 
    14321454 
    1433                                 VssRayContainer rays; 
    14341455                                VssRayContainer::const_iterator it, it_end = vssRays.end(); 
     1456                                const float prop = 200.0f / (float)vssRays.size(); 
    14351457 
    14361458                                for (it = vssRays.begin(); it != it_end; ++ it) 
    1437                                         rays.push_back(*it); 
    1438                          
    1439                                 exporter->ExportRays(rays, RgbColor(1, 0, 0)); 
     1459                                { 
     1460                                        if (RandomValue(0, 1) < prop) 
     1461                                                if ((*it)->mTerminationObject == NULL) 
     1462                                                        castRays.push_back(*it); 
     1463                                                else  
     1464                                                        initRays.push_back(*it); 
     1465                                } 
     1466 
     1467                                exporter->ExportRays(castRays, RgbColor(1, 0, 0)); 
     1468                                exporter->ExportRays(initRays, RgbColor(0, 1, 0)); 
    14401469                        } 
    14411470                } 
     
    14441473                m.mDiffuseColor = RgbColor(1, 0, 0); 
    14451474                exporter->SetForcedMaterial(m); 
     1475 
     1476                Intersectable::NewMail(); 
    14461477 
    14471478                ObjectPvsMap::const_iterator it, 
     
    14691500        //-- export final view cells 
    14701501        Exporter *exporter = Exporter::GetExporter("vspkdtree_merged.x3d");  
    1471         exporter->SetFilled(); 
     1502         
     1503        /*if (exportGeometry) exporter->SetWireframe(); 
     1504        else exporter->SetFilled();*/ 
     1505 
    14721506        ExportViewCells(exporter); 
    14731507 
     
    14921526                        rays.push_back(sampleRays[i]); 
    14931527                } 
    1494                 exporter->ExportRays(rays, RgbColor(1, 0, 0)); 
     1528                exporter->ExportRays(rays, RgbColor(1, 0, 0));   
    14951529        } 
    14961530 
     
    16441678        GetRaySets(rays, constructionRays, savedRays); 
    16451679         
    1646         mVspBspTree->Construct(constructionRays); 
     1680        mVspBspTree->Construct(constructionRays, sceneBbox); 
    16471681        Debug << mVspBspTree->GetStatistics() << endl; 
    16481682 
     
    16691703                ViewCellContainer viewCells; 
    16701704 
     1705                // cast line segment and store intersections with the rays 
    16711706                CastLineSegment(vssRay->mTermination, vssRay->mOrigin, viewCells); 
    16721707 
     
    16921727                return 0; 
    16931728        } 
    1694  
    1695         if (mBspRays.empty()) 
    1696                 ConstructBspRays(rays, mConstructionSamples); 
    16971729 
    16981730        //-- post processing of bsp view cells 
     
    17171749                        //exporter->SetWireframe(); 
    17181750                        exporter->SetFilled(); 
    1719                          
    17201751                        ExportViewCells(exporter); 
    17211752 
    1722                         if (0) 
     1753                        bool exportGeometry = false; 
     1754                        environment->GetBoolValue("VspBspTree.Visualization.exportGeometry", exportGeometry); 
     1755 
     1756                        if (exportGeometry) 
    17231757                        { 
    17241758                                Material m; 
    17251759                                m.mDiffuseColor = RgbColor(0, 1, 0); 
    17261760                                exporter->SetForcedMaterial(m); 
    1727                                 exporter->SetWireframe(); 
     1761                                exporter->SetFilled(); 
    17281762 
    17291763                                exporter->ExportGeometry(objects); 
     
    17481782        vector<BspIntersection>::const_iterator iit; 
    17491783 
     1784        // matt TODO: remove 
    17501785        if (0) 
    1751         for (int i = 0; i < (int)mBspRays.size(); ++ i) 
    1752         {   
    1753                 BspRay *ray = mBspRays[i]; 
     1786        { 
     1787                if (mBspRays.empty()) 
     1788                        ConstructBspRays(rays, mPostProcessSamples); 
     1789 
     1790                for (int i = 0; i < (int)mBspRays.size(); ++ i) 
     1791                { 
     1792                        BspRay *ray = mBspRays[i]; 
    17541793           
    1755                 // traverse leaves stored in the rays and compare and merge consecutive 
    1756                 // leaves (i.e., the neighbors in the tree) 
    1757                 if (ray->intersections.size() < 2) 
    1758                         continue; 
     1794                        // traverse leaves stored in the rays and compare and merge consecutive 
     1795                        // leaves (i.e., the neighbors in the tree) 
     1796                        if (ray->intersections.size() < 2) 
     1797                                continue; 
    17591798           
    1760                 iit = ray->intersections.begin(); 
    1761  
    1762                 BspLeaf *previousLeaf = (*iit).mLeaf; 
    1763                 ++ iit; 
    1764                  
    1765                 for (; iit != ray->intersections.end(); ++ iit) 
    1766                 { 
    1767                         BspLeaf *leaf = (*iit).mLeaf; 
    1768  
    1769                         if (ShouldMerge(leaf, previousLeaf)) 
    1770                         {                        
    1771                                 MergeVspBspLeafViewCells(leaf, previousLeaf); 
    1772  
    1773                                 ++ merged; 
     1799                        iit = ray->intersections.begin(); 
     1800 
     1801                        BspLeaf *previousLeaf = (*iit).mLeaf; 
     1802                        ++ iit; 
     1803                 
     1804                        for (; iit != ray->intersections.end(); ++ iit) 
     1805                        { 
     1806                                BspLeaf *leaf = (*iit).mLeaf; 
     1807 
     1808                                if (ShouldMerge(leaf, previousLeaf)) 
     1809                                {                        
     1810                                        MergeVspBspLeafViewCells(leaf, previousLeaf); 
     1811                                        ++ merged; 
     1812                                } 
     1813                                previousLeaf = leaf; 
    17741814                        } 
    1775                  
    1776                         previousLeaf = leaf; 
    17771815                } 
    17781816        } 
     
    18081846                return; 
    18091847 
     1848#if 1 
    18101849        if (mBspRays.empty()) 
    1811                 ConstructBspRays(sampleRays, mConstructionSamples); 
    1812          
     1850                ConstructBspRays(sampleRays, mVisualizationSamples); 
     1851#endif 
     1852 
    18131853        if (1) // export view cells 
    18141854        { 
     
    19111951#endif 
    19121952        int limit = min(leafOut, (int)mViewCells.size());  
    1913                  
     1953 
    19141954        for (int i = 0; i < limit; ++ i) 
    19151955        { 
     
    19241964                cout << "creating output for view cell " << i << " ... "; 
    19251965 
    1926 #if 0 
     1966#if 1 
    19271967                // check whether we can add the current ray to the output rays 
    19281968                for (int k = 0; k < raysOut; ++ k)  
     
    19652005                         
    19662006                // export rays piercing this view cell 
     2007#if 1 
     2008                exporter->ExportRays(vcRays, RgbColor(0, 1, 0)); 
     2009#endif 
    19672010#if 0 
    1968                 exporter->ExportRays(vcRays, RgbColor(0, 1, 0)); 
    1969 #else 
    19702011                vector<BspLeaf *>::const_iterator lit, lit_end = vc->mLeaves.end(); 
     2012 
    19712013                for (lit = vc->mLeaves.begin(); lit != lit_end; ++ lit) 
    19722014                        exporter->ExportRays((*lit)->mVssRays); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r482 r483  
    223223} 
    224224 
    225 void VspBspTree::Construct(const VssRayContainer &sampleRays) 
     225void VspBspTree::Construct(const VssRayContainer &sampleRays, 
     226                                                   AxisAlignedBox3 *forcedBoundingBox) 
    226227{ 
    227228    mStat.nodes = 1; 
     
    259260        } 
    260261 
    261         // compute bounding box 
    262         Polygon3::IncludeInBox(polys, mBox); 
     262        //-- compute bounding box 
     263        if (forcedBoundingBox) 
     264                mBox = *forcedBoundingBox; 
     265        else 
     266                Polygon3::IncludeInBox(polys, mBox); 
    263267 
    264268        //-- store rays 
     
    269273                float minT, maxT; 
    270274 
    271                 // TODO: not very efficient to implictly cast between rays types ... 
     275                // TODO: not very efficient to implictly cast between rays types 
    272276                if (mBox.GetRaySegment(*ray, minT, maxT)) 
    273277                { 
     
    18581862                                node = in->GetBack(); 
    18591863 
    1860                                 if(extSide <= 0) // plane does not split ray => no far child 
     1864                                if (extSide <= 0) // plane does not split ray => no far child 
    18611865                                        continue; 
    18621866 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r482 r483  
    159159                created in the leafs and stored in the container 
    160160        */ 
    161         void Construct(const VssRayContainer &sampleRays); 
     161        void Construct(const VssRayContainer &sampleRays, 
     162                                   AxisAlignedBox3 *forcedBoundingBox); 
    162163 
    163164        /** Returns list of BSP leaves. 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp

    r482 r483  
    810810 
    811811        //-- ray density substitute for probability 
    812         if (1) 
     812        if (0) 
    813813        { 
    814814                pBack = (float)raysBack; 
     
    19791979        const Vector3 dir = termination - origin; 
    19801980 
    1981         stack<LineSegmentTraversalData > tStack; 
     1981        stack<LineTraversalData> tStack; 
    19821982 
    19831983        Intersectable::NewMail(); 
     
    20332033                        // case N4 or P4 
    20342034                        float tdist = (position - origin[axis]) / dir[axis]; 
    2035                         //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 
     2035                        tStack.push(LineTraversalData(farChild, extp, maxt)); //TODO 
    20362036                        extp = origin + dir * tdist; 
    20372037                        maxt = tdist; 
     
    20502050                        } 
    20512051 
     2052                        if (1) //matt TODO: REMOVE LATER 
     2053                                leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 
     2054 
    20522055                        // get the next node from the stack 
    20532056                        if (tStack.empty()) 
     
    20572060                        mint = maxt; 
    20582061                         
    2059                         LineSegmentTraversalData &s  = tStack.top(); 
     2062                        LineTraversalData &s  = tStack.top(); 
    20602063                        node = s.mNode; 
    20612064                        extp = s.mExitPoint; 
     
    21392142} 
    21402143 
    2141  
    2142  
    2143 int VspKdTree::MergeLeaves() 
    2144 { 
     2144void VspKdTree::CollectMergeCandidates() 
     2145{ 
     2146        MergeCandidate::sOverallCost = 0; 
    21452147        vector<VspKdLeaf *> leaves; 
    2146         priority_queue<MergeCandidate> mergeQueue; 
    21472148 
    21482149        // collect the leaves, e.g., the "voxels" that will build the view cells 
    21492150        CollectLeaves(leaves); 
    2150  
    2151         int vcSize = (int)leaves.size(); 
    2152         int savedVcSize = vcSize; 
    21532151 
    21542152        VspKdLeaf::NewMail(); 
     
    21782176                        for (nit = neighbors.begin(); nit != nit_end; ++ nit) 
    21792177                        { 
     2178                                // TODO: test if at least one ray goes from one leaf to the other 
    21802179                                MergeCandidate mc = MergeCandidate(leaf, *nit); 
    2181                                 mergeQueue.push(mc); 
     2180                                mMergeQueue.push(mc); 
    21822181 
    21832182                                MergeCandidate::sOverallCost += mc.GetLeaf1Cost(); 
     
    21862185                } 
    21872186        } 
    2188  
     2187} 
     2188 
     2189/* 
     2190void VspKdTree::CollectMergeCandidates(const vector<VspKdRay *> &rays) 
     2191{ 
     2192        MergeCandidate::sOverallCost = 0; 
     2193 
     2194        vector<VspKdIntersection>::const_iterator iit; 
     2195 
     2196        for (int i = 0; i < (int)rays.size(); ++ i) 
     2197        {   
     2198                //VspKdLeaf::NewMail(); 
     2199 
     2200                VspKdRay *ray = rays[i]; 
     2201           
     2202                // traverse leaves stored in the rays and compare and merge consecutive 
     2203                // leaves (i.e., the neighbors in the tree) 
     2204                if (ray->intersections.size() < 2) 
     2205                        continue; 
     2206           
     2207                iit = ray->intersections.begin(); 
     2208 
     2209                BspLeaf *previousLeaf = (*iit).mLeaf; 
     2210         
     2211                ++ iit; 
     2212                 
     2213                for (; iit != ray->intersections.end(); ++ iit) 
     2214                { 
     2215            BspLeaf *leaf = (*iit).mLeaf; 
     2216                         
     2217                        // TODO: how to sort out doubles? 
     2218                        MergeCandidate mc = MergeCandidate(leaf, previousLeaf); 
     2219                        mMergeQueue.push(mc); 
     2220 
     2221                        MergeCandidate::sOverallCost += mc.GetLeaf1Cost(); 
     2222                        MergeCandidate::sOverallCost += mc.GetLeaf2Cost(); 
     2223 
     2224                        previousLeaf = leaf; 
     2225        } 
     2226        } 
     2227} 
     2228*/ 
     2229 
     2230int VspKdTree::MergeLeaves() 
     2231{ 
    21892232        int merged = 0; 
    21902233 
     2234        int vcSize = mStat.nodes / 2 + 1; 
    21912235        // use priority queue to merge leaves 
    2192         while (!mergeQueue.empty() && (vcSize > mMergeMinViewCells) && 
    2193                    (mergeQueue.top().GetMergeCost() <  
     2236        while (!mMergeQueue.empty() && (vcSize > mMergeMinViewCells) && 
     2237                   (mMergeQueue.top().GetMergeCost() <  
    21942238                    mMergeMaxCostRatio * MergeCandidate::sOverallCost)) 
    21952239        { 
    21962240                //Debug << "mergecost: " << mergeQueue.top().GetMergeCost() / MergeCandidate::sOverallCost << " " << mMergeMaxCostRatio << endl; 
    2197                 MergeCandidate mc = mergeQueue.top(); 
    2198                 mergeQueue.pop(); 
     2241                MergeCandidate mc = mMergeQueue.top(); 
     2242                mMergeQueue.pop(); 
    21992243 
    22002244                // both view cells equal! 
     
    22182262                        // validate and reinsert into queue 
    22192263                        mc.SetValid(); 
    2220                         mergeQueue.push(mc); 
     2264                        mMergeQueue.push(mc); 
    22212265                        //Debug << "validate " << mc.GetMergeCost() << endl; 
    22222266                } 
     
    22282272        RepairVcLeafLists(); 
    22292273 
    2230         Debug << "merged " << merged << " of " << savedVcSize << " leaves" << endl; 
     2274        Debug << "merged " << merged << " of " << mStat.nodes / 2 + 1 << " leaves" << endl; 
    22312275 
    22322276        //TODO: should return sample contributions 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h

    r482 r483  
    529529        }; 
    530530         
    531         struct LineSegmentTraversalData  
     531        struct LineTraversalData  
    532532        { 
    533533                VspKdNode *mNode; 
     
    536536                float mMaxT; 
    537537     
    538                 LineSegmentTraversalData () {} 
    539                 LineSegmentTraversalData (VspKdNode *n, 
     538                LineTraversalData () {} 
     539                LineTraversalData (VspKdNode *n, 
    540540                                                                  const Vector3 &p, 
    541541                                                                  const float maxt): 
     
    608608        */ 
    609609        void RefineViewCells(); 
     610 
     611        /** Collects candidates for the merge in the merge queue. 
     612        */ 
     613        void CollectMergeCandidates(); 
    610614 
    611615protected: 
     
    770774         
    771775        ViewCellsManager *mViewCellsManager; 
     776 
     777        priority_queue<MergeCandidate> mMergeQueue; 
     778 
    772779 
    773780        ///////////////////////////// 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp

    r482 r483  
    158158  for (; ri != rays.end(); ri++) { 
    159159    const Vector3 a = (*ri)->GetOrigin(); 
    160         const Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir()); 
    161          
     160        //const Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir()); 
     161        const Vector3 b = (*ri)->GetTermination(); // matt: change again!! 
     162 
    162163    stream<<a.x<<" "<<a.y<<" "<<a.z<<" ,"; 
    163164        stream<<b.x<<" "<<b.y<<" "<<b.z<<" ,\n"; 
Note: See TracChangeset for help on using the changeset viewer.