Changeset 3234
- Timestamp:
- 12/24/08 15:55:54 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 10 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
r3233 r3234 35 35 // this sampling scheme has the benefit that it is hierarchical 36 36 int maxTries = 1000; 37 const float f_reduction = 0.9 f;37 const float f_reduction = 0.95f; 38 38 39 39 float r[2]; 40 40 41 // the maximal possible radius: our radius is a fraction of this radius 42 // this is used as a measure of the quality of distribution of the point samples 43 const float rmax = 2.0f * mRadius * sqrt(1.0f / (2.0f * sqrt(3.0f) * mNumSamples)); 44 41 45 // generates poisson distribution on disc 42 // start with some threshold 43 // best case: all samples lie on the circumference of circle 46 // start with some thresholds: all samples lie on the circumference of circle 44 47 45 const float eps = 0.2f; 46 const float minDist = 2.0f * mRadius * M_PI * (1.0f - eps) / (float)mNumSamples; 48 float minDist = 2.0f * rmax; 47 49 float sqrMinDist = minDist * minDist; 48 50 51 int tries = 0; 52 49 53 //cout << "minDist before= " << minDist << endl; 50 54 Sample2 *s = (Sample2 *)samples; 51 55 52 int totalTries = 0;53 54 56 // check if on disc 55 57 for (int i = 0; i < mNumSamples; ++ i) 56 58 { 57 int tries = 0;58 59 59 // repeat until valid sample was found 60 60 while (1) 61 61 { 62 ++ tries; 63 ++ totalTries; 64 65 // note: should use halton, but seems somewhat broken 66 mHalton->GetNext(r); 62 // q: should we use halton or does it conflict with the poisson disc properties? 63 r[0] = RandomValue(0, 1); r[1] = RandomValue(0, 1); 64 //mHalton->GetNext(r); 67 65 68 66 // scale to -1 .. 1 … … 99 97 } 100 98 99 ++ tries; 100 101 101 if (tries > maxTries) 102 102 { 103 sqrMinDist *= f_reduction; 104 tries = 0; 103 minDist *= f_reduction; 104 sqrMinDist = minDist * minDist; 105 106 maxTries += 1000; 105 107 } 106 108 } 107 109 } 108 110 109 cout << "minDist after= " << sqrt(sqrMinDist) << " #tries: " << totalTries << endl;111 cout << "minDist after= " << (float)minDist / mNumSamples<< " #tries: " << tries << endl; 110 112 } 111 113
Note: See TracChangeset
for help on using the changeset viewer.