-
Notifications
You must be signed in to change notification settings - Fork 2.1k
PokePointer and TouchableVolume fix for packed scenes and nested set-ups #10531
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
PokePointer and TouchableVolume fix for packed scenes and nested set-ups #10531
Conversation
For packed scenes the huge ray range used for Touchable volumes, regularly hits arbitrary colliders in the scene, instead of the actual touched object. Touchable volumes will now properly calculate the penetration distance into the object. Further PokePointer ray has been adjusted to only cast through the very touchable volume.
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
RogPodge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial check seems good. I need some time to try it out myself and investigate if there's a way to do this without the additional performance hit of another raycast.
@jloehr do you have time to revisit this? Otherwise, do I have permission to clone and implement any changes that might be required? I really appreciate you contributing this valuable fix (and including unit tests!!)
| // Return value less than zero so that when poke pointer is inside object, it will not raise a touch up event. | ||
| float rayScale = 1.1f; | ||
| Vector3 outsidePoint = TouchableCollider.bounds.center + normal * (TouchableCollider.bounds.extents.magnitude * rayScale); | ||
| if (TouchableCollider.Raycast(new Ray(outsidePoint, -normal), out RaycastHit raycastHit, TouchableCollider.bounds.size.magnitude * rayScale)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some concerns about performing a raycast everything this calculation is done. Is there a way to calculate the distance using the existing normal vector?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to search for other ways, but didn't find any.
TouchableCollider ususally is a BoxCollider, but can also be any arbitrary collider including a complex mesh collider. So doing any math based upon that assumption basically resolves to a raycast.
Also keep in mind, this raycast is only executed if we're already touching a volume and only for volumes we're touching. Further it's NOT a Physics.Raycast but a Collider.Raycast which is only considering the given collider. Therefore should be hopefully cheap (especially if its a primitive collider).
|
@RogPodge I do have some spare time to revisit this, so hit me up with suggestions. |
Thanks! Can you address the first PR comment I left? I'll add more as I get chances to dig through the PR. |
|
Also a heads up, can you retarget this to https://github.com/microsoft/MixedRealityToolkit-Unity/tree/prerelease/2.8.0, since we're going to be cutting a release soon and would really like to get this in! |
You mean, retargeting this PR to merge into the 2.8.0 prelease branch, right? |
|
Yep! |
Done! Surprisingly no merge conflicts and tests are still fine on my local system. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Overview
As described in the issue, when touching a volume, a long distance raycast through the entire scene was used for the poke pointer. This long distance raycast was often hitting other colliders in more packed scenes or certain set-ups.
This change introduces proper penetration distance calculation for touched
NearInteractionTouchableVolume. This in turn allows for more narrow raycasting, raising the chance of hitting the correct object in the scene.With the correct distance to the surface of a touched volume, we can also now properly sort touched volumes, resolving intersecting and nested touchable volumes.
Video of the fix in action:
Unity_qAXjDIhoom.mp4
Changes
Verification