Postmerge cleanup

#2391
This commit is contained in:
Wojtek Figat
2024-08-30 14:48:06 +02:00
parent 3b9cca30bb
commit 653aaecaec
9 changed files with 111 additions and 418 deletions

View File

@@ -477,24 +477,25 @@ namespace FlaxEngine
Quaternion.Slerp(ref start.Orientation, ref end.Orientation, amount, out result.Orientation);
Float3.Lerp(ref start.Scale, ref end.Scale, amount, out result.Scale);
}
/// <summary>
/// Combines the functions: <br/>
/// <see cref="Vector3.SnapToRotatedGridWithOffset"/>,<br/>
/// Combines the functions:<br/>
/// <see cref="Vector3.SnapToGrid(FlaxEngine.Vector3,FlaxEngine.Vector3)"/>,<br/>
/// <see cref="Quaternion.GetRotationFromNormal"/>.
/// <example><para><b>Example code:</b></para>
/// <code>
/// <see langword="public" /> <see langword="class" /> AlignRotationToObjectAndSnapToGridExample : <see cref="Script"/><br/>
/// <see langword="public" /> <see cref="float"/> Offset = 50.0f;<br/>
/// <see langword="public" /> <see cref="Vector3"/> Offset = new Vector3(0, 0, 50f);<br/>
/// <see langword="public" /> <see cref="Vector3"/> GridSize = <see cref="Vector3.One"/> * 20.0f;<br/>
/// <see langword="public" /> <see cref="Actor"/> RayOrgin;<br/>
/// <see langword="public" /> <see cref="Actor"/> RayOrigin;<br/>
/// <see langword="public" /> <see cref="Actor"/> SomeObject;<br/>
/// <see langword="public" /> <see langword="override" /> <see langword="void" /> <see cref="Script.OnFixedUpdate"/><br/>
/// {<br/>
/// <see langword="if" /> (<see cref="Physics"/>.RayCast(RayOrgin.Position, RayOrgin.Transform.Forward, out <see cref="RayCastHit"/> Hit)
/// <see langword="if" /> (<see cref="Physics"/>.RayCast(RayOrigin.Position, RayOrigin.Transform.Forward, out <see cref="RayCastHit"/> hit)
/// {<br/>
/// <see cref="Transform"/> transform = Hit.Collider.Transform;
/// <see cref="Vector3"/> point = Hit.Point;
/// <see cref="Vector3"/> normal = Hit.Normal;
/// <see cref="Transform"/> transform = hit.Collider.Transform;
/// <see cref="Vector3"/> point = hit.Point;
/// <see cref="Vector3"/> normal = hit.Normal;
/// SomeObject.Transform = <see cref="Transform"/>.AlignRotationToNormalAndSnapToGrid
/// (
/// point,
@@ -502,7 +503,8 @@ namespace FlaxEngine
/// Offset,
/// transform,
/// SomeObject.Scale,
/// GridSize
/// GridSize,
/// Float3.One
/// );
/// }
/// }
@@ -510,127 +512,37 @@ namespace FlaxEngine
/// </code>
/// </example>
/// </summary>
/// <param name="InPoint">The position to snap.</param>
/// <param name="InGridSize">The size of the grid.</param>
/// <param name="InNormalOffset">The local Z grid offset to apply after snapping.</param>
/// <param name="InNormal">The normal vector.</param>
/// <param name="InRelativeTo">The relative transform.</param>
/// <param name="InReturnScale">The scale to apply to the transform.</param>
/// <param name="point">The position to snap.</param>
/// <param name="gridSize">The size of the grid.</param>
/// <param name="normalOffset">The local grid offset to apply after snapping.</param>
/// <param name="normal">The normal vector.</param>
/// <param name="relativeTo">The relative transform.</param>
/// <param name="scale">The scale to apply to the transform.</param>
/// <returns>The rotated and snapped transform.</returns>
public static Transform AlignRotationToNormalAndSnapToGrid(Vector3 InPoint, Vector3 InNormal, float InNormalOffset, Transform InRelativeTo, Float3 InReturnScale, Vector3 InGridSize)
public static Transform AlignRotationToNormalAndSnapToGrid(Vector3 point, Vector3 normal, Vector3 normalOffset, Transform relativeTo, Vector3 gridSize, Float3 scale)
{
Quaternion rot = Quaternion.GetRotationFromNormal(InNormal, InRelativeTo);
return new Transform(Vector3.SnapToRotatedGridWithOffset(InPoint, InRelativeTo.Translation, new Vector3(0, 0, InNormalOffset), rot, InGridSize), rot, InReturnScale);
}
/// <summary>
/// Combines the functions: <br/>
/// <see cref="Vector3.SnapToRotatedGridWithOffset"/>,<br/>
/// <see cref="Quaternion.GetRotationFromNormal"/>.
/// <example><para><b>Example code:</b></para>
/// <code>
/// <see langword="public" /> <see langword="class" /> AlignRotationToObjectAndSnapToGridExample : <see cref="Script"/><br/>
/// <see langword="public" /> <see cref="float"/> Offset = 50.0f;<br/>
/// <see langword="public" /> <see cref="Vector3"/> GridSize = <see cref="Vector3.One"/> * 20.0f;<br/>
/// <see langword="public" /> <see cref="Actor"/> RayOrgin;<br/>
/// <see langword="public" /> <see cref="Actor"/> SomeObject;<br/>
/// <see langword="public" /> <see langword="override" /> <see langword="void" /> <see cref="Script.OnFixedUpdate"/><br/>
/// {<br/>
/// <see langword="if" /> (<see cref="Physics"/>.RayCast(RayOrgin.Position, RayOrgin.Transform.Forward, out <see cref="RayCastHit"/> Hit)
/// {<br/>
/// <see cref="Transform"/> transform = Hit.Collider.Transform;
/// <see cref="Vector3"/> point = Hit.Point;
/// <see cref="Vector3"/> normal = Hit.Normal;
/// SomeObject.Transform = <see cref="Transform"/>.AlignRotationToNormalAndSnapToGrid
/// (
/// point,
/// normal,
/// Offset,
/// transform,
/// GridSize
/// );
/// }
/// }
/// }
/// </code>
/// </example>
/// </summary>
/// <param name="InPoint">The position to snap.</param>
/// <param name="InGridSize">The size of the grid.</param>
/// <param name="InNormalOffset">The local Z grid offset to apply after snapping.</param>
/// <param name="InNormal">The normal vector.</param>
/// <param name="InRelativeTo">The relative transform.</param>
/// <returns>The rotated and snapped transform with scale <see cref="Float3.One"/>.</returns>
public static Transform AlignRotationToNormalAndSnapToGrid(Vector3 InPoint, Vector3 InNormal, float InNormalOffset, Transform InRelativeTo, Vector3 InGridSize)
{
Quaternion rot = Quaternion.GetRotationFromNormal(InNormal, InRelativeTo);
return new Transform(Vector3.SnapToRotatedGridWithOffset(InPoint, InRelativeTo.Translation, new Vector3(0, 0, InNormalOffset), rot, InGridSize), rot, Float3.One);
Quaternion rot = Quaternion.GetRotationFromNormal(normal, relativeTo);
return new Transform(Vector3.SnapToGrid(point, gridSize, rot, relativeTo.Translation, normalOffset), rot, scale);
}
/// <summary>
/// Combines the functions:<br/>
/// <see cref="Vector3.SnapToRotatedGridWithOffset"/>,<br/>
/// <see cref="Vector3.SnapToGrid(FlaxEngine.Vector3,FlaxEngine.Vector3)"/>,<br/>
/// <see cref="Quaternion.GetRotationFromNormal"/>.
/// <example><para><b>Example code:</b></para>
/// <code>
/// <see langword="public" /> <see langword="class" /> AlignRotationToObjectAndSnapToGridExample : <see cref="Script"/><br/>
/// <see langword="public" /> <see cref="Vector3"/> Offset = new Vector3(0, 0, 50f);<br/>
/// <see langword="public" /> <see cref="Vector3"/> GridSize = <see cref="Vector3.One"/> * 20.0f;<br/>
/// <see langword="public" /> <see cref="Actor"/> RayOrgin;<br/>
/// <see langword="public" /> <see cref="Actor"/> RayOrigin;<br/>
/// <see langword="public" /> <see cref="Actor"/> SomeObject;<br/>
/// <see langword="public" /> <see langword="override" /> <see langword="void" /> <see cref="Script.OnFixedUpdate"/><br/>
/// {<br/>
/// <see langword="if" /> (<see cref="Physics"/>.RayCast(RayOrgin.Position, RayOrgin.Transform.Forward, out <see cref="RayCastHit"/> Hit)
/// <see langword="if" /> (<see cref="Physics"/>.RayCast(RayOrigin.Position, RayOrigin.Transform.Forward, out <see cref="RayCastHit"/> hit)
/// {<br/>
/// <see cref="Transform"/> transform = Hit.Collider.Transform;
/// <see cref="Vector3"/> point = Hit.Point;
/// <see cref="Vector3"/> normal = Hit.Normal;
/// SomeObject.Transform = <see cref="Transform"/>.AlignRotationToNormalAndSnapToGrid
/// (
/// point,
/// normal,
/// Offset,
/// transform,
/// SomeObject.Scale,
/// GridSize
/// );
/// }
/// }
/// }
/// </code>
/// </example>
/// </summary>
/// <param name="InPoint">The position to snap.</param>
/// <param name="InGridSize">The size of the grid.</param>
/// <param name="InNormalOffset">The local Z grid offset to apply after snapping.</param>
/// <param name="InNormal">The normal vector.</param>
/// <param name="InRelativeTo">The relative transform.</param>
/// <param name="InReturnScale">The scale to apply to the transform.</param>
/// <returns>The rotated and snapped transform.</returns>
public static Transform AlignRotationToNormalAndSnapToGrid(Vector3 InPoint, Vector3 InNormal, Vector3 InNormalOffset, Transform InRelativeTo, Float3 InReturnScale, Vector3 InGridSize)
{
Quaternion rot = Quaternion.GetRotationFromNormal(InNormal, InRelativeTo);
return new Transform(Vector3.SnapToRotatedGridWithOffset(InPoint, InRelativeTo.Translation, InNormalOffset, rot, InGridSize), rot, InReturnScale);
}
/// <summary>
/// Combines the functions:<br/>
/// <see cref="Vector3.SnapToRotatedGridWithOffset"/>,<br/>
/// <see cref="Quaternion.GetRotationFromNormal"/>.
/// <example><para><b>Example code:</b></para>
/// <code>
/// <see langword="public" /> <see langword="class" /> AlignRotationToObjectAndSnapToGridExample : <see cref="Script"/><br/>
/// <see langword="public" /> <see cref="Vector3"/> Offset = new Vector3(0, 0, 50f);<br/>
/// <see langword="public" /> <see cref="Vector3"/> GridSize = <see cref="Vector3.One"/> * 20.0f;<br/>
/// <see langword="public" /> <see cref="Actor"/> RayOrgin;<br/>
/// <see langword="public" /> <see cref="Actor"/> SomeObject;<br/>
/// <see langword="public" /> <see langword="override" /> <see langword="void" /> <see cref="Script.OnFixedUpdate"/><br/>
/// {<br/>
/// <see langword="if" /> (<see cref="Physics"/>.RayCast(RayOrgin.Position, RayOrgin.Transform.Forward, out <see cref="RayCastHit"/> Hit)
/// {<br/>
/// <see cref="Transform"/> transform = Hit.Collider.Transform;
/// <see cref="Vector3"/> point = Hit.Point;
/// <see cref="Vector3"/> normal = Hit.Normal;
/// <see cref="Transform"/> transform = hit.Collider.Transform;
/// <see cref="Vector3"/> point = hit.Point;
/// <see cref="Vector3"/> normal = hit.Normal;
/// SomeObject.Transform = <see cref="Transform"/>.AlignRotationToNormalAndSnapToGrid
/// (
/// point,
@@ -645,16 +557,15 @@ namespace FlaxEngine
/// </code>
/// </example>
/// </summary>
/// <param name="InPoint">The position to snap.</param>
/// <param name="InGridSize">The size of the grid.</param>
/// <param name="InNormalOffset">The local Z grid offset to apply after snapping.</param>
/// <param name="InNormal">The normal vector.</param>
/// <param name="InRelativeTo">The relative transform.</param>
/// <param name="point">The position to snap.</param>
/// <param name="gridSize">The size of the grid.</param>
/// <param name="normalOffset">The local grid offset to apply after snapping.</param>
/// <param name="normal">The normal vector.</param>
/// <param name="relativeTo">The relative transform.</param>
/// <returns>The rotated and snapped transform with scale <see cref="Float3.One"/>.</returns>
public static Transform AlignRotationToNormalAndSnapToGrid(Vector3 InPoint, Vector3 InNormal, Vector3 InNormalOffset, Transform InRelativeTo, Vector3 InGridSize)
public static Transform AlignRotationToNormalAndSnapToGrid(Vector3 point, Vector3 normal, Vector3 normalOffset, Transform relativeTo, Vector3 gridSize)
{
Quaternion rot = Quaternion.GetRotationFromNormal(InNormal, InRelativeTo);
return new Transform(Vector3.SnapToRotatedGridWithOffset(InPoint, InRelativeTo.Translation, InNormalOffset, rot, InGridSize), rot, Float3.One);
return AlignRotationToNormalAndSnapToGrid(point, normal, normalOffset, relativeTo, gridSize, Float3.One);
}
/// <summary>