init
This commit is contained in:
@@ -1273,6 +1273,33 @@ namespace FlaxEngine
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <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, 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds two vectors.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user