Changeset 1723 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 11/07/06 21:32:10 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1718 r1723 844 844 float minBorder = nodeBbox.Max(axis); 845 845 float maxBorder = nodeBbox.Min(axis); 846 846 847 float areaLeft = 0, areaRight = 0; 847 848 -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1713 r1723 1242 1242 "vss_store_storedInitialSamples=", 1243 1243 "false"); 1244 1245 RegisterOption("VssPreprocessor.useViewSpaceBox", 1246 optBool, 1247 "vss_use_viewspace_box=", 1248 "false"); 1249 1244 1250 1245 1251 1246 … … 1820 1815 "false"); 1821 1816 1822 1817 RegisterOption("Preprocessor.useViewSpaceBox", 1818 optBool, 1819 "preprocessor_use_viewspace_box=", 1820 "false"); 1821 1823 1822 /*************************************************************************/ 1824 1823 /* VSS Preprocessor cells related options */ -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r1707 r1723 234 234 ObjectContainer::const_iterator oit, oit_end = objects.end(); 235 235 236 if ( 0&&!exportSingleMesh)236 if (!exportSingleMesh) 237 237 { 238 238 for (oit = objects.begin(); oit != oit_end; ++ oit) -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1719 r1723 79 79 80 80 81 void HierarchySubdivisionStats::Print(ostream &app) const 82 { 83 app << "#Pass\n" << 0 << endl 84 << "#Splits\n" << mNumSplits << endl 85 << "#TotalRenderCost\n" << mTotalRenderCost << endl 86 << "#TotalEntriesInPvs\n" << mEntriesInPvs << endl 87 << "#Memory\n" << mMemoryCost << endl 88 << "#StepsView\n" << mViewSpaceSplits << endl 89 << "#StepsObject\n" << mObjectSpaceSplits << endl 90 << "#VspOspRatio\n" << VspOspRatio() << endl 91 << "#FullMem\n" << mFullMemory << endl 92 << "#RenderCostDecrease\n" << mRenderCostDecrease << endl 93 << "#FpsPerMb\n" << FpsPerMb() << endl 94 << endl; 95 } 96 97 81 98 void HierarchyManager::ParseEnvironment() 82 99 { … … 265 282 { 266 283 // question: should I also add the mem usage of the hierarchies? 267 const float objectSpaceMem = 0;//GetObjectSpaceMemUsage(); 268 const float viewSpaceMem = 0;//mVspTree->GetMemUsage(); 269 270 // calculate cost in MB 271 const float memoryCost = mHierarchyStats.mMemory / float(1024 * 1024) 272 + objectSpaceMem + viewSpaceMem; 273 274 //cout << "pvs entries " << mHierarchyStats.pvsEntries << endl; 275 AddSubdivisionStats(mHierarchyStats.Leaves(), 276 mHierarchyStats.mRenderCostDecrease, 277 mHierarchyStats.mTotalCost, 278 mHierarchyStats.mPvsEntries, 279 memoryCost, 280 1.0f / (mHierarchyStats.mTotalCost * memoryCost), 281 (float)mVspTree->mVspStats.Leaves() / (float)GetObjectSpaceSubdivisionLeaves() 282 ); 284 const float objectSpaceMem = GetObjectSpaceMemUsage(); 285 const float viewSpaceMem = mVspTree->GetMemUsage(); 286 287 HierarchySubdivisionStats stats; 288 stats.mNumSplits = mHierarchyStats.Leaves(); 289 stats.mTotalRenderCost = mHierarchyStats.mTotalCost; 290 stats.mEntriesInPvs = mHierarchyStats.mPvsEntries; 291 stats.mMemoryCost = mHierarchyStats.mMemory / float(1024 * 1024); 292 stats.mFullMemory = mHierarchyStats.mMemory / float(1024 * 1024) 293 + objectSpaceMem + viewSpaceMem; 294 stats.mViewSpaceSplits = mVspTree->mVspStats.Leaves(); 295 stats.mObjectSpaceSplits = GetObjectSpaceSubdivisionLeaves(); 296 297 stats.Print(mSubdivisionStats); 283 298 } 284 299 … … 299 314 << "#Memory\n" << memory << endl 300 315 << "#FpsPerMb\n" << renderCostPerStorage << endl 301 << "#VspOspRatio\n" << vspOspRatio << endl; 316 << "#VspOspRatio\n" << vspOspRatio << endl 317 << endl; 302 318 } 303 319 … … 882 898 883 899 cout << "\nstarting object space subdivision after " 884 << mVspTree->mVspStats.nodes << " (" << mMinStepsOfSameType << ") " << endl; 900 << mVspTree->mVspStats.nodes << " (" << mMinStepsOfSameType << ") steps, mem=" 901 << mHierarchyStats.mMemory / float(1024 * 1024) << " MB" << endl; 885 902 886 903 SubdivisionCandidate *ospSc = PrepareObjectSpaceSubdivision(sampleRays, objects); … … 897 914 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 898 915 899 cout << "\nstarting view space subdivision at depth"916 cout << "\nstarting view space subdivision at " 900 917 << GetObjectSpaceSubdivisionLeaves() << " (" 901 << mMinStepsOfSameType << ") " << endl; 918 << mMinStepsOfSameType << ") , mem=" 919 << mHierarchyStats.mMemory / float(1024 * 1024) << " MB" << endl; 902 920 903 921 SubdivisionCandidate *vspSc = PrepareViewSpaceSubdivision(sampleRays, objects); … … 1602 1620 1603 1621 1604 static void UpdateStats(ofstream &stats,1605 const int splits,1606 const float totalRenderCost,1607 const int entriesInPvs,1608 const float memoryCost,1609 const int viewSpaceSplits,1610 const int objectSpaceSplits)1611 {1612 stats << "#Pass\n" << 0 << endl1613 << "#Splits\n" << splits << endl1614 << "#TotalRenderCost\n" << totalRenderCost << endl1615 << "#TotalEntriesInPvs\n" << entriesInPvs << endl1616 << "#Memory\n" << memoryCost << endl1617 << "#ViewSpaceSplits\n" << viewSpaceSplits << endl1618 << "#ObjectSpaceSplits\n" << objectSpaceSplits << endl1619 << "#VspOspRatio\n" << (float)viewSpaceSplits / (float)objectSpaceSplits << endl1620 << endl;1621 }1622 1623 1624 1622 class HierarchyNodeWrapper; 1625 1623 … … 1863 1861 const ObjectContainer &objects) 1864 1862 { 1865 float totalRenderCost = (float)objects.size(); 1866 int entriesInPvs = 1; 1867 int steps = 0; 1868 int viewSpaceSplits = 0; 1869 int objectSpaceSplits = 0; 1863 HierarchySubdivisionStats subStats; 1864 subStats.Reset(); 1865 1866 ///////////// 1867 //-- initial situation 1868 1869 subStats.mNumSplits = 0; 1870 subStats.mTotalRenderCost = (float)objects.size(); 1871 subStats.mEntriesInPvs = 1; 1872 subStats.mMemoryCost = (float)ObjectPvs::GetEntrySize(); 1873 subStats.mFullMemory = subStats.mMemoryCost; 1874 subStats.mViewSpaceSplits = 0; 1875 subStats.mObjectSpaceSplits = 0; 1876 1877 subStats.Print(stats); 1870 1878 1871 1879 cout << "exporting vsposp stats ... " << endl; 1872 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize();1873 1874 /////////////1875 //-- first view cell1876 1877 UpdateStats(stats, 2, totalRenderCost, entriesInPvs, memoryCost, viewSpaceSplits, objectSpaceSplits);1878 1880 1879 1881 //-- go through tree in the order of render cost decrease … … 1898 1900 1899 1901 isLeaf = newNode->IsLeaf(); 1900 rcDecr= oldNode->mRenderCostDecr;1902 subStats.mRenderCostDecrease = oldNode->mRenderCostDecr; 1901 1903 entriesIncr = oldNode->mPvsEntriesIncr; 1902 1904 } … … 1909 1911 1910 1912 isLeaf = newNode->IsLeaf(); 1911 rcDecr= oldNode->mRenderCostDecr;1913 subStats.mRenderCostDecrease = oldNode->mRenderCostDecr; 1912 1914 entriesIncr = oldNode->mPvsEntriesIncr; 1913 1915 } … … 1915 1917 if (!isLeaf) 1916 1918 { 1917 totalRenderCost -= rcDecr; 1918 entriesInPvs += entriesIncr; 1919 subStats.mTotalRenderCost -= subStats.mRenderCostDecrease; 1920 subStats.mEntriesInPvs += entriesIncr; 1921 1919 1922 // if (rcDecr <= 0) 1920 1923 if (nextCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 1921 1924 { 1922 ++ viewSpaceSplits;1925 ++ subStats.mViewSpaceSplits; 1923 1926 cout << "v";//cout << "vsp t: " << timeStamp << " rc: " << rcDecr << " pvs: " << entriesIncr << endl; 1924 1927 } 1925 1928 else 1926 1929 { 1927 ++ objectSpaceSplits;1930 ++ subStats.mObjectSpaceSplits; 1928 1931 cout << "o";//"osp t: " << timeStamp << " rc: " << rcDecr << " pvs: " << entriesIncr << endl; 1929 1932 } 1930 1933 1931 ++ steps; 1932 1933 if ((steps % 500) == 499) 1934 cout << steps << " steps taken" << endl; 1935 1936 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 1937 UpdateStats(stats, steps, totalRenderCost, entriesInPvs, memoryCost, viewSpaceSplits, objectSpaceSplits); 1934 ++ subStats.mNumSplits; 1935 1936 if ((subStats.mNumSplits % 500) == 499) 1937 cout << subStats.mNumSplits << " steps taken" << endl; 1938 1939 subStats.mMemoryCost = (float)subStats.mEntriesInPvs * (float)ObjectPvs::GetEntrySize(); 1940 subStats.mFullMemory = subStats.mMemoryCost; 1941 1942 subStats.Print(stats); 1943 1938 1944 } 1939 1945 … … 2023 2029 const int splitsStepSize) 2024 2030 { 2031 HierarchySubdivisionStats subStats; 2032 2025 2033 int splits = 0; 2026 2034 2027 float renderCost;2028 float memory;2029 int pvsEntries;2030 int viewSpaceSplits;2031 int objectSpaceSplits;2032 2033 2035 while (1) 2034 2036 { 2035 const int numSplits = ExtractStatistics(splits,2037 subStats.mNumSplits = ExtractStatistics(splits, 2036 2038 99999.0, 2037 renderCost, 2038 memory, 2039 pvsEntries, 2040 viewSpaceSplits, 2041 objectSpaceSplits); 2039 subStats.mTotalRenderCost, 2040 subStats.mMemoryCost, 2041 subStats.mEntriesInPvs, 2042 subStats.mViewSpaceSplits, 2043 subStats.mObjectSpaceSplits); 2044 2042 2045 2043 UpdateStats(splitsStats, 2044 numSplits, 2045 renderCost, 2046 pvsEntries, 2047 memory, 2048 viewSpaceSplits, 2049 objectSpaceSplits); 2046 const float objectSpaceHierarchyMem = float( 2047 subStats.mObjectSpaceSplits * sizeof(BvhLeaf *) + 2048 (subStats.mObjectSpaceSplits - 1) * sizeof(BvhInterior *) + 2049 sizeof(BvHierarchy) 2050 ) / float(1024 * 1024); 2051 2052 2053 const float viewSpaceHierarchyMem = float( 2054 subStats.mViewSpaceSplits * sizeof(VspLeaf *) + 2055 (subStats.mViewSpaceSplits - 1) * sizeof(VspInterior *) + 2056 sizeof(VspTree) 2057 ) / float(1024 * 1024); 2058 2059 subStats.mFullMemory = subStats.mMemoryCost + objectSpaceHierarchyMem + viewSpaceHierarchyMem; 2060 2061 subStats.Print(splitsStats); 2050 2062 2051 2063 splits += splitsStepSize; 2052 2064 2053 if ( numSplits == mHierarchyStats.Leaves())2065 if (subStats.mNumSplits == mHierarchyStats.Leaves()) 2054 2066 break; 2055 2067 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1718 r1723 108 108 109 109 110 class HierarchySubdivisionStats 111 { 112 public: 113 114 int mNumSplits; 115 116 float mRenderCostDecrease; 117 118 float mTotalRenderCost; 119 120 int mEntriesInPvs; 121 122 float mMemoryCost; 123 124 float mFullMemory; 125 126 int mViewSpaceSplits; 127 128 int mObjectSpaceSplits; 129 130 131 float VspOspRatio() const { return (float)mViewSpaceSplits / (float)mObjectSpaceSplits; } 132 133 float FpsPerMb() const { return 1.0f / (mTotalRenderCost * mMemoryCost); } 134 135 HierarchySubdivisionStats() { Reset(); } 136 137 void Reset() 138 { 139 mNumSplits = 0; 140 mRenderCostDecrease = 0; 141 mTotalRenderCost = 0; 142 mEntriesInPvs = 0; 143 mMemoryCost = 0; 144 mFullMemory = 0; 145 mViewSpaceSplits = 0; 146 mObjectSpaceSplits = 0; 147 } 148 149 150 void Print(ostream &app) const; 151 152 friend ostream &operator<<(ostream &s, const HierarchySubdivisionStats &stat) 153 { 154 stat.Print(s); 155 return s; 156 } 157 }; 158 159 110 160 /** This class implements a structure holding two different hierarchies, 111 161 one for object space partitioning and one for view space partitioning. -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1715 r1723 161 161 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportObj", mExportObj); 162 162 163 Environment::GetSingleton()->GetBoolValue("Preprocessor.useViewSpaceBox", mUseViewSpaceBox); 164 163 165 Debug << "******* Preprocessor Options **********" << endl; 164 166 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; … … 166 168 Debug << "load meshes: " << mLoadMeshes << endl; 167 169 Debug << "export obj: " << mExportObj << endl; 170 Debug << "use view space box: " << mUseViewSpaceBox << endl; 168 171 } 169 172 … … 515 518 // temp hack 516 519 //ExportObj("cropped_vienna.obj", mObjects); 517 518 520 mSceneGraph->GetRoot()->UpdateBox(); 519 521 520 522 cout << "finished loading" << endl; 521 522 523 if (0)524 {525 Exporter *exporter = Exporter::GetExporter("testload.x3d");526 if (exporter)527 {528 exporter->ExportGeometry(mObjects);529 delete exporter;530 }531 }532 523 } 533 524 … … 658 649 659 650 // default view space is the extent of the scene 660 AxisAlignedBox3 box = mSceneGraph->GetBox(); 661 662 if (0) 663 { 651 AxisAlignedBox3 viewSpaceBox; 652 653 if (mUseViewSpaceBox) 654 { 655 viewSpaceBox = mSceneGraph->GetBox(); 656 664 657 // use a small box outside of the scene 665 box.Scale(Vector3(0.1f,0.5f,0.5f)); 666 box.Translate(Vector3(Magnitude(mSceneGraph->GetBox().Size())*0.5f, 0, 0)); 667 } 668 669 mViewCellsManager->SetViewSpaceBox(box); 670 658 viewSpaceBox.Scale(Vector3(0.15f, 0.3f, 0.5f)); 659 //viewSpaceBox.Translate(Vector3(Magnitude(mSceneGraph->GetBox().Size()) * 0.5f, 0, 0)); 660 viewSpaceBox.Translate(Vector3(Magnitude(mSceneGraph->GetBox().Size()) * 0.3f, 0, 0)); 661 mViewCellsManager->SetViewSpaceBox(viewSpaceBox); 662 } 663 else 664 { 665 viewSpaceBox = mSceneGraph->GetBox(); 666 mViewCellsManager->SetViewSpaceBox(viewSpaceBox); 667 } 668 671 669 bool loadVcGeometry; 672 670 Environment::GetSingleton()->GetBoolValue("ViewCells.loadGeometry", loadVcGeometry); -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1695 r1723 196 196 197 197 int mPass; 198 199 bool mDelayVisibilityComputation;200 198 199 bool mDelayVisibilityComputation; 200 bool mStopComputation; 201 201 202 202 bool mExportObj; 203 204 203 205 204 protected: … … 231 230 GlRendererBuffer *renderer; 232 231 233 232 /// if box around view space should be used 233 bool mUseViewSpaceBox; 234 234 }; 235 235 -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1715 r1723 422 422 const float pdf) 423 423 { 424 mSamples--;424 -- mSamples; 425 425 426 426 std::map<T, S, LtSample<T> >:: -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1715 r1723 496 496 497 497 long time = GetTime(); 498 totalTime = TimeDiff(startTime, time)*1e-3 ;498 totalTime = TimeDiff(startTime, time)*1e-3f; 499 499 lastTime = time; 500 500 -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r1718 r1723 206 206 Name="VCLinkerTool" 207 207 AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib RTScene.lib RTWorld.lib QtCore4.lib qtmain.lib QtOpenGL4.lib Qt3Support4.lib QtTest4.lib QtGui4.lib QtGlRenderer.lib" 208 OutputFile="../bin/release/Preprocessor 2.exe"208 OutputFile="../bin/release/Preprocessor.exe" 209 209 LinkIncremental="1" 210 210 AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;"$(QTDIR)\lib";.\QtGlRenderer\Release" -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1718 r1723 42 42 // HACK 43 43 const static bool SAMPLE_AFTER_SUBDIVISION = true; 44 //const static bool CLAMP_TO_BOX = false;45 const static bool CLAMP_TO_BOX = true;44 const static bool CLAMP_TO_BOX = false; 45 //const static bool CLAMP_TO_BOX = true; 46 46 47 47 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r1705 r1723 36 36 Environment::GetSingleton()->GetBoolValue("VssPreprocessor.loadInitialSamples", mLoadInitialSamples); 37 37 Environment::GetSingleton()->GetBoolValue("VssPreprocessor.storeInitialSamples", mStoreInitialSamples); 38 Environment::GetSingleton()->GetBoolValue("VssPreprocessor.useViewSpaceBox", mUseViewSpaceBox);39 38 Environment::GetSingleton()->GetBoolValue("VssPreprocessor.testBeamSampling", mTestBeamSampling); 40 39 Environment::GetSingleton()->GetBoolValue("VssPreprocessor.enlargeViewSpace", mEnlargeViewSpace); … … 376 375 int totalSamples = 0; 377 376 378 if (mUseViewSpaceBox) 379 { 380 AxisAlignedBox3 viewSpaceBox; 381 viewSpaceBox.Initialize(); 382 383 viewSpaceBox = AxisAlignedBox3(mKdTree->GetBox()); 384 AxisAlignedBox3 tbox(mViewCellsManager->GetViewSpaceBox()); 385 386 const Vector3 size = tbox.Size(); 387 viewSpaceBox.SetMax(0, tbox.Max(0) + size[0] * 0.5f); 388 viewSpaceBox.SetMin(0, tbox.Min(0) + size[0]); 389 390 // change the view space of the view cells manager 391 mViewCellsManager->SetViewSpaceBox(viewSpaceBox); 392 } 393 394 mSceneGraph->CollectObjects(&mObjects); 377 //mSceneGraph->CollectObjects(&mObjects); 395 378 396 379 if (!mLoadViewCells) -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.h
r1563 r1723 36 36 /// if initial samples should be stored in file 37 37 bool mStoreInitialSamples; 38 /// if box around view space should be used 39 bool mUseViewSpaceBox; 38 40 39 // rays cast during the processing 41 40 VssRayContainer mVssRays; -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1715 r1723 149 149 } 150 150 151 151 #include "ViewCellsManager.h" 152 152 int 153 153 main(int argc, char **argv) … … 244 244 } 245 245 } 246 247 248 // parse view cells related options 249 if (!preprocessor->PrepareViewCells()) 250 { 251 Cleanup(); 252 exit(1); 253 } 254 246 255 if (0){ 247 256 Exporter *exporter= Exporter::GetExporter("test1.wrl"); 248 AxisAlignedBox3 bbox = preprocessor->mKdTree->GetBox(); 249 bbox.Scale(Vector3(0.5, 1, 0.5)); 257 AxisAlignedBox3 bbox = preprocessor->mViewCellsManager->GetViewSpaceBox(); 250 258 exporter->SetWireframe(); 251 exporter->ExportBox(preprocessor->mKdTree->GetBox());252 259 exporter->ExportBox(bbox); 253 260 exporter->SetFilled(); 254 exporter->ExportGeometry(preprocessor->mObjects, true , &bbox);261 exporter->ExportGeometry(preprocessor->mObjects, true); 255 262 delete exporter; 256 263 } 257 264 258 259 // parse view cells related options260 if (!preprocessor->PrepareViewCells())261 {262 Cleanup();263 exit(1);264 }265 266 265 if (0) 267 266 {
Note: See TracChangeset
for help on using the changeset viewer.