Changeset 1667 for GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
- Timestamp:
- 10/23/06 20:24:14 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1666 r1667 358 358 // hack: assume that object space can be seen from view space 359 359 mHierarchyStats.mTotalCost = (float)objects.size(); 360 // only one entry for start 360 361 mHierarchyStats.mPvsEntries = 1; 361 362 const int entrySize = sizeof(PvsData) + sizeof(Intersectable *); 363 mHierarchyStats.mMemory = entrySize / (1024.0f * 1024.0f); 362 mHierarchyStats.mMemory = (float)ObjectPvs::GetEntrySizeByte(); 364 363 365 364 EvalSubdivisionStats(); … … 396 395 // for first round, use sah splits. Once view space partition 397 396 // has started, use render cost heuristics instead 398 const int ospSteps = 399 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps); 397 const int ospSteps = RunConstruction(objectSpaceQueue, dirtyVspList, NULL, minSteps); 400 398 401 399 cout << "\n" << ospSteps << " object space partition steps taken" << endl; 402 400 403 401 // create view space 404 SubdivisionCandidate *vsc = 405 PrepareViewSpaceSubdivision(sampleRays, objects); 402 SubdivisionCandidate *vsc = PrepareViewSpaceSubdivision(sampleRays, objects); 406 403 407 404 viewSpaceQueue.Push(vsc); … … 414 411 // account so we can compare to view space splits 415 412 ResetQueue(objectSpaceQueue, false); 416 417 //minSteps = 1;418 413 419 414 // This method subdivides view space / object space … … 425 420 while (!(viewSpaceQueue.Empty() && objectSpaceQueue.Empty())) 426 421 { 427 float vspPriority; 422 // decide upon next split type 423 const float vspPriority = viewSpaceQueue.Top() ? viewSpaceQueue.Top()->GetPriority() : -1e20; 424 const float ospPriority = viewSpaceQueue.Top() ? objectSpaceQueue.Top()->GetPriority() : -1e20; 428 425 429 // decide upon next split type430 if (!viewSpaceQueue.Empty())431 {432 vspPriority = viewSpaceQueue.Top()->GetPriority();433 434 // rather take this into account directly when computing priority435 if (0 && mConsiderMemory)436 vspPriority /= ((float)viewSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small);437 }438 else439 {440 vspPriority = 0;441 }442 443 float ospPriority;444 445 if (!objectSpaceQueue.Empty())446 {447 ospPriority = objectSpaceQueue.Top()->GetPriority();448 449 // rather take this into account directly when computing priority450 if (0 && mConsiderMemory)451 ospPriority /= ((float)objectSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small);452 }453 else454 {455 ospPriority = 0;456 }457 458 426 cout << "new decicion, vsp: " << vspPriority << ", osp: " << ospPriority << endl; 459 427 … … 471 439 // has started, use render cost heuristics instead 472 440 const int ospSteps = 473 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps);441 RunConstruction(objectSpaceQueue, dirtyVspList, viewSpaceQueue.Top(), minSteps); 474 442 475 443 cout << "\n" << ospSteps << " object space partition steps taken" << endl; … … 493 461 // process view space candidates 494 462 const int vspSteps = 495 RunConstruction(viewSpaceQueue, dirtyOspList, renderCostDecr, minSteps);463 RunConstruction(viewSpaceQueue, dirtyOspList, objectSpaceQueue.Top(), minSteps); 496 464 497 465 cout << "\n" << vspSteps << " view space partition steps taken" << endl; … … 526 494 mHierarchyStats.mNodes = 2; 527 495 mHierarchyStats.mPvsEntries = 1; 528 mHierarchyStats.mMemory = sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f);496 mHierarchyStats.mMemory = (float)ObjectPvs::GetEntrySizeByte(); 529 497 mHierarchyStats.mTotalCost = (float)objects.size(); 530 498 … … 570 538 571 539 // begin subdivision 572 RunConstruction(mRepairQueue, 573 sampleRays, 574 objects, 575 forcedViewSpace); 540 RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); 576 541 577 542 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 734 699 //cout << "pvs entries: " << pvsEntriesIncr << " " << mHierarchyStats.pvsEntries << endl; 735 700 736 const int sizeOfEntry = sizeof(PvsData) + sizeof(Intersectable *);737 701 // memory size in byte 738 mHierarchyStats.mMemory += float(pvsEntriesIncr * sizeOfEntry);702 mHierarchyStats.mMemory += (float)ObjectPvs::GetEntrySizeByte(); 739 703 mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 740 704 … … 744 708 { 745 709 memoryCount += 100000; 746 cout << "\nstorage cost: " << mHierarchyStats.mMemory / (1024.0f * 1024.0f) << ", steps: " << mHierarchyStats.Leaves() << endl;710 cout << "\nstorage cost: " << mHierarchyStats.mMemory / float(1024 * 1024) << " MB, steps: " << mHierarchyStats.Leaves() << endl; 747 711 } 748 712 … … 930 894 int HierarchyManager::RunConstruction(SplitQueue &splitQueue, 931 895 SubdivisionCandidateContainer &dirtyCandidates, 932 const float minRenderCostDecr,896 SubdivisionCandidate *oldCandidate, 933 897 const int minSteps) 934 898 { … … 939 903 while (!splitQueue.Empty()) 940 904 { 905 const float threshold = oldCandidate ? oldCandidate->GetPriority() : 1e20; 941 906 SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue); 942 907 //cout << "here2 " << sc->GetPriority() << " " << threshold << endl; 908 943 909 // minimum slope reached 944 if ((sc->GetRenderCostDecrease() < minRenderCostDecr) && 945 !(steps < minSteps)) 946 { 947 //cout << "breaking on " << sc->GetRenderCostDecrease() << " smaller than " << minRenderCostDecr << endl; 910 if ((sc->GetPriority() < threshold) && !(steps < minSteps)) 911 { 912 cout << "**************** breaking on " << sc->GetPriority() << " smaller than " << threshold << endl; 948 913 break; 949 914 } 915 950 916 //////// 951 917 //-- subdivide leaf node of either type … … 993 959 mHierarchyStats.mPvsEntries = mBvHierarchy->CountViewCells(objects); 994 960 995 mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries *996 sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f);961 mHierarchyStats.mMemory = 962 (float)mHierarchyStats.mPvsEntries * ObjectPvs::GetEntrySizeByte(); 997 963 998 964 mHierarchyStats.mRenderCostDecrease = 0; … … 1038 1004 mHierarchyStats.mRenderCostDecrease = 0; 1039 1005 1040 mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries * 1041 sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 1006 mHierarchyStats.mMemory = (float)mHierarchyStats.mPvsEntries * ObjectPvs::GetEntrySizeByte(); 1042 1007 1043 1008 // evaluate new stats before first subdivsiion … … 1309 1274 const float rcd = sc->GetRenderCostDecrease(); 1310 1275 1311 splitQueue.Erase(sc); // erase from queue 1312 sc->EvalPriority(recomputeSplitPlaneOnRepair); // reevaluate 1313 1276 // erase from queue 1277 splitQueue.Erase(sc); 1278 // reevaluate candidate 1279 sc->EvalCandidate(recomputeSplitPlaneOnRepair); 1280 // reinsert 1281 splitQueue.Push(sc); 1282 1283 cout << "."; 1284 1314 1285 #ifdef _DEBUG 1315 1286 Debug << "candidate " << sc << " reevaluated\n" … … 1317 1288 << " old: " << rcd << " new " << sc->GetRenderCostDecrease() << endl; 1318 1289 #endif 1319 splitQueue.Push(sc); // reinsert1320 cout << ".";1321 1290 } 1322 1291 … … 1339 1308 SubdivisionCandidate *candidate = NextSubdivisionCandidate(splitQueue); 1340 1309 // reevaluate local split plane and priority 1341 candidate->Eval Priority(recomputeSplitPlane);1310 candidate->EvalCandidate(recomputeSplitPlane); 1342 1311 cout << "."; 1343 1312 mCandidateBuffer.push_back(candidate);
Note: See TracChangeset
for help on using the changeset viewer.