Skip to content

Commit 0ab1671

Browse files
neichnerkeveleigh
andauthored
Look Rotation Viewing Vector Is Zero log every update (#895)
* Update Follow.cs Signed-off-by: Niek Eichner <[email protected]> * Update according to comment. Signed-off-by: Niek Eichner <[email protected]> * Add a few doc clarifications * Update CHANGELOG.md * Use epsilon instead of 0 --------- Signed-off-by: Niek Eichner <[email protected]> Co-authored-by: Kurtis <[email protected]> Co-authored-by: Kurtis <[email protected]>
1 parent 7640ebc commit 0ab1671

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

org.mixedrealitytoolkit.spatialmanipulation/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1313
* Fixed tap to place `StartPlacement()` when called just after instantiation of the component. [PR #785](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/785)
1414
* Fix null ref in SpatialManipulationReticle when multiple interactables are hovered. [PR #873](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/873)
1515
* ConstantViewSize solver now retains the initial scale and aspect ratio [PR #719](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/719)
16+
* Fixed Follow solver frequently logging "Look Rotation Viewing Vector Is Zero" [PR #895](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/895)
1617

1718
## [3.3.0] - 2024-04-30
1819

org.mixedrealitytoolkit.spatialmanipulation/Solvers/Follow.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,20 +462,27 @@ private float SimplifyAngle(float angle)
462462
/// local xz and yz planes. If these angles fall within the leashing bounds, then we don't have
463463
/// to modify refForward. Otherwise, we apply a correction rotation to bring it within bounds.
464464
/// </summary>
465+
/// <returns>Whether <paramref name="refForward"/> was clamped or not.</returns>
465466
private bool AngularClamp(Vector3 refPosition, Quaternion refRotation, Vector3 currentPosition, ref Vector3 refForward)
466467
{
467468
using (AngularClampPerfMarker.Auto())
468469
{
469470
Vector3 toTarget = currentPosition - refPosition;
470471
float currentDistance = toTarget.magnitude;
471-
if (currentDistance <= 0)
472+
if (currentDistance <= Mathf.Epsilon)
472473
{
473474
// No need to clamp
474475
return false;
475476
}
476477

477478
toTarget.Normalize();
478479

480+
if (toTarget == Vector3.zero)
481+
{
482+
// No need to clamp
483+
return false;
484+
}
485+
479486
// Start off with a rotation towards the target. If it's within leashing bounds, we can leave it alone.
480487
Quaternion rotation = Quaternion.LookRotation(toTarget, Vector3.up);
481488

0 commit comments

Comments
 (0)