Changeset 382 for trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.h
- Timestamp:
- 11/05/05 20:03:25 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.h
r372 r382 43 43 // totals number of rays 44 44 int rays; 45 // total number of query domains 45 // initial size of the pvs 46 int initialPvsSize; 47 // total number of query domains 46 48 int queryDomains; 47 49 // total number of ray references 48 50 int rayRefs; 49 // refs in non empty leafs 50 int rayRefsNonZeroQuery; 51 // total number of query references 52 int queryDomainRefs; 53 // nodes with zero queries 54 int zeroQueryNodes; 55 // max depth nodes 51 52 // max depth nodes 56 53 int maxDepthNodes; 57 54 // max depth nodes 58 55 int minCostNodes; 56 // max ray contribution nodes 57 int maxRayContribNodes; 58 // max depth nodes 59 int minSizeNodes; 60 59 61 // max number of rays per node 60 62 int maxRayRefs; … … 78 80 splits[i] = 0; 79 81 rays = queryDomains = 0; 80 rayRefs = rayRefsNonZeroQuery = queryDomainRefs = 0; 81 zeroQueryNodes = 0; 82 rayRefs = 0; 82 83 maxDepthNodes = 0; 83 84 minCostNodes = 0; 84 85 maxRayRefs = 0; 85 86 addedRayRefs = removedRayRefs = 0; 87 initialPvsSize = 0; 88 maxRayContribNodes = 0; 89 minSizeNodes = 0; 86 90 } 87 91 … … 101 105 // For sorting rays 102 106 // -------------------------------------------------------------- 103 struct S SortableEntry107 struct SortableEntry 104 108 { 105 109 enum EType { … … 112 116 void *data; 113 117 114 S SortableEntry() {}115 S SortableEntry(const int t, const float v, void *d):type(t),116 117 118 119 friend bool operator<(const S SortableEntry &a, const SSortableEntry &b) {118 SortableEntry() {} 119 SortableEntry(const int t, const float v, void *d):type(t), 120 value(v), 121 data(d) {} 122 123 friend bool operator<(const SortableEntry &a, const SortableEntry &b) { 120 124 return a.value < b.value; 121 125 } … … 215 219 void SetMaxT (const float t) { mMaxT = t; } 216 220 #endif 221 222 223 int ComputeRayIntersection(const float axis, 224 const float position, 225 float &t 226 ) const { 227 228 // intersect the ray with the plane 229 float denom = mRay->GetDir(axis); 230 231 if (fabs(denom) < 1e-20) 232 //if (denom == 0.0f) 233 return (mRay->GetOrigin(axis) > position) ? 1 : -1; 234 235 t = (position - mRay->GetOrigin(axis))/denom; 236 237 if (t < GetMinT()) 238 return (denom > 0) ? 1 : -1; 239 240 if (t > GetMaxT()) 241 return (denom > 0) ? -1 : 1; 242 243 return 0; 244 } 245 246 217 247 }; 218 248 … … 329 359 330 360 361 331 362 int ComputeRayIntersection(const RayInfo &rayData, 332 363 float &t 333 364 ) { 334 335 // intersect the ray with the plane 336 float denom = rayData.mRay->GetDir(axis); 337 338 if (fabs(denom) < 1e-20) 339 //if (denom == 0.0f) 340 return (rayData.mRay->GetOrigin(axis) > position) ? 1 : -1; 341 342 t = (position - rayData.mRay->GetOrigin(axis))/denom; 343 344 if (t < rayData.GetMinT()) 345 return (denom > 0) ? 1 : -1; 346 347 if (t > rayData.GetMaxT()) 348 return (denom > 0) ? -1 : 1; 349 350 return 0; 365 return rayData.ComputeRayIntersection(axis, position, t); 351 366 } 352 367 … … 365 380 366 381 RayInfoContainer rays; 367 368 369 VssTreeLeaf(VssTreeInterior *p, const int n):VssTreeNode(p), rays() { 370 rays.reserve(n); 382 int mPvsSize; 383 384 VssTreeLeaf(VssTreeInterior *p, 385 const int nRays 386 ):VssTreeNode(p), rays(), mPvsSize(0) { 387 rays.reserve(nRays); 371 388 } 372 389 … … 392 409 } 393 410 411 float GetAvgRayContribution() const { 412 return mPvsSize/(float)rays.size(); 413 } 394 414 }; 395 415 … … 490 510 // max depth of the tree 491 511 int termMaxDepth; 492 // minimal cost of the node to still get subdivided493 int termMinCost;494 512 // minimal ratio of the volume of the cell and the query volume 495 513 float termMinSize; 496 514 497 // minimal cost imporvement to subdivide a node 498 float maxCostRatio; 499 515 // minimal pvs per node to still get subdivided 516 int termMinPvs; 517 518 // maximal cost ration to subdivide a node 519 float termMaxCostRatio; 520 521 // maximal contribution per ray to subdivide the node 522 float termMaxRayContribution; 523 524 500 525 // randomized construction 501 526 bool randomize; 502 527 503 528 // type of the splitting to use fo rthe tree construction 504 enum {ESplitRegular, ESplitVolume , ESplitQueries};529 enum {ESplitRegular, ESplitVolume }; 505 530 int splitType; 506 531 … … 528 553 529 554 // reusable array of split candidates 530 vector<S SortableEntry> *splitCandidates;555 vector<SortableEntry> *splitCandidates; 531 556 ///////////////////////////// 532 557 … … 540 565 Construct( 541 566 VssRayContainer &rays, 542 const bool onlyStaticPart567 AxisAlignedBox3 *forcedBoundingBox = NULL 543 568 ); 544 569 … … 565 590 int 566 591 SelectPlane(VssTreeLeaf *leaf, 567 const AxisAlignedBox3 &box, 568 float &position 569 ); 592 const AxisAlignedBox3 &box, 593 float &position, 594 int &raysBack, 595 int &raysFront, 596 int &pvsBack, 597 int &pvsFront 598 ); 570 599 571 600 void … … 590 619 } 591 620 621 float 622 BestCostRatio( 623 VssTreeLeaf *node, 624 int &axis, 625 float &position, 626 int &raysBack, 627 int &raysFront 628 ); 629 630 float 631 EvalCostRatio( 632 VssTreeLeaf *node, 633 const int axis, 634 const float position, 635 int &raysBack, 636 int &raysFront, 637 int &pvsBack, 638 int &pvsFront 639 ); 592 640 593 641 AxisAlignedBox3 GetBBox(const VssTreeNode *node) { … … 664 712 EvaluateLeafStats(const TraversalData &data); 665 713 714 void 715 EvalLeafPvs(VssTreeLeaf *leaf); 716 717 666 718 }; 667 719
Note: See TracChangeset
for help on using the changeset viewer.