Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -462,20 +462,27 @@ private float SimplifyAngle(float angle)
/// local xz and yz planes. If these angles fall within the leashing bounds, then we don't have
/// to modify refForward. Otherwise, we apply a correction rotation to bring it within bounds.
/// </summary>
/// <returns>Whether <paramref name="refForward"/> was clamped or not.</returns>
private bool AngularClamp(Vector3 refPosition, Quaternion refRotation, Vector3 currentPosition, ref Vector3 refForward)
{
using (AngularClampPerfMarker.Auto())
{
Vector3 toTarget = currentPosition - refPosition;
float currentDistance = toTarget.magnitude;
if (currentDistance <= 0)
if (currentDistance <= 0f)
{
// No need to clamp
return false;
}

toTarget.Normalize();

if (toTarget == Vector3.zero)
{
// No need to clamp
return false;
}

// Start off with a rotation towards the target. If it's within leashing bounds, we can leave it alone.
Quaternion rotation = Quaternion.LookRotation(toTarget, Vector3.up);

Expand Down