Cleanup code #1795 and unify new api in vector types
This commit is contained in:
@@ -1255,6 +1255,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 Double2 SnapToGrid(Double2 pos, Double2 gridSize)
|
||||
{
|
||||
pos.X = Mathd.Ceil((pos.X - (gridSize.X * 0.5)) / gridSize.Y) * gridSize.X;
|
||||
pos.Y = Mathd.Ceil((pos.Y - (gridSize.Y * 0.5)) / gridSize.X) * gridSize.Y;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds two vectors.
|
||||
/// </summary>
|
||||
|
||||
@@ -1536,6 +1536,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 Double3 SnapToGrid(Double3 pos, Double3 gridSize)
|
||||
{
|
||||
pos.X = Mathd.Ceil((pos.X - (gridSize.X * 0.5)) / gridSize.X) * gridSize.X;
|
||||
pos.Y = Mathd.Ceil((pos.Y - (gridSize.Y * 0.5)) / gridSize.Y) * gridSize.Y;
|
||||
pos.Z = Mathd.Ceil((pos.Z - (gridSize.Z * 0.5)) / gridSize.Z) * gridSize.Z;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds two vectors.
|
||||
/// </summary>
|
||||
|
||||
@@ -1274,30 +1274,16 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// funcion for grid snaping snap to absolute world grid
|
||||
/// <br>desined for snaping using a ray / draging object</br>
|
||||
/// Snaps the input position into the grid.
|
||||
/// </summary>
|
||||
/// <param name="Translation"></param>
|
||||
/// <param name="GridSize"></param>
|
||||
/// <returns>out = Ceil(((A - (GridSize * 0.5f)) / GridSize) * GridSize</returns>
|
||||
public static Float2 SnapToGrid(Float2 translation, Float2 gridSize)
|
||||
/// <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 Float2 SnapToGrid(Float2 pos, Float2 gridSize)
|
||||
{
|
||||
translation.X = Mathf.Ceil((translation.X - (gridSize.X * 0.5f)) / gridSize.Y) * gridSize.X;
|
||||
translation.Y = Mathf.Ceil((translation.Y - (gridSize.Y * 0.5f)) / gridSize.X) * gridSize.Y;
|
||||
return translation;
|
||||
}
|
||||
/// <summary>
|
||||
/// funcion for grid snaping snap to absolute world grid
|
||||
/// <br>desined for snaping using a ray / draging object</br>
|
||||
/// </summary>
|
||||
/// <param name="Translation"></param>
|
||||
/// <param name="GridSize"></param>
|
||||
/// <returns>out = Ceil(((A - (GridSize * 0.5f)) / GridSize) * GridSize</returns>
|
||||
public static Float2 SnapToGrid(Float2 translation, float gridSize)
|
||||
{
|
||||
translation.X = Mathf.Ceil((translation.X - (gridSize * 0.5f)) / gridSize) * gridSize;
|
||||
translation.Y = Mathf.Ceil((translation.Y - (gridSize * 0.5f)) / gridSize) * gridSize;
|
||||
return translation;
|
||||
pos.X = Mathf.Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.Y) * gridSize.X;
|
||||
pos.Y = Mathf.Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.X) * gridSize.Y;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1672,32 +1672,17 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// funcion for grid snaping snap to absolute world grid
|
||||
/// <br>desined for snaping using a ray / draging object</br>
|
||||
/// Snaps the input position into the grid.
|
||||
/// </summary>
|
||||
/// <param name="Translation"></param>
|
||||
/// <param name="GridSize"></param>
|
||||
/// <returns>out = Ceil(((A - (GridSize * 0.5f)) / GridSize) * GridSize</returns>
|
||||
public static Vector3 SnapToGrid(Vector3 translation, float gridSize)
|
||||
/// <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 Vector3 SnapToGrid(Vector3 pos, Vector3 gridSize)
|
||||
{
|
||||
translation.X = Mathr.Ceil((translation.X - (gridSize * 0.5f)) / gridSize) * gridSize;
|
||||
translation.Y = Mathr.Ceil((translation.Y - (gridSize * 0.5f)) / gridSize) * gridSize;
|
||||
translation.Z = Mathr.Ceil((translation.Z - (gridSize * 0.5f)) / gridSize) * gridSize;
|
||||
return translation;
|
||||
}
|
||||
/// <summary>
|
||||
/// funcion for grid snaping snap to absolute world grid
|
||||
/// <br>desined for snaping using a ray / draging object</br>
|
||||
/// </summary>
|
||||
/// <param name="Translation"></param>
|
||||
/// <param name="GridSize"></param>
|
||||
/// <returns>out = Ceil(((A - (GridSize * 0.5f)) / GridSize) * GridSize</returns>
|
||||
public static Vector3 SnapToGrid(Vector3 translation, Float3 gridSize)
|
||||
{
|
||||
translation.X = Mathr.Ceil((translation.X - (gridSize.X * 0.5f)) / gridSize.X) * gridSize.X;
|
||||
translation.Y = Mathr.Ceil((translation.Y - (gridSize.Y * 0.5f)) / gridSize.Y) * gridSize.Y;
|
||||
translation.Z = Mathr.Ceil((translation.Z - (gridSize.Z * 0.5f)) / gridSize.Z) * gridSize.Z;
|
||||
return translation;
|
||||
pos.X = Mathr.Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.X) * gridSize.X;
|
||||
pos.Y = Mathr.Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.Y) * gridSize.Y;
|
||||
pos.Z = Mathr.Ceil((pos.Z - (gridSize.Z * 0.5f)) / gridSize.Z) * gridSize.Z;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user