6#include <Common/assertion.h>
7#include <Common/primitive_type.h>
27 SampleFlow(
const real* savedDims, std::size_t numSavedDims);
37 std::array<real, 2>
flow2D();
42 std::array<real, 3>
flow3D();
48 template<std::
size_t N>
49 std::array<real, N>
flowND();
57 bool pick(real pickProbability);
78 const real* m_savedDims;
79 std::size_t m_numSavedDims;
80 std::size_t m_numReadDims;
81 std::optional<real> m_partiallyUsedDim;
83 bool hasMoreToRead()
const;
90 m_savedDims (nullptr),
97 m_savedDims (savedDims),
98 m_numSavedDims (numSavedDims),
102 PH_ASSERT(savedDims);
120template<std::
size_t N>
123 std::array<real, N> sample;
124 for(std::size_t i = 0; i < N; ++i)
126 sample[i] = load1D();
138 real dimValue = load1D();
141 PH_ASSERT(!m_partiallyUsedDim.has_value());
142 m_partiallyUsedDim = dimValue;
152inline bool SampleFlow::hasMoreToRead()
const
154 return m_numReadDims < m_numSavedDims;
157inline real SampleFlow::load1D()
159 if(m_partiallyUsedDim.has_value())
161 const real dimValue = m_partiallyUsedDim.value();
162 m_partiallyUsedDim.reset();
166 return m_savedDims && hasMoreToRead()
167 ? m_savedDims[m_numReadDims++]
A sample with arbitrary dimensions with fine-grained sampling control.
Definition SampleFlow.h:19
bool pick(real pickProbability)
Consumes the next dimension and use it to perform a random pick. Effectively using flow1D() to perfor...
Definition SampleFlow.h:131
std::array< real, N > flowND()
Makes a N-D sample by consuming the next N dimension.
Definition SampleFlow.h:121
bool unflowedRandomPick(real pickProbability)
Performs a random pick independent to this flow. No dimension is being consumed. This method is inten...
Definition SampleFlow.h:147
std::array< real, 3 > flow3D()
Makes a 3-D sample by consuming the next three dimensions.
Definition SampleFlow.h:115
real flow1D()
Makes a 1-D sample by consuming the next dimension.
Definition SampleFlow.h:105
SampleFlow()
Creates a flow of totally random values.
Definition SampleFlow.h:89
std::array< real, 2 > flow2D()
Makes a 2-D sample by consuming the next two dimensions.
Definition SampleFlow.h:110
bool unflowedPick(real pickProbability)
Uses the next dimension to perform a random pick without consuming it. This method does not cause the...
Definition SampleFlow.h:136
static real sample()
Get a uniform random value in [0, 1].
Definition Random.cpp:44
bool pick(const T pickProbability, const T sample)
Randomly pick a branch with some probability.
Definition sample.h:41
bool reused_pick(const T pickProbability, T &sample)
Definition sample.h:50
The root for all renderer implementations.
Definition EEngineProject.h:6