microsoft/MixedRealityToolkit-Unity

Flattened BoundsControl collapse or expand to infinity

johannes-weidenfeller opened this issue · 0 comments

This issue has been migrated a new MRTK repository, and the status of this issue will now be tracked at the following location:


Describe the bug

When BoundsControls with the BoundingBoxWithHandles visuals prefab are flattened, the handles sometimes collapse along the wrong axis and sometimes expand out to infinity.

To reproduce

Steps to reproduce the behavior:

  1. Add a plane (flat object) to the scene
  2. Equip plane with ObjectManipulator and BoundsControl scripts
  3. Assign BoundingBoxWithHandles prefab to the Bounds Visual Prefab field of the BoundsControl component and set HandlesActive field to True
  4. Ensure that FlattenMode is set to either Auto or Always

Expected behavior

Bounds should automatically flatten across the flattest axis of the object.

Screenshots

image

image

Your setup (please complete the following information)

  • Unity Version 2021.3.19.f1
  • MRTK3 pre.17

Target platform (please complete the following information)

  • HoloLens 2

Additional context

It seems like the issue lies in the calculation of the flattenVector in the SqueezableBoxVisuals.cs script. When the flattenVector is calculated in line 193 it is calculated with respect to the newly spawned BoxVisuals. Since these are of uniform scale, the flattenVector always computes to one of the unit vectors.
This faulty flattenVector is then used in the BoundsHandleInteractable.cs script (line 138) to resize the handles.
Note that the BoundsControl component itself also (correctly) calculates a flattenVector which maybe could be used instead in the BoundsHandleInteractable script.