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

Partial fix for BoundsControl collider issues and inconsistency #9973

Merged
merged 5 commits into from
Jun 16, 2021

Conversation

Zee2
Copy link
Contributor

@Zee2 Zee2 commented Jun 14, 2021

Overview

Currently, BoundsControl has several issues and inconsistencies regarding the handles and activation mechanisms. This PR is the first in a series to address these problems.

This PR adjusts how the colliders on the per-axis handles are constructed and aligned, resolving the collider alignment issues for the rotate and translate handle types only. Currently, scale handles are a different type of Handle entirely, and this PR will not resolve scale handle collider issues. A future PR will address those issues.

BoundsControl constructs a container transform for each handle and an accompanying child transform which holds the "visual" of the handle. This separation allows BoundsControl to independently scale the handle visual without affecting the collider, which improves reliability and collision detection. (Scaling of the handle is necessary for ProximityEffect and the "grow" animation that triggers on proximity.) However, this separation induces an issue where per-axis handle visuals are rotated to fit the object, but the colliders cannot be rotated to match their visual counterparts. (Colliders are axis-aligned Bounds, and therefore cannot be rotated easily).

Originally, these container transforms that held the colliders would not be rotated, but the underlying visual object would be rotated. To solve the issue of not being able to rotate the axis-aligned colliders, this PR revises the handle construction code to instead rotate the container transform, and leave the handle visual un-rotated. By letting the container transform perform the rotation instead of the visual, the collider remains properly aligned with the handle visual.

Old: the handle is rotated separately from the collider, causing misalignment:

New: the transform container performs the rotation, keeping the collider aligned:

Included in this PR is also several amendments to variable naming schemes and inline comments/doccomments. Due to a previous refactor, the PerAxisHandles class was previously exclusively used for rotation handles. This PR removes several instances of comments/variables referring exclusively to rotation affordances.

A TODO is marked to fix a hard-coded cursor icon issue. A future PR in this series will resolve that as well.

This PR partially solves #9946, but requires additional PRs to cover all functionalities affected by this issue (including scale handles!)

Changes

  • Edits variable names and comments in PerAxisHandles to more accurately and consistently reflect the current usage
  • Changes how rotation realignments are applied to handle affordances and their colliders
  • Improves the scaling logic across the handles and VisualUtils so that GetMaxComponent is always used to determine handle size, rather than an arbitrary axis
  • Zeroes out local handle visual rotation on rig rebuild

Verification

Existing BoundsControl tests cover this functionality, but they previously passed due to the margin of error/tolerance in the test case. Tighter test tolerances, in my opinion, are not strictly necessary. The issue this solves is more visible with larger/more strangely shaped colliders, as seen in the linked issue.

@Zee2
Copy link
Contributor Author

Zee2 commented Jun 14, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@CDiaz-MS
Copy link
Contributor

The issue this solves is more visible with larger/more strangely shaped colliders, as seen in the linked issue.

Could we add a test with a strangely shaped collider as an additional scenario to cover?

@Zee2
Copy link
Contributor Author

Zee2 commented Jun 15, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

@keveleigh keveleigh left a comment

Choose a reason for hiding this comment

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

Approved for the bug fix itself, but definitely echoing @CDiaz-MS's request

Could we add a test with a strangely shaped collider as an additional scenario to cover?

@david-c-kline
Copy link

Could we add a test with a strangely shaped collider as an additional scenario to cover?

Do we want this test before we merge?

@Zee2
Copy link
Contributor Author

Zee2 commented Jun 16, 2021

Could we add a test with a strangely shaped collider as an additional scenario to cover?

Do we want this test before we merge?

@davidkline-ms Yes, I'll add the test tomorrow morning. Should be quick.

Copy link

@david-c-kline david-c-kline left a comment

Choose a reason for hiding this comment

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

Approved pending addition of new test

@Zee2
Copy link
Contributor Author

Zee2 commented Jun 16, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Zee2 Zee2 merged commit 8acbb64 into microsoft:main Jun 16, 2021
keveleigh pushed a commit to keveleigh/HoloToolkit-Unity that referenced this pull request Dec 7, 2021
Partial fix for BoundsControl collider issues and inconsistency
keveleigh pushed a commit to keveleigh/HoloToolkit-Unity that referenced this pull request Dec 7, 2021
Partial fix for BoundsControl collider issues and inconsistency
keveleigh pushed a commit to keveleigh/HoloToolkit-Unity that referenced this pull request Dec 7, 2021
Partial fix for BoundsControl collider issues and inconsistency
keveleigh pushed a commit to keveleigh/HoloToolkit-Unity that referenced this pull request Dec 7, 2021
Partial fix for BoundsControl collider issues and inconsistency
keveleigh pushed a commit to keveleigh/HoloToolkit-Unity that referenced this pull request Dec 8, 2021
Partial fix for BoundsControl collider issues and inconsistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug UX Controls - Bounds Control formerly known as BoundingBox
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants