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