Mixedrealitytoolkit-unity: Extensible FocusProvider to add custom raycast

Created on 15 May 2019  路  8Comments  路  Source: microsoft/MixedRealityToolkit-Unity

In our application, we are performing a custom raycast for objects without colliders. So, in order to show pointers based on the custom raycast hit, we would need to add the custom raycast in QueryScene method of FocusProvider.

I tried to extend the FocusProvider's QueryScene method, but it is not virtual. So, I copy pasted the whole script and updated the necessary code.

Please provide solutions to extend FocusProvider or make QueryScene method virtual.

Duplicate Feature Request ISV Input System

Most helpful comment

I think @Railboy has a good suggestion here if I understand correctly.

Looking through the pointer-related code, all the raycasting goes through the MixedRealityRaycaster, and it's not just FocusProvider that uses it. SurfaceMagnetism feature uses the MixedRealityRaycaster class as well.

Making the MixedRealityRayCaster extensible (it's just a static class), so that methods for SimpleRaycast/SphereCast/etc could be extended and overridden would then allow for adding custom raycastable objects into the mix. (In my case, I have a visual component that does not use Unity colliders at all, so none of the Physics.Raycast APIs apply, but this component still provides an API to raycast it nonetheless).

At that point, it definitely seems like the "Raycaster" would then be specified as part of the MRTK config.

All 8 comments

@luis-valverde-ms curious to hear your thoughts on this one.

I would like to specify the raycaster class as a SystemType in the input profile.

@keveleigh I've seen a few developers utilize custom raycasting solutions, so we may need some way to inject logic or override a portion of the MRTK scene query behavior.

My preferred solution would be to add a QueryScene() method to the pointer interface that would be called by the focus provider if pointer.SceneQueryMethod has a specific value (e.g. SceneQueryType.Custom).

I think @Railboy has a good suggestion here if I understand correctly.

Looking through the pointer-related code, all the raycasting goes through the MixedRealityRaycaster, and it's not just FocusProvider that uses it. SurfaceMagnetism feature uses the MixedRealityRaycaster class as well.

Making the MixedRealityRayCaster extensible (it's just a static class), so that methods for SimpleRaycast/SphereCast/etc could be extended and overridden would then allow for adding custom raycastable objects into the mix. (In my case, I have a visual component that does not use Unity colliders at all, so none of the Physics.Raycast APIs apply, but this component still provides an API to raycast it nonetheless).

At that point, it definitely seems like the "Raycaster" would then be specified as part of the MRTK config.

A possible solution to this is provided in PR #4678. I'm looking for feedback, so please check it out.

4325

I'm closing this out only because it's a duplicate of another issue we're already tracking (as Yoyo mentions above). I'll update the other issue to have a pointer to this one so that we don't lose the info here.

Was this page helpful?
0 / 5 - 0 ratings