HighMap icon indicating copy to clipboard operation
HighMap copied to clipboard

Fix out-of-bounds in bilinear interpolations

Open otto-link opened this issue 1 year ago • 0 comments

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);
    }

otto-link avatar Mar 08 '24 22:03 otto-link