Skip to content

Fix Bugs with Bounding Box Initialized at Runtime - #558

Merged
AMollis merged 11 commits into
MixedRealityToolkit:mainfrom
marlenaklein-msft:BoundsControlFix
Dec 9, 2023
Merged

Fix Bugs with Bounding Box Initialized at Runtime#558
AMollis merged 11 commits into
MixedRealityToolkit:mainfrom
marlenaklein-msft:BoundsControlFix

Conversation

@marlenaklein-msft

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

@AMollis AMollis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One comment :)

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.

2 participants