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

View File

@@ -20,9 +20,9 @@ public sealed class Player
{
Vector3 p = this.Position;
return new Vector3i(
Player.FloorDiv((int)MathF.Floor(p.X), VoxelChunk.Size),
Player.FloorDiv((int)MathF.Floor(p.Y), VoxelChunk.Size),
Player.FloorDiv((int)MathF.Floor(p.Z), VoxelChunk.Size));
ChunkMath.FloorDiv((int)MathF.Floor(p.X), VoxelChunk.Size),
ChunkMath.FloorDiv((int)MathF.Floor(p.Y), VoxelChunk.Size),
ChunkMath.FloorDiv((int)MathF.Floor(p.Z), VoxelChunk.Size));
}
}
@@ -35,11 +35,4 @@ public sealed class Player
public void Move(Vector3 delta) => this.Camera.Move(delta);
public void AddRotation(float yawDelta, float pitchDelta) => this.Camera.AddRotation(yawDelta, pitchDelta);
private static int FloorDiv(int value, int size)
{
int q = value / size;
if (value % size != 0 && value < 0) q--;
return q;
}
}