Add Actor.RotateAround

This commit is contained in:
Wojtek Figat
2021-07-15 22:07:25 +02:00
parent 73c283fdd4
commit 8ae3c23ec8

View File

@@ -317,6 +317,23 @@ namespace FlaxEngine
}
}
/// <summary>
/// Rotates the actor around axis passing through point in world-space by angle (in degrees).
/// </summary>
/// <remarks>Modifies both the position and the rotation of the actor (scale remains the same).</remarks>
/// <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)
{
var transform = Transform;
var q = Quaternion.RotationAxis(axis, angle * Mathf.DegreesToRadians);
var dif = (transform.Translation - point) * q;
transform.Translation = point + dif;
transform.Orientation = q;
Transform = transform;
}
/// <inheritdoc />
public override string ToString()
{