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

Fix Bugs with Bounding Box Initialized at Runtime #558

Merged
merged 11 commits into from
Dec 9, 2023

Conversation

marlenaklein-msft
Copy link
Contributor

@marlenaklein-msft marlenaklein-msft commented Nov 21, 2023

Fixes the errors reported in #543, as well as current behavior where an empty game object initialized at runtime will have unreasonable bounds values for one frame and a non-empty prefab like the coffee cup will have handles incorrectly enabled for one frame:

image

This change ensures that the LateUpdate in BoundsHandleInteractable prevents incorrect vector values and division by zero, and the other odd behavior for that first frame.

@AMollis AMollis added Type: Bug A problem with an existing feature that can be fixed with the next patched release. Package: Spatial Manipulation The Project spatial manipulation package is impacted by this issue. labels Dec 8, 2023
@marlenaklein-msft
Copy link
Contributor Author

Issue 1: Handles Incorrectly Appear
The handlesEnabled variable is applied during SqueezeableBoxVisuals' Update. If an object with handles disabled is initialized at runtime, BoundsHandleInteractable's LateUpdate is called first and the handles will incorrectly appear for that first frame.
Solution: Call Update from Awake in Squeezable Box Visuals, make a protected flag, or delay LateUpdate until after Update in BoundsHandleInteractable.

Issue 2: Errors logged for invalid scale
In BoundsHandleInteractable LateUpdate, the local scale is set to 1/transform.lossyscale. When transform.lossyscale is 0 we get an error from division by 0. The lossyscale being 0 is attributable to the grandparent object (SqueezableBoxVisuals) which has its bounds set by BoundsControl's ComputeBounds which is called from BoundsControl's Update.
Solution: Check explicitly for division by 0, change the call ComputeBounds (complicated to refactor), or delay LateUpdate until after Update in BoundsHandleInteractable.

Issue 3: Star-shaped explosion when colliders are enabled with invalid scale.
Solution: Move enabling of colliders to Update or delay LateUpdate until after Update in BoundsHandleInteractable.

AMollis
AMollis previously approved these changes Dec 9, 2023
Copy link
Contributor

@AMollis AMollis left a comment

Choose a reason for hiding this comment

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

One comment :)

@AMollis AMollis merged commit ec5c141 into MixedRealityToolkit:main Dec 9, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: Spatial Manipulation The Project spatial manipulation package is impacted by this issue. Type: Bug A problem with an existing feature that can be fixed with the next patched release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants