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

Skip processing for non-convex MeshCollider #1657

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

tichise
Copy link

@tichise tichise commented Sep 29, 2024

Summary

This implementation ensures that the Collider.ClosestPoint method is only used with BoxCollider, SphereCollider, CapsuleCollider, and convex MeshCollider. Non-convex MeshColliders are skipped to avoid errors.

Contributor Tasks

  • Create or edit test cases here
  • Add a CHANGELOG entry for this change.
  • Ensure documentation requirements are met e.g., public API is commented.
  • Consider any licensing/other legal implications for this MR e.g. notices required by any new libraries.

Test Cycle

Link to the test cycle here.

Reviewer Tasks

  • Code reviewed.
  • Non-code assets e.g. Unity assets/scenes reviewed.
  • All tests must be ran and cover all scenarios (If not, add new tests to the cycle and run them).
  • Documentation has been reviewed.
  • Approve with a comment of any additional tests run or any observations.

Related JIRA Issues

If this MR closes any JIRA issues list them below in the form Closes PROJECT-#

Pull Request Templates

Switch template by going to preview and clicking the link - note it will not work if you've made any changes to the description.

You are currently using: default.md

Note: these links work by overwriting query parameters of the current url. If the current url contains any you may want to amend the url with &template=name.md instead of using the link. See query parameter docs for more information.

colliderPos = ContactUtils.ClosestPointEstimationFromRectangle(_palmColCenter, _palmColRotation, _palmExtentsReduced.xz(), collider);
bonePos = ContactUtils.ClosestPointToRectangleFace(_palmPoints, _palmPlane.ClosestPointOnPlane(colliderTransformPosition));
midPoint = colliderPos + (bonePos + ((bonePos - colliderPos).normalized * width) - colliderPos) / 2f;
if (collider is BoxCollider || collider is SphereCollider || collider is CapsuleCollider || (collider is MeshCollider meshCollider && meshCollider.convex))
Copy link
Member

Choose a reason for hiding this comment

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

To reduce the number of type checks here, could you invert this logic to just check if (collider is MeshCollider meshCollider && !meshCollider.convex)?

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.

2 participants