- Timestamp:
- 03/05/07 11:07:44 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2124 r2187 384 384 BvhTraversalData &backData) 385 385 { 386 mNodeTimer.Entry(); 386 387 const BvhTraversalData &tData = sc.mParentData; 387 388 BvhLeaf *leaf = tData.mNode; … … 480 481 } 481 482 483 mNodeTimer.Exit(); 484 482 485 // return the new interior node 483 486 return node; … … 489 492 const bool globalCriteriaMet) 490 493 { 494 mSubdivTimer.Entry(); 495 491 496 BvhSubdivisionCandidate *sc = 492 497 static_cast<BvhSubdivisionCandidate *>(splitCandidate); … … 505 510 // create new interior node and two leaf node 506 511 currentNode = SubdivideNode(*sc, tFrontData, tBackData); 507 512 508 513 // decrease the weighted average cost of the subdivisoin 509 514 mTotalCost -= sc->GetRenderCostDecrease(); … … 524 529 EvalSubdivisionCandidate(*frontCandidate); 525 530 EvalSubdivisionCandidate(*backCandidate); 526 531 527 532 // cross reference 528 533 tFrontData.mNode->SetSubdivisionCandidate(frontCandidate); … … 550 555 } 551 556 557 mSubdivTimer.Exit(); 558 552 559 return currentNode; 553 560 } … … 608 615 bool computeSplitPlane) 609 616 { 617 mEvalTimer.Entry(); 610 618 if (computeSplitPlane) 611 619 { … … 697 705 // compute global decrease in render cost 698 706 splitCandidate.SetPriority(priority); 707 mEvalTimer.Exit(); 699 708 } 700 709 … … 1549 1558 bool useVisibilityBasedHeuristics) 1550 1559 { 1560 mSplitTimer.Entry(); 1561 1551 1562 if (mIsInitialSubdivision) 1552 1563 { … … 1653 1664 backObjects = nBackObjects[bestAxis]; 1654 1665 1666 mSplitTimer.Exit(); 1667 1655 1668 //cout << "val: " << nCostRatio[bestAxis] << " axis: " << bestAxis << endl; 1656 1669 return nCostRatio[bestAxis]; … … 2312 2325 const ObjectContainer &objects) 2313 2326 { 2327 mSortTimer.Entry(); 2328 2329 const bool doSort = true; 2330 2314 2331 // we sort the objects as a preprocess so they don't have 2315 2332 // to be sorted for each split … … 2320 2337 CreateLocalSubdivisionCandidates(objects, 2321 2338 &sortedObjects, 2322 true,2339 doSort, 2323 2340 i); 2324 2341 … … 2342 2359 2343 2360 *(tData.mSortedObjects[3]) = objects; 2344 //stable_sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2345 sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2361 2362 stable_sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2363 //sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2364 2365 mSortTimer.Exit(); 2346 2366 } 2347 2367 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r2176 r2187 14 14 #include "IntersectableWrapper.h" 15 15 #include "HierarchyManager.h" 16 #include "PerfTimer.h" 16 17 17 18 … … 495 496 float GetPriority() const 496 497 { 497 return (float)-mParentData.mDepth;498 //return mPriority;498 //return (float)-mParentData.mDepth; 499 return mPriority; 499 500 } 500 501 … … 656 657 void Compress(); 657 658 void CreateUniqueObjectIds(); 659 660 PerfTimer mSortTimer; 661 PerfTimer mNodeTimer; 662 PerfTimer mSubdivTimer; 663 PerfTimer mEvalTimer; 664 PerfTimer mSplitTimer; 658 665 659 666 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2161 r2187 1163 1163 void GvsPreprocessor::DeterminePvsObjects(VssRayContainer &rays) 1164 1164 { 1165 // store triangle directly 1165 1166 mViewCellsManager->DeterminePvsObjects(rays, true); 1166 1167 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r2170 r2187 409 409 410 410 411 void HierarchyManager::PrintTimings(const bool lastSplitWasOsp) 412 { 413 double sortTime, evalTime, nodeTime, splitTime, subdTime; 414 415 sortTime = mBvHierarchy->mSortTimer.TotalTime(); 416 evalTime = mBvHierarchy->mEvalTimer.TotalTime(); 417 nodeTime = mBvHierarchy->mNodeTimer.TotalTime(); 418 splitTime = mBvHierarchy->mSplitTimer.TotalTime(); 419 subdTime = mBvHierarchy->mSubdivTimer.TotalTime(); 420 421 cout << "bvh times" 422 << " sort : " << sortTime 423 << " eval : " << evalTime 424 << " node : " << nodeTime 425 << " split: " << splitTime 426 << " subd : " << subdTime << endl; 427 428 Debug << "bvh times" 429 << " sort : " << sortTime 430 << " eval : " << evalTime 431 << " node : " << nodeTime 432 << " split: " << splitTime 433 << " subd : " << subdTime << endl; 434 435 sortTime = mVspTree->mSortTimer.TotalTime(); 436 evalTime = mVspTree->mEvalTimer.TotalTime(); 437 nodeTime = mVspTree->mNodeTimer.TotalTime(); 438 splitTime = mVspTree->mSplitTimer.TotalTime(); 439 subdTime = mVspTree->mSubdivTimer.TotalTime(); 440 441 cout << "vsp times" 442 << " sort : " << sortTime 443 << " eval : " << evalTime 444 << " node : " << nodeTime 445 << " split: " << splitTime 446 << " subd : " << subdTime << endl; 447 448 Debug << "vsp times" 449 << " sort : " << sortTime 450 << " eval : " << evalTime 451 << " node : " << nodeTime 452 << " split: " << splitTime 453 << " subd : " << subdTime << endl; 454 cout << endl; 455 Debug << endl; 456 } 457 458 411 459 void HierarchyManager::ConstructInterleavedWithGradient(const VssRayContainer &sampleRays, 412 460 const ObjectContainer &objects, … … 518 566 //if (!lastSplitWasOsp) 519 567 { 568 ///////////////// 569 // subdivide object space with respect to the objects 570 520 571 lastSplitWasOsp = true; 521 572 cout << "osp" << endl; … … 545 596 else 546 597 { 598 ///////////////// 599 // subdivide view space with respect to the objects 600 547 601 lastSplitWasOsp = false; 548 602 cout << "vsp" << endl; 549 550 /////////////////551 // subdivide view space with respect to the objects552 603 553 604 // dirtied object space candidates … … 574 625 << (int)dirtyOspList.size() << " dirtied candidates" << endl; 575 626 } 627 628 PrintTimings(lastSplitWasOsp); 576 629 } 577 630 … … 1845 1898 //cout << "priority: " << nodeWrapper->GetMergeCost() << endl; 1846 1899 // save the view cells if it is a leaf or if enough view cells have already been traversed 1847 // because of the priority queue, this will be the optimal set of v 1900 // because of the priority queue, this will be the optimal set of view cells 1848 1901 if (nodeWrapper->IsLeaf() || 1849 1902 ((viewCells.size() + bvhNodes.size() + tqueue.size() + 1) >= maxSplits) || … … 1887 1940 1888 1941 if (obj->Type() != Intersectable::BVH_INTERSECTABLE) 1889 cout << "error " << obj->Type() << endl; 1942 { 1943 cout << "error: wrong object type detected: " << obj->Type() << endl; 1944 exit(0); 1945 } 1890 1946 1891 1947 BvhNode *intersect = static_cast<BvhNode *>(obj); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r2176 r2187 323 323 protected: 324 324 325 void PrintTimings(const bool osp); 326 325 327 /** Returns true if the global termination criteria were met. 326 328 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
r2105 r2187 115 115 const bool pruneInvalidRays) 116 116 { 117 117 CastRays16(rays, 0, vssRays, sbox, castDoubleRay, pruneInvalidRays); 118 118 } 119 119 … … 322 322 } 323 323 324 for (; offset < rays.size(); offset++)324 for (; offset < (int)rays.size(); offset++) 325 325 CastRay(rays[offset], vssRays, sbox, castDoubleRay, pruneInvalidRays); 326 326 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2183 r2187 32 32 namespace GtpVisibilityPreprocessor { 33 33 34 const static bool ADDITIONAL_GEOMETRY_HACK = false; 35 36 Preprocessor *preprocessor = NULL; 37 38 // HACK: Artificially modify scene to watch rendercost changes 39 static void AddGeometry(SceneGraph *scene) 40 { 41 scene->GetRoot()->UpdateBox(); 42 43 AxisAlignedBox3 sceneBox = scene->GetBox(); 44 45 int n = 200; 46 47 if (0) 48 { 49 // form grid of boxes 50 for (int i = 0; i < n; ++ i) 51 { 52 for (int j = 0; j < n; ++ j) 53 { 54 const Vector3 scale2((float)j * 0.8f / n + 0.1f, 0.05f, (float)i * 0.8f / (float)n + 0.1f); 55 56 const Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 57 58 const Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 59 AxisAlignedBox3 box(pt2, pt2 + boxSize); 60 Mesh *mesh = CreateMeshFromBox(box); 61 62 mesh->Preprocess(); 63 64 MeshInstance *mi = new MeshInstance(mesh); 65 scene->GetRoot()->mGeometry.push_back(mi); 66 } 67 } 68 69 for (int i = 0; i < n; ++ i) 70 { 71 for (int j = 0; j < n; ++ j) 72 { 73 const Vector3 scale2(0.15f, (float)j * 0.8f / n + 0.1f, (float)i * 0.8f / (float)n + 0.1f); 74 75 Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 76 77 Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 78 AxisAlignedBox3 box(pt2, pt2 + boxSize); 79 Mesh *mesh = CreateMeshFromBox(box); 80 81 mesh->Preprocess(); 82 83 MeshInstance *mi = new MeshInstance(mesh); 84 scene->GetRoot()->mGeometry.push_back(mi); 85 } 86 } 87 88 for (int i = 0; i < n; ++ i) 89 { 90 const Vector3 scale2(2, 0.2f, (float)i * 0.8f / (float)n + 0.1f); 91 92 Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 93 Vector3 boxSize = sceneBox.Size() * Vector3(0.005f, 0.02f, 0.005f); 94 95 AxisAlignedBox3 box(pt2 + 0.1f, pt2 + boxSize); 96 Mesh *mesh = CreateMeshFromBox(box); 97 98 mesh->Preprocess(); 99 100 MeshInstance *mi = new MeshInstance(mesh); 101 scene->GetRoot()->mGeometry.push_back(mi); 102 } 103 104 scene->GetRoot()->UpdateBox(); 105 } 106 107 if (1) 108 { 109 // plane separating view space regions 110 const Vector3 scale(1.0f, 0.0, 0); 111 112 Vector3 pt = sceneBox.Min() + scale * (sceneBox.Max() - sceneBox.Min()); 113 114 Plane3 cuttingPlane(Vector3(1, 0, 0), pt); 115 Mesh *planeMesh = new Mesh(); 116 117 Polygon3 *poly = sceneBox.CrossSection(cuttingPlane); 118 IncludePolyInMesh(*poly, *planeMesh); 119 120 planeMesh->Preprocess(); 121 122 MeshInstance *planeMi = new MeshInstance(planeMesh); 123 scene->GetRoot()->mGeometry.push_back(planeMi); 124 } 125 } 126 34 35 Preprocessor *preprocessor = NULL; 36 127 37 128 38 Preprocessor::Preprocessor(): … … 599 509 if (result) 600 510 { 601 // HACK602 if (ADDITIONAL_GEOMETRY_HACK)603 AddGeometry(mSceneGraph);604 511 605 512 mSceneGraph->AssignObjectIds(); … … 1228 1135 Environment::GetSingleton()->GetBoolValue("ViewCells.loadFromFile", loadViewCells); 1229 1136 1230 int reserveRays; 1137 int reserveRays; 1138 int constructionSamples; 1231 1139 1232 1140 if (!loadViewCells) 1233 1141 { 1234 cout << "setting ray pool size to view cell construction ize" << endl; 1142 cout << "hack: setting ray pool size to view cell construction or evaluation size" << endl; 1143 1144 constructionSamples = 1000000; 1235 1145 1236 1146 char buf[100]; 1237 1147 Environment::GetSingleton()->GetStringValue("ViewCells.type", buf); 1238 1148 1239 1149 if (strcmp(buf, "vspBspTree") == 0) 1240 1150 { 1241 Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", reserveRays);1242 reserveRays *= 2;1151 Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", constructionSamples); 1152 1243 1153 } 1244 1154 else if (strcmp(buf, "vspOspTree") == 0) 1245 1155 { 1246 Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", reserveRays); 1247 reserveRays *= 2; 1248 } 1156 Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", constructionSamples); 1157 } 1158 1159 int evalSamplesPerPass; 1160 1161 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", evalSamplesPerPass); 1162 1163 reserveRays = max(constructionSamples, evalSamplesPerPass); 1164 reserveRays *= 2; 1249 1165 } 1250 1166 else 1251 1167 { 1252 cout << "setting ray pool size to samples per pass" << endl; 1253 1168 cout << "setting ray pool size to samples per pass" << endl; 1254 1169 reserveRays = mSamplesPerPass * 2; 1255 1170 } … … 1274 1189 const long t1 = GetTime(); 1275 1190 1276 if ((int)rays.size() > 10000) { 1191 if (1 && (rays.size() > 10000)) 1192 { 1277 1193 1278 1194 mRayCaster->SortRays(rays); … … 1298 1214 1299 1215 if (mUseHwGlobalLines) 1216 { 1300 1217 CastRaysWithHwGlobalLines( 1301 1218 rays, … … 1304 1221 pruneInvalidRays 1305 1222 ); 1223 } 1306 1224 else 1225 { 1307 1226 mRayCaster->CastRays( 1308 1227 rays, … … 1311 1230 castDoubleRays, 1312 1231 pruneInvalidRays); 1313 1314 if ((int)rays.size() > 10000) 1232 } 1233 1234 if (rays.size() > 10000) 1315 1235 { 1316 1236 cout << endl; … … 1328 1248 } 1329 1249 1330 1331 1250 1332 1251 void 1333 1252 Preprocessor::CastRaysWithHwGlobalLines( 1334 1253 SimpleRayContainer &rays, 1335 VssRayContainer &vssRays, 1336 const bool castDoubleRays, 1337 const bool pruneInvalidRays 1338 ) 1254 VssRayContainer &vssRays, 1255 const bool castDoubleRays, 1256 const bool pruneInvalidRays) 1339 1257 { 1340 1258 SimpleRayContainer::const_iterator rit, rit_end = rays.end(); … … 1352 1270 } 1353 1271 #endif 1354 1355 1356 1357 if ((int)rayBucket.size() >= 16)1358 { 1359 1360 1361 1362 1363 1364 1365 1366 1367 } 1368 1369 if ( (int)rays.size() > 100000 && i % 100000 == 0)1272 rayBucket.push_back(ray); 1273 1274 // 16 rays gathered => do ray casting 1275 if (rayBucket.size() >= 16) 1276 { 1277 mRayCaster->CastRays16( 1278 rayBucket, 1279 vssRays, 1280 mViewCellsManager->GetViewSpaceBox(), 1281 castDoubleRays, 1282 pruneInvalidRays); 1283 1284 rayBucket.clear(); 1285 } 1286 1287 if (rays.size() > 100000 && i % 100000 == 0) 1370 1288 cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 1371 1289 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2183 r2187 57 57 58 58 /** Load the input scene. 59 @param filename file to load60 @return true on success59 @param filename file to load 60 @return true on success 61 61 */ 62 62 virtual bool LoadScene(const string filename); 63 63 64 64 /** Export all preprocessed data in a XML format understandable by the 65 PreprocessingInterface of the GtpVisibilityPreprocessor Module.66 The file can be compressed depending on the environement settings.67 @return true on successful export65 PreprocessingInterface of the GtpVisibilityPreprocessor Module. 66 The file can be compressed depending on the environement settings. 67 @return true on successful export 68 68 */ 69 69 virtual bool ExportPreprocessedData(const string filename); 70 70 71 71 /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction 72 is driven by the environment settings, which also sais which of the three types of73 entities should be used to drive the heuristical construction (only occluders by default)72 is driven by the environment settings, which also sais which of the three types of 73 entities should be used to drive the heuristical construction (only occluders by default) 74 74 */ 75 75 virtual bool BuildKdTree(); 76 76 77 77 /** Compute visibility method. This method has to be reimplemented by the actual 78 Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,79 GlobalSamplingpreprocessor)78 Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor, 79 GlobalSamplingpreprocessor) 80 80 */ 81 81 virtual bool ComputeVisibility() = 0; 82 82 83 83 /** Post Process the computed visibility. By default applys the visibility filter 84 (if specified in the environment and export the preprocessed data */ 84 (if specified in the environment and export the preprocessed data 85 */ 85 86 virtual bool PostProcessVisibility(); 86 87 87 88 /** View cells are either loaded or prepared for generation, according to the chosen environment 88 object. Important evironment options are, e.g, the view cell type.89 Should be done after scene loading (i.e., some options are based on scene type).89 object. Important evironment options are, e.g, the view cell type. 90 Should be done after scene loading (i.e., some options are based on scene type). 90 91 */ 91 92 bool PrepareViewCells(); … … 111 112 @returns true if samples were loaded successfully 112 113 */ 113 bool LoadSamples(VssRayContainer &samples, 114 ObjectContainer &objects) const; 114 bool LoadSamples(VssRayContainer &samples, ObjectContainer &objects) const; 115 115 116 116 /** Exports samples to file. 117 @returns true if samples were written successfully117 @returns true if samples were written successfully 118 118 */ 119 119 bool ExportSamples(const VssRayContainer &samples) const; … … 158 158 ); 159 159 160 /** Compute pixel error of the current PVS solution by sampling given number of viewpoints 160 /** Compute pixel error of the current PVS solution by sampling given number of viewpoints. 161 161 */ 162 162 virtual void ComputeRenderError(); … … 223 223 bool mUseGlRenderer; 224 224 bool mUseGlDebugger; 225 bool mUseHwGlobalLines; 225 226 bool mUseHwGlobalLines; 226 227 bool mLoadViewCells; 227 228 … … 261 262 RayCaster *mRayCaster; 262 263 264 263 265 protected: 264 266 … … 288 290 vector<FaceParentInfo> mFaceParents; 289 291 290 291 292 292 /// if box around view space should be used 293 293 bool mUseViewSpaceBox; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r2176 r2187 267 267 Name="VCCLCompilerTool" 268 268 Optimization="3" 269 GlobalOptimizations="TRUE" 269 270 InlineFunctionExpansion="0" 270 FavorSizeOrSpeed="0" 271 OptimizeForProcessor="3" 271 EnableIntrinsicFunctions="TRUE" 272 FavorSizeOrSpeed="1" 273 OmitFramePointers="TRUE" 274 EnableFiberSafeOptimizations="TRUE" 275 OptimizeForProcessor="0" 272 276 OptimizeForWindowsApplication="TRUE" 273 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing; "$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include""277 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;Timer" 274 278 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;NO_QT" 279 StringPooling="TRUE" 275 280 ExceptionHandling="TRUE" 276 281 RuntimeLibrary="2" 282 EnableEnhancedInstructionSet="2" 277 283 DisableLanguageExtensions="FALSE" 278 284 ForceConformanceInForLoopScope="FALSE" 279 RuntimeTypeInfo=" TRUE"285 RuntimeTypeInfo="FALSE" 280 286 UsePrecompiledHeader="0" 281 287 BrowseInformation="1" … … 1160 1166 </File> 1161 1167 <File 1168 RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h"> 1169 </File> 1170 <File 1162 1171 RelativePath=".\sparsehash\src\windows\hash_fun.h"> 1163 </File>1164 <File1165 RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h">1166 1172 </File> 1167 1173 <File -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
r2105 r2187 238 238 239 239 240 VssRay *RayCaster::RequestRay(const Vector3 &origin, 241 const Vector3 &termination, 242 Intersectable *originObject, 243 Intersectable *terminationObject, 244 const int pass, 245 const float pdf) 246 { 247 #if DEBUG_RAYCAST 248 Debug<<"PR2a"<<flush; 249 #endif 250 251 // old method: always allocate 252 if (1) return new VssRay(origin, termination, originObject, terminationObject, pass, pdf); 253 254 VssRay *vssRay = mVssRayPool.Alloc(); 255 256 #if DEBUG_RAYCAST 257 Debug<<"PR2b"<<flush; 258 #endif 259 260 *vssRay = VssRay(origin, termination, originObject, terminationObject, pass, pdf); 261 262 #if DEBUG_RAYCAST 263 Debug<<"PR2c"<<flush; 264 #endif 265 266 return vssRay; 267 } 268 240 269 241 270 int … … 306 335 307 336 if (!pruneInvalidRays || hitA.mObject) { 308 #if DEBUG_RAYCAST 309 Debug<<"PR2a"<<flush; 310 #endif 311 312 VssRay *vssRay = mVssRayPool.Alloc(); 313 314 #if DEBUG_RAYCAST 315 Debug<<"PR2b"<<flush; 316 #endif 317 *vssRay = VssRay( 318 !castDoubleRay ? simpleRay.mOrigin : clipB, 337 338 VssRay *vssRay = 339 RequestRay(!castDoubleRay ? simpleRay.mOrigin : clipB, 319 340 hitA.mPoint, 320 341 hitB.mObject, … … 323 344 1.0f //simpleRay.mPdf 324 345 ); 325 #if DEBUG_RAYCAST 326 Debug<<"PR2c"<<flush; 327 #endif 328 346 329 347 if (validA) 330 348 vssRay->mFlags |= VssRay::Valid; … … 344 362 if (castDoubleRay && (!pruneInvalidRays || hitB.mObject)) 345 363 { 346 VssRay *vssRay = mVssRayPool.Alloc(); 347 348 *vssRay = VssRay( 349 clipA, 350 hitB.mPoint, 351 hitA.mObject, 352 hitB.mObject, 353 mPreprocessor.mPass, 354 1.0f //simpleRay.mPdf 355 ); 364 VssRay *vssRay = RequestRay( 365 clipA, 366 hitB.mPoint, 367 hitA.mObject, 368 hitB.mObject, 369 mPreprocessor.mPass, 370 1.0f //simpleRay.mPdf 371 ); 356 372 357 373 if (validB) … … 381 397 const bool pruneInvalidRays ) 382 398 { 383 384 385 386 CastRay(399 SimpleRayContainer::const_iterator rit, rit_end = rays.end(); 400 401 for (rit = rays.begin(); rit != rit_end; ++ rit) { 402 CastRay( 387 403 *rit, 388 404 vssRays, … … 390 406 castDoubleRay, 391 407 pruneInvalidRays); 392 393 394 } 395 396 } 408 } 409 } 410 411 412 } -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
r2176 r2187 108 108 }; 109 109 110 111 110 VssRayPool mVssRayPool; 112 111 … … 121 120 122 121 protected: 122 123 VssRay *RequestRay(const Vector3 &origin, 124 const Vector3 &termination, 125 Intersectable *originObject, 126 Intersectable *terminationObject, 127 const int pass, 128 const float pdf); 129 123 130 void _SortRays(SimpleRayContainer &rays, 124 131 const int l, -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r2116 r2187 52 52 // terminate the whole method? 53 53 for (; i < number; i++) 54 54 { 55 55 int j = 0; 56 56 bool sampleGenerated = false; 57 57 58 58 for (j = 0; !sampleGenerated && (j < maxTries); ++ j) 59 59 { 60 60 sampleGenerated = GenerateSample(ray); 61 61 62 62 if (sampleGenerated) 63 63 { 64 64 ++ samples; 65 65 rays.push_back(ray); 66 } 67 } 68 } 69 70 71 66 } 67 } 68 } 72 69 73 70 return samples; … … 313 310 return true; 314 311 } 315 316 317 #if 0318 bool ObjectsInteriorDistribution::GenerateSample(SimpleRay &ray)319 {320 Vector3 origin, direction;321 322 // get random object323 const int i = RandomValue(0, mPreprocessor.mObjects.size() - 1);324 325 const Intersectable *obj = mPreprocessor.mObjects[i];326 327 // note: if we load the polygons as meshes,328 // asymtotically every second sample is lost!329 origin = obj->GetBox().GetRandomPoint();330 331 // uniformly distributed direction332 direction = UniformRandomVector();333 334 const float c = Magnitude(direction);335 336 if (c <= Limits::Small)337 return false;338 339 const float pdf = 1.0f;340 341 direction *= 1.0f / c;342 ray = SimpleRay(origin, direction, pdf);343 344 return true;345 }346 347 #endif348 312 349 313 -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r2176 r2187 256 256 GlobalOptimizations="TRUE" 257 257 InlineFunctionExpansion="2" 258 FavorSizeOrSpeed="1" 258 EnableIntrinsicFunctions="TRUE" 259 FavorSizeOrSpeed="1" 260 OmitFramePointers="TRUE" 259 261 EnableFiberSafeOptimizations="TRUE" 260 OptimizeForProcessor=" 3"262 OptimizeForProcessor="0" 261 263 OptimizeForWindowsApplication="TRUE" 262 264 AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;"$(QTDIR)\include\QtOpenGl";"$(QTDIR)\include\Qt";"$(QTDIR)\include\QtCore";"$(QTDIR)\include"" 263 265 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;NO_QT" 264 RuntimeLibrary="2" 265 RuntimeTypeInfo="TRUE" 266 StringPooling="TRUE" 267 MinimalRebuild="FALSE" 268 RuntimeLibrary="2" 269 EnableEnhancedInstructionSet="2" 270 RuntimeTypeInfo="FALSE" 266 271 UsePrecompiledHeader="0" 267 272 WarningLevel="3" … … 275 280 OutputFile="../bin/release/Preprocessor.exe" 276 281 LinkIncremental="1" 277 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" 278 GenerateDebugInformation="FALSE" 279 SubSystem="1" 280 OptimizeReferences="2" 281 EnableCOMDATFolding="2" 282 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" 283 GenerateDebugInformation="FALSE" 284 SubSystem="1" 285 LargeAddressAware="0" 286 OptimizeReferences="2" 287 EnableCOMDATFolding="2" 288 OptimizeForWindows98="1" 282 289 TargetMachine="1" 283 290 FixedBaseAddress="1"/> -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2176 r2187 969 969 if (mShowVisualization) 970 970 { 971 if (0)972 {973 mStrategies.clear();974 mStrategies.push_back(SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION);975 }976 977 971 /////////////// 978 972 //-- visualization rays, e.g., to show some samples in the scene … … 2712 2706 if (!useHitObjects) 2713 2707 { 2708 // store higher order object (e.g., bvh node) instead of object itself 2714 2709 VssRayContainer::const_iterator it, it_end = rays.end(); 2715 2710 … … 2717 2712 { 2718 2713 VssRay *vssRay = *it; 2714 2719 2715 // set only the termination object 2720 vssRay->mTerminationObject = GetIntersectable( 2721 *vssRay, 2722 true); 2716 vssRay->mTerminationObject = GetIntersectable(*vssRay, true); 2723 2717 } 2724 2718 } … … 2771 2765 ray.mRelativePvsContribution = 0.0f; 2772 2766 2773 mSamplesStat.mRays++;2767 ++ mSamplesStat.mRays; 2774 2768 2775 2769 if (!ray.mTerminationObject) … … 2796 2790 static VssRay *lastVssRay = NULL; 2797 2791 2792 // check if last ray was not same ray with reverse direction 2798 2793 if (lastVssRay == NULL || 2799 2794 !(ray.mOrigin == lastVssRay->mTermination) || … … 2819 2814 ray.mViewCells = viewCells; 2820 2815 #else 2821 cerr <<"Vss store viewcells not supported."<<endl;2816 cerr << "Vss store viewcells not supported." << endl; 2822 2817 exit(1); 2823 2818 #endif … … 2850 2845 mSamplesStat.mPvsContributions += ray.mPvsContribution; 2851 2846 if (ray.mPvsContribution) 2852 mSamplesStat.mContributingRays++;2847 ++ mSamplesStat.mContributingRays; 2853 2848 2854 2849 #if AVG_RAY_CONTRIBUTIONS -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2176 r2187 668 668 const bool globalCriteriaMet) 669 669 { 670 mSubdivTimer.Entry(); 671 670 672 // todo remove dynamic cast 671 673 VspSubdivisionCandidate *sc = … … 686 688 const int maxCostMisses = sc->GetMaxCostMisses(); 687 689 688 newNode = SubdivideNode(*sc, 689 tFrontData, 690 tBackData); 691 690 newNode = SubdivideNode(*sc, tFrontData, tBackData); 691 692 692 // how often was max cost ratio missed in this branch? 693 693 tFrontData.mMaxCostMisses = maxCostMisses; … … 766 766 } 767 767 768 mSubdivTimer.Exit(); 769 768 770 return newNode; 769 771 } … … 773 775 bool computeSplitPlane) 774 776 { 777 mEvalTimer.Entry(); 778 775 779 if (computeSplitPlane) 776 780 { … … 825 829 826 830 splitCandidate.SetPriority(priority); 831 832 mEvalTimer.Exit(); 827 833 } 828 834 … … 887 893 VspTraversalData &backData) 888 894 { 895 mNodeTimer.Entry(); 896 889 897 VspLeaf *leaf = static_cast<VspLeaf *>(sc.mParentData.mNode); 890 898 … … 993 1001 AddViewCellReferences(backLeaf->GetViewCell()); 994 1002 #endif 1003 1004 mNodeTimer.Exit(); 995 1005 996 1006 return interior; … … 1023 1033 1024 1034 if (entry) 1025 { cout<<"a";1035 { 1026 1036 madeContrib = 1027 1037 vc->GetPvs().AddSample(entry, ray->mPdf); … … 1052 1062 1053 1063 void VspTree::SortSubdivisionCandidates(const RayInfoContainer &rays, 1054 const int axis, 1055 float minBand, 1056 float maxBand) 1057 { 1064 const int axis, 1065 float minBand, 1066 float maxBand) 1067 { 1068 mSortTimer.Entry(); 1069 1058 1070 mLocalSubdivisionCandidates->clear(); 1059 1071 … … 1102 1114 stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1103 1115 //sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1116 1117 mSortTimer.Exit(); 1104 1118 } 1105 1119 … … 1408 1422 float &pBack) 1409 1423 { 1424 mSplitTimer.Entry(); 1425 1410 1426 float nPosition[3]; 1411 1427 float nCostRatio[3]; … … 1502 1518 pFront = nProbFront[bestAxis]; 1503 1519 pBack = nProbBack[bestAxis]; 1520 1521 mSplitTimer.Exit(); 1504 1522 1505 1523 return nCostRatio[bestAxis]; … … 3191 3209 { 3192 3210 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 3193 UpdateContributionsToPvs(leaf, cf, frontPvs, backPvs, totalPvs );3211 UpdateContributionsToPvs(leaf, cf, frontPvs, backPvs, totalPvs, false); 3194 3212 break; 3195 3213 } … … 3242 3260 int pvs = 0; 3243 3261 3244 switch (mHierarchyManager->GetObjectSpaceSubdivisionType())3262 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 3245 3263 { 3246 3264 case HierarchyManager::NO_OBJ_SUBDIV: -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r2176 r2187 12 12 #include "SubdivisionCandidate.h" 13 13 #include "HierarchyManager.h" 14 #include "PerfTimer.h" 14 15 15 16 … … 535 536 float GetPriority() const 536 537 { 537 return (float)-mParentData.mDepth; 538 //return mPriority; 538 return mPriority; 539 539 } 540 540 … … 723 723 VspNode *SubdivideAndCopy(SplitQueue &tQueue, SubdivisionCandidate *splitCandidate); 724 724 725 PerfTimer mSortTimer; 726 PerfTimer mSplitTimer; 727 PerfTimer mNodeTimer; 728 PerfTimer mSubdivTimer; 729 PerfTimer mEvalTimer; 725 730 726 731 protected: … … 985 990 float &backPvs, 986 991 float &totalPvsm, 987 const bool countEntries = false) const;992 const bool countEntries) const; 988 993 989 994 /** Evaluates the contribution for kd leaves. -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r2116 r2187 623 623 void VssPreprocessor::DeterminePvsObjects(VssRayContainer &rays) 624 624 { 625 // Preprocessor::DeterminePvsObjects(rays);626 mViewCellsManager->DeterminePvsObjects(rays, true);627 } 628 629 630 } 625 // store higher order object 626 mViewCellsManager->DeterminePvsObjects(rays, false); 627 } 628 629 630 } -
GTP/trunk/Lib/Vis/Preprocessing/src/common.cpp
r2176 r2187 158 158 TimeDiff(long time1, long time2) // in ms 159 159 { 160 const Real clk=1.0e-3f; // ticks per second160 //const Real clk=1.0e-3f; // ticks per second 161 161 // $$ tmp store time in ms 162 //const Real clk=1.0f; // ticks per second162 const Real clk=1.0f; // ticks per second 163 163 long t=time2-time1; 164 164
Note: See TracChangeset
for help on using the changeset viewer.