5
5
6
6
#include " ../openpgl_common.h"
7
7
8
- #define INTERGER_V2
9
-
10
8
namespace openpgl
11
9
{
12
10
struct SampleStatistics
@@ -229,11 +227,11 @@ struct IntegerSampleStatistics
229
227
Vector3 sampleBoundsMax{0 };
230
228
Vector3 sampleBoundsExtend{0 };
231
229
Vector3 invSampleBoundsExtend{0 };
232
- # ifdef INTERGER_V2
230
+ // sample bound stats to center the collected samples before discretization
233
231
Vector3 sampleBoundsCenter{0 };
234
232
Vector3 sampleBoundsHalfExtend{0 };
235
233
Vector3 invSampleBoundsHalfExtend{0 };
236
- # endif
234
+
237
235
IntegerSampleStatistics ()
238
236
{
239
237
mean = Point3i (0 );
@@ -245,11 +243,9 @@ struct IntegerSampleStatistics
245
243
sampleBoundsMax = Vector3 (0 );
246
244
sampleBoundsExtend = Vector3 (0 );
247
245
invSampleBoundsExtend = Vector3 (0 );
248
- #ifdef INTERGER_V2
249
246
sampleBoundsCenter = Vector3 (0 );
250
247
sampleBoundsHalfExtend = Vector3 (0 );
251
248
invSampleBoundsHalfExtend = Vector3 (0 );
252
- #endif
253
249
}
254
250
255
251
IntegerSampleStatistics (const BBox &bounds)
@@ -270,11 +266,9 @@ struct IntegerSampleStatistics
270
266
sampleBoundsMax = scaledBounds.upper ;
271
267
sampleBoundsExtend = scaledBounds.upper - scaledBounds.lower ;
272
268
invSampleBoundsExtend = embree::rcp (sampleBoundsExtend);
273
- #ifdef INTERGER_V2
274
269
sampleBoundsHalfExtend = sampleBoundsExtend * 0 .5f ;
275
270
invSampleBoundsHalfExtend = embree::rcp (sampleBoundsHalfExtend);
276
271
sampleBoundsCenter = sampleBoundsMin + sampleBoundsHalfExtend;
277
- #endif
278
272
}
279
273
280
274
void clear ()
@@ -289,21 +283,15 @@ struct IntegerSampleStatistics
289
283
sampleBoundsMax = Vector3 (0 );
290
284
sampleBoundsExtend = Vector3 (0 );
291
285
invSampleBoundsExtend = Vector3 (0 );
292
- #ifdef INTERGER_V2
293
286
sampleBoundsCenter = Vector3 (0 );
294
287
sampleBoundsHalfExtend = Vector3 (0 );
295
288
invSampleBoundsHalfExtend = Vector3 (0 );
296
- #endif
297
289
}
298
290
299
291
inline void addSample (const Point3 sample)
300
292
{
301
293
numSamples++;
302
- #ifdef INTERGER_V2
303
- Point3 tmpSample = ((sample - sampleBoundsCenter) * invSampleBoundsHalfExtend); // * INTEGER_BINS;
304
- #else
305
- Point3 tmpSample = ((sample - sampleBoundsMin) * invSampleBoundsExtend); // * INTEGER_BINS;
306
- #endif
294
+ Point3 tmpSample = ((sample - sampleBoundsCenter) * invSampleBoundsHalfExtend);
307
295
Vector3 tmpVariance = (tmpSample * tmpSample) * INTEGER_BINS;
308
296
tmpSample *= INTEGER_BINS;
309
297
@@ -345,15 +333,11 @@ struct IntegerSampleStatistics
345
333
Vector3 sampleVariance = (Vector3 (variance.x , variance.y , variance.z ) / (INTEGER_BINS)) * invNumSamples;
346
334
sampleVariance -= sampleMean * sampleMean;
347
335
sampleVariance = Vector3 (std::fabs (sampleVariance.x ), std::fabs (sampleVariance.y ), std::fabs (sampleVariance.z ));
348
- # ifdef INTERGER_V2
336
+
349
337
sampleMean = sampleMean * sampleBoundsHalfExtend;
350
338
sampleMean += sampleBoundsCenter;
351
339
sampleVariance = sampleVariance * (sampleBoundsHalfExtend * sampleBoundsHalfExtend);
352
- #else
353
- sampleMean = sampleMean * sampleBoundsExtend;
354
- sampleMean += sampleBoundsMin;
355
- sampleVariance = sampleVariance * (sampleBoundsExtend * sampleBoundsExtend);
356
- #endif
340
+
357
341
sampleStats.mean = sampleMean;
358
342
sampleStats.numSamples = numSamples;
359
343
sampleStats.sampleVariance = sampleVariance * float (numSamples);
0 commit comments