Changeset 1576 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/05/06 18:51:15 (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
r1571 r1576 369 369 370 370 // how often was max cost ratio missed in this branch? 371 frontData.mMaxCostMisses = sc. mMaxCostMisses;372 backData.mMaxCostMisses = sc. mMaxCostMisses;371 frontData.mMaxCostMisses = sc.GetMaxCostMisses(); 372 backData.mMaxCostMisses = sc.GetMaxCostMisses(); 373 373 374 374 // assign the objects in sorted order … … 475 475 const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 476 476 477 splitCandidate. mMaxCostMisses =maxCostRatioViolated ?477 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ? 478 478 splitCandidate.mParentData.mMaxCostMisses + 1 : 479 splitCandidate.mParentData.mMaxCostMisses ;479 splitCandidate.mParentData.mMaxCostMisses); 480 480 481 481 const float oldProp = EvalViewCellsVolume(leaf->mObjects); … … 488 488 489 489 const float renderCostDecr = oldRenderCost - newRenderCost; 490 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate); 490 491 491 492 #ifdef _DEBUG … … 494 495 Debug << "render cost decrease: " << renderCostDecr << endl; 495 496 #endif 497 496 498 splitCandidate.SetRenderCostDecrease(renderCostDecr); 499 splitCandidate.SetPvsEntriesIncr(EvalPvsEntriesIncr(splitCandidate)); 497 500 498 501 #if 1 … … 510 513 511 514 515 int BvHierarchy::EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate) const 516 { 517 const int oldPvsSize = CountViewCells(splitCandidate.mParentData.mNode->mObjects); 518 519 const int fPvsSize = CountViewCells(splitCandidate.mFrontObjects); 520 const int bPvsSize = CountViewCells(splitCandidate.mBackObjects); 521 522 return fPvsSize + bPvsSize - oldPvsSize; 523 } 524 525 512 526 inline bool BvHierarchy::LocalTerminationCriteriaMet(const BvhTraversalData &data) const 513 527 { … … 515 529 return ( 0 516 530 || ((int)data.mNode->mObjects.size() <= mTermMinObjects) 517 || (data.mProbability <= mTermMinProbability) 518 || (data.mDepth >= mTermMaxDepth) 519 || (data.mNumRays <= mTermMinRays) 531 //|| (data.mProbability <= mTermMinProbability) 532 //|| (data.mNumRays <= mTermMinRays) 520 533 ); 521 534 } … … 1063 1076 return vol; 1064 1077 } 1078 1065 1079 /////////////////////////////////////////////////////////// 1066 1080 … … 1289 1303 return 0.0f; 1290 1304 1291 //////////////// ////1305 //////////////// 1292 1306 //-- surface area heuristics 1293 1307 … … 1298 1312 } 1299 1313 else 1300 { /////////////// /////1314 { /////////////// 1301 1315 //-- render cost heuristics 1302 1316 1303 1317 const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 1318 1304 1319 // probability that view point lies in a view cell which sees this node 1305 1320 const float p = EvalViewCellsVolume(objects) / viewSpaceVol; … … 1404 1419 for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 1405 1420 { 1406 VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 1421 //VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 1422 ViewCell *vc = *vit; 1407 1423 1408 1424 // store view cells … … 1426 1442 } 1427 1443 } 1444 } 1445 1446 1447 int BvHierarchy::CountViewCells(Intersectable *obj) const 1448 { 1449 int result = 0; 1450 1451 VssRayContainer::const_iterator rit, rit_end = obj->mVssRays.end(); 1452 1453 for (rit = obj->mVssRays.begin(); rit < rit_end; ++ rit) 1454 { 1455 VssRay *ray = (*rit); 1456 ViewCellContainer tmpViewCells; 1457 1458 mHierarchyManager->mVspTree->GetViewCells(*ray, tmpViewCells); 1459 1460 ViewCellContainer::const_iterator vit, vit_end = tmpViewCells.end(); 1461 for (vit = tmpViewCells.begin(); vit != vit_end; ++ vit) 1462 { 1463 ViewCell *vc = *vit; 1464 1465 // store view cells 1466 if (!vc->Mailed()) 1467 { 1468 vc->Mail(); 1469 ++ result; 1470 } 1471 } 1472 } 1473 1474 return result; 1475 } 1476 1477 1478 int BvHierarchy::CountViewCells(const ObjectContainer &objects) const 1479 { 1480 // no view cells yet 1481 if (mHierarchyManager->GetViewSpaceSubdivisionType() == 1482 HierarchyManager::NO_VIEWSPACE_SUBDIV) 1483 return 1; 1484 1485 int nViewCells = 0; 1486 1487 ViewCell::NewMail(); 1488 1489 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1490 1491 // loop through all object and collect view cell pvs of this node 1492 for (oit = objects.begin(); oit != oit_end; ++ oit) 1493 { 1494 nViewCells += CountViewCells(*oit); 1495 } 1496 1497 return nViewCells; 1428 1498 } 1429 1499 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1548 r1576 724 724 const bool setCounter = false) const; 725 725 726 /** Counts the view cells of this object. note: only 727 counts unmailed objects. 728 */ 729 int CountViewCells(Intersectable *obj) const; 730 731 /** Counts the view cells seen by this bvh leaf 732 */ 733 int CountViewCells(const ObjectContainer &objects) const; 734 726 735 /** Collects view cells which see an object. 727 736 */ … … 731 740 const bool useMailBoxing, 732 741 const bool setCounter = false) const; 742 743 /** Evaluates increase in pvs size. 744 */ 745 int EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate) const; 733 746 734 747 /** Rays will be clipped to the bounding box. -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1545 r1576 2165 2165 2166 2166 RegisterOption("VspTree.Construction.renderCostDecreaseWeight", 2167 optFloat,2168 "vsp_construction_render_cost_decrease_weight=",2169 "0.99");2167 optFloat, 2168 "vsp_construction_render_cost_decrease_weight=", 2169 "0.99"); 2170 2170 2171 2171 RegisterOption("VspTree.Termination.maxDepth", … … 2188 2188 optFloat, 2189 2189 "vsp_term_min_probability=", 2190 "0.00 1");2190 "0.0000001"); 2191 2191 2192 2192 RegisterOption("VspTree.Termination.maxRayContribution", 2193 optFloat,2194 "vsp_term_ray_contribution=",2195 "0.9");2193 optFloat, 2194 "vsp_term_ray_contribution=", 2195 "0.9"); 2196 2196 2197 2197 RegisterOption("VspTree.Termination.maxCostRatio", 2198 optFloat,2199 "vsp_term_max_cost_ratio=",2200 "1.5");2198 optFloat, 2199 "vsp_term_max_cost_ratio=", 2200 "1.5"); 2201 2201 2202 2202 RegisterOption("VspTree.Termination.maxViewCells", 2203 optInt,2204 "vsp_term_max_view_cells=",2205 "10000");2203 optInt, 2204 "vsp_term_max_view_cells=", 2205 "10000"); 2206 2206 2207 2207 2208 2208 RegisterOption("VspTree.Termination.missTolerance", 2209 optInt,2210 "vsp_term_miss_tolerance=",2211 "4");2209 optInt, 2210 "vsp_term_miss_tolerance=", 2211 "4"); 2212 2212 2213 2213 RegisterOption("VspTree.Termination.minGlobalCostRatio", … … 2237 2237 2238 2238 RegisterOption("VspTree.maxStaticMemory", 2239 optFloat,2240 "vsp_max_static_mem=",2241 "8.0");2239 optFloat, 2240 "vsp_max_static_mem=", 2241 "8.0"); 2242 2242 2243 2243 RegisterOption("VspTree.useCostHeuristics", 2244 optBool,2245 "vsp_use_cost_heuristics=",2246 "false");2244 optBool, 2245 "vsp_use_cost_heuristics=", 2246 "false"); 2247 2247 2248 2248 RegisterOption("VspTree.simulateOctree", 2249 optBool,2250 "vsp_simulate_octree=",2251 "false");2249 optBool, 2250 "vsp_simulate_octree=", 2251 "false"); 2252 2252 2253 2253 RegisterOption("VspTree.Construction.randomize", 2254 optBool,2255 "vsp_construction_randomize=",2256 "false");2254 optBool, 2255 "vsp_construction_randomize=", 2256 "false"); 2257 2257 2258 2258 RegisterOption("VspTree.subdivisionStats", … … 2398 2398 optFloat, 2399 2399 "bvh_term_min_objects=", 2400 "0.0000 1");2400 "0.0000001"); 2401 2401 2402 2402 RegisterOption("BvHierarchy.Termination.minRays", … … 2515 2515 "hierarchy_construction_multilevel=", 2516 2516 "false"); 2517 2518 RegisterOption("Hierarchy.Construction.levels", 2519 optInt, 2520 "hierarchy_construction_levels=", 2521 "4"); 2517 2522 2518 2523 ///////////////////////////////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1572 r1576 81 81 bool GvsPreprocessor::HandleRay(VssRay *vssRay) 82 82 { 83 cout << " \nhere12 " << (int)vssRay->mFlags << endl;83 cout << "x " << (int)vssRay->mFlags; 84 84 const bool storeRaysForViz = true; 85 85 mViewCellsManager->ComputeSampleContribution(*vssRay, true, storeRaysForViz); … … 367 367 // add samples to ray queue 368 368 VssRayContainer::const_iterator vit, vit_end = samples.end(); 369 369 for (vit = samples.begin(); vit != vit_end; ++ vit) 370 370 { 371 371 HandleRay(*vit); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1564 r1576 146 146 147 147 if (mOspTree) 148 { 148 149 mOspTree->SetViewCellsManager(vcm); 150 } 149 151 else if (mBvHierarchy) 152 { 150 153 mBvHierarchy->SetViewCellsManager(vcm); 154 } 151 155 } 152 156 … … 179 183 return mBvHierarchy->mBoundingBox; 180 184 default: 181 // empty box185 // hack: empty box 182 186 return AxisAlignedBox3(); 183 187 } … … 198 202 const float costDecr = tData.GetRenderCostDecrease(); 199 203 200 switch (mObjectSpaceSubdivisionType) 201 { 202 case KD_BASED_OBJ_SUBDIV: 203 AddSubdivisionStats(mOspTree->mOspStats.Leaves() + mVspTree->mVspStats.Leaves(), 204 costDecr, 205 mTotalCost 206 ); 207 break; 208 case BV_BASED_OBJ_SUBDIV: 209 AddSubdivisionStats(mBvHierarchy->mBvhStats.Leaves() + mVspTree->mVspStats.Leaves(), 210 costDecr, 211 mTotalCost 212 ); 213 break; 214 default: 215 AddSubdivisionStats(mVspTree->mVspStats.Leaves(), 216 costDecr, 217 mTotalCost 218 ); 219 break; 220 } 204 AddSubdivisionStats(mHierarchyStats.Leaves(), 205 costDecr, 206 mTotalCost, 207 mTotalPvsEntries 208 ); 221 209 } 222 210 … … 224 212 void HierarchyManager::AddSubdivisionStats(const int splits, 225 213 const float renderCostDecr, 226 const float totalRenderCost) 214 const float totalRenderCost, 215 const int pvsEntries) 227 216 { 228 217 mSubdivisionStats 229 218 << "#Splits\n" << splits << endl 230 219 << "#RenderCostDecrease\n" << renderCostDecr << endl 220 << "#TotalPvsEntries\n" << pvsEntries << endl 231 221 << "#TotalRenderCost\n" << totalRenderCost << endl; 232 //<< "#AvgRenderCost\n" << avgRenderCost << endl;233 222 } 234 223 … … 525 514 { 526 515 cout << mCurrentCandidate->Type() << " "; 527 if (0) cout << "subdividing candidate " << ++ i << " of type "528 << mCurrentCandidate->Type() << endl;516 517 // update stats 529 518 mHierarchyStats.nodes += 2; 530 519 mHierarchyStats.pvsEntries += mCurrentCandidate->GetPvsEntriesIncr(); 520 mHierarchyStats.memory += 0; // TODO 531 521 // subdivision successful 532 522 EvalSubdivisionStats(*mCurrentCandidate); … … 534 524 // reevaluate candidates affected by the split for view space splits, 535 525 // this would be object space splits and other way round 536 if (repairQueue) RepairQueue(); 526 if (repairQueue) 527 { 528 RepairQueue(); 529 } 537 530 } 538 531 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1563 r1576 49 49 { 50 50 public: 51 51 /// total number of entries in the pvs 52 int pvsEntries; 53 /// storage cost 54 int memory; 52 55 /// total number of nodes 53 56 int nodes; … … 81 84 accumDepth = 0; 82 85 repairTime = 0; 86 memory = 0; 87 pvsEntries = 0; 83 88 } 84 89 … … 255 260 const int splits, 256 261 const float renderCostDecr, 257 const float totalRenderCost); 262 const float totalRenderCost, 263 const int totalPvsEntries); 258 264 259 265 void CollectObjectSpaceDirtyList(); … … 343 349 344 350 //////// 345 //-- global criteria 351 //-- global termination criteria 352 346 353 float mTermMinGlobalCostRatio; 347 354 int mTermGlobalCostMissTolerance; 348 355 356 //////////////////// 357 349 358 /// keeps track of cost during subdivision 350 359 float mTotalCost; 351 360 361 int mTotalPvsEntries; 352 362 HierarchyStatistics mHierarchyStats; 353 363 -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r1570 r1576 433 433 tBackData); 434 434 435 const int maxCostMisses = sc-> mMaxCostMisses;435 const int maxCostMisses = sc->GetMaxCostMisses(); 436 436 437 437 // how often was max cost ratio missed in this branch? … … 505 505 splitCandidate.SetRenderCostDecrease(renderCostDecr); 506 506 507 const float pvsSizeIncr = 0; // todo 507 508 #if 0 508 509 const float priority = (float)-data.mDepth; … … 518 519 splitCandidate.SetPriority(priority); 519 520 520 splitCandidate. mMaxCostMisses =521 s uccess ? splitCandidate.mParentData.mMaxCostMisses :522 splitCandidate.mParentData.mMaxCostMisses + 1;521 splitCandidate.SetMaxCostMisses(success ? 522 splitCandidate.mParentData.mMaxCostMisses : 523 splitCandidate.mParentData.mMaxCostMisses + 1); 523 524 } 524 525 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1520 r1576 62 62 { 63 63 Vector3 origin, direction; 64 65 64 const int i = (int)RandomValue(0, (Real)((int)mPreprocessor.mObjects.size() - 1)); 66 67 65 Intersectable *object = mPreprocessor.mObjects[i]; 68 66 … … 95 93 96 94 direction = UniformRandomVector(); 97 98 95 const float c = Magnitude(direction); 99 96 -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1473 r1576 38 38 /** Position in queue. 39 39 */ 40 in t GetPosition() const40 inline int GetPosition() const 41 41 { 42 42 return mPosition; 43 43 } 44 45 inline void SetSplitAxis(const int splitAxis) 46 { 47 mSplitAxis = splitAxis; 48 } 49 inline void SetMaxCostMisses(const int misses) 50 { 51 mMaxCostMisses = misses; 52 } 53 inline void SetPvsEntriesIncr(const int pvsEntriesIncr) 54 { 55 mPvsEntriesIncr = pvsEntriesIncr; 56 } 57 58 inline int GetSplitAxis() const 59 { 60 return mSplitAxis; 61 } 62 inline int GetMaxCostMisses() const 63 { 64 return mMaxCostMisses; 65 } 66 inline int GetPvsEntriesIncr() const 67 { 68 return mPvsEntriesIncr; 69 } 70 71 protected: 44 72 45 73 /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned) … … 47 75 /// the number of misses of max cost ratio until this split 48 76 int mMaxCostMisses; 49 50 protected:51 52 77 /// render cost decrease achieved through this split 53 78 float mRenderCostDecrease; 54 79 /// the decrease of the number of pvs entries 80 int mPvsEntriesIncr; 55 81 }; 56 82 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1571 r1576 4774 4774 4775 4775 int sampleContributions = 0; 4776 4777 4776 VssRayContainer sampleRays; 4778 4777 … … 4792 4791 mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 4793 4792 4794 4793 #if TEST_EVALUATION 4794 VssRayContainer::const_iterator tit, tit_end = constructionRays.end(); 4795 for (tit = constructionRays.begin(); tit != tit_end; ++ tit) 4796 { 4797 storedRays.push_back(new VssRay(*(*tit))); 4798 } 4799 #endif 4800 4795 4801 ///////////////////////// 4796 4802 //-- print satistics for subdivision and view cells … … 4800 4806 ResetViewCells(); 4801 4807 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 4802 4803 if (0)4804 {4805 OUT_STREAM stream("osptree.xml.zip");4806 mHierarchyManager->ExportObjectSpaceHierarchy(stream);4807 }4808 4809 4808 4810 4809 ////////////// … … 5573 5572 } 5574 5573 5575 //#define TEST_EVALUATION5576 5574 5577 5575 #if TEST_EVALUATION … … 5587 5585 5588 5586 // should directional sampling be used? 5589 const bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION);5587 const bool dirSamples = (mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 5590 5588 5591 5589 cout << "reseting pvs ... "; … … 5649 5647 } 5650 5648 5651 Debug << "\nrendercost hack: " << rc / m HierarchyManager->GetViewSpaceBox() << endl;5649 Debug << "\nrendercost hack: " << rc / mViewSpaceBox.GetVolume() << endl; 5652 5650 mViewCellsTree->ExportStats(fileName); 5653 5651 cout << "finished" << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1571 r1576 692 692 int mMaxFilterSize; 693 693 694 695 694 // only for debugging 695 VssRayContainer storedRays; 696 696 ////////////////// 697 697 //-- visualization options … … 1027 1027 }; 1028 1028 1029 #define TEST_EVALUATION 01029 #define TEST_EVALUATION 1 1030 1030 1031 1031 /** -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1571 r1576 616 616 void VspTree::CreateViewCell(VspTraversalData &tData, const bool updatePvs) 617 617 { 618 /////////////// 618 619 //-- create new view cell 619 VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode);620 VspLeaf *leaf = tData.mNode; 620 621 621 622 VspViewCell *viewCell = new VspViewCell(); … … 627 628 if (updatePvs) 628 629 { 629 // --update pvs of view cell630 // update pvs of view cell 630 631 AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); 631 632 … … 642 643 /////////// 643 644 //-- store sampling rays 644 645 RayInfoContainer::const_iterator it, it_end = tData.mRays->end(); 645 646 646 647 for (it = tData.mRays->begin(); it != it_end; ++ it) 647 648 { 648 649 (*it).mRay->Ref(); 650 // note: should rather store rays with view cell 649 651 leaf->mVssRays.push_back((*it).mRay); 650 652 } … … 689 691 // create new interior node and two leaf node 690 692 const AxisAlignedPlane splitPlane = sc->mSplitPlane; 691 const int maxCostMisses = sc-> mMaxCostMisses;693 const int maxCostMisses = sc->GetMaxCostMisses(); 692 694 693 695 newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData); … … 788 790 789 791 // max cost threshold violated? 790 splitCandidate. mMaxCostMisses =maxCostRatioViolated ?792 splitCandidate.SetMaxCostMisses(maxCostRatioViolated ? 791 793 splitCandidate.mParentData.mMaxCostMisses + 1: 792 splitCandidate.mParentData.mMaxCostMisses ;794 splitCandidate.mParentData.mMaxCostMisses); 793 795 794 796 float oldRenderCost; … … 800 802 801 803 splitCandidate.SetRenderCostDecrease(renderCostDecr); 804 805 // the increase in pvs entries num induced by this split 806 const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate); 807 splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr); 802 808 803 809 #if 0 … … 814 820 815 821 822 int VspTree::EvalPvsEntriesIncr(VspSubdivisionCandidate &splitCandidate) const 823 { 824 float oldPvsSize = 0; 825 float fPvsSize = 0; 826 float bPvsSize = 0; 827 828 AxisAlignedPlane candidatePlane = splitCandidate.mSplitPlane; 829 RayInfoContainer::const_iterator rit, 830 rit_end = splitCandidate.mParentData.mRays->end(); 831 832 // this is the main ray classification loop! 833 for(rit = splitCandidate.mParentData.mRays->begin(); rit != rit_end; ++ rit) 834 { 835 VssRay *ray = (*rit).mRay; 836 RayInfo rayInf = *rit; 837 838 float t; 839 // classify ray 840 const int cf = 841 rayInf.ComputeRayIntersection(candidatePlane.mAxis, 842 candidatePlane.mPosition, t); 843 844 UpdatePvsEntriesContribution(*ray, true, cf, fPvsSize, bPvsSize, oldPvsSize); 845 } 846 847 return (int)(fPvsSize + bPvsSize - oldPvsSize); 848 } 849 850 816 851 VspInterior *VspTree::SubdivideNode(const AxisAlignedPlane &splitPlane, 817 852 VspTraversalData &tData, … … 836 871 *backData.mRays); 837 872 838 /////////////839 873 //-- compute pvs 840 874 frontData.mPvs = EvalPvsSize(*frontData.mRays); 841 875 backData.mPvs = EvalPvsSize(*backData.mRays); 842 //Debug << "f pvs: " << frontData.mPvs << " b pvs: " << backData.mPvs << " pvs " << tData.mPvs << endl; 843 876 844 877 //-- split front and back node geometry and compute area 845 878 tData.mBoundingBox.Split(splitPlane.mAxis, … … 851 884 backData.mProbability = tData.mProbability - frontData.mProbability; 852 885 853 // update some stats 854 // store maximal depth 886 887 //////// 888 //-- update some stats 889 855 890 if (tData.mDepth > mVspStats.maxDepth) 856 { 857 //Debug << "max depth increases to " << tData.mDepth << " at " << mVspStats.Leaves() << " leaves" << endl; 891 { //Debug << "max depth increases to " << tData.mDepth << " at " << mVspStats.Leaves() << " leaves" << endl; 858 892 mVspStats.maxDepth = tData.mDepth; 859 893 } 860 894 861 // two more leaves 895 // two more leaves per split 862 896 mVspStats.nodes += 2; 863 897 /// and a new split … … 865 899 866 900 867 ///////////////////////901 //////////////// 868 902 //-- create front and back and subdivide further 869 903 … … 902 936 CreateViewCell(frontData, false); 903 937 CreateViewCell(backData, false); 904 905 938 906 939 #if WORK_WITH_VIEWCELL_PVS … … 1436 1469 // mark objects in the front / back / both using mailboxing 1437 1470 // then count pvs sizes 1471 1438 1472 Intersectable::NewMail(3); 1439 1473 KdLeaf::NewMail(3); … … 1497 1531 << "render cost decrease: " << renderCostDecrease << endl; 1498 1532 #endif 1533 1499 1534 return renderCostDecrease; 1500 1535 } … … 1519 1554 1520 1555 const int pvsSize = data.mPvs; 1521 1522 1556 RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 1523 1557 … … 1535 1569 } 1536 1570 1537 1571 ////////////// 1538 1572 //-- evaluate cost heuristics 1539 1540 1573 float pOverall = data.mProbability; 1541 1574 … … 1555 1588 1556 1589 1557 void VspTree::UpdateContributionsToPvs(Intersectable *obj,1558 const int cf,1559 float &frontPvs,1560 float &backPvs,1561 float &totalPvs) const1562 {1563 if (!obj) return;1564 1565 //const float renderCost = mViewCellsManager->SimpleRay &raynderCost(obj);1566 const int renderCost = 1;1567 1568 // object in no pvs => new1569 if (!obj->Mailed() && !obj->Mailed(1) && !obj->Mailed(2))1570 {1571 totalPvs += renderCost;1572 }1573 1574 // QUESTION matt: is it safe to assume that1575 // the object belongs to no pvs in this case?1576 //if (cf == Ray::COINCIDENT) return;1577 1578 if (cf >= 0) // front pvs1579 {1580 if (!obj->Mailed() && !obj->Mailed(2))1581 {1582 frontPvs += renderCost;1583 1584 // already in back pvs => in both pvss1585 if (obj->Mailed(1))1586 obj->Mail(2);1587 else1588 obj->Mail();1589 }1590 }1591 1592 if (cf <= 0) // back pvs1593 {1594 if (!obj->Mailed(1) && !obj->Mailed(2))1595 {1596 backPvs += renderCost;1597 1598 // already in front pvs => in both pvss1599 if (obj->Mailed())1600 obj->Mail(2);1601 else1602 obj->Mail(1);1603 }1604 }1605 }1606 1607 1608 1590 void VspTree::UpdateContributionsToPvs(BvhLeaf *leaf, 1609 1591 const int cf, 1610 1592 float &frontPvs, 1611 1593 float &backPvs, 1612 float &totalPvs) const 1594 float &totalPvs, 1595 const bool countEntries) const 1613 1596 { 1614 1597 if (!leaf) return; 1615 1616 const int renderCost = (int)leaf->mObjects.size(); 1598 const int renderCost = countEntries ? 1 : (int)leaf->mObjects.size(); 1617 1599 1618 1600 // leaf in no pvs => new … … 1621 1603 totalPvs += renderCost; 1622 1604 } 1623 1624 // QUESTION matt: is it safe to assume that1625 // the leaf belongs to no pvs in this case?1626 //if (cf == Ray::COINCIDENT) return;1627 1605 1628 1606 if (cf >= 0) // front pvs … … 1684 1662 } 1685 1663 1686 // QUESTION matt: is it safe to assume that1687 // the object belongs to no pvs in this case?1688 //if (cf == Ray::COINCIDENT) return;1689 1690 1664 if (cf >= 0) // front pvs 1691 1665 { … … 2146 2120 2147 2121 2122 int VspTree::EvalPvsEntriesContribution(const VssRay &ray, 2123 const bool isTermination) const 2124 2125 { 2126 Intersectable *obj; 2127 Vector3 pt; 2128 KdNode *node; 2129 2130 ray.GetSampleData(isTermination, pt, &obj, &node); 2131 if (!obj) return 0; 2132 2133 switch(mHierarchyManager->GetObjectSpaceSubdivisionType()) 2134 { 2135 case HierarchyManager::NO_OBJ_SUBDIV: 2136 { 2137 if (!obj->Mailed()) 2138 { 2139 obj->Mail(); 2140 return 1; 2141 } 2142 2143 return 0; 2144 } 2145 2146 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 2147 { 2148 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 2149 if (!leaf->Mailed()) 2150 { 2151 leaf->Mail(); 2152 return 1; 2153 } 2154 2155 return 0; 2156 } 2157 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 2158 { 2159 BvhLeaf *bvhleaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 2160 2161 if (!bvhleaf->Mailed()) 2162 { 2163 bvhleaf->Mail(); 2164 return 1; 2165 } 2166 2167 return 0; 2168 } 2169 default: 2170 break; 2171 } 2172 2173 return 0; 2174 } 2175 2176 2177 int VspTree::EvalPvsEntriesSize(const RayInfoContainer &rays) const 2178 { 2179 int pvsSize = 0; 2180 2181 Intersectable::NewMail(); 2182 KdNode::NewMail(); 2183 BvhLeaf::NewMail(); 2184 2185 RayInfoContainer::const_iterator rit, rit_end = rays.end(); 2186 2187 for (rit = rays.begin(); rit != rays.end(); ++ rit) 2188 { 2189 VssRay *ray = (*rit).mRay; 2190 2191 pvsSize += EvalPvsEntriesContribution(*ray, true); 2192 pvsSize += EvalPvsEntriesContribution(*ray, false); 2193 } 2194 2195 return pvsSize; 2196 } 2197 2198 2148 2199 float VspTree::GetEpsilon() const 2149 2200 { … … 2991 3042 2992 3043 2993 int VspTree::EvalContributionToPvs(const VssRay &ray, 2994 const bool isTermination) const 3044 void VspTree::UpdatePvsEntriesContribution(const VssRay &ray, 3045 const bool isTermination, 3046 const int cf, 3047 float &frontPvs, 3048 float &backPvs, 3049 float &totalPvs) const 3050 { 3051 /*ray.GetSampleData(isTermination, pt, &obj, &node); 3052 if (!obj) return 0; 3053 3054 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 3055 { 3056 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 3057 // TODO 3058 break; 3059 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 3060 { 3061 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 3062 UpdateContributionsToPvs(leaf, true, cf, pvsFront, pvsBack, totalPvs, true); 3063 break; 3064 } 3065 default: 3066 UpdateContributionsToPvs(obj, true, cf, pvsFront, pvsBack, totalPvs, true); 3067 break; 3068 }*/ 3069 } 3070 3071 3072 int VspTree::EvalContributionToPvs(const VssRay &ray, const bool isTermination) const 2995 3073 { 2996 3074 Intersectable *obj; … … 3018 3096 { 3019 3097 KdLeaf *leaf = mHierarchyManager->mOspTree->GetLeaf(pt, node); 3020 3021 3098 pvs += EvalContributionToPvs(leaf); 3022 3099 break; … … 3048 3125 leaf->Mail(); 3049 3126 3127 // this is the pvs which is uniquely part of this kd leaf 3050 3128 int pvs = (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 3051 3129 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1570 r1576 36 36 class VspTree; 37 37 class KdTreeStatistics; 38 //class SubdivisionCandidate; 39 //class VspSubdivisionCandidate; 38 40 39 41 40 /** View space partition statistics. … … 781 780 int EvalPvsSize(const RayInfoContainer &rays) const; 782 781 782 int EvalPvsEntriesIncr(VspSubdivisionCandidate &splitCandidate) const; 783 784 /** Returns number of effective entries in the pvs. 785 */ 786 int EvalPvsEntriesSize(const RayInfoContainer &rays) const; 787 int EvalPvsEntriesContribution(const VssRay &ray, const bool isTermination) const; 783 788 /** Computes best cost for axis aligned planes. 784 789 */ … … 845 850 RayInfoContainer &frontRays, 846 851 RayInfoContainer &backRays) const; 852 853 void UpdatePvsEntriesContribution( 854 const VssRay &ray, 855 const bool isTermination, 856 const int cf, 857 float &frontPvs, 858 float &backPvs, 859 float &totalPvs) const; 847 860 848 861 /** Classfifies the object with respect to the … … 880 893 float &frontPvs, 881 894 float &backPvs, 882 float &totalPvs) const; 895 float &totalPvsm, 896 const bool countEntries = false) const; 883 897 884 898 /** Evaluates the contribution for kd leaves.
Note: See TracChangeset
for help on using the changeset viewer.