-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Improved contact types #616
Open
Jondolf
wants to merge
9
commits into
main
Choose a base branch
from
improved-contact-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jondolf
added
C-Enhancement
New feature or request
A-Collision
Relates to the broad phase, narrow phase, colliders, or other collision functionality
C-Usability
A quality-of-life improvement that makes Avian easier to use
labels
Jan 5, 2025
Jondolf
commented
Jan 5, 2025
Comment on lines
260
to
262
pub during_current_frame: bool, | ||
/// True if the bodies were in contact during the previous frame. | ||
pub during_previous_frame: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These and is_sensor
should use a ContactPairFlags
bitflag type or similar, but I'll do that in another PR where I rework contact pair management.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Collision
Relates to the broad phase, narrow phase, colliders, or other collision functionality
C-Enhancement
New feature or request
C-Usability
A quality-of-life improvement that makes Avian easier to use
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
A lot of Avian's current contact types store some redundant data, aren't properly optimized, and aren't explicit enough about what they represent.
This PR is a clean-up pass to make the types a bit smaller and clearer.
Solution
Contacts
total_normal_impulse
property withtotal_normal_impulse
,total_normal_impulse_magnitude
, andmax_normal_impulse
helperstotal_normal_force
helpertotal_tangent_impulse
property andtotal_friction_force
helperContactManifold
ContactManifold::contacts
toContactManifold::points
ArrayVec
with a capacity of 2 instead of aVec
to store 2DContactManifold
points directly on the stacknormal1
andnormal2
with a single world-spacenormal
total_normal_impulse
andmax_normal_impulse
helpersContactData
ContactData
toContactPoint
(represents a point in a contact manifold)ManifoldPoint
like in Box2D; not sure which one is betterpoint1
andpoint2
tolocal_point1
andlocal_point2
for explicitnessnormal1
andnormal2
fromContactPoint
, since the normal is already stored in theContactManifold
Other
Migration Guide
There have been several changes to Avian's contact types to make them more optimized and clearer.
Contacts
total_normal_impulse
property has been replaced with atotal_normal_impulse
helper method.total_normal_force
helper has been deprecated. Instead, just divide the impulse by the substep timestep.total_tangent_impulse
property andtotal_friction_force
helper have been removed for being inaccurate/misleading. The tangent impulse magnitudes of each individual point can still be accessed.ContactManifold
ContactManifold::contacts
has been renamed toContactManifold::points
.normal1
andnormal2
have been replaced with a single world-spacenormal
, pointing from the first shape to the second.ContactData
ContactData
has been renamed toContactPoint
, since it specifically represents a point in a contact manifold, not general contact data.point1
andpoint2
have been renamed tolocal_point1
andlocal_point2
for explicitnessnormal1
andnormal2
have been removed, since the normal is already stored in theContactManifold
.