Merge remote-tracking branch 'origin/master' into 1.2
This commit is contained in:
@@ -697,6 +697,27 @@ namespace FlaxEngine
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the orientation from the direction vector.
|
||||
/// </summary>
|
||||
/// <param name="direction">The direction vector (normalized).</param>
|
||||
/// <returns>The orientation.</returns>
|
||||
public static Quaternion FromDirection(Vector3 direction)
|
||||
{
|
||||
Quaternion orientation;
|
||||
if (Vector3.Dot(direction, Vector3.Up) >= 0.999f)
|
||||
{
|
||||
orientation = RotationAxis(Vector3.Left, Mathf.PiOverTwo);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 right = Vector3.Cross(direction, Vector3.Up);
|
||||
Vector3 up = Vector3.Cross(right, direction);
|
||||
orientation = LookRotation(direction, up);
|
||||
}
|
||||
return orientation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a linear interpolation between two quaternions.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user