// Calculates climate value from 4 cached values // Use relative positions here public override int GetLerpedClimateAt(double posX, double posZ, int[] climateCache, int sizeX) { int posXInt = (int)(posX); int posZInt = (int)(posZ); return(GameMath.BiSerpRgbColor( (float)(posX - posXInt), (float)(posZ - posZInt), climateCache[posZInt * sizeX + posXInt], climateCache[posZInt * sizeX + posXInt + 1], climateCache[(posZInt + 1) * sizeX + posXInt], climateCache[(posZInt + 1) * sizeX + posXInt + 1] )); }
// Calculates interpolated climate value from anew public override int GetLerpedClimateAt(double posX, double posZ) { int posXInt = (int)posX; int posZInt = (int)posZ; InitPositionSeed(posXInt, posZInt); int leftTop = GetRandomClimate(); InitPositionSeed(posXInt + 1, posZInt); int rightTop = GetRandomClimate(); InitPositionSeed(posXInt, posZInt + 1); int leftBottom = GetRandomClimate(); InitPositionSeed(posXInt + 1, posZInt + 1); int rightBottom = GetRandomClimate(); return(GameMath.BiSerpRgbColor((float)(posX - posXInt), (float)(posZ - posZInt), leftTop, rightTop, leftBottom, rightBottom)); }