- Timestamp:
- 01/21/06 18:32:30 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r562 r563 171 171 172 172 173 void ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays) 174 { 175 // view cells not yet constructed 176 if (!ViewCellsConstructed()) 177 return; 178 179 VssRayContainer::const_iterator it, it_end = rays.end(); 180 181 for (it = rays.begin(); it != it_end; ++ it) 182 { 183 ComputeSampleContributions(*(*it)); 184 } 173 float 174 ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays, 175 const bool addRays 176 ) 177 { 178 // view cells not yet constructed 179 if (!ViewCellsConstructed()) 180 return 0.0f; 181 182 VssRayContainer::const_iterator it, it_end = rays.end(); 183 184 float sum = 0.0f; 185 for (it = rays.begin(); it != it_end; ++ it) { 186 sum += ComputeSampleContributions(*(*it), addRays); 187 } 188 return sum; 185 189 } 186 190 … … 440 444 } 441 445 446 void 447 ViewCellsManager::AddSampleContributions(const VssRayContainer &rays) 448 { 449 if (!ViewCellsConstructed()) 450 return; 451 452 VssRayContainer::const_iterator it, it_end = rays.end(); 453 454 for (it = rays.begin(); it != it_end; ++ it) { 455 AddSampleContributions(*(*it)); 456 } 457 } 442 458 443 459 int ViewCellsManager::GetMinPvsSize() const … … 454 470 455 471 456 void ViewCellsManager::ComputeSampleContributions(VssRay &ray)457 { 458 ViewCellContainer viewcells; 459 460 ray.mPvsContribution = 0;461 ray.mRelativePvsContribution = 0.0f;462 463 // matt TODO: remove this!!464 Ray hray(ray);465 //static Ray hray;466 //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 467 468 float tmin = 0, tmax = 1.0; 469 470 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 471 return;472 473 Vector3 origin = hray.Extrap(tmin); 474 Vector3 termination = hray.Extrap(tmax);475 476 CastLineSegment(origin, termination, viewcells);477 //Debug << "constribution: " << (int)viewcells.size() << endl;478 // copy viewcells memory efficiently 479 const bool storeViewcells = false; 480 if (storeViewcells) 481 { 482 ray.mViewCells.reserve(viewcells.size()); 483 ray.mViewCells = viewcells;484 } 485 486 ViewCellContainer::const_iterator it = viewcells.begin(); 487 488 bool addInPlace = false;489 490 if (addInPlace) 491 {492 for (; it != viewcells.end(); ++it) {493 ViewCell *viewcell = *it; 494 495 // if ray not outside of view space 496 float contribution; 497 bool added = 498 viewcell->GetPvs().AddSample(ray.mTerminationObject, 499 ray.mPdf, 500 contribution501 502 if (added)503 ray.mPvsContribution++;504 505 ray.mRelativePvsContribution += contribution;506 } 507 }508 else 509 {510 for (; it != viewcells.end(); ++it) {511 ViewCell *viewcell = *it;512 // if ray not outside of view space513 float contribution;514 if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject,515 ray.mPdf,516 contribution517 ))518 ray.mPvsContribution++; 519 ray.mRelativePvsContribution += contribution; 520 } 521 522 for (it = viewcells.begin(); it != viewcells.end(); ++it) {523 ViewCell *viewcell = *it;524 // if ray not outside of view space525 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf);526 } 527 } 472 void 473 ViewCellsManager::AddSampleContributions(VssRay &ray) 474 { 475 // assumes viewcells have been stored... 476 ViewCellContainer *viewcells = &ray.mViewCells; 477 ViewCellContainer::const_iterator it; 478 for (it = viewcells->begin(); it != viewcells->end(); ++it) { 479 ViewCell *viewcell = *it; 480 // if ray not outside of view space 481 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 482 } 483 } 484 485 float 486 ViewCellsManager::ComputeSampleContributions(VssRay &ray, 487 const bool addRays 488 ) 489 { 490 ViewCellContainer viewcells; 491 492 ray.mPvsContribution = 0; 493 ray.mRelativePvsContribution = 0.0f; 494 495 // matt TODO: remove this!! 496 Ray hray(ray); 497 float tmin = 0, tmax = 1.0; 498 499 //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 500 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 501 return 0.0f; 502 503 Vector3 origin = hray.Extrap(tmin); 504 Vector3 termination = hray.Extrap(tmax); 505 506 CastLineSegment(origin, 507 termination, 508 viewcells); 509 510 //Debug << "constribution: " << (int)viewcells.size() << endl; 511 512 // copy viewcells memory efficiently 513 const bool storeViewcells = !addRays; 514 515 if (storeViewcells) 516 { 517 ray.mViewCells.reserve(viewcells.size()); 518 ray.mViewCells = viewcells; 519 } 520 521 ViewCellContainer::const_iterator it = viewcells.begin(); 522 523 524 for (; it != viewcells.end(); ++it) { 525 ViewCell *viewcell = *it; 526 // if ray not outside of view space 527 float contribution; 528 if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 529 ray.mPdf, 530 contribution 531 )) 532 ray.mPvsContribution++; 533 ray.mRelativePvsContribution += contribution; 534 } 535 536 if (addRays) 537 for (it = viewcells.begin(); it != viewcells.end(); ++it) { 538 ViewCell *viewcell = *it; 539 // if ray not outside of view space 540 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 541 } 542 543 return ray.mRelativePvsContribution; 528 544 } 529 545
Note: See TracChangeset
for help on using the changeset viewer.