Changeset 395 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 11/09/05 15:09:09 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.cpp
r387 r395 196 196 197 197 198 void 199 VssTreeLeaf::EvalPvsSize() 200 { 201 if (!mValidPvs) { 202 Intersectable::NewMail(); 203 int pvsSize = 0; 204 for(VssTreeNode::RayInfoContainer::iterator ri = rays.begin(); 205 ri != rays.end(); 206 ri++) 207 if ((*ri).mRay->IsActive()) { 208 Intersectable *object; 209 #if BIDIRECTIONAL_RAY 210 object = (*ri).mRay->mOriginObject; 211 if (object && !object->Mailed()) { 212 pvsSize++; 213 object->Mail(); 214 } 215 #endif 216 object = (*ri).mRay->mTerminationObject; 217 if (object && !object->Mailed()) { 218 pvsSize++; 219 object->Mail(); 220 } 221 } 222 mPvsSize = pvsSize; 223 mValidPvs = true; 224 } 225 } 198 226 199 227 … … 238 266 239 267 240 if ( forcedBoundingBox)268 if ( forcedBoundingBox ) 241 269 bbox = *forcedBoundingBox; 242 270 … … 245 273 246 274 stat.rays = leaf->rays.size(); 247 EvalLeafPvs(leaf);248 stat.initialPvsSize = leaf-> mPvsSize;275 leaf->EvalPvsSize(); 276 stat.initialPvsSize = leaf->GetPvsSize(); 249 277 // Subdivide(); 250 278 root = Subdivide(TraversalData(leaf, bbox, 0)); … … 263 291 } 264 292 265 void266 VssTree::EvalLeafPvs(VssTreeLeaf *leaf)267 {268 Intersectable::NewMail();269 int pvsSize = 0;270 for(VssTreeNode::RayInfoContainer::iterator ri = leaf->rays.begin();271 ri != leaf->rays.end();272 ri++)273 if ((*ri).mRay->IsActive()) {274 Intersectable *object;275 #if BIDIRECTIONAL_RAY276 object = (*ri).mRay->mOriginObject;277 if (object && !object->Mailed()) {278 pvsSize++;279 object->Mail();280 }281 #endif282 object = (*ri).mRay->mTerminationObject;283 if (object && !object->Mailed()) {284 pvsSize++;285 object->Mail();286 }287 }288 leaf->mPvsSize = pvsSize;289 }290 293 291 294 … … 433 436 434 437 // eval pvs size 435 int pvsSize = leaf-> mPvsSize;438 int pvsSize = leaf->GetPvsSize(); 436 439 437 440 Intersectable::NewMail(3); … … 600 603 601 604 int rl=0, rr = leaf->rays.size(); 602 int pl=0, pr = leaf-> mPvsSize;605 int pl=0, pr = leaf->GetPvsSize(); 603 606 float minBox = box.Min(axis); 604 607 float maxBox = box.Max(axis); … … 675 678 } 676 679 677 float oldCost = leaf-> mPvsSize;680 float oldCost = leaf->GetPvsSize(); 678 681 float newCost = ct_div_ci + minSum/sizeBox; 679 682 float ratio = newCost/oldCost; … … 739 742 // if ( (int)(leaf->rays.size()) < termMinCost) 740 743 // stat.minCostNodes++; 741 if ( leaf-> mPvsSize< termMinPvs)744 if ( leaf->GetPvsSize() < termMinPvs) 742 745 stat.minCostNodes++; 743 746 … … 765 768 { 766 769 767 if ( (leaf-> mPvsSize< termMinPvs) ||770 if ( (leaf->GetPvsSize() < termMinPvs) || 768 771 (leaf->GetAvgRayContribution() > termMaxRayContribution ) || 769 772 (leaf->depth >= termMaxDepth) || … … 813 816 814 817 VssTreeLeaf *back = new VssTreeLeaf(node, raysBack); 815 back-> mPvsSize = pvsBack;818 back->SetPvsSize(pvsBack); 816 819 VssTreeLeaf *front = new VssTreeLeaf(node, raysFront); 817 front-> mPvsSize = pvsFront;820 front->SetPvsSize(pvsFront); 818 821 819 822 // replace a link from node's parent … … 968 971 if ( 969 972 // leaf->rays.size() > (unsigned)termMinCost && 970 (leaf-> mPvsSize>= termMinPvs) &&973 (leaf->GetPvsSize() >= termMinPvs) && 971 974 SqrMagnitude(leafBBox.Size()) > sizeThreshold) { 972 975 … … 1130 1133 1131 1134 if (!data.node->IsLeaf()) { 1132 1133 1135 TraverseInternalNode(data, tstack); 1134 1135 1136 } else { 1136 1137 // remove the ray from the leaf … … 1196 1197 else { 1197 1198 // directional split 1198 // if (DotProd(data.rayData.mRay->GetNormalizedDir(), in->refDir) > sinRefDir ) 1199 // tstack.push(RayTraversalData(in->front, data.rayData)); 1200 // else 1201 // tstack.push(RayTraversalData(in->back, data.rayData)); 1202 } 1203 1199 if (data.rayData.mRay->GetDirParametrization(in->axis - 3) > in->position) 1200 tstack.push(RayTraversalData(in->front, data.rayData)); 1201 else 1202 tstack.push(RayTraversalData(in->back, data.rayData)); 1203 } 1204 1204 } 1205 1205 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.h
r387 r395 375 375 public VssTreeNode 376 376 { 377 private: 378 int mPvsSize; 377 379 public: 378 380 static int mailID; … … 380 382 381 383 RayInfoContainer rays; 382 int mPvsSize;383 384 bool mValidPvs; 385 384 386 VssTreeLeaf(VssTreeInterior *p, 385 387 const int nRays 386 ):VssTreeNode(p), rays(), mPvsSize(0) {388 ):VssTreeNode(p), rays(), mPvsSize(0), mValidPvs(false) { 387 389 rays.reserve(nRays); 388 390 } … … 397 399 398 400 void AddRay(const RayInfo &data) { 401 mValidPvs = false; 399 402 rays.push_back(data); 400 403 data.mRay->Ref(); 401 404 } 405 406 int GetPvsSize() const { 407 return mPvsSize; 408 } 409 void SetPvsSize(const int s) { 410 mPvsSize = s; 411 } 412 413 void 414 EvalPvsSize(); 402 415 403 416 void Mail() { mailbox = mailID; } … … 410 423 411 424 float GetAvgRayContribution() const { 412 return mPvsSize/(float)rays.size();425 return GetPvsSize()/(float)rays.size(); 413 426 } 414 427 }; … … 471 484 #if 1 472 485 return 473 leafa-> mPvsSize*a.bbox.GetVolume()486 leafa->GetPvsSize()*a.bbox.GetVolume() 474 487 < 475 leafb-> mPvsSize*b.bbox.GetVolume();488 leafb->GetPvsSize()*b.bbox.GetVolume(); 476 489 #endif 477 490 #if 0 478 491 return 479 leafa-> mPvsSize492 leafa->GetPvsSize() 480 493 < 481 leafb-> mPvsSize;494 leafb->GetPvsSize(); 482 495 #endif 483 496 #if 0 484 497 return 485 leafa-> mPvsSize/(leafa->rays.size()+1)498 leafa->GetPvsSize()/(leafa->rays.size()+1) 486 499 > 487 leafb-> mPvsSize/(leafb->rays.size()+1);500 leafb->GetPvsSize()/(leafb->rays.size()+1); 488 501 #endif 489 502 #if 0 490 503 return 491 leafa-> mPvsSize*leafa->rays.size()504 leafa->GetPvsSize()*leafa->rays.size() 492 505 < 493 leafb-> mPvsSize*leafb->rays.size();506 leafb->GetPvsSize()*leafb->rays.size(); 494 507 #endif 495 508 } … … 751 764 EvaluateLeafStats(const TraversalData &data); 752 765 753 void754 EvalLeafPvs(VssTreeLeaf *leaf);755 766 756 767 int
Note: See TracChangeset
for help on using the changeset viewer.