Changeset 2342 for GTP/trunk/Lib/Vis
- Timestamp:
- 05/02/07 17:28:26 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2332 r2342 400 400 ViewCell::NewMail(3); 401 401 402 // mail view cells which can see front object 402 403 ViewCellContainer::const_iterator fit, fit_end = frontViewCells.end(); 403 404 … … 408 409 } 409 410 411 // mail view cells which can see back or both objects 410 412 ViewCellContainer::const_iterator bit, bit_end = backViewCells.end(); 411 413 … … 429 431 int vcObj; 430 432 431 float oldVcTri = vc->Get PvsCost();433 float oldVcTri = vc->GetTrianglesInPvs(); 432 434 int oldVcObj = vc->GetEntriesInPvs(); 433 435 434 // both objects in view cell 436 // both objects seen from view cell 437 // => no reduction, but an additional pvs entry 435 438 if (vc->Mailed(2)) 436 439 { … … 438 441 vcObj = oldVcObj + 1; 439 442 } 443 // only back object seen from view cell 444 // => reduction in triangles 440 445 else if (vc->Mailed(1)) 441 446 { … … 443 448 vcObj = oldVcObj; 444 449 } 445 else // (vc->Mailed(0))450 else // front object 446 451 { 447 452 vcTri = oldVcTri - totalTri + frontTri; … … 449 454 } 450 455 451 vc->Set PvsCost(vcTri);456 vc->SetTrianglesInPvs(vcTri); 452 457 vc->SetEntriesInPvs(vcObj); 453 458 … … 567 572 } 568 573 569 // compute e.g., new render cost decrease after this split 574 // compute new stats for the view cells which see this object, 575 // e.g. new render cost decrease after the split 570 576 UpdateViewCells(sc); 571 577 … … 870 876 int vcObj; 871 877 872 float oldVcTri = vc->Get PvsCost();878 float oldVcTri = vc->GetTrianglesInPvs(); 873 879 int oldVcObj = vc->GetEntriesInPvs(); 874 880 … … 2228 2234 const bool onlyUnmailedRays)// const 2229 2235 { 2236 // view cells not cached 2230 2237 if (obj->GetOrCreateViewCells()->empty()) 2231 2238 { 2232 //cerr << "g";//CollectViewCells: view cells empty, view cells cache not working" << endl;2233 2239 return CollectViewCellsFromRays(obj, viewCells, useMailBoxing, setCounter, onlyUnmailedRays); 2234 2240 } 2235 2236 mCollectTimer.Entry();2237 2238 ViewCellContainer *objViewCells = obj->GetOrCreateViewCells();2239 2241 2240 2242 /////////// 2241 2243 //-- use view cells cache 2242 2244 2243 // fastest way: just copy to the end 2244 //if (!useMailBoxing) viewCells.insert(viewCells.end(), objViewCells->begin(), objViewCells->end()); 2245 mCollectTimer.Entry(); 2246 2247 ViewCellContainer *objViewCells = obj->GetOrCreateViewCells(); 2245 2248 2246 2249 // loop through view cells 2247 // matt: probably slow to insert 2250 // matt: probably slow to insert view cells one by one 2248 2251 ViewCellContainer::const_iterator vit, vit_end = objViewCells->end(); 2249 2252 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r2332 r2342 559 559 560 560 /// Repair split queue 561 cout << "repairing queue ... " << endl;561 cout << "repairing object space queue ... " << endl; 562 562 RepairQueue(dirtyList, objectSpaceQueue, true); 563 563 cout << "repaired " << (int)dirtyList.size() << " candidates" << endl; 564 564 565 565 dirtyList.clear(); 566 567 /// also repair some candidates from view space queue 568 /*cout << "repairing view space queue ... " << endl; 569 CollectRandomCandidates(dirtyList); 570 RepairQueue(dirtyList, viewSpaceQueue, true); 571 cout << "repaired " << (int)dirtyList.size() << " candidates" << endl; 572 dirtyList.clear();*/ 566 573 //PrintTimings(false); 567 574 } … … 743 750 mVspTree->PrepareConstruction(tQueue, sampleRays, *viewSpaceRays); 744 751 745 /////////746 //-- new stats747 748 752 if (0) 749 753 { 754 ///////// 755 //-- new render cost 756 750 757 mHierarchyStats.mTotalCost = mVspTree->mTotalCost; 751 758 cout << "\nreseting cost for vsp construction, new total cost: " << mHierarchyStats.mTotalCost << endl; … … 2278 2285 { 2279 2286 ComputePvs(vc->GetPvs(), triangles, entries); 2280 vc->Set PvsCost(triangles);2287 vc->SetTrianglesInPvs(triangles); 2281 2288 } 2282 2289 … … 2502 2509 } 2503 2510 2504 2505 } 2511 #ifdef USE_SSE 2512 int HierarchyManager::CastLineSegment(RayPacket &packet) 2513 { 2514 return mVspTree->TraverseRayPacket(packet, true); 2515 } 2516 2517 #endif 2518 2519 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r2332 r2342 321 321 ViewCellContainer &viewcells, 322 322 const bool useMailboxing = true); 323 323 324 #ifdef USE_SSE 325 int CastLineSegment(RayPacket &packet); 326 #endif 327 328 324 329 protected: 325 330 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2307 r2342 229 229 230 230 231 bool Preprocessor::ExportBinaryObj(const string filename, SceneGraphNode *root)231 bool Preprocessor::ExportBinaryObj(const string &filename, SceneGraphNode *root) 232 232 { 233 233 ogzstream samplesOut(filename.c_str()); … … 266 266 267 267 268 bool Preprocessor::ExportObj(const string filename, const ObjectContainer &objects)268 bool Preprocessor::ExportObj(const string &filename, const ObjectContainer &objects) 269 269 { 270 270 ofstream samplesOut(filename.c_str()); … … 320 320 } 321 321 322 static string ReplaceSuffix( stringfilename, string a, string b)322 static string ReplaceSuffix(const string &filename, string a, string b) 323 323 { 324 324 string result = filename; … … 381 381 382 382 bool 383 Preprocessor::LoadScene(const string filename)383 Preprocessor::LoadScene(const string &filename) 384 384 { 385 385 // use leaf nodes of the original spatial hierarchy as occludees … … 533 533 534 534 bool 535 Preprocessor::ExportPreprocessedData(const string filename)535 Preprocessor::ExportPreprocessedData(const string &filename) 536 536 { 537 537 mViewCellsManager->ExportViewCells(filename, true, mObjects); … … 605 605 606 606 bool 607 Preprocessor::Export( const string filename,607 Preprocessor::Export( const string &filename, 608 608 const bool scene, 609 609 const bool kdtree … … 813 813 814 814 815 bool Preprocessor::LoadKdTree(const string filename)815 bool Preprocessor::LoadKdTree(const string &filename) 816 816 { 817 817 mKdTree = new KdTree(); … … 821 821 822 822 823 bool Preprocessor::ExportKdTree(const string filename)823 bool Preprocessor::ExportKdTree(const string &filename) 824 824 { 825 825 return mKdTree->ExportBinTree(filename.c_str()); … … 1034 1034 1035 1035 1036 bool Preprocessor::LoadInternKdTree( const string internKdTree) 1037 { 1038 bool mUseKdTree = true; 1039 1040 if (!mUseKdTree) { 1041 // create just a dummy KdTree 1042 mKdTree = new KdTree; 1036 bool Preprocessor::LoadInternKdTree(const string &internKdTree) 1037 { 1038 bool mUseKdTree = true; 1039 1040 if (!mUseKdTree) { 1041 // create just a dummy KdTree 1042 mKdTree = new KdTree; 1043 return true; 1044 } 1045 1046 // always try to load the kd tree 1047 cout << "loading kd tree file " << internKdTree << " ... " << endl; 1048 1049 if (!LoadKdTree(internKdTree)) { 1050 cout << "error loading kd tree with filename " 1051 << internKdTree << ", rebuilding it instead ... " << endl; 1052 // build new kd tree from scene geometry 1053 BuildKdTree(); 1054 1055 // export kd tree? 1056 const long startTime = GetTime(); 1057 cout << "exporting kd tree ... "; 1058 1059 if (!ExportKdTree(internKdTree)) 1060 { 1061 cout << " error exporting kd tree with filename " 1062 << internKdTree << endl; 1063 } 1064 else 1065 { 1066 cout << "finished in " 1067 << TimeDiff(startTime, GetTime()) * 1e-3 1068 << " secs" << endl; 1069 } 1070 } 1071 1072 KdTreeStatistics(cout); 1073 cout << mKdTree->GetBox() << endl; 1074 1043 1075 return true; 1044 } 1045 1046 // always try to load the kd tree 1047 cout << "loading kd tree file " << internKdTree << " ... " << endl; 1048 1049 if (!LoadKdTree(internKdTree)) { 1050 cout << "error loading kd tree with filename " 1051 << internKdTree << ", rebuilding it instead ... " << endl; 1052 // build new kd tree from scene geometry 1053 BuildKdTree(); 1054 1055 // export kd tree? 1056 const long startTime = GetTime(); 1057 cout << "exporting kd tree ... "; 1058 1059 if (!ExportKdTree(internKdTree)) 1060 { 1061 cout << " error exporting kd tree with filename " 1062 << internKdTree << endl; 1063 } 1064 else 1065 { 1066 cout << "finished in " 1067 << TimeDiff(startTime, GetTime()) * 1e-3 1068 << " secs" << endl; 1069 } 1070 } 1071 1072 KdTreeStatistics(cout); 1073 cout << mKdTree->GetBox() << endl; 1074 1075 return true; 1076 } 1077 1078 1079 bool Preprocessor::InitRayCast(const string externKdTree, 1080 const string internKdTree) 1076 } 1077 1078 1079 bool Preprocessor::InitRayCast(const string &externKdTree, 1080 const string &internKdTree) 1081 1081 { 1082 1082 // always try to load the kd tree -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2187 r2342 9 9 #include "SimpleRay.h" 10 10 11 11 12 namespace GtpVisibilityPreprocessor { 12 class PreprocessorThread; 13 13 14 class PreprocessorThread; 14 15 class RenderSimulator; 15 16 class SceneGraph; … … 60 61 @return true on success 61 62 */ 62 virtual bool LoadScene(const string filename);63 virtual bool LoadScene(const string &filename); 63 64 64 65 /** Export all preprocessed data in a XML format understandable by the … … 67 68 @return true on successful export 68 69 */ 69 virtual bool ExportPreprocessedData(const string filename);70 virtual bool ExportPreprocessedData(const string &filename); 70 71 71 72 /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction … … 102 103 /** Export preprocessor data. 103 104 */ 104 bool Export(const string filename, const bool scene, const bool kdtree);105 bool Export(const string &filename, const bool scene, const bool kdtree); 105 106 106 107 virtual void KdTreeStatistics(ostream &s); … … 119 120 bool ExportSamples(const VssRayContainer &samples) const; 120 121 121 bool LoadKdTree(const string filename);122 bool ExportKdTree(const string filename);122 bool LoadKdTree(const string &filename); 123 bool ExportKdTree(const string &filename); 123 124 124 125 virtual bool … … 150 151 const bool pruneInvalidRays = true); 151 152 152 153 154 155 156 157 158 153 virtual void 154 CastRaysWithHwGlobalLines( 155 SimpleRayContainer &rays, 156 VssRayContainer &vssRays, 157 const bool castDoubleRays, 158 const bool pruneInvalidRays 159 ); 159 160 160 161 /** Compute pixel error of the current PVS solution by sampling given number of viewpoints. … … 168 169 GlRendererBuffer *GetRenderer(); 169 170 170 bool InitRayCast(const string externKdTree, const stringinternKdTree);171 172 bool LoadInternKdTree(const string internKdTree);173 174 bool ExportObj(const string filename, const ObjectContainer &objects);171 bool InitRayCast(const string &externKdTree, const string &internKdTree); 172 173 bool LoadInternKdTree(const string &internKdTree); 174 175 bool ExportObj(const string &filename, const ObjectContainer &objects); 175 176 176 177 Intersectable *GetParentObject(const int index) const; … … 192 193 193 194 static bool LoadObjects(const string &filename, 194 195 ObjectContainer &pvsObjects, 195 196 const ObjectContainer &preprocessorObject); 196 197 197 //////////////////////////////////////////////// 198 199 ///////////////////////// 198 200 199 201 /// scene graph loaded from file … … 223 225 bool mUseGlRenderer; 224 226 bool mUseGlDebugger; 225 227 226 228 bool mUseHwGlobalLines; 227 229 bool mLoadViewCells; … … 242 244 243 245 int mPass; 244 246 245 247 bool mStopComputation; 246 248 247 249 bool mExportObj; 248 250 … … 254 256 255 257 GlRendererBuffer *renderer; 256 258 257 259 int mTotalSamples; 258 260 int mTotalTime; … … 260 262 int mSamplesPerEvaluation; 261 263 262 264 RayCaster *mRayCaster; 263 265 264 266 … … 266 268 267 269 bool LoadBinaryObj(const std::string &filename, 268 270 SceneGraphNode *root, 269 271 std::vector<FaceParentInfo> *parents); 270 272 271 bool ExportBinaryObj(const std::string filename, SceneGraphNode *root);273 bool ExportBinaryObj(const std::string &filename, SceneGraphNode *root); 272 274 273 275 void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const; … … 276 278 277 279 virtual void EvalViewCellHistogram(); 280 278 281 279 282 ///////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r2332 r2342 106 106 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 107 107 </Configuration> 108 109 108 <Configuration 110 109 Name="Release_Internal|Win32" … … 454 453 </File> 455 454 <File 456 RelativePath=".\HashPvs2.h">457 </File>458 <File459 455 RelativePath=".\HierarchyManager.cpp"> 460 456 </File> … … 637 633 Outputs=""/> 638 634 </FileConfiguration> 639 640 635 <FileConfiguration 641 636 Name="Release_Internal|Win32"> … … 690 685 Outputs=""/> 691 686 </FileConfiguration> 692 693 687 <FileConfiguration 694 688 Name="Release_Internal|Win32"> … … 1109 1103 </File> 1110 1104 <File 1105 RelativePath=".\sparsehash\src\windows\hash_fun.h"> 1106 </File> 1107 <File 1111 1108 RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h"> 1112 </File>1113 <File1114 RelativePath=".\sparsehash\src\windows\hash_fun.h">1115 1109 </File> 1116 1110 <File -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r2332 r2342 229 229 LinkIncremental="1" 230 230 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" 231 GenerateDebugInformation=" TRUE"231 GenerateDebugInformation="FALSE" 232 232 SubSystem="1" 233 233 OptimizeReferences="2" -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r2332 r2342 34 34 myless<vector<ViewCell *>::value_type> > TraversalQueue; 35 35 36 int ViewCell::sMailId = 10000;//2147483647; 37 int ViewCell::sReservedMailboxes = 1; 38 36 int ViewCell::sMailId = 10000;//2147483647; 37 int ViewCell::sReservedMailboxes = 1; 39 38 40 39 float MergeCandidate::sRenderCostWeight = 0; … … 1305 1304 { 1306 1305 const float penalty = 1307 EvalPvsPenalty(Get PvsCost(vc), lower, upper);1306 EvalPvsPenalty(GetTrianglesInPvs(vc), lower, upper); 1308 1307 1309 1308 return (mAvgRenderCost - penalty) * (mAvgRenderCost - penalty) / … … 1323 1322 if (1) 1324 1323 { 1325 const float penalty = EvalPvsPenalty(Get PvsCost(vc), lower, upper);1324 const float penalty = EvalPvsPenalty(GetTrianglesInPvs(vc), lower, upper); 1326 1325 return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 1327 1326 } … … 1515 1514 const float vol = box.GetVolume(); 1516 1515 1517 const float rootPvs = Get PvsCost(mRoot);1516 const float rootPvs = GetTrianglesInPvs(mRoot); 1518 1517 const int rootEntries = GetPvsEntries(mRoot); 1519 1518 … … 1550 1549 ViewCellInterior *interior = static_cast<ViewCellInterior *>(vc); 1551 1550 1552 const float parentCost = Get PvsCost(interior);1551 const float parentCost = GetTrianglesInPvs(interior); 1553 1552 const int parentPvsEntries = GetPvsEntries(interior); 1554 1553 const float parentExpCost = (float)parentCost * interior->GetVolume(); … … 1566 1565 ViewCell *vc = *it; 1567 1566 1568 const float pvsCost = Get PvsCost(vc);1567 const float pvsCost = GetTrianglesInPvs(vc); 1569 1568 const int pvsEntries = GetPvsEntries(vc); 1570 1569 … … 1953 1952 1954 1953 1955 float ViewCellsTree::Get PvsCost(ViewCell *vc) const1954 float ViewCellsTree::GetTrianglesInPvs(ViewCell *vc) const 1956 1955 { 1957 1956 float pvsCost = 0; … … 2159 2158 2160 2159 const float vol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 2161 const float rootPvs = Get PvsCost(mRoot);2160 const float rootPvs = GetTrianglesInPvs(mRoot); 2162 2161 2163 2162 float totalRenderCost; … … 2182 2181 ViewCellInterior *interior = static_cast<ViewCellInterior *>(vc); 2183 2182 2184 const float parentCost = Get PvsCost(interior);2183 const float parentCost = GetTrianglesInPvs(interior); 2185 2184 const float parentExpCost = parentCost * interior->GetVolume(); 2186 2185 … … 2196 2195 ViewCell *vc = *it; 2197 2196 2198 const float pvsCost = Get PvsCost(vc);2197 const float pvsCost = GetTrianglesInPvs(vc); 2199 2198 2200 2199 childExpCost += (float) pvsCost * vc->GetVolume(); … … 2248 2247 ViewCellInterior *interior = static_cast<ViewCellInterior *>(vc); 2249 2248 2250 const float parentPvsCost = Get PvsCost(interior);2249 const float parentPvsCost = GetTrianglesInPvs(interior); 2251 2250 const int parentPvsEntries = GetPvsEntries(interior); 2252 2251 const float parentExpCost = (float)parentPvsCost * interior->GetVolume(); … … 2288 2287 ++ vcStat.viewCells; 2289 2288 2290 const float pvsCost = Get PvsCost(vc);2289 const float pvsCost = GetTrianglesInPvs(vc); 2291 2290 2292 2291 vcStat.pvsCost += pvsCost; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r2332 r2342 287 287 } 288 288 289 void Set PvsCost(const float c) {289 void SetTrianglesInPvs(const float c) { 290 290 mPvsCost = c; 291 291 } … … 295 295 } 296 296 297 float Get PvsCost() const {297 float GetTrianglesInPvs() const { 298 298 return mPvsCost; 299 299 } … … 508 508 /** Returns pvs size (i.e. the render cost of the stored objects) 509 509 */ 510 float Get PvsCost(ViewCell *vc) const;510 float GetTrianglesInPvs(ViewCell *vc) const; 511 511 512 512 /** Returns number of entries associated with this view cell. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2332 r2342 169 169 Environment::GetSingleton()->GetFloatValue("ViewCells.objectWeight", mObjectWeight); 170 170 171 // mix of sampling strategies172 if ( 1)171 // choose mix of sampling strategies 172 if (0) 173 173 { 174 174 mStrategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); … … 1317 1317 (*it)->UpdatePvsCost(); 1318 1318 else 1319 (*it)->Set PvsCost((float)(*it)->GetFilteredPvsSize());1319 (*it)->SetTrianglesInPvs((float)(*it)->GetFilteredPvsSize()); 1320 1320 } 1321 1321 … … 1325 1325 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 1326 1326 1327 maxPvs = viewCells.back()->Get PvsCost();1327 maxPvs = viewCells.back()->GetTrianglesInPvs(); 1328 1328 minVal = 0; 1329 1329 … … 1369 1369 1370 1370 while ((i < (int)viewCells.size()) && 1371 (viewCells[i]->Get PvsCost() < currentPvs))1371 (viewCells[i]->GetTrianglesInPvs() < currentPvs)) 1372 1372 { 1373 1373 volDif += viewCells[i]->GetVolume(); … … 1380 1380 1381 1381 // if (0 && (i < (int)viewCells.size())) 1382 // Debug << "new pvs cost increase: " << mViewCellsTree->Get PvsCost(viewCells[i])1382 // Debug << "new pvs cost increase: " << mViewCellsTree->GetTrianglesInPvs(viewCells[i]) 1383 1383 // << " " << currentPvs << endl; 1384 1384 … … 1412 1412 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 1413 1413 1414 maxPvs = viewCells.back()->Get PvsCost();1414 maxPvs = viewCells.back()->GetTrianglesInPvs(); 1415 1415 minVal = 0; 1416 1416 … … 1456 1456 1457 1457 while ((i < (int)viewCells.size()) && 1458 (viewCells[i]->Get PvsCost() < currentPvs))1458 (viewCells[i]->GetTrianglesInPvs() < currentPvs)) 1459 1459 { 1460 1460 volDif += viewCells[i]->GetVolume(); … … 1467 1467 1468 1468 // if (0 && (i < (int)viewCells.size())) 1469 // Debug << "new pvs cost increase: " << mViewCellsTree->Get PvsCost(viewCells[i])1469 // Debug << "new pvs cost increase: " << mViewCellsTree->GetTrianglesInPvs(viewCells[i]) 1470 1470 // << " " << currentPvs << endl; 1471 1471 … … 2418 2418 ViewCell *viewcell = *it; 2419 2419 if (viewcell->GetValid()) { 2420 const float pvsCost = mViewCellsTree->Get PvsCost(viewcell);2420 const float pvsCost = mViewCellsTree->GetTrianglesInPvs(viewcell); 2421 2421 const float renderCost = pvsCost * viewcell->GetVolume() / vol; 2422 2422 … … 2908 2908 float ViewCellsManager::GetRendercost(ViewCell *viewCell) const 2909 2909 { 2910 return (float)mViewCellsTree->Get PvsCost(viewCell);2910 return (float)mViewCellsTree->GetTrianglesInPvs(viewCell); 2911 2911 } 2912 2912 … … 3603 3603 if (mCurrentViewCellsStats.maxPvs) 3604 3604 { 3605 importance = (float)mViewCellsTree->Get PvsCost(vc) / 700;3605 importance = (float)mViewCellsTree->GetTrianglesInPvs(vc) / 700; 3606 3606 //(float)mCurrentViewCellsStats.maxPvs; 3607 3607 } … … 4105 4105 Exporter *exporter = Exporter::GetExporter(s); 4106 4106 4107 cout << "view cell " << idx << ": pvs cost=" << (int)mViewCellsTree->Get PvsCost(vc) << endl;4107 cout << "view cell " << idx << ": pvs cost=" << (int)mViewCellsTree->GetTrianglesInPvs(vc) << endl; 4108 4108 4109 4109 if (exportRays) … … 5430 5430 Exporter *exporter = Exporter::GetExporter(s); 5431 5431 5432 const float pvsCost = mViewCellsTree->Get PvsCost(vc);5432 const float pvsCost = mViewCellsTree->GetTrianglesInPvs(vc); 5433 5433 cout << "view cell " << vc->GetId() << ": pvs cost=" << pvsCost << endl; 5434 5434 … … 6482 6482 Exporter *exporter = Exporter::GetExporter(s); 6483 6483 6484 cout << "view cell " << vc->GetId() << ": pvs cost=" << mViewCellsTree->Get PvsCost(vc) << endl;6484 cout << "view cell " << vc->GetId() << ": pvs cost=" << mViewCellsTree->GetTrianglesInPvs(vc) << endl; 6485 6485 6486 6486 if (exportPvs) … … 7028 7028 if (tmpRays.size() == 4) 7029 7029 { 7030 // cast packets of 4 rays 7030 7031 RayPacket packet(tmpRays); 7031 7032 7032 mHierarchyManager->CastLineSegment(packet); 7033 7033 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2332 r2342 568 568 else 569 569 { 570 // todo: set correct scalars 571 viewCell->SetPvsCost(renderCost); 570 viewCell->SetTrianglesInPvs(renderCost); 572 571 viewCell->SetEntriesInPvs(pvs); 572 573 573 //cout << "create view cell with tri=" << (int)renderCost << " pvs=" << pvs << endl; 574 574 } … … 753 753 RayInfoContainer::const_iterator rit, rit_end = splitCandidate.mParentData.mRays->end(); 754 754 755 float frontRenderCost = 0, backRenderCost = 0, totalRenderCost = 0;756 755 float frontTriangles = 0, backTriangles = 0, totalTriangles = 0; 757 int 756 int frontObjects = 0, backObjects = 0, totalObjects = 0; 758 757 759 758 Intersectable::NewMail(3); … … 803 802 } 804 803 805 totalRenderCost = mViewCellsManager->ComputeRenderCost((int)totalTriangles, totalObjects);806 backRenderCost = mViewCellsManager->ComputeRenderCost((int)backTriangles, backObjects);807 frontRenderCost = mViewCellsManager->ComputeRenderCost((int)frontTriangles, frontObjects);808 809 804 const float totalRenderCost = mViewCellsManager->ComputeRenderCost((int)totalTriangles, totalObjects); 805 const float backRenderCost = mViewCellsManager->ComputeRenderCost((int)backTriangles, backObjects); 806 const float frontRenderCost = mViewCellsManager->ComputeRenderCost((int)frontTriangles, frontObjects); 807 808 810 809 ///////////// 811 810 // avg ray contri … … 843 842 // take render cost of node into account 844 843 // otherwise danger of being stuck in a local minimum! 845 const float factor = mRenderCostDecreaseWeight; 846 847 float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 844 float priority = mRenderCostDecreaseWeight * renderCostDecr + (1.0f - mRenderCostDecreaseWeight) * oldRenderCost; 848 845 849 846 if (mHierarchyManager->mConsiderMemory) … … 854 851 splitCandidate.SetPriority(priority); 855 852 856 //cout << "vsp render cost decrease=" << renderCostDecr <<endl;853 //cout << "vsp render cost decrease=" << renderCostDecr << endl; 857 854 mEvalTimer.Exit(); 858 855 } … … 883 880 splitCandidate.mBackPvs = (float)bPvsSize; 884 881 885 if (0) 886 cout << "vsp pvs" 887 << " avg ray contri: " << splitCandidate.GetAvgRayContribution() << " ratio: " << oldPvsRatio 888 << " parent: " << correctedOldPvs << " " << " old vol: " << oldPvsSize 889 << " frontpvs: " << fPvsSize << " corr. " << splitCandidate.mCorrectedFrontPvs 890 << " backpvs: " << bPvsSize << " corr. " << splitCandidate.mCorrectedBackPvs << endl; 891 892 882 #if TODO 893 883 return (int)(splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - correctedOldPvs); 884 #else 885 return fPvsSize + bPvsSize - oldPvsSize; 886 #endif 894 887 } 895 888 … … 1633 1626 float VspTree::EvalRenderCostDecrease(VspSubdivisionCandidate &sc, 1634 1627 float &normalizedOldRenderCost, 1635 const float total Pvs,1636 const float pvsFront,1637 const float pvsBack) const1628 const float totalRenderCost, 1629 const float frontRenderCost, 1630 const float backRenderCost) const 1638 1631 { 1639 1632 const float viewSpaceVol = mBoundingBox.GetVolume(); … … 1643 1636 const float avgRaysPerObject = sc.GetAvgRaysPerObject(); 1644 1637 1645 ///////////////////////// 1646 // mark objects in the front / back / both using mailboxing 1647 // then count pvs sizes 1648 1649 Intersectable::NewMail(3); 1650 KdLeaf::NewMail(3); 1651 1638 1652 1639 AxisAlignedBox3 frontBox; 1653 1640 AxisAlignedBox3 backBox; … … 1667 1654 //-- evaluate render cost heuristics 1668 1655 1669 const float oldRenderCostRatio = (tData.mRenderCost > 0)? (totalPvs / tData.mRenderCost) : 1; 1656 // ratio of how render cost changed since last evaluation 1657 const float oldRenderCostRatio = (tData.mRenderCost > 0)? (totalRenderCost / tData.mRenderCost) : 1; 1670 1658 const float penaltyOld = tData.mCorrectedRenderCost * oldRenderCostRatio; 1671 1659 1672 sc.mCorrectedFrontRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsFront, penaltyOld, avgRaysPerObject); 1673 sc.mCorrectedBackRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsBack, penaltyOld, avgRaysPerObject); 1674 1675 sc.mFrontRenderCost = pvsFront; 1676 sc.mBackRenderCost = pvsBack; 1677 1678 const float oldRenderCost = pOverall * penaltyOld; 1660 sc.mCorrectedFrontRenderCost = mHierarchyManager->EvalCorrectedPvs(frontRenderCost, penaltyOld, avgRaysPerObject); 1661 sc.mCorrectedBackRenderCost = mHierarchyManager->EvalCorrectedPvs(backRenderCost, penaltyOld, avgRaysPerObject); 1662 1663 sc.mFrontRenderCost = frontRenderCost; 1664 sc.mBackRenderCost = backRenderCost; 1665 1666 #if TODO // undersampling evalution does not work yet 1667 1668 const float oldRenderCost = penaltyOld * pOverall; 1679 1669 const float newRenderCost = sc.mCorrectedFrontRenderCost * pFront + 1680 1670 sc.mCorrectedBackRenderCost * pBack; 1681 1671 1682 // we also return the old render cost 1672 #else 1673 1674 const float oldRenderCost = totalRenderCost * pOverall; 1675 const float newRenderCost = frontRenderCost * pFront + backRenderCost * pBack; 1676 1677 #endif 1678 1679 // the normalized old render cost is needed for the priority 1683 1680 normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 1684 1681 … … 3255 3252 leaf->SetViewCell(viewCell); 3256 3253 3257 viewCell->Set PvsCost((float)objects.size());3254 viewCell->SetTrianglesInPvs((float)objects.size()); 3258 3255 viewCell->SetEntriesInPvs(1); 3259 3256 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r2332 r2342 14 14 #include "Timer/PerfTimer.h" 15 15 16 16 17 #ifdef USE_SSE 17 18 #include <xmmintrin.h> 18 19 #endif 19 20 20 21 21 … … 797 797 float EvalRenderCostDecrease(VspSubdivisionCandidate &splitData, 798 798 float &normalizedOldRenderCost, 799 const float total Pvs,800 const float pvsFront,801 const float pvsBack) const;799 const float totalRenderCost, 800 const float frontRenderCost, 801 const float backRenderCost) const; 802 802 803 803 /** Collects view cells in the subtree under root. … … 1113 1113 int CompressObjects(VspLeaf *leaf); 1114 1114 1115 1115 1116 #ifdef USE_SSE 1116 1117 struct RayPacket1118 {1119 union { float mOriginX[4]; __m128 mOriginX4; };1120 union { float mOriginY[4]; __m128 mOriginY4; };1121 union { float mOriginZ[4]; __m128 mOriginZ4; };1122 1123 union { float mTerminationX[4]; __m128 mTerminationX4; };1124 union { float mTerminationY[4]; __m128 mTerminationY4; };1125 union { float mTerminationZ[4]; __m128 mTerminationZ4; };1126 1127 ViewCellContainer mViewCells[4];1128 };1129 1130 1117 struct PacketTraversalData 1131 1118 { … … 1141 1128 PacketTraversalData () {} 1142 1129 PacketTraversalData (VspNode *n, 1143 1144 1145 1130 const __m128 &px, const __m128 &py, const __m128 &pz, 1131 const __m128 &maxt, 1132 const __m128 &mask): 1146 1133 mNode(n), 1147 mExitPointX4(px), mExitPointY4(py), mExitPointZ4(pz),1148 mMaxT4(maxt),1149 mMask4(mask)1134 mExitPointX4(px), mExitPointY4(py), mExitPointZ4(pz), 1135 mMaxT4(maxt), 1136 mMask4(mask) 1150 1137 {} 1151 1138 }; 1152 1139 1153 1154 int TraverseRayPacket(RayPacket &rp, 1155 const bool useMailboxing); 1140 1141 int TraverseRayPacket(RayPacket &rp, const bool useMailboxing); 1156 1142 1157 1143 #endif 1144 1158 1145 1159 1146 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h
r2234 r2342 7 7 #include "Containers.h" 8 8 9 // 9 #ifdef USE_SSE 10 #include <xmmintrin.h> 11 #endif 10 12 11 13 … … 19 21 #define ABS_CONTRIBUTION_WEIGHT 0.0f 20 22 #define VSS_STORE_VIEWCELLS 1 21 23 24 #ifdef USE_SSE 25 26 struct RayPacket 27 { 28 union { float mOriginX[4]; __m128 mOriginX4; }; 29 union { float mOriginY[4]; __m128 mOriginY4; }; 30 union { float mOriginZ[4]; __m128 mOriginZ4; }; 31 32 union { float mTerminationX[4]; __m128 mTerminationX4; }; 33 union { float mTerminationY[4]; __m128 mTerminationY4; }; 34 union { float mTerminationZ[4]; __m128 mTerminationZ4; }; 35 36 ViewCellContainer mViewCells[4]; 37 }; 38 39 40 #endif 41 42 22 43 class VssRay { 23 44 public:
Note: See TracChangeset
for help on using the changeset viewer.