- Timestamp:
- 02/08/06 15:05:04 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r601 r605 16 16 #include "RssPreprocessor.h" 17 17 18 #define SAMPLE_AFTER_SUBDIVISION 1 18 19 19 20 … … 189 190 190 191 // TODO: leak? 191 if(0)ComputeSampleContributions(constructionSamples, true, false); 192 if (SAMPLE_AFTER_SUBDIVISION) 193 ComputeSampleContributions(constructionSamples, true, false); 192 194 cout << "finished" << endl; 193 195 … … 211 213 // store viewCells for postprocessing 212 214 const bool storeViewCells = true; 213 if(0)ComputeSampleContributions(postProcessSamples, true, storeViewCells); 215 216 if (SAMPLE_AFTER_SUBDIVISION) 217 ComputeSampleContributions(postProcessSamples, true, storeViewCells); 214 218 // merge the view cells 215 219 PostProcess(preprocessor->mObjects, postProcessSamples); … … 224 228 visualizationSamples); 225 229 226 if(0)ComputeSampleContributions(visualizationSamples, true, storeViewCells); 230 if (SAMPLE_AFTER_SUBDIVISION) 231 ComputeSampleContributions(visualizationSamples, true, storeViewCells); 227 232 228 233 //Debug << "visualizationsamples: " << mVisualizationSamples << " " << visualizationSamples.size() << endl; … … 377 382 for (it = mViewCells.begin(); it != it_end; ++ it) 378 383 { 379 (*it)->UpdateViewCellsStats(mViewCellsStats);384 mViewCellsTree->UpdateViewCellsStats(*it, mViewCellsStats); 380 385 } 381 386 } … … 858 863 859 864 865 float ViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 866 { 867 return mViewCellsTree->GetPvsSize(viewCell) * objRendercost; 868 } 869 870 860 871 float ViewCellsManager::GetAccVcArea() 861 872 { … … 1082 1093 1083 1094 1084 float BspViewCellsManager::GetRendercost(ViewCell *viewCell,1085 float objRendercost) const1086 {1087 return viewCell->GetPvs().GetSize() * objRendercost;1088 }1089 1090 1095 1091 1096 int BspViewCellsManager::CastLineSegment(const Vector3 &origin, … … 1157 1162 // reset view cells and stats 1158 1163 ResetViewCells(); 1164 Debug << "\nView cells after merge:\n" << mViewCellsStats << endl; 1159 1165 1160 1166 int savedColorCode = mColorCode; 1161 1167 1162 1168 //BspLeaf::NewMail(); 1163 1169 if (1) // export merged view cells 1164 1170 { 1165 1171 mColorCode = 0; 1166 cout << "reseting view cells ... "; 1167 ResetViewCells(); 1168 cout << "finished" << endl; 1169 1172 1170 1173 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 1171 Debug << "\nView cells after merge:\n" << mViewCellsStats << endl;1174 1172 1175 1173 1176 cout << "exporting view cells after merge ... "; … … 1387 1390 ExportViewCellGeometry(exporter, vc); 1388 1391 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 1395 1392 // export rays piercing this view cell 1396 1393 exporter->ExportRays(vcRays, RgbColor(0, 1, 0)); … … 1677 1674 } 1678 1675 1676 1679 1677 float KdViewCellsManager::GetProbability(ViewCell *viewCell) 1680 1678 { 1681 1679 // 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 1698 1687 1699 1688 … … 1810 1799 AxisAlignedBox3 box = mKdTree->GetBox(leaf); 1811 1800 exporter->ExportBox(box); 1812 1813 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()1814 << ", piercing rays=" << (int)vcRays.size() << endl;1815 1801 1816 1802 // export rays piercing this view cell … … 1995 1981 float VspKdViewCellsManager::GetProbability(ViewCell *viewCell) 1996 1982 { 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 2010 1991 2011 1992 … … 2144 2125 VspKdViewCell *vc = dynamic_cast<VspKdViewCell *>(mViewCells[idx]); 2145 2126 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;2148 2127 //-- export geometry 2149 2128 Material m; … … 2393 2372 2394 2373 2395 float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell,2396 float objRendercost) const2397 {2398 return viewCell->GetPvs().GetSize() * objRendercost;2399 }2400 2401 2374 2402 2375 bool VspBspViewCellsManager::ViewCellsConstructed() const … … 2515 2488 2516 2489 cout << "Computing remaining ray contributions ... "; 2490 2517 2491 // recast rest of rays 2518 if ( 0)2519 ComputeSampleContributions(savedRays, true, false);2492 if (SAMPLE_AFTER_SUBDIVISION) 2493 ComputeSampleContributions(savedRays, true, false); 2520 2494 cout << "finished" << endl; 2521 2495 … … 2697 2671 2698 2672 VssRayContainer postProcessRays; 2699 if(0)GetRaySets(rays, mPostProcessSamples, postProcessRays); 2673 2674 GetRaySets(rays, mPostProcessSamples, postProcessRays); 2700 2675 2701 2676 Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; … … 2718 2693 RefineViewCells(postProcessRays, objects); 2719 2694 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: " << erc2732 << " dev: " << dev2733 << " totalpvs: " << totalpvs2734 << " avg: " << avg << endl;2735 }2736 2737 2695 //-- render simulation after merge 2738 2739 2740 2741 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); 2742 2700 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; 2746 2705 2747 2706 … … 2758 2717 pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 2759 2718 Debug << "number of entries after compress: " << pvsEntries << endl; 2760 }2761 2762 2763 //-- export refined (shuffled) view cells2764 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 else2812 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;2825 2719 } 2826 2720
Note: See TracChangeset
for help on using the changeset viewer.