Changeset 517


Ignore:
Timestamp:
01/11/06 18:13:07 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
4 added
11 edited

Legend:

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

    r513 r517  
    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 
    1717        filename ../data/soda/soda5.dat 
     
    2828 
    2929VssPreprocessor { 
    30         samplesPerPass  500000 
    31         initialSamples 200000 
    32         vssSamples 200000 
     30        samplesPerPass  100000 
     31        initialSamples 300000 
     32        vssSamples 500000 
    3333        vssSamplesPerPass 100000 
    3434        useImportanceSampling true 
     
    169169 
    170170ViewCells { 
    171         loadFromFile false 
    172         exportToFile true 
     171        loadFromFile true 
     172        exportToFile false 
    173173        #type kdTree 
    174174        #type vspKdTree 
     
    179179         
    180180        height 5.0 
    181         maxViewCells 500 
     181        maxViewCells 100 
    182182        #percentage of total visible objects where pvs is considered invalid 
    183         maxPvsRatio 0.1 
     183        maxPvsRatio 1 
     184                 
     185        delayedConstruction true 
     186                 
    184187                 
    185188        PostProcess { 
     
    203206#       filename ../data/vienna/viewcells-25.x3d 
    204207#       filename ../data/vienna/viewcells-large-sel.x3d 
    205         filename ../scripts/viewcells.xml 
     208        filename ../scripts/viewcells_soda.xml 
    206209} 
    207210 
     
    266269        # pvs                  = 1024 
    267270         
    268         splitPlaneStrategy 1026 
     271        splitPlaneStrategy 1024 
    269272         
    270273        # maximal candidates for split planes 
    271274        maxPolyCandidates 100 
    272         maxRayCandidates 100 
     275        #maxRayCandidates 100 
    273276         
    274277        # maximal tested rays for split cost heuristics 
     
    284287        Termination { 
    285288                # parameters used for autopartition 
    286                 minRays                 500 
     289                minRays                 900 
    287290                minPolygons             -1 
    288291                maxDepth                30 
    289                 minPvs                  20 
     292                minPvs                  10 
    290293                minArea                 0.0001 
    291294                #minArea                0.000 
    292                 maxRayContribution      0.5 
    293                 maxCostRatio            0.95 
    294                 missTolerance           5 
     295                maxRayContribution      0.4 
     296                maxCostRatio            0.93 
     297                missTolerance           3 
    295298                #maxAccRayLength        100 
    296299                 
     
    301304                 
    302305                AxisAligned { 
    303                         minRays                 2000 
     306                        minRays                 200000 
    304307                        maxRayContribution      0.5 
    305308                } 
     
    315318        PostProcess { 
    316319                maxCostRatio 0.1 
    317                 minViewCells 200 
     320                minViewCells 100 
    318321                maxPvsSize   1000 
    319322                useRaysForMerge true 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r516 r517  
    12461246        RegisterOption("ViewCells.Visualization.colorCode", 
    12471247                optString, 
    1248                 "-view_cells_visualization.color_code", 
     1248                "-view_cells_visualization_color_code", 
    12491249                "PVS"); 
    12501250 
    12511251        RegisterOption("ViewCells.Visualization.exportRays", 
    12521252                optBool, 
    1253                 "-bsp_visualization.export_rays", 
     1253                "-view_cells_delayed_construction", 
     1254                "false"); 
     1255 
     1256        RegisterOption("ViewCells.delayedConstruction", 
     1257                optBool, 
     1258                "-view_cells_delayed_construction", 
    12541259                "false"); 
    12551260 
    12561261        RegisterOption("ViewCells.Visualization.exportGeometry", 
    12571262                optBool, 
    1258                 "-bsp_visualization.export_geometry", 
     1263                "-view_cells_visualization_export_geometry", 
    12591264                "false"); 
    12601265 
     
    18261831                "vsp_bsp_max_static_mem=",  
    18271832                "8.0"); 
     1833         
    18281834        ////////////////////////////////////////////////////////////////////////////////// 
    18291835} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp

    r516 r517  
    4848GlRenderer::~GlRenderer() 
    4949{ 
     50} 
     51 
     52 
     53static void handleCgError()  
     54{ 
     55    fprintf(stderr, "Cg error: %s\n", cgGetErrorString(cgGetError())); 
     56    exit(1); 
    5057} 
    5158 
     
    147154 
    148155  // cg initialization 
     156  cgSetErrorCallback(handleCgError); 
    149157  sCgContext = cgCreateContext(); 
    150158 
     
    406414{ 
    407415  static int glList = -1; 
    408   if (glList == -1) { 
     416  if (glList != -1) { 
     417        glCallList(glList); 
     418  } else { 
    409419        glList = glGenLists(1); 
    410         glNewList(glList, GL_COMPILE); 
     420        glNewList(glList, GL_COMPILE_AND_EXECUTE); 
    411421        ObjectContainer::const_iterator oi = mObjects.begin(); 
    412422        for (; oi != mObjects.end(); oi++) 
     
    414424        glEndList(); 
    415425  } 
    416   glCallList(glList); 
    417426  return true; 
    418427} 
     
    570579                                                                                           Beam &beam, 
    571580                                                                                           const int desiredSamples, 
    572                                                                                            GlRendererBuffer::BeamSampleStatistics &stat) 
     581                                                                                           BeamSampleStatistics &stat) 
    573582{ 
    574583        // TODO: should not be done every time here 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r508 r517  
    1313#include "ViewCellsParser.h" 
    1414 
     15 
    1516ViewCellsManager::ViewCellsManager(): 
    1617mRenderer(NULL), 
     
    1920mVisualizationSamples(0), 
    2021mTotalAreaValid(false), 
    21 mTotalArea(0.0f) 
     22mTotalArea(0.0f), 
     23mViewCellsFinished(false) 
    2224{ 
    2325        mSceneBox.Initialize(); 
    2426        ParseEnvironment(); 
    2527} 
     28 
    2629 
    2730ViewCellsManager::ViewCellsManager(int constructionSamples): 
     
    2932mRenderer(NULL), 
    3033mPostProcessSamples(0), 
    31 mVisualizationSamples(0) 
     34mVisualizationSamples(0), 
     35mViewCellsFinished(false) 
    3236{ 
    3337        mSceneBox.Initialize(); 
    3438        ParseEnvironment(); 
    3539} 
     40 
    3641 
    3742void ViewCellsManager::ParseEnvironment() 
     
    348353                                  termination, 
    349354                                  viewcells); 
    350  
     355  //Debug << "constribution: " << (int)viewcells.size() << endl; 
    351356  // copy viewcells memory efficiently 
    352357  const bool storeViewcells = false; 
     
    462467 
    463468 
    464 void ViewCellsManager::CreateViewCellsMeshes() 
     469void ViewCellsManager::CreateViewCellMeshes() 
    465470{ 
    466471        // convert to meshes 
     
    469474        for (it = mViewCells.begin(); it != it_end; ++ it) 
    470475        { 
    471                 CreateMesh(*it); 
     476                if (!(*it)->GetMesh()) 
     477                        CreateMesh(*it); 
    472478        } 
    473479} 
     
    18601866        startTime = GetTime(); 
    18611867 
    1862         //-- merge the individual view cells: Should be done here because it makes 
    1863         MergeViewCells(rays, objects); 
    1864         //-- refines the merged view cells 
    1865         RefineViewCells(rays); 
    1866         // collapse sibling leaves that share the same view cell 
    1867         mVspBspTree->CollapseTree(); 
    1868  
    18691868        // reset view cells and stats 
    18701869        ResetViewCells(); 
     
    18911890        int pvsSize = 0; 
    18921891 
    1893         VssRayContainer postProcessRays; 
    1894         GetRaySets(rays, mPostProcessSamples, postProcessRays); 
    1895  
    1896         Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; 
    1897         EvaluateViewCellsStats(); 
    1898         Debug << "\noriginal view cell partition:\n" << mViewCellsStats << endl << endl; 
    1899  
    19001892        mRenderer->RenderScene(); 
    19011893        SimulationStatistics ss; 
     
    19101902 
    19111903        // TODO: should be done BEFORE the ray casting 
    1912         merged = mVspBspTree->MergeViewCells(postProcessRays); 
     1904        merged = mVspBspTree->MergeViewCells(rays); 
    19131905 
    19141906        //-- stats and visualizations 
     
    19781970} 
    19791971 
     1972 
    19801973int VspBspViewCellsManager::PostProcess(const ObjectContainer &objects, 
    19811974                                                                                const VssRayContainer &rays) 
     
    19831976        if (!ViewCellsConstructed()) 
    19841977        { 
    1985                 Debug << "view cells not constructed" << endl; 
     1978                Debug << "postprocess error: no view cells constructed" << endl; 
    19861979                return 0; 
    19871980        } 
     1981        // view cells already finished 
     1982        else if (mViewCellsFinished) 
     1983                return 0; 
     1984 
     1985        VssRayContainer postProcessRays; 
     1986        GetRaySets(rays, mPostProcessSamples, postProcessRays); 
     1987 
     1988        Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; 
     1989        EvaluateViewCellsStats(); 
     1990        Debug << "\nview cell partition after sampling:\n" << mViewCellsStats << endl << endl; 
     1991 
     1992 
     1993        //-- merge the individual view cells: Should be done here because it makes 
     1994        MergeViewCells(postProcessRays, objects); 
     1995        //-- refines the merged view cells 
     1996        RefineViewCells(postProcessRays); 
     1997        // collapse sibling leaves that share the same view cell 
     1998        mVspBspTree->CollapseTree(); 
    19881999 
    19892000        // real meshes are only contructed only at this stage 
    1990         CreateViewCellsMeshes(); 
     2001        CreateViewCellMeshes(); 
     2002 
    19912003        // write view cells to disc 
    19922004        if (mExportViewCells) 
    19932005        { 
    1994                 ExportViewCells("viewcells.xml"); 
     2006                char buff[100]; 
     2007                environment->GetStringValue("ViewCells.filename", buff); 
     2008                string vcFilename(buff); 
     2009 
     2010                ExportViewCells(buff); 
    19952011        } 
    19962012 
     
    23712387        bool success = parser.ParseFile(filename, mVspBspTree, this, objects); 
    23722388        ResetViewCells(); 
    2373          
     2389        CreateViewCellMeshes(); 
     2390 
    23742391        Debug << (int)mViewCells.size() << " view cells loaded" << endl; 
     2392 
     2393        mViewCellsFinished = true; 
    23752394 
    23762395        return success; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r508 r517  
    277277        /** Creates meshes from the view cells. 
    278278        */ 
    279         void CreateViewCellsMeshes(); 
     279        void CreateViewCellMeshes(); 
    280280 
    281281        /** 
     
    320320        bool mExportGeometry; 
    321321        bool mExportRays; 
     322 
     323        bool mViewCellsFinished; 
    322324}; 
    323325 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r511 r517  
    8888        environment->GetBoolValue("VspBspTree.PostProcess.useRaysForMerge", mUseRaysForMerge); 
    8989 
    90         environment->GetIntValue("ViewCells.pvsInvalid", mMaxPvsRatio); 
     90        environment->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio); 
    9191 
    9292        //-- termination criteria for axis aligned split 
     
    311311 
    312312        mMaxPvs = (int)(mMaxPvsRatio * (float)numObj); 
    313  
     313        Debug << "maximal pvs where view cell is valid: " << mMaxPvs << endl; 
    314314        //-- store rays 
    315315        for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
     
    938938        Plane3 plane; 
    939939        float lowestCost = MAX_FLOAT; 
    940                  
     940         
     941        // decides if the first few splits should be only axisAligned 
    941942        const bool onlyAxisAligned  =  
    942943                (mSplitPlaneStrategy & AXIS_ALIGNED) && 
     
    944945                ((int)data.GetAvgRayContribution() < mTermMaxRayContriForAxisAligned); 
    945946         
    946         // split polygons if no axis aligned splits 
    947947        const int limit = onlyAxisAligned ? 0 :  
    948948                Min((int)data.mPolygons->size(), mMaxPolyCandidates); 
     
    20842084                        if (leaf->GetParent()) 
    20852085                                leaf->GetParent()->ReplaceChildLink(node, leaf); 
    2086                                                  
     2086                        else 
     2087                                mRoot = leaf; 
     2088 
    20872089                        ++ collapsed; 
    20882090                        delete interior; 
     
    20992101{ 
    21002102        int collapsed = 0; 
     2103         
    21012104        (void)CollapseTree(mRoot, collapsed); 
     2105 
    21022106        // revalidate leaves 
    2103         RepairVcLeafLists(); 
     2107        RepairViewCellsLeafLists(); 
    21042108 
    21052109        return collapsed; 
     
    21072111 
    21082112 
    2109 void VspBspTree::RepairVcLeafLists() 
     2113void VspBspTree::RepairViewCellsLeafLists() 
    21102114{ 
    21112115        // list not valid anymore => clear 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r511 r517  
    336336        /** Helper function revalidating the view cell leaf list after merge. 
    337337        */ 
    338         void RepairVcLeafLists(); 
     338        void RepairViewCellsLeafLists(); 
    339339 
    340340        /** Evaluates tree stats in the BSP tree leafs. 
     
    692692        int mMaxPvs; 
    693693 
    694         int mMaxPvsRatio; 
     694        float mMaxPvsRatio; 
    695695 
    696696        /// View cell corresponding to the space outside the valid view space 
     
    704704        /// maximal tree memory 
    705705        float mMaxMemory; 
    706  
     706        /// the tree is out of memory 
    707707        bool mOutOfMemory; 
     708 
    708709private: 
    709710         
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp

    r503 r517  
    23602360 
    23612361 
    2362 void VspKdTree::RepairVcLeafLists() 
     2362void VspKdTree::RepairViewCellsLeafLists() 
    23632363{ 
    23642364        // list not valid anymore => clear 
     
    24462446        CollapseTree(mRoot, collapsed); 
    24472447        // revalidate leaves 
    2448         RepairVcLeafLists(); 
     2448        RepairViewCellsLeafLists(); 
    24492449 
    24502450        return collapsed; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h

    r501 r517  
    790790        /** Helper function revalidating the view cell leaf list after merge. 
    791791        */ 
    792         void RepairVcLeafLists(); 
     792        void RepairViewCellsLeafLists(); 
    793793 
    794794        /** Shuffles the leaves, i.e., tests if exchanging 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r508 r517  
    2525  environment->GetIntValue("VssPreprocessor.vssSamplesPerPass", mVssSamplesPerPass); 
    2626  environment->GetBoolValue("VssPreprocessor.useImportanceSampling", mUseImportanceSampling); 
     27  environment->GetBoolValue("ViewCells.delayedConstruction", mDelayedViewCellsConstruction); 
    2728 
    2829  environment->GetBoolValue("VssPreprocessor.loadInitialSamples", mLoadInitialSamples); 
     
    498499 
    499500  // construct view cells 
    500   mViewCellsManager->Construct(mObjects, mVssRays); 
    501  
     501  if (!mDelayedViewCellsConstruction) 
     502        mViewCellsManager->Construct(mObjects, mVssRays); 
     503  
    502504  vssTree = new VssTree; 
    503505  // viewcells = Construct(mVssRays); 
     
    536538  int pass = 0; 
    537539 
    538   /// Rays used for post processing and visualizations 
    539   RayContainer storedRays; 
    540540  // cast view cell samples 
    541541  while (1) { 
     
    570570        cout<<"Average PVS size = "<<avgPvs<<endl; 
    571571 
     572        //Debug << "samples: " << samples << " construction samples " << mViewCellsManager->GetConstructionSamples() << endl; 
     573        // construct view cells after vss 
     574        if (!mViewCellsManager->ViewCellsConstructed() && 
     575                (samples + mInitialSamples >  mViewCellsManager->GetConstructionSamples())) 
     576        { 
     577                VssRayContainer constructionRays; 
     578                vssTree->CollectRays(constructionRays,  
     579                                                         mViewCellsManager->GetConstructionSamples()); 
     580                mViewCellsManager->Construct(mObjects, constructionRays); 
     581        } 
     582 
     583        /// compute view cell contribution of rays 
     584        mViewCellsManager->ComputeSampleContributions(vssRays); 
     585         
    572586        if (numExportRays) { 
    573587          char filename[64]; 
     
    579593          ExportRays(filename, vssRays, numExportRays); 
    580594        } 
    581  
    582         //-- prepare traversal rays for view cell intersections 
    583         /// compute view cell contribution of rays 
    584         mViewCellsManager->ComputeSampleContributions(vssRays); 
    585595 
    586596        samples+=num; 
     
    596606 
    597607 
    598   { 
    599         VssRayContainer storedRays; 
    600         vssTree->CollectRays(storedRays, Max( 
    601                                                                                  mViewCellsManager->GetPostProcessSamples(), 
    602                                                                                  mViewCellsManager->GetVisualizationSamples())); 
    603  
    604     //-- post process view cells 
    605         mViewCellsManager->PostProcess(mObjects, storedRays); 
    606  
    607         //-- several visualizations and statistics 
    608         Debug << "\nview cells after post processing: " << endl; 
    609         mViewCellsManager->PrintStatistics(Debug); 
    610  
    611         mViewCellsManager->Visualize(mObjects, storedRays); 
    612   } 
    613  
     608  VssRayContainer viewCellRays; 
     609   
     610  // compute rays used for view cells construction 
     611  int numRays = Max(mViewCellsManager->GetPostProcessSamples(), 
     612                                        mViewCellsManager->GetVisualizationSamples()); 
     613 
     614  vssTree->CollectRays(viewCellRays, numRays); 
     615   
     616  //-- post process view cells 
     617  mViewCellsManager->PostProcess(mObjects, viewCellRays); 
     618 
     619  //-- several visualizations and statistics 
     620  Debug << "\nview cells after post processing: " << endl; 
     621  mViewCellsManager->PrintStatistics(Debug); 
     622 
     623  mViewCellsManager->Visualize(mObjects, viewCellRays); 
     624   
    614625  //-- render simulation after merge 
    615626  cout << "\nevaluating bsp view cells render time after merge ... "; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.h

    r501 r517  
    3737  VssRayContainer mVssRays; 
    3838         
     39  bool mDelayedViewCellsConstruction; 
     40 
    3941  VssPreprocessor(); 
    4042  ~VssPreprocessor(); 
Note: See TracChangeset for help on using the changeset viewer.