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

CMCL-1634: decollider would sometimes cause camera to slip inside cracks between adjacent colliders #1033

Merged
merged 3 commits into from
Jan 29, 2025

Conversation

glabute
Copy link
Collaborator

@glabute glabute commented Jan 9, 2025

Purpose of this PR

CMCL-1634: decollider would sometimes cause camera to slip inside cracks between adjacent colliders

This is because the collider detection algorithm was inadequate. Algorithm was reworked to be more robust around colliders made up of multiple adjacent colliders. Camera will only go into the crack if the crack is wider than the camera radius specified in the Decollider.

Bonus: smoothing logic was also simplified and corrected, fixing an intermittent bug that caused the camera to sometimes snap out of its smoothed position, bypassing damping. That bug was unreported.

Testing status

  • Added an automated test
  • Passed all automated tests
  • Manually tested

Documentation status

  • Updated CHANGELOG
  • Updated README (if applicable)
  • Commented all public classes, properties, and methods
  • Updated user documentation

Technical risk

low

Comments to reviewers

Please see test scene in the Jira ticket.

@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 50 lines in your changes missing coverage. Please review.

Project coverage is 27.21%. Comparing base (ba4cc2b) to head (c6b10f0).
Report is 78 commits behind head on main.

Files with missing lines Patch % Lines
...achine/Runtime/Behaviours/CinemachineDecollider.cs 0.00% 50 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1033      +/-   ##
==========================================
+ Coverage   26.97%   27.21%   +0.24%     
==========================================
  Files         254      254              
  Lines       28418    28485      +67     
==========================================
+ Hits         7665     7753      +88     
+ Misses      20753    20732      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@sebastienduverne sebastienduverne left a comment

Choose a reason for hiding this comment

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

Minor things in Changelog.

com.unity.cinemachine/CHANGELOG.md Show resolved Hide resolved
com.unity.cinemachine/CHANGELOG.md Outdated Show resolved Hide resolved
style

Co-authored-by: Sébastien Duverne <[email protected]>
const int kColliderBufferSize = 10;
static Collider[] s_ColliderBuffer = new Collider[kColliderBufferSize];
static float[] s_ColliderDistanceBuffer = new float[kColliderBufferSize];
static int[] s_ColliderOrderBuffer = new int[kColliderBufferSize];
Copy link
Contributor

@alexzaranek alexzaranek Jan 20, 2025

Choose a reason for hiding this comment

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

Small nitpick but would it be possible to avoid instantiating this buffer and instead sort the colliders in distance order directly in the s_ColliderBuffer? Using Array.Sort(s_ColliderDistanceBuffer, s_ColliderBuffer) should sort both buffers in the distance order.

Copy link
Contributor

@alexzaranek alexzaranek left a comment

Choose a reason for hiding this comment

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

Other than that small nitpick, I've tested the changes and the camera decollider now works as expected.

@glabute glabute merged commit 64b9293 into main Jan 29, 2025
3 of 69 checks passed
@glabute glabute deleted the dev/decollider-slips-into-cracks branch January 29, 2025 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants