Cleanup code #1795 and unify new api in vector types
This commit is contained in:
@@ -1520,6 +1520,20 @@ namespace FlaxEngine
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Snaps the input position into the grid.
|
||||
/// </summary>
|
||||
/// <param name="pos">The position to snap.</param>
|
||||
/// <param name="gridSize">The size of the grid.</param>
|
||||
/// <returns>The position snapped to the grid.</returns>
|
||||
public static Float3 SnapToGrid(Float3 pos, Float3 gridSize)
|
||||
{
|
||||
pos.X = Mathf.Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.X) * gridSize.X;
|
||||
pos.Y = Mathf.Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.Y) * gridSize.Y;
|
||||
pos.Z = Mathf.Ceil((pos.Z - (gridSize.Z * 0.5f)) / gridSize.Z) * gridSize.Z;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds two vectors.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user