summaryrefslogtreecommitdiffstats
path: root/src/Noise/InterpolNoise.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Noise/InterpolNoise.h')
-rw-r--r--src/Noise/InterpolNoise.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/Noise/InterpolNoise.h b/src/Noise/InterpolNoise.h
index 447796739..12b167dbe 100644
--- a/src/Noise/InterpolNoise.h
+++ b/src/Noise/InterpolNoise.h
@@ -427,28 +427,37 @@ public:
// Calculate query values using Cell:
int FromZ = 0;
- for (int z = 0; z < NumSameZ; z++)
+ for (int z = 0; z < NumSameZ;)
{
int ToZ = FromZ + SameZ[z];
int CurFloorZ = FloorZ[FromZ];
int FromY = 0;
- for (int y = 0; y < NumSameY; y++)
+ for (int y = 0; y < NumSameY;)
{
int ToY = FromY + SameY[y];
int CurFloorY = FloorY[FromY];
int FromX = 0;
- for (int x = 0; x < NumSameX; x++)
+ for (int x = 0; x < NumSameX;)
{
int ToX = FromX + SameX[x];
Cell.Generate(FromX, ToX, FromY, ToY, FromZ, ToZ);
- Cell.Move(FloorX[ToX], CurFloorY, CurFloorZ);
- FromX = ToX;
+ if (++x < NumSameX) // Call Move() every time except for the last loop iteration
+ {
+ Cell.Move(FloorX[ToX], CurFloorY, CurFloorZ);
+ FromX = ToX;
+ }
+ }
+ if (++y < NumSameY) // Call Move() every time except for the last loop iteration
+ {
+ Cell.Move(FloorX[0], FloorY[ToY], CurFloorZ);
+ FromY = ToY;
}
- Cell.Move(FloorX[0], FloorY[ToY], CurFloorZ);
- FromY = ToY;
} // for y
- Cell.Move(FloorX[0], FloorY[0], FloorZ[ToZ]);
- FromZ = ToZ;
+ if (++z < NumSameZ) // Call Move() every time except for the last loop iteration
+ {
+ Cell.Move(FloorX[0], FloorY[0], FloorZ[ToZ]);
+ FromZ = ToZ;
+ }
} // for z
}