22#include "NoiseLib/include/controlfunction.h"
23#include "NoiseLib/include/math2d.h"
24#include "NoiseLib/include/utils.h"
43 x = std::clamp(x, 0.f, 1.f);
44 y = std::clamp(y, 0.f, 1.f);
51 return x >= 0.f && x <= 1.f && y >= 0.f && y <= 1.f;
61 const Point2D p(x, y);
63 const Point2D topLeft(0.f, 0.f);
64 const Point2D topRight(1.f, 0.f);
65 const Point2D bottomLeft(0.f, 1.f);
66 const Point2D bottomRight(1.f, 1.f);
70 auto dist = std::numeric_limits<float>::max();
72 dist = std::min(dist, distToLineSegment(p, topLeft, topRight, c));
73 dist = std::min(dist, distToLineSegment(p, topRight, bottomRight, c));
74 dist = std::min(dist, distToLineSegment(p, bottomRight, bottomLeft, c));
75 dist = std::min(dist, distToLineSegment(p, bottomLeft, topLeft, c));
91 float get(
int i,
int j)
const
93 return (
float)m_array(i, j);
96 float sample(
float ri,
float rj)
const
98 float x = ri * (m_array.
shape.x - 1);
99 float y = rj * (m_array.
shape.y - 1);
107 if (i == m_array.
shape.x - 1)
109 i = m_array.
shape.x - 2;
115 if (j == m_array.
shape.y - 1)
117 j = m_array.
shape.y - 2;
137 : noise_function(noise_function), offset(offset), scaling(scaling)
144 return offset + scaling * noise_function.
get_delegate()(x, y, 0.f);
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Definition dendry_array_control_function.hpp:32
float DistToDomainImpl(float x, float y) const
Definition dendry_array_control_function.hpp:54
float MaximumImpl() const
Definition dendry_array_control_function.hpp:85
float EvaluateImpl(float x, float y) const
Definition dendry_array_control_function.hpp:41
float MinimumImpl() const
Definition dendry_array_control_function.hpp:80
bool InsideDomainImpl(float x, float y) const
Definition dendry_array_control_function.hpp:49
ArrayControlFunction(hmap::Array array)
Definition dendry_array_control_function.hpp:36
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
float get_value_bilinear_at(int i, int j, float u, float v) const
Retrieves the array value at the location (x, y) near the index (i, j) using bilinear interpolation.
Definition methods.cpp:225
glm::ivec2 shape
The shape of the array {ni, nj}.
Definition array.hpp:38
HMAP_FCT_XY_TYPE get_delegate() const
Get the current delegate function.
Definition functions.cpp:44
A class for generating noise functions.
Definition functions.hpp:714
Definition dendry_array_control_function.hpp:130
double EvaluateImpl(float x, float y) const
Definition dendry_array_control_function.hpp:142
XyControlFunction(NoiseFunction noise_function, float offset=0.f, float scaling=1.f)
Definition dendry_array_control_function.hpp:134
bool InsideDomainImpl(float, float) const
Definition dendry_array_control_function.hpp:147
double DistToDomainImpl(float, float) const
Definition dendry_array_control_function.hpp:152
double MaximumImpl() const
Definition dendry_array_control_function.hpp:162
double MinimumImpl() const
Definition dendry_array_control_function.hpp:157
Defines modular function objects for procedural generation, including noise algorithms (Perlin,...
Definition algebra.hpp:23