Files
VoxelEngine/Core/ChunkMath.cs

14 lines
403 B
C#

namespace VoxelEngine.Core;
internal static class ChunkMath
{
// Floor division: floors toward negative infinity (not toward zero like C#'s /).
// Required for correct world-coord -> chunk-index mapping for negative coordinates.
internal static int FloorDiv(int value, int size)
{
int q = value / size;
if (value % size != 0 && value < 0) q--;
return q;
}
}