Changeset 1718 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 11/07/06 13:56:58 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1717 r1718 2628 2628 2629 2629 2630 void 2631 ViewCellsManager::UpdatePvsForEvaluation() 2632 { 2633 ObjectPvs objPvs; 2634 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), objPvs); 2630 void ViewCellsManager::UpdatePvsForEvaluation() 2631 { 2632 ObjectPvs objPvs; 2633 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), objPvs); 2635 2634 } 2636 2635 … … 5725 5724 5726 5725 #if 1 5727 #if TEST_EVALUATION5728 void VspOspViewCellsManager::EvalViewCellPartition()5729 {5730 const int castSamples = (int)storedRays.size();5731 char s[64];5732 char statsPrefix[100];5733 5734 Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix);5735 5736 Debug << "view cell stats prefix: " << statsPrefix << endl;5737 5738 // should directional sampling be used?5739 const bool dirSamples = (mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION);5740 5741 cout << "reseting pvs ... ";5742 const bool startFromZero = true;5743 5744 if (startFromZero)5745 {5746 // reset pvs and start over from zero5747 mViewCellsTree->ResetPvs();5748 }5749 else5750 {5751 // statistics before casting more samples5752 cout << "compute new statistics ... ";5753 sprintf(s, "-%09d-eval.log", castSamples);5754 string fName = string(statsPrefix) + string(s);5755 5756 mViewCellsTree->ExportStats(fName);5757 cout << "finished" << endl;5758 }5759 cout << "finished" << endl;5760 5761 cout << "Evaluating view cell partition ... " << endl;5762 5763 VssRayContainer evaluationSamples = storedRays;5764 const int samplingType = mEvaluationSamplingType;5765 5766 cout << "computing sample contributions of " << (int)evaluationSamples.size() << " samples ... ";5767 5768 ComputeSampleContributions(evaluationSamples, true, false);5769 5770 cout << "finished" << endl;5771 5772 cout << "compute new statistics ... ";5773 5774 // propagate pvs or pvs size information5775 ObjectPvs pvs;5776 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs);5777 5778 5779 /////////////////////5780 // $§temporary matt: test render cost5781 5782 sprintf(s, "-%09d-eval.log", castSamples);5783 string fileName = string(statsPrefix) + string(s);5784 5785 ViewCellContainer leaves;5786 5787 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves);5788 float rc = 0;5789 5790 ViewCellContainer::const_iterator vit, vit_end = leaves.end();5791 5792 for (vit = leaves.begin(); vit != vit_end; ++ vit)5793 {5794 ViewCell *vc = *vit;5795 const float pvsCost = vc->GetPvs().EvalPvsCost();5796 const float vol = vc->GetVolume();5797 rc += pvsCost * vol;5798 }5799 5800 Debug << "\nrendercost hack: " << rc / mViewSpaceBox.GetVolume() << endl;5801 mViewCellsTree->ExportStats(fileName);5802 cout << "finished" << endl;5803 5804 disposeRays(evaluationSamples, NULL);5805 }5806 5807 #else5808 5726 5809 5727 void VspOspViewCellsManager::EvalViewCellPartition() … … 5812 5730 int numSamples; 5813 5731 int castSamples = 0; 5732 int oldSamples = 0; 5733 int samplesForStats; 5734 char statsPrefix[100]; 5735 char suffix[100]; 5814 5736 int splitsStepSize; 5815 5737 5816 char str[64]; 5817 5738 5818 5739 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass); 5740 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesForStats", samplesForStats); 5819 5741 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samples", numSamples); 5742 Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 5820 5743 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.stepSize", splitsStepSize); 5821 5822 char statsPrefix[100]; 5823 Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 5824 5744 5745 Debug << "step size: " << splitsStepSize << endl; 5825 5746 Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl; 5826 5747 Debug << "view cell evaluation samples: " << numSamples << endl; 5827 5748 Debug << "view cell stats prefix: " << statsPrefix << endl; 5828 Debug << "step size: " << splitsStepSize << endl; 5749 5750 // should directional sampling be used? 5751 bool dirSamples = 5752 (mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 5829 5753 5830 5754 cout << "reseting pvs ... "; 5831 5755 5832 const bool startFromZero = true;5833 5834 5756 // reset pvs and start over from zero 5835 if (startFromZero) 5836 { 5837 mViewCellsTree->ResetPvs(); 5838 } 5839 else // start from current sampless 5840 { 5841 // statistics before casting more samples 5842 cout << "compute new statistics ... "; 5843 sprintf(str, "-%09d-eval.log", castSamples); 5844 string fName = string(statsPrefix) + string(str); 5845 5846 mViewCellsTree->ExportStats(fName); 5847 cout << "finished" << endl; 5848 } 5849 5757 mViewCellsTree->ResetPvs(); 5758 5850 5759 cout << "finished" << endl; 5851 5760 cout << "Evaluating view cell partition ... " << endl; … … 5853 5762 while (castSamples < numSamples) 5854 5763 { 5855 VssRayContainer evaluationSamples;5856 5857 5764 /////////////// 5858 5765 //-- we have to use uniform sampling strategy for construction rays 5859 5766 5860 //VssRayContainer evaluationSamples;5767 VssRayContainer evaluationSamples; 5861 5768 const int samplingType = mEvaluationSamplingType; 5862 5769 … … 5871 5778 5872 5779 Real timeDiff = TimeDiff(startTime, GetTime()); 5873 Debug << "finished in " << timeDiff * 1e-3 << " secs" << endl; 5874 cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 5875 5780 5781 cout << "finished in " << timeDiff * 1e-3f << " secs" << endl; 5876 5782 cout << "computing sample contributions of " << (int)evaluationSamples.size() << " samples ... "; 5783 5784 Debug << "finished in " << timeDiff * 1e-3f << " secs" << endl; 5877 5785 Debug << "computing sample contributions of " << (int)evaluationSamples.size() << " samples ... "; 5878 5786 … … 5885 5793 Debug << "finished in " << timeDiff * 1e-3 << " secs" << endl; 5886 5794 5887 startTime = GetTime(); 5888 cout << "compute new statistics ... " << endl; 5889 5890 /////////// 5891 //-- output stats 5892 5893 sprintf(str, "-%09d-eval.log", castSamples); 5894 const string splitsFilename = string(statsPrefix) + string(str); 5895 5896 ofstream splitsStr(splitsFilename.c_str()); 5897 mHierarchyManager->EvaluateSubdivision2(splitsStr, splitsStepSize); 5898 5899 timeDiff = TimeDiff(startTime, GetTime()); 5900 cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 5901 Debug << "statistics computed in " << timeDiff * 1e-3 << " secs" << endl; 5902 5795 if ((castSamples >= samplesForStats + oldSamples) || (castSamples >= numSamples)) 5796 { 5797 oldSamples += samplesForStats; 5798 5799 /////////// 5800 //-- output stats 5801 5802 sprintf(suffix, "-%09d-eval.log", castSamples); 5803 const string filename = string(statsPrefix) + string(suffix); 5804 5805 startTime = GetTime(); 5806 cout << "compute new statistics ... " << endl; 5807 5808 ofstream ofstr(filename.c_str()); 5809 mHierarchyManager->EvaluateSubdivision2(ofstr, splitsStepSize); 5810 5811 timeDiff = TimeDiff(startTime, GetTime()); 5812 cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 5813 Debug << "statistics computed in " << timeDiff * 1e-3 << " secs" << endl; 5814 5815 // only for debugging purpose 5816 if (1) 5817 { 5818 ViewCellContainer viewCells; 5819 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), viewCells); 5820 5821 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 5822 int pvsSize = 0; 5823 5824 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 5825 { 5826 pvsSize += (*vit)->GetPvs().GetSize(); 5827 } 5828 5829 cout << "debug entries: " << pvsSize << ", memcost: " << (float)pvsSize * ObjectPvs::GetEntrySize() << endl; 5830 } 5831 } 5832 5903 5833 disposeRays(evaluationSamples, NULL); 5904 5834 } 5835 5905 5836 } 5906 5837 #endif 5907 #endif 5908 } 5838 }
Note: See TracChangeset
for help on using the changeset viewer.