Cleanup code #1795 and unify new api in vector types
This commit is contained in:
@@ -1381,6 +1381,19 @@ 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 Vector2 SnapToGrid(Vector2 pos, Vector2 gridSize)
|
||||
{
|
||||
pos.X = Mathr.Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.Y) * gridSize.X;
|
||||
pos.Y = Mathr.Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.X) * gridSize.Y;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds two vectors.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user