Fix more and add bool check to orient the actor or not.

This commit is contained in:
Chandler Cox
2023-09-30 21:33:27 -05:00
parent 1366c2850f
commit cc681de30e

View File

@@ -364,13 +364,20 @@ namespace FlaxEngine
/// <param name="point">The point (world-space).</param>
/// <param name="axis">The axis (normalized).</param>
/// <param name="angle">The angle (in degrees).</param>
public void RotateAround(Vector3 point, Vector3 axis, float angle)
/// /// <param name="orientActor">Whether to orient the actor the same amount as rotation.</param>
public void RotateAround(Vector3 point, Vector3 axis, float angle, bool orientActor = true)
{
var transform = Transform;
var q = Quaternion.RotationAxis(axis, angle * Mathf.DegreesToRadians);
var dif = (transform.Translation - point) * q;
transform.Translation = point + dif;
transform.Orientation *= q;
if (Vector3.NearEqual(point, transform.Translation))
transform.Orientation *= q;
else
{
transform.Translation = point + dif;
if (orientActor)
transform.Orientation *= q;
}
Transform = transform;
}