Changeset 2742 for GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
- Timestamp:
- 06/06/08 17:40:59 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2741 r2742 140 140 141 141 // note: deletion of the ray is handled by ray pool 142 mRayCaster->SheduleRayForDeletion(ray); 142 143 } 143 144 } … … 209 210 210 211 mGvsStats.mReverseSamples += (int)reverseRays.size(); 211 212 212 EnqueueRays(reverseRays); 213 213 … … 234 234 simpleRays.clear(); 235 235 236 CreateRandomizedReverseRays(currentRay, predictedHit, simpleRays, 16 );236 CreateRandomizedReverseRays(currentRay, predictedHit, simpleRays, 16, hitTriangle); 237 237 238 238 static VssRayContainer reverseRays; … … 344 344 bool GvsPreprocessor::HandleRay(VssRay *vssRay) 345 345 { 346 if (!vssRay || !HasContribution(*vssRay))346 if (!vssRay) 347 347 return false; 348 348 349 if (!HasContribution(*vssRay)) 350 { 351 mRayCaster->SheduleRayForDeletion(vssRay); 352 return false; 353 } 354 349 355 if (0 && GVS_DEBUG) 350 356 mVssRays.push_back(new VssRay(*vssRay)); … … 354 360 355 361 ++ mGvsStats.mTotalContribution; 362 363 if (mRayQueue.size() % 10000 == 0) 364 cout << "ray queue size: " << mRayQueue.size() << endl; 365 366 if (mGvsStats.mTotalContribution % 10000 == 0) 367 cout << "contri: " << mGvsStats.mTotalContribution << endl; 356 368 357 369 return true; … … 452 464 // cast single ray to check if a triangle was missed. note: not efficient!! 453 465 newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell); 466 ++ castRays; 467 454 468 castTimer.Exit(); 455 469 456 ++ castRays; 457 458 // this ray will not be further processed 459 // note: ray deletion is handled by ray pool 460 if (!newRay) return castRays; 461 462 rayTimer.Entry(); 463 464 // new triangle discovered? => add new ray to queue 465 HandleRay(newRay); 466 467 rayTimer.Exit(); 468 470 if (!newRay) 471 return castRays; 472 469 473 //newRay->mFlags |= VssRay::BorderSample; 470 474 471 475 // cast reverse rays if necessary 472 castRays += CheckDiscontinuity( ray2, hitTriangle, oldRay);473 476 castRays += CheckDiscontinuity(*newRay, hitTriangle, oldRay); 477 474 478 // subdivide further 475 479 castRays += SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay); 476 480 castRays += SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay); 477 481 482 rayTimer.Entry(); 483 484 // new triangle discovered? => add new ray to queue 485 HandleRay(newRay); 486 487 rayTimer.Exit(); 488 478 489 return castRays; 479 490 } … … 549 560 int castRays = (int)simpleRays.size(); 550 561 551 // handle cast rays552 EnqueueRays(vssRays);553 554 562 if (0) 555 563 { … … 567 575 (*rit)->mFlags |= VssRay::BorderSample; 568 576 } 569 577 #if 0 570 578 // recursivly subdivide each edge 571 579 for (int i = 0; i < numBorderSamples; ++ i) … … 580 588 currentRay); 581 589 } 582 590 #endif 583 591 mGvsStats.mBorderSamples += castRays; 584 592 593 // handle cast rays 594 EnqueueRays(vssRays); 595 585 596 return castRays; 586 597 } … … 602 613 cout << "error: gvs sampling for " << Intersectable::GetTypeName(tObj) << " not implemented" << endl; 603 614 615 616 static SimpleRayContainer simpleRays; 617 simpleRays.clear(); 618 619 604 620 generationTimer.Entry(); 605 621 #if 0 606 622 static VertexContainer enlargedTriangle; 607 623 enlargedTriangle.clear(); … … 625 641 } 626 642 627 /// create rays from sample points and handle them628 static SimpleRayContainer simpleRays;629 simpleRays.clear();630 631 643 VertexContainer::const_iterator vit, vit_end = subdivEnlargedTri.end(); 632 644 … … 639 651 } 640 652 641 653 #endif 642 654 ////////// 643 655 //-- fill up simple rays with random rays so we can cast 16 rays at a time … … 675 687 int castRays = (int)simpleRays.size(); 676 688 677 // handle cast rays 678 EnqueueRays(vssRays); 679 680 681 #if 1 689 #if 0 682 690 for (size_t i = 0; i < vssRays.size(); ++ i) 683 691 { … … 685 693 castRays += CheckDiscontinuity2(*vssRays[i], hitTriangle, currentRay); 686 694 } 687 695 #endif 696 #if 0 688 697 689 698 // recursivly subdivide each edge … … 702 711 703 712 mGvsStats.mBorderSamples += castRays; 704 713 714 // handle cast rays 715 EnqueueRays(vssRays); 716 705 717 return castRays; 706 718 } … … 844 856 else 845 857 { 846 GenerateRays(mUseDeterministicGvs ? numSamples : numSamples / 16, *mDistribution, simpleRays, sInvalidSamples); 858 GenerateRays(mUseDeterministicGvs ? 859 numSamples : numSamples / 16, *mDistribution, simpleRays, sInvalidSamples); 847 860 } 848 861 … … 883 896 884 897 885 void GvsPreprocessor::EnqueueRays( VssRayContainer &samples)898 void GvsPreprocessor::EnqueueRays(const VssRayContainer &samples) 886 899 { 887 900 rayTimer.Entry(); … … 893 906 VssRay *ray = *vit; 894 907 HandleRay(ray); 895 // note: deletion of invalid samples handked by ray pool896 908 } 897 909 … … 918 930 else 919 931 castSamples += AdaptiveBorderSamplingOpt(*ray); 920 921 // note: don't have to delete because handled by ray pool922 932 } 923 933 … … 2001 2011 void GvsPreprocessor::PrepareProbablyVisibleSampling() 2002 2012 { 2003 2004 2013 // warning: using mailing! 2005 2014 Intersectable::NewMail(); … … 2043 2052 const Vector3 &predictedPoint, 2044 2053 SimpleRayContainer &rays, 2045 int number) 2054 int number, 2055 const Triangle3 &triangle) 2046 2056 { 2047 2057 size_t currentNumber = rays.size(); … … 2052 2062 { 2053 2063 SimpleRay simpleRay; 2054 if (CreateRandomizedReverseRay(ray, predictedPoint, simpleRay ))2064 if (CreateRandomizedReverseRay(ray, predictedPoint, simpleRay, triangle)) 2055 2065 rays.push_back(simpleRay); 2056 2066 } 2057 2067 2068 if (rays.size() != 16) 2069 cout << "x"; 2070 //else cout <<"y"; 2058 2071 //cout << "generated " << rays.size() << " rays" << endl; 2059 2072 } … … 2062 2075 bool GvsPreprocessor::CreateRandomizedReverseRay(const VssRay &ray, 2063 2076 const Vector3 &predictedPoint, 2064 SimpleRay &simpleRay) 2065 { 2066 //Vector3 nd = ray.GetNormalizedDir(); 2077 SimpleRay &simpleRay, 2078 const Triangle3 &triangle) 2079 { 2080 /*Vector3 nd = ray.GetNormalizedDir(); 2067 2081 const AxisAlignedBox3 box = mCurrentViewCell->GetBox(); 2068 2082 //Vector3 nd = box.GetNearestFace(origin).GetNormal(); … … 2070 2084 2071 2085 // Compute right handed coordinate system from direction 2072 /*Vector3 U, V;2086 Vector3 U, V; 2073 2087 nd.RightHandedBase(U, V); 2074 2088 … … 2079 2093 2080 2094 Vector2 vr2(rr[0], rr[1]); 2081 const float sigma = 1.0f;//triangle.GetBoundingBox().Radius() * mRadiusOfInfluence;2095 const float sigma = triangle.GetBoundingBox().Radius() * 1.0f; 2082 2096 Vector2 gaussvec2; 2083 2097 2084 2098 GaussianOn2D(vr2, sigma, // input 2085 2099 gaussvec2); // output 2086 2087 const Vector3 shift = gaussvec2.xx * U + gaussvec2.yy * V;2088 2089 Vector3 newOrigin = ray.mOrigin + shift;2090 2100 */ 2101 const Vector3 shift = 0;//gaussvec2.xx * U + gaussvec2.yy * V; 2102 2103 const Vector3 newTermination = ray.mTermination + shift; 2104 2091 2105 //cout << "o: " << origin << " new o: " << newOrigin << endl; 2092 Vector3 newOrigin = box.GetRandomPoint();2093 Vector3 direction = predictedPoint- newOrigin;2106 Vector3 newOrigin = mCurrentViewCell->GetBox().GetRandomPoint(); 2107 Vector3 direction = newTermination - newOrigin; 2094 2108 2095 2109 const float len = Magnitude(direction); … … 2101 2115 2102 2116 if (0 && !IntersectsViewCell(newOrigin, -direction)) 2103 {2104 //cout << "x";2105 2117 return false; 2106 }2107 2118 2108 2119 //cout << "y"; … … 2114 2125 } 2115 2126 2116 2117 } 2127 }
Note: See TracChangeset
for help on using the changeset viewer.