refactor: extract shared ChunkMath.FloorDiv helper

This commit is contained in:
2026-06-01 10:45:58 +02:00
parent 2afeee50d5
commit 39375b83ea
3 changed files with 28 additions and 34 deletions

13
Core/ChunkMath.cs Normal file
View File

@@ -0,0 +1,13 @@
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;
}
}