Changeset 1370 for GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
- Timestamp:
- 09/14/06 18:55:38 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1344 r1370 95 95 "Hierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 96 96 97 Environment::GetSingleton()->GetBoolValue( 98 "Hierarchy.Construction.startWithObjectSpace", mStartWithObjectSpace); 99 97 100 Environment::GetSingleton()->GetIntValue( 98 101 "Hierarchy.Termination.maxLeaves", mTermMaxLeaves); … … 103 106 Environment::GetSingleton()->GetIntValue( 104 107 "Hierarchy.Construction.minDepthForOsp", mMinDepthForObjectSpaceSubdivion); 108 109 Environment::GetSingleton()->GetIntValue( 110 "Hierarchy.Construction.minDepthForVsp", mMinDepthForViewSpaceSubdivion); 105 111 106 112 Environment::GetSingleton()->GetBoolValue( … … 125 131 126 132 133 int HierarchyManager::GetObjectSpaceSubdivisionType() const 134 { 135 return mObjectSpaceSubdivisionType; 136 } 137 138 139 int HierarchyManager::GetViewSpaceSubdivisionType() const 140 { 141 return mViewSpaceSubdivisionType; 142 } 143 144 127 145 void HierarchyManager::SetViewCellsManager(ViewCellsManager *vcm) 128 146 { … … 220 238 mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 221 239 240 mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 241 mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 242 222 243 // start with view space subdivison: prepare vsp tree for traversal 223 244 if (StartViewSpaceSubdivision()) … … 238 259 239 260 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 261 240 262 mHierarchyStats.Stop(); 241 263 mVspTree->mVspStats.Stop(); 264 FinishObjectSpaceSubdivision(); 265 266 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 267 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 242 268 } 243 269 … … 247 273 AxisAlignedBox3 *forcedViewSpace) 248 274 { 275 cout << "starting view space hierarchy construction ... " << endl; 276 249 277 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 250 278 SubdivisionCandidate *vsc = … … 291 319 const ObjectContainer &objects) 292 320 { 321 cout << "starting osp tree construction ... " << endl; 322 293 323 RayInfoContainer *objectSpaceRays = new RayInfoContainer(); 294 295 cout << "starting osp tree construction ... " << endl;296 324 297 325 // start with one big kd cell - all objects can be seen from everywhere … … 342 370 343 371 372 int HierarchyManager::GetObjectSpaceSubdivisionDepth() const 373 { 374 int maxDepth = 0; 375 376 if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 377 { 378 maxDepth = mOspTree->mOspStats.maxDepth; 379 } 380 else if (mObjectSpaceSubdivisionType == BV_BASED_OBJ_SUBDIV) 381 { 382 maxDepth = mBvHierarchy->mBvhStats.maxDepth; 383 } 384 385 return maxDepth; 386 } 387 388 344 389 bool HierarchyManager::StartObjectSpaceSubdivision() const 345 390 { 346 const bool ospDepthReached = 347 (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth); 348 349 return !ObjectSpaceSubdivisionConstructed() && 350 (mTQueue.Empty() || ((mConstructionType == INTERLEAVED) && ospDepthReached)); 391 // view space construction already started 392 if (ObjectSpaceSubdivisionConstructed()) 393 return false; 394 395 // start immediately with object space subdivision? 396 if (mStartWithObjectSpace) 397 return true; 398 399 // is the queue empty again? 400 if (ViewSpaceSubdivisionConstructed() && mTQueue.Empty()) 401 return true; 402 403 // has the depth for subdivision been reached? 404 return 405 ((mConstructionType == INTERLEAVED) && 406 (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth)); 351 407 } 352 408 … … 354 410 bool HierarchyManager::StartViewSpaceSubdivision() const 355 411 { 356 const bool vspDepthReached = 357 (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth); 358 359 return !ViewSpaceSubdivisionConstructed() && 360 (mTQueue.Empty() || ((mConstructionType == INTERLEAVED) && vspDepthReached)); 412 // view space construction already started 413 if (ViewSpaceSubdivisionConstructed()) 414 return false; 415 416 // start immediately with view space subdivision? 417 if (!mStartWithObjectSpace) 418 return true; 419 420 // is the queue empty again? 421 if (ObjectSpaceSubdivisionConstructed() && mTQueue.Empty()) 422 return true; 423 424 // has the depth for subdivision been reached? 425 return 426 ((mConstructionType == INTERLEAVED) && 427 (mMinDepthForViewSpaceSubdivion <= GetObjectSpaceSubdivisionDepth())); 361 428 } 362 429 … … 384 451 } 385 452 453 /////////////////////////// 386 454 //-- subdivide leaf node 387 455 if (ApplySubdivisionCandidate(mCurrentCandidate)) … … 420 488 421 489 cout << "starting view space subdivision at depth " 422 << mVspTree->mVspStats.maxDepth<< " ("423 << mMinDepthFor ObjectSpaceSubdivion << ") " << endl;490 << GetObjectSpaceSubdivisionDepth() << " (" 491 << mMinDepthForViewSpaceSubdivion << ") " << endl; 424 492 425 493 PrepareViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); … … 432 500 DEL_PTR(mCurrentCandidate); 433 501 } 434 435 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType;436 502 } 437 503 … … 632 698 { 633 699 BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 634 return mBvHierarchy->AddLeafToPvs(leaf, vc, pdf, contribution); 700 BvhIntersectable *bvhObj = mBvHierarchy->GetOrCreateBvhIntersectable(leaf); 701 702 return vc->AddPvsSample(bvhObj, pdf, contribution); 635 703 } 636 704 default: … … 647 715 stream << mVspTree->GetStatistics() << endl; 648 716 stream << "\nobject space:" << endl << endl; 717 649 718 switch (mObjectSpaceSubdivisionType) 650 719 { … … 726 795 727 796 728 } 797 void HierarchyManager::FinishObjectSpaceSubdivision() const 798 { 799 switch (mObjectSpaceSubdivisionType) 800 { 801 case KD_BASED_OBJ_SUBDIV: 802 { 803 mOspTree->mOspStats.Stop(); 804 break; 805 } 806 case BV_BASED_OBJ_SUBDIV: 807 { 808 mBvHierarchy->mBvhStats.Stop(); 809 break; 810 } 811 default: 812 break; 813 } 814 } 815 816 }
Note: See TracChangeset
for help on using the changeset viewer.