Skip to content

Commit

Permalink
MRTK3 change to make the cursor visuals very steady in editor and on …
Browse files Browse the repository at this point in the history
…device (#11739)

* Revert PR 11575 and fix merge conflicts

* Add sample hand menu to DwellExample (fix #11727)

* Revert "Add sample hand menu to DwellExample (fix #11727)"

This reverts commit d73af8f.

* Update MixedRealityGraphicsTools to 0.5.14 to pick up the render order change

* Debug bounds control test

* Try longer wait for cursor move

* Disable scalehandle cursor rotation tests until they are debugged

* Disable other cursor rotation tests

* Fix programmer stupidity

* Trying fix for failing unit tests

* Batch mode test

* Remove failed test changes

* Test if OnBeforeRender gets called in tests

* Verified that OnBeforeRender event doesn't fire in batch mode, so add the call to UpdateReticle in LateUpdate if we're in batch mode.
  • Loading branch information
shaynie committed Jul 25, 2023
1 parent ea862f0 commit 3e321a9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion UnityProjects/MRTKDevTemplate/Packages/manifest.json
Expand Up @@ -10,7 +10,7 @@
"com.microsoft.mrtk.data": "file:../../../com.microsoft.mrtk.data",
"com.microsoft.mrtk.diagnostics": "file:../../../com.microsoft.mrtk.diagnostics",
"com.microsoft.mrtk.extendedassets": "file:../../../com.microsoft.mrtk.extendedassets",
"com.microsoft.mrtk.graphicstools.unity": "https://github.com/microsoft/MixedReality-GraphicsTools-Unity.git?path=/com.microsoft.mrtk.graphicstools.unity#v0.5.12",
"com.microsoft.mrtk.graphicstools.unity": "https://github.com/microsoft/MixedReality-GraphicsTools-Unity.git?path=/com.microsoft.mrtk.graphicstools.unity#v0.5.14",
"com.microsoft.mrtk.input": "file:../../../com.microsoft.mrtk.input",
"com.microsoft.mrtk.spatialmanipulation": "file:../../../com.microsoft.mrtk.spatialmanipulation",
"com.microsoft.mrtk.standardassets": "file:../../../com.microsoft.mrtk.standardassets",
Expand Down
4 changes: 2 additions & 2 deletions UnityProjects/MRTKDevTemplate/Packages/packages-lock.json
Expand Up @@ -96,11 +96,11 @@
}
},
"com.microsoft.mrtk.graphicstools.unity": {
"version": "https://github.com/microsoft/MixedReality-GraphicsTools-Unity.git?path=/com.microsoft.mrtk.graphicstools.unity#v0.5.12",
"version": "https://github.com/microsoft/MixedReality-GraphicsTools-Unity.git?path=/com.microsoft.mrtk.graphicstools.unity#v0.5.14",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "3361204314b43c83990b9148ebfcfb913ae657f4"
"hash": "96743038a313c93322c935d99d2deb18e831aa2d"
},
"com.microsoft.mrtk.input": {
"version": "file:../../../com.microsoft.mrtk.input",
Expand Down
Expand Up @@ -51,6 +51,7 @@ public ReticleVisibilitySettings VisibilitySettings
private void OnEnable()
{
rayInteractor.selectEntered.AddListener(LocateTargetHitPoint);
Application.onBeforeRender += UpdateReticle;

// If no custom reticle root is specified, just use the interactor's transform.
if (reticleRoot == null)
Expand All @@ -66,20 +67,27 @@ private void OnEnable()
private void OnDisable()
{
rayInteractor.selectEntered.RemoveListener(LocateTargetHitPoint);
Application.onBeforeRender -= UpdateReticle;

ReticleSetActive(false);
}

/// <summary>
/// A Unity event function that is called every frame, if this object is enabled.
/// </summary>
private void Update()
private void LateUpdate()
{
UpdateReticle();
// if running in batch mode the onBeforeRender event doesn't fire so
// we need to update the reticle here
if (Application.isBatchMode)
{
UpdateReticle();
}
}

private static readonly ProfilerMarker UpdateReticlePerfMarker = new ProfilerMarker("[MRTK] MRTKRayReticleVisual.UpdateReticle");

[BeforeRenderOrder(XRInteractionUpdateOrder.k_BeforeRenderLineVisual)]
private void UpdateReticle()
{
using (UpdateReticlePerfMarker.Auto())
Expand Down
Expand Up @@ -331,7 +331,8 @@ private bool ApproximatelyEquals(Quaternion a, Quaternion b, float tolerance = 0
{
return Mathf.Abs(a.x - b.x) <= tolerance
&& Mathf.Abs(a.y - b.y) <= tolerance
&& Mathf.Abs(a.z - b.z) <= tolerance;
&& Mathf.Abs(a.z - b.z) <= tolerance
&& Mathf.Abs(a.w - b.w) <= tolerance;
}

private IEnumerator HoverCursorRotation(string handleName, Vector3 expectedRotation, string visualsPath)
Expand Down Expand Up @@ -376,7 +377,7 @@ private IEnumerator HoverCursorRotation(string handleName, Vector3 expectedRotat
SpatialManipulationReticle[] reticles = Object.FindObjectsOfType<SpatialManipulationReticle>();
Assert.AreEqual(reticles.Length, 1, "Cursor should appear.");
GameObject cursor = reticles[0].gameObject;
Assert.IsTrue(ApproximatelyEquals(cursor.transform.eulerAngles, expectedRotation), $"Cursor should be rotated for {handleName}.");
Assert.IsTrue(ApproximatelyEquals(cursor.transform.eulerAngles, expectedRotation), $"Cursor should be rotated for {handleName}. Expected euler angles: {expectedRotation}. Actual: {cursor.transform.eulerAngles}");
Quaternion worldRotation = cursor.transform.rotation;

// Select the handle
Expand Down Expand Up @@ -410,4 +411,4 @@ private IEnumerator HoverCursorRotation(string handleName, Vector3 expectedRotat
}
}
}
#pragma warning restore CS1591
#pragma warning restore CS1591

0 comments on commit 3e321a9

Please sign in to comment.