Skip to content

Commit 8f8da62

Browse files
[samplestats] Code cleanup
1 parent b1d4fdc commit 8f8da62

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

openpgl/data/SampleStatistics.h

+5-21
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
#include "../openpgl_common.h"
77

8-
#define INTERGER_V2
9-
108
namespace openpgl
119
{
1210
struct SampleStatistics
@@ -229,11 +227,11 @@ struct IntegerSampleStatistics
229227
Vector3 sampleBoundsMax{0};
230228
Vector3 sampleBoundsExtend{0};
231229
Vector3 invSampleBoundsExtend{0};
232-
#ifdef INTERGER_V2
230+
// sample bound stats to center the collected samples before discretization
233231
Vector3 sampleBoundsCenter{0};
234232
Vector3 sampleBoundsHalfExtend{0};
235233
Vector3 invSampleBoundsHalfExtend{0};
236-
#endif
234+
237235
IntegerSampleStatistics()
238236
{
239237
mean = Point3i(0);
@@ -245,11 +243,9 @@ struct IntegerSampleStatistics
245243
sampleBoundsMax = Vector3(0);
246244
sampleBoundsExtend = Vector3(0);
247245
invSampleBoundsExtend = Vector3(0);
248-
#ifdef INTERGER_V2
249246
sampleBoundsCenter = Vector3(0);
250247
sampleBoundsHalfExtend = Vector3(0);
251248
invSampleBoundsHalfExtend = Vector3(0);
252-
#endif
253249
}
254250

255251
IntegerSampleStatistics(const BBox &bounds)
@@ -270,11 +266,9 @@ struct IntegerSampleStatistics
270266
sampleBoundsMax = scaledBounds.upper;
271267
sampleBoundsExtend = scaledBounds.upper - scaledBounds.lower;
272268
invSampleBoundsExtend = embree::rcp(sampleBoundsExtend);
273-
#ifdef INTERGER_V2
274269
sampleBoundsHalfExtend = sampleBoundsExtend * 0.5f;
275270
invSampleBoundsHalfExtend = embree::rcp(sampleBoundsHalfExtend);
276271
sampleBoundsCenter = sampleBoundsMin + sampleBoundsHalfExtend;
277-
#endif
278272
}
279273

280274
void clear()
@@ -289,21 +283,15 @@ struct IntegerSampleStatistics
289283
sampleBoundsMax = Vector3(0);
290284
sampleBoundsExtend = Vector3(0);
291285
invSampleBoundsExtend = Vector3(0);
292-
#ifdef INTERGER_V2
293286
sampleBoundsCenter = Vector3(0);
294287
sampleBoundsHalfExtend = Vector3(0);
295288
invSampleBoundsHalfExtend = Vector3(0);
296-
#endif
297289
}
298290

299291
inline void addSample(const Point3 sample)
300292
{
301293
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);
307295
Vector3 tmpVariance = (tmpSample * tmpSample) * INTEGER_BINS;
308296
tmpSample *= INTEGER_BINS;
309297

@@ -345,15 +333,11 @@ struct IntegerSampleStatistics
345333
Vector3 sampleVariance = (Vector3(variance.x, variance.y, variance.z) / (INTEGER_BINS)) * invNumSamples;
346334
sampleVariance -= sampleMean * sampleMean;
347335
sampleVariance = Vector3(std::fabs(sampleVariance.x), std::fabs(sampleVariance.y), std::fabs(sampleVariance.z));
348-
#ifdef INTERGER_V2
336+
349337
sampleMean = sampleMean * sampleBoundsHalfExtend;
350338
sampleMean += sampleBoundsCenter;
351339
sampleVariance = sampleVariance * (sampleBoundsHalfExtend * sampleBoundsHalfExtend);
352-
#else
353-
sampleMean = sampleMean * sampleBoundsExtend;
354-
sampleMean += sampleBoundsMin;
355-
sampleVariance = sampleVariance * (sampleBoundsExtend * sampleBoundsExtend);
356-
#endif
340+
357341
sampleStats.mean = sampleMean;
358342
sampleStats.numSamples = numSamples;
359343
sampleStats.sampleVariance = sampleVariance * float(numSamples);

0 commit comments

Comments
 (0)