HighMap
HighMap copied to clipboard
Fix out-of-bounds in bilinear interpolations
clamp indices
for (int i = 0; i < shape.x; i++)
for (int j = 0; j < shape.y; j++)
{
int ip = std::clamp((int)x[i], 0, array.shape.x - 1);
int jp = std::clamp((int)y[j], 0, array.shape.y - 1);
float u = x[i] - ip;
float v = y[j] - jp;
(*this)(i, j) = array.get_value_bilinear_at(ip, jp, u, v);
}