Ignore:
Timestamp:
02/08/06 15:05:04 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r601 r605  
    1616#include "RssPreprocessor.h" 
    1717 
     18#define SAMPLE_AFTER_SUBDIVISION 1 
    1819 
    1920 
     
    189190 
    190191                // TODO: leak? 
    191                 if(0)ComputeSampleContributions(constructionSamples, true, false); 
     192                if (SAMPLE_AFTER_SUBDIVISION) 
     193                        ComputeSampleContributions(constructionSamples, true, false); 
    192194                cout << "finished" << endl; 
    193195 
     
    211213        // store viewCells for postprocessing 
    212214        const bool storeViewCells = true; 
    213         if(0)ComputeSampleContributions(postProcessSamples, true, storeViewCells); 
     215 
     216        if (SAMPLE_AFTER_SUBDIVISION) 
     217                ComputeSampleContributions(postProcessSamples, true, storeViewCells); 
    214218        // merge the view cells 
    215219        PostProcess(preprocessor->mObjects, postProcessSamples); 
     
    224228                                        visualizationSamples); 
    225229 
    226         if(0)ComputeSampleContributions(visualizationSamples, true, storeViewCells); 
     230        if (SAMPLE_AFTER_SUBDIVISION) 
     231                ComputeSampleContributions(visualizationSamples, true, storeViewCells); 
    227232 
    228233        //Debug << "visualizationsamples: " << mVisualizationSamples << " " << visualizationSamples.size() << endl; 
     
    377382        for (it = mViewCells.begin(); it != it_end; ++ it) 
    378383        { 
    379                 (*it)->UpdateViewCellsStats(mViewCellsStats); 
     384                mViewCellsTree->UpdateViewCellsStats(*it, mViewCellsStats); 
    380385        } 
    381386} 
     
    858863 
    859864 
     865float ViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
     866{ 
     867        return mViewCellsTree->GetPvsSize(viewCell) * objRendercost; 
     868} 
     869 
     870 
    860871float ViewCellsManager::GetAccVcArea() 
    861872{ 
     
    10821093 
    10831094 
    1084 float BspViewCellsManager::GetRendercost(ViewCell *viewCell,  
    1085                                                                                  float objRendercost) const 
    1086 { 
    1087         return viewCell->GetPvs().GetSize() * objRendercost; 
    1088 } 
    1089  
    10901095 
    10911096int BspViewCellsManager::CastLineSegment(const Vector3 &origin, 
     
    11571162    // reset view cells and stats 
    11581163        ResetViewCells(); 
     1164        Debug << "\nView cells after merge:\n" << mViewCellsStats << endl; 
    11591165 
    11601166        int savedColorCode  = mColorCode; 
    1161  
     1167         
    11621168        //BspLeaf::NewMail(); 
    11631169        if (1) // export merged view cells 
    11641170        { 
    11651171                mColorCode = 0; 
    1166                 cout << "reseting view cells ... "; 
    1167                 ResetViewCells(); 
    1168                 cout << "finished" << endl; 
    1169  
     1172                 
    11701173                Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 
    1171                 Debug << "\nView cells after merge:\n" << mViewCellsStats << endl; 
     1174                 
    11721175 
    11731176                cout << "exporting view cells after merge ... "; 
     
    13871390                ExportViewCellGeometry(exporter, vc); 
    13881391                 
    1389  
    1390                 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) 
    1391                           << ", piercing rays=" << (int)vcRays.size() << endl; 
    1392                          // << ", leaves=" << (int)vc->mLeaves.size() << endl; 
    1393  
    1394  
    13951392                // export rays piercing this view cell 
    13961393                exporter->ExportRays(vcRays, RgbColor(0, 1, 0)); 
     
    16771674} 
    16781675 
     1676 
    16791677float KdViewCellsManager::GetProbability(ViewCell *viewCell) 
    16801678{ 
    16811679        // compute view cell area / volume as subsititute for probability 
    1682 #if 0 
    1683         return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 
    1684 #endif 
    1685 #if 1 
    1686         return GetArea(viewCell) / GetAccVcArea(); 
    1687 #endif 
    1688 #if 0 
    1689         return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 
    1690 #endif 
    1691 } 
    1692  
    1693  
    1694 float KdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
    1695 { 
    1696         return viewCell->GetPvs().GetSize() * objRendercost; 
    1697 } 
     1680        if (0) 
     1681                return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 
     1682        else 
     1683                return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 
     1684} 
     1685 
     1686 
    16981687 
    16991688 
     
    18101799                        AxisAlignedBox3 box = mKdTree->GetBox(leaf); 
    18111800                        exporter->ExportBox(box); 
    1812  
    1813                         Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 
    1814                                 << ", piercing rays=" << (int)vcRays.size() << endl; 
    18151801 
    18161802                        // export rays piercing this view cell 
     
    19951981float VspKdViewCellsManager::GetProbability(ViewCell *viewCell) 
    19961982{ 
    1997         // volume or area substitutes for view point probability 
    1998 #if 0 
    1999         return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 
    2000 #else 
    2001         return GetArea(viewCell) / GetAccVcArea(); 
    2002 #endif 
    2003 } 
    2004  
    2005  
    2006 float VspKdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
    2007 { 
    2008         return viewCell->GetPvs().GetSize() * objRendercost; 
    2009 } 
     1983        // compute view cell area / volume as subsititute for probability 
     1984        if (0) 
     1985                return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 
     1986        else 
     1987                return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 
     1988} 
     1989 
     1990 
    20101991 
    20111992 
     
    21442125                VspKdViewCell *vc = dynamic_cast<VspKdViewCell *>(mViewCells[idx]); 
    21452126 
    2146                 cout << "Output view cell " << i << " with pvs size " << vc->GetPvs().GetSize() << endl; 
    2147                 Debug << "Output view cell " << i << " with pvs size " << vc->GetPvs().GetSize() << endl; 
    21482127                //-- export geometry 
    21492128                Material m; 
     
    23932372 
    23942373 
    2395 float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell, 
    2396                                                                                         float objRendercost) const 
    2397 { 
    2398         return viewCell->GetPvs().GetSize() * objRendercost; 
    2399 } 
    2400  
    24012374 
    24022375bool VspBspViewCellsManager::ViewCellsConstructed() const 
     
    25152488 
    25162489        cout << "Computing remaining ray contributions ... "; 
     2490 
    25172491        // recast rest of rays 
    2518         if (0) 
    2519         ComputeSampleContributions(savedRays, true, false); 
     2492        if (SAMPLE_AFTER_SUBDIVISION) 
     2493                ComputeSampleContributions(savedRays, true, false); 
    25202494        cout << "finished" << endl; 
    25212495 
     
    26972671 
    26982672        VssRayContainer postProcessRays; 
    2699         if(0)GetRaySets(rays, mPostProcessSamples, postProcessRays); 
     2673 
     2674        GetRaySets(rays, mPostProcessSamples, postProcessRays); 
    27002675 
    27012676        Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; 
     
    27182693                RefineViewCells(postProcessRays, objects); 
    27192694 
    2720          
    2721         if (1) 
    2722         {                
    2723                 float totalCost, erc, var, dev, avg; 
    2724                 int totalpvs; 
    2725  
    2726                 mViewCellsStats.Reset(); 
    2727  
    2728         EvaluateRenderStatistics(totalCost, erc, dev, var, totalpvs, avg); 
    2729                  
    2730                 Debug << "statistics after merge "   
    2731                           << " erc: " << erc  
    2732                           << " dev: " << dev 
    2733                           << " totalpvs: " << totalpvs  
    2734                           << " avg: " << avg << endl; 
    2735         } 
    2736  
    27372695        //-- render simulation after merge 
    2738   cout << "\nevaluating bsp view cells render time before compress ... "; 
    2739   dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 
    2740   SimulationStatistics ss; 
    2741   dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
     2696        cout << "\nevaluating bsp view cells render time before compress ... "; 
     2697        dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 
     2698        SimulationStatistics ss; 
     2699        dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
    27422700   
    2743   cout << " finished" << endl; 
    2744   cout << ss << endl; 
    2745   Debug << ss << endl; 
     2701 
     2702        cout << " finished" << endl; 
     2703        cout << ss << endl; 
     2704        Debug << ss << endl; 
    27462705 
    27472706 
     
    27582717                pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 
    27592718                Debug << "number of entries after compress: " << pvsEntries << endl; 
    2760         } 
    2761  
    2762  
    2763         //-- export refined (shuffled) view cells 
    2764         if (0) 
    2765         { 
    2766                 cout << "exporting shuffled view cells ... "; 
    2767  
    2768                 Exporter *exporter = Exporter::GetExporter("shuffled_view_cells.x3d"); 
    2769                 if (exporter) 
    2770                 { 
    2771                         if (1) 
    2772                         { 
    2773                                 exporter->SetWireframe(); 
    2774                                 exporter->ExportBox(mViewSpaceBox); 
    2775                                 exporter->SetFilled(); 
    2776                         } 
    2777  
    2778                         if (mExportGeometry) 
    2779                         { 
    2780                                 exporter->ExportGeometry(objects); 
    2781                         } 
    2782  
    2783                         ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
    2784  
    2785                         Material vm, lm; 
    2786  
    2787                         for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
    2788                         { 
    2789                                 ViewCell *vc = *vit; 
    2790  
    2791                                 vm = RandomMaterial(); 
    2792  
    2793                                 lm = vm; 
    2794  
    2795                                 vm.mDiffuseColor.r -= 0.45f; 
    2796                                 vm.mDiffuseColor.g -= 0.45f; 
    2797                                 vm.mDiffuseColor.b -= 0.45f; 
    2798  
    2799  
    2800                                 ViewCellContainer leaves; 
    2801                                 mViewCellsTree->CollectLeaves(vc, leaves); 
    2802  
    2803                                 ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 
    2804  
    2805                                 for (lit = leaves.begin(); lit != lit_end; ++ lit) 
    2806                                 { 
    2807                                         BspLeaf *leaf = dynamic_cast<BspViewCell *>(*lit)->mLeaf; 
    2808  
    2809                                         if (leaf->Mailed()) 
    2810                                                 exporter->SetForcedMaterial(lm); 
    2811                                         else 
    2812                                                 exporter->SetForcedMaterial(vm); 
    2813  
    2814                                         BspNodeGeometry geom; 
    2815                                         mVspBspTree->ConstructGeometry(leaf, geom); 
    2816                                         exporter->ExportPolygons(geom.mPolys); 
    2817                                 } 
    2818                         } 
    2819  
    2820                         delete exporter; 
    2821                 } 
    2822  
    2823  
    2824                 cout << "finished" << endl; 
    28252719        } 
    28262720 
Note: See TracChangeset for help on using the changeset viewer.