Problematic BoundingBox bounds setting & calculations
Describe the bug
The BoundingBox components code path for calculating bounds has various issues depending on certain cases & uses.
- Bounds Overide property is private [SerializedField] and thus cannot be set at runtime. For example, one customer loads model file dynamically and AddComponent
() but cannot set the bounds override.
Issues with BoundingBox.GetTargetBounds() 2) The first phase of the method looks at children objects that are not part of the BB rig. However, the code only takes into account direct children of the Target object and not sub-children. (Also, code can be simplified to be foreach (Transform child in transform) {} )
-
GetSingleObjectBounds() is not accurate as a default BoxCollider added to an empty gameobject will be center <0,0,0> but size <1,1,1> which will pass the zero size check in the algorithm
-
The next stage of the algorithm can be simplified by leveraging the existing code in MRTK of Transform.GetColliderBounds() which does the exact same thing
-
There is also already an enum in GetTargetBounds() for what type of bounds calculation was utilized. It would actually be nice to have this setting visible to the user for them to choose which method of bounds calculation should be utilized.
Related issues: #4557 BoundingBox doesn't recompute bounds when boundsOverride is modified
#4434 Bounding box scaling varies based on whether the box is directly on the target/collider or parented to it
To reproduce
Notice sub-children beyond L1 are not considered even if they have colliders attached Notice empty game objects having impact on bounds calculation when using encapsulation
Expected behavior
-
Making BoundsOverride public settable property like other updated properties (ShowWireframe etc)
-
GetTargetBounds() when calculating bounds on first attempt, should look at all children in hierarchy of target, not just L1
-
Empty gameobjects should be ignored for calculating bounds.
-
Re-use code of GetColliderBounds() already in MRTK to reduce redundancy
Screenshots
If applicable, add screenshots to help explain your problem.
Your Setup (please complete the following information)
- Unity Version 2018.4
- MRTK Version RC2 (latest right before launch
Target Platform (please complete the following information)
- HoloLens
- HoloLens 2
- WMR immersive
- OpenVR
Additional context
Add any other context about the problem here.
#5307 Fixes 3.
The current code looks like as if BoundsOverride can be set via property
@thalbern FYI in case any of this overlaps for the new UX design
This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.
@thalbern Is this fixed (or will be fixed) in any of the current bounds control / bounding box work?
This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.
@Troy-Ferrell @polar-kev Can we please close this since it was fixed? Thanks!
@BillingsAm3 thanks for following up on this.