setHeightValueAtIndex method

void setHeightValueAtIndex(
  1. int xi,
  2. int yi,
  3. double value
)

Set the height value at an index. Don't forget to update maxValue and minValue after you're done.

Implementation

void setHeightValueAtIndex(int xi, int yi, double value){
  final data = this.data;
  data[xi][yi] = value;

  // Invalidate cache
  clearCachedConvexTrianglePillar(xi, yi, false);
  if (xi > 0) {
    clearCachedConvexTrianglePillar(xi - 1, yi, true);
    clearCachedConvexTrianglePillar(xi - 1, yi, false);
  }
  if (yi > 0) {
    clearCachedConvexTrianglePillar(xi, yi - 1, true);
    clearCachedConvexTrianglePillar(xi, yi - 1, false);
  }
  if (yi > 0 && xi > 0) {
    clearCachedConvexTrianglePillar(xi - 1, yi - 1, true);
  }
}