Skip to content

Instantly share code, notes, and snippets.

@deltaluca
Created October 27, 2013 09:14
Show Gist options
  • Save deltaluca/7179494 to your computer and use it in GitHub Desktop.
Save deltaluca/7179494 to your computer and use it in GitHub Desktop.
...
const std::array<float32_t, 2> bounds;
private:
static std::array<float32_t, 2> compute_bounds(const std::vector<Component>& components)
{
std::array<float32_t, 2> bounds = {0, 0};
for (const auto& component: components)
{
bounds[0] -= component.multiplier;
bounds[1] += component.multiplier;
}
bounds[0] = 0.5 * (1 + bounds[0]);
bounds[1] = 0.5 * (1 + bounds[1]);
return bounds;
}
public:
template <typename N, typename C>
FractalNoise(N&& noise,
C&& components):
noise(std::forward<N>(noise))
components(std::forward<C>(components)),
bounds(compute_bounds(this->components)) // <--- HERE
{
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment