Changeset 1259 for GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
- Timestamp:
- 08/22/06 22:48:02 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1237 r1259 20 20 #include "VspTree.h" 21 21 #include "OspTree.h" 22 #include "BvHierarchy.h" 22 23 23 24 … … 33 34 34 35 35 HierarchyManager::HierarchyManager(VspTree &vspTree, OspTree &ospTree): 36 mVspTree(vspTree), mOspTree(ospTree) 37 { 38 // cross references 39 mVspTree.mOspTree = &ospTree; 40 mOspTree.mVspTree = &vspTree; 41 36 HierarchyManager::HierarchyManager(VspTree &vspTree, OspTree &ospTree) 37 //:mVspTree(vspTree), mOspTree(ospTree) 38 { 42 39 char subdivisionStatsLog[100]; 43 40 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", … … 63 60 { 64 61 SubdivisionCandidate *vsc = 65 mVspTree .PrepareConstruction(sampleRays, forcedViewSpace, viewSpaceRays);62 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, viewSpaceRays); 66 63 mTQueue.Push(vsc); 67 64 68 65 SubdivisionCandidate *osc = 69 mOspTree .PrepareConstruction(sampleRays, objects, forcedViewSpace, objectSpaceRays);66 mOspTree->PrepareConstruction(sampleRays, objects, forcedViewSpace, objectSpaceRays); 70 67 71 68 mTQueue.Push(osc); … … 78 75 79 76 //mTotalCost -= costDecr; 80 // 81 82 AddSubdivisionStats(mOspTree .mOspStats.Leaves() + mVspTree.mVspStats.Leaves(),77 //mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 78 79 AddSubdivisionStats(mOspTree->mOspStats.Leaves() + mVspTree->mVspStats.Leaves(), 83 80 costDecr, 84 81 mTotalCost … … 116 113 PrepareConstruction(sampleRays, objects, forcedViewSpace, *viewSpaceRays, *objectSpaceRays); 117 114 118 mVspTree .mVspStats.Reset();119 mVspTree .mVspStats.Start();115 mVspTree->mVspStats.Reset(); 116 mVspTree->mVspStats.Start(); 120 117 121 118 cout << "Constructing view space / object space tree ... \n"; … … 126 123 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 127 124 128 mVspTree .mVspStats.Stop();125 mVspTree->mVspStats.Stop(); 129 126 } 130 127 … … 139 136 if (vspSplit) 140 137 { 141 VspNode *n = mVspTree .Subdivide(mTQueue, sc, globalTerminationCriteriaMet);138 VspNode *n = mVspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 142 139 } 143 140 else 144 141 { 145 KdNode *n = mOspTree .Subdivide(mTQueue, sc, globalTerminationCriteriaMet);142 KdNode *n = mOspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 146 143 } 147 144 … … 209 206 // during view space partition 210 207 const bool savedCountMethod = mVspTree.mUseKdPvsForHeuristics; 211 const bool savedStoreMethod = mVspTree.mStore KdPvs;208 const bool savedStoreMethod = mVspTree.mStoreObjectPvs; 212 209 213 210 mVspTree.mUseKdPvsForHeuristics = false; 214 mVspTree.mStore KdPvs = false;211 mVspTree.mStoreObjectPvs = false; 215 212 #endif 216 213 217 214 SubdivisionCandidate *vsc = 218 mVspTree .PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays);215 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 219 216 220 217 // add to queue … … 224 221 cout << "starting vsp contruction ... " << endl; 225 222 226 mVspTree .mVspStats.Reset();227 mVspTree .mVspStats.Start();223 mVspTree->mVspStats.Reset(); 224 mVspTree->mVspStats.Start(); 228 225 229 226 int i = 0; … … 238 235 239 236 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 240 mVspTree.mVspStats.Stop(); 241 237 mVspTree->mVspStats.Stop(); 242 238 243 239 … … 255 251 // compute first candidate 256 252 SubdivisionCandidate *osc = 257 mOspTree .PrepareConstruction(sampleRays, objects, forcedViewSpace, *objectSpaceRays);253 mOspTree->PrepareConstruction(sampleRays, objects, forcedViewSpace, *objectSpaceRays); 258 254 259 255 Debug << "reseting cost, new total cost: " << mTotalCost << endl; 260 mTotalCost = mOspTree .mTotalCost;256 mTotalCost = mOspTree->mTotalCost; 261 257 262 258 mTQueue.Push(osc); 263 259 264 mOspTree .mOspStats.Reset();265 mOspTree .mOspStats.Start();260 mOspTree->mOspStats.Reset(); 261 mOspTree->mOspStats.Start(); 266 262 267 263 startTime = GetTime(); … … 272 268 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 273 269 274 mOspTree .mOspStats.Stop();275 276 float rc = mOspTree .EvalRenderCost(sampleRays);270 mOspTree->mOspStats.Stop(); 271 272 float rc = mOspTree->EvalRenderCost(sampleRays); 277 273 278 274 Debug << "here47 My render cost evalulation: " << rc << endl; … … 280 276 #if 0 281 277 // reset parameters 282 mVspTree .mUseKdPvsForHeuristics = savedCountMethod;283 mVspTree .mStoreKdPvs = savedStoreMethod;278 mVspTree->mUseKdPvsForHeuristics = savedCountMethod; 279 mVspTree->mStoreObjectPvs = savedStoreMethod; 284 280 #endif 285 281 } … … 290 286 AxisAlignedBox3 *forcedViewSpace) 291 287 { 292 // only view space partition288 // construct only view space partition 293 289 // object kd tree is taken for osp 294 290 295 mVspTree .mVspStats.Reset();296 mVspTree .mVspStats.Start();291 mVspTree->mVspStats.Reset(); 292 mVspTree->mVspStats.Start(); 297 293 298 294 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 299 295 300 296 SubdivisionCandidate *sc = 301 mVspTree .PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays);297 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 302 298 303 299 mTQueue.Push(sc); … … 310 306 311 307 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 312 mVspTree .mVspStats.Stop();308 mVspTree->mVspStats.Stop(); 313 309 } 314 310 … … 320 316 321 317 322 void HierarchyManager::CollectDirtyCandidates(vector<SubdivisionCandidate *> &dirtyList) 318 void HierarchyManager::CollectObjectSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 319 { 320 switch (mObjectSpaceSubdivisonType) 321 { 322 case KD_BASED_OBJ_SUBDIV: 323 { 324 OspTree::OspSubdivisionCandidate *sc = 325 dynamic_cast<OspTree::OspSubdivisionCandidate *>(mCurrentCandidate); 326 327 mOspTree->CollectDirtyCandidates(sc, dirtyList); 328 break; 329 } 330 case BV_BASED_OBJ_SUBDIV: 331 { 332 BvHierarchy::BvhSubdivisionCandidate *sc = 333 dynamic_cast<BvHierarchy::BvhSubdivisionCandidate *>(mCurrentCandidate); 334 335 mBvHierarchy->CollectDirtyCandidates(sc, dirtyList); 336 break; 337 } 338 default: 339 break; 340 } 341 } 342 343 344 void HierarchyManager::CollectViewSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 345 { 346 VspTree::VspSubdivisionCandidate *sc = 347 dynamic_cast<VspTree::VspSubdivisionCandidate *>(mCurrentCandidate); 348 349 mVspTree->CollectDirtyCandidates(sc, dirtyList); 350 } 351 352 353 void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList) 323 354 { 324 355 // we have either a object space or view space split 325 356 if (mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 326 357 { 327 VspTree::VspSubdivisionCandidate *sc = 328 dynamic_cast<VspTree::VspSubdivisionCandidate *>(mCurrentCandidate); 329 330 mVspTree.CollectDirtyCandidates(sc, dirtyList); 358 CollectViewSpaceDirtyList(dirtyList); 331 359 } 332 360 else // object space split 333 { 334 OspTree::OspSubdivisionCandidate *sc = 335 dynamic_cast<OspTree::OspSubdivisionCandidate *>(mCurrentCandidate); 336 337 mOspTree.CollectDirtyCandidates(sc, dirtyList); 361 { 362 CollectObjectSpaceDirtyList(dirtyList); 338 363 } 339 364 } … … 380 405 } 381 406 382 } 407 408 }
Note: See TracChangeset
for help on using the changeset viewer.