refactor: extract shared ChunkMath.FloorDiv helper
This commit is contained in:
13
Core/ChunkMath.cs
Normal file
13
Core/ChunkMath.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user