Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check for valid uiRaycastResults and fixed pointer registration #1350

Merged
merged 11 commits into from
Nov 15, 2017

Conversation

StephenHodgson
Copy link
Contributor

@StephenHodgson StephenHodgson commented Nov 12, 2017

Changes

…sages in the console. The warning during play mode should be enough.
@SimonDarksideJ
Copy link
Contributor

Will test this in the morning.

@StephenHodgson StephenHodgson changed the title Added check for valid uiRaycastResults Added check for valid uiRaycastResults and fixed pointer registration Nov 13, 2017
@Railboy
Copy link
Contributor

Railboy commented Nov 13, 2017

This fixes the exception on my end.

While we're in here, how do we feel about adding some Debug.Asserts in FocusManager, on lines 544 & 603 (or wherever else makes sense):

Debug.Assert(pointer.PointingSource.Rays != null);
Debug.Assert(pointer.PointingSource.Rays.Length > 0);

Might as well get ahead of incorrectly configured pointers.

Railboy
Railboy previously approved these changes Nov 13, 2017
@SabinMG
Copy link

SabinMG commented Nov 14, 2017

OnInputClicked(InputClickedEventData eventData) event is not called anymore perfectly after adding this changes.

@StephenHodgson
Copy link
Contributor Author

@sabingeo can you elaborate?

@SabinMG
Copy link

SabinMG commented Nov 14, 2017

After merging the changes to the latest commit it's no longer possible to select uGUI controls. OnIputClicked of the IInputClickHandler interface is no longer called. tested in the MotionControllerTest scene.

eg : TapResponder.cs

@StephenHodgson
Copy link
Contributor Author

Which inputs are you using? Your Hands or the Motion controllers?

@SabinMG
Copy link

SabinMG commented Nov 14, 2017

Motion controllers

@StephenHodgson
Copy link
Contributor Author

Did you double check to make sure the RaycastCamera on the InputManager was assigned to your canvases?

@SabinMG
Copy link

SabinMG commented Nov 14, 2017

in the MotionControllerTest.unity there is no canvas in the scene. There is blue cube attached with TapResponder.cs script.

public void OnInputClicked(InputClickedEventData eventData)
{
           // Increase the scale of the object just as a response.
           gameObject.transform.localScale += 0.05f * gameObject.transform.localScale;

           eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
}

and this part is never called after pressing the trigger.

@StephenHodgson
Copy link
Contributor Author

Are you also getting the failed assertions and nullable errors?

@SabinMG
Copy link

SabinMG commented Nov 14, 2017

sometimes I see the assertion failed and nullable errors. but not always

@StephenHodgson
Copy link
Contributor Author

@sabingeo try the latest

@Railboy
Copy link
Contributor

Railboy commented Nov 14, 2017

Are you also getting the failed assertions and nullable errors?

So the failed assertions / errors I'm seeing are caused when GazeManager.UpdateGazeInfo() calls FocusManager.Instance.GetPointingExtent(this) to get its extent.

public float GetPointingExtent(IPointingSource pointingSource)
{
        return GetPointingExtent(GetPointer(pointingSource));
}

GetPointingExtent (IPointingSource pointingSource) attempts to track down the PointerData associated with this pointing source via TryGetPointerIndex(IPointingSource pointingSource) before passing it to this function:

private float GetPointingExtent(PointerData pointer)
{
        return (pointer.PointingSource.ExtentOverride ?? pointingExtent);
}

Changing GetPointer to return a default doesn't seem to get ahead of this, because the pointers array isn't always populated before GetPointingExtent is called.

Since IPointingSource has all the information you need to determine its extent, I don't understand the purpose of passing an IPointingSource to one function, then looking up its PointerData, then passing that to a private function, only to use the original IPointerData in the end. I could be missing something, but this seems like it could be cruft?

We could make GetPointingExtent(IPointingSource pointingSource) a public function and eliminate the private function altogether:

public float GetPointingExtent (IPointingSource pointingSource) {
        if (pointingSource == null)
                return 0;

        return (pointingSource.ExtentOverride ?? pointingExtent);
}

This gives us a universal way for pointers to determine their own extent without causing errors.

@StephenHodgson
Copy link
Contributor Author

Agreed on all counts. In the middle of some updates, that I'm testing out atm.

Essentially I removed the nullable types and replaced them with nicer fallbacks.

@StephenHodgson
Copy link
Contributor Author

Just working on one last small issue with the gaze getting unregistered when we should probably never do that.

Updated internal pointer utilities.
misc formatting.
@StephenHodgson
Copy link
Contributor Author

StephenHodgson commented Nov 14, 2017

@Railboy I think I fixed all the issues.

Please let me know what you think.

All tests passed, and built to HoloLens and PC with successful input testing.
Test scenes:

  • Motion Controller Test
  • Input Manager Test

@Railboy
Copy link
Contributor

Railboy commented Nov 14, 2017

Checking it out now.

Copy link
Contributor

@Railboy Railboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

}

if ((pointers.Count == 0) && autoRegisterGazePointerIfNoPointersRegistered && GazeManager.IsInitialized)
if (pointers.Count == 0 && autoRegisterGazePointerIfNoPointersRegistered && GazeManager.IsInitialized)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoRegisterGazePointerIfNoPointersRegistered
what about:
autoRegisterGazeIfPointersEmpty ?

(matter of taste, feel free to ignore)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that field name is obnoxiously long haha

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI in Unity 2017.0.2f3 I'm getting 3 assertion failures on startup in the InputManagerTest scene. But they're unrelated to the pointer issue:

Assertion failed: Main camera does not exist!
UnityEngine.XR.WSA.HolographicSettings:get_IsDisplayOpaque()

IsDisplayOpaque is being called by FadeScript and BoundaryManager. These failures don't happen in Unity MRTP 4 so I'm guessing it's an already-fixed XR bug on Unity's end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm trying to understand why you'd ever want to skip registering the gaze pointer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was a hold over from only having active pointers registered. It looks like you've changed the way that works though, but I haven't had a chance to review all these recent changes.

@SabinMG
Copy link

SabinMG commented Nov 15, 2017

@StephenHodgson I have checkout the latest source from your branch https://github.com/StephenHodgson/MixedRealityToolkit-Unity/tree/MRTK-uiRaycastHotfix

Input events triggers perfectly fine now. But I see some other issues

  1. After the build headset camera postions are not updating anymore, still rotation works fine though. It even happens sometimes running on editor as well. (if you restart mixed reality-Portal app some time it fixes the issue and then fall back to the same case )
    I even downloaded some apps from the store and some has the same issue. Anything wrong with my develop environment setup ?

  2. Cursor Default distance is no more reflefted to the value that you set in the inspector.

  3. And I also see slight peformance drop in the app after the build.

I am using Unity 2017.2.0p1-MRTP4 (64-bit) and OS Windows 10 pro Insider preview. Version 1709

@StephenHodgson
Copy link
Contributor Author

StephenHodgson commented Nov 15, 2017

@sabingeo Thanks for taking a look. Are those issues related to this PR specifically?

You may want to open a separate issue for these. I will not address them here unless they're directly related to this.

Cursor Default distance is no more reflected to the value that you set in the inspector.

I'll look into this.

… instead of searching though our index of pointers.
@StephenHodgson
Copy link
Contributor Author

@Railboy I updated the PR with some of your suggestions about directly getting the pointer extents, etc.

@Railboy
Copy link
Contributor

Railboy commented Nov 15, 2017

Great, the new function names / purposes seem a lot clearer to me.

I'm not getting the camera translation errors @sabingeo is seeing so it may be a setup issue.

The cursor distance issue is caused by using the terminus of the last RayStep in the cursor's pointer:

protected virtual void UpdateCursorTransform()
{
    FocusDetails focusDetails = FocusManager.Instance.GetFocusDetails(Pointer);
    GameObject newTargetedObject = focusDetails.Object;

    // Get the forward vector looking back along the pointing ray.
    RayStep lastStep = Pointer.Rays[Pointer.Rays.Length - 1];
    Vector3 lookForward = -lastStep.direction;

We can honor the maximum distance by using a static function to get a point along a set of RaySteps by distance. I can open up a new pull request to do this.

@StephenHodgson
Copy link
Contributor Author

Just open a PR on this branch I'm workin on if you got a fix.

@Railboy
Copy link
Contributor

Railboy commented Nov 15, 2017

Since it's only tangentially related I'd rather roll it into #1364. It may take time to implement / test and I don't want to hold this merge up.

@StephenHodgson StephenHodgson merged commit 78d4d44 into microsoft:master Nov 15, 2017
@StephenHodgson StephenHodgson deleted the MRTK-uiRaycastHotfix branch November 15, 2017 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants