-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# 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` - Replace `total_normal_impulse` property with `total_normal_impulse`, `total_normal_impulse_magnitude`, and `max_normal_impulse` helpers - Deprecate `total_normal_force` helper - You can just divide by the substep timestep - Remove `total_tangent_impulse` property and `total_friction_force` helper - These could previously technically be wrong/misleading, since each contact point can have a different tangent direction, especially in 3D, and they can also change between substeps. The tangent impulse magnitudes of each individual point can still be accessed. ### `ContactManifold` - Rename `ContactManifold::contacts` to `ContactManifold::points` - Use an `ArrayVec` with a capacity of 2 instead of a `Vec` to store 2D `ContactManifold` points directly on the stack - Replace the local `normal1` and `normal2` with a single world-space `normal` - Internals only need the world-space normal, and it makes e.g. contact modification more straightforward - Add `total_normal_impulse` and `max_normal_impulse` helpers ### `ContactData` - Rename `ContactData` to `ContactPoint` (represents a point in a contact manifold) - Another option would be `ManifoldPoint` like in Box2D; not sure which one is better - Rename `point1` and `point2` to `local_point1` and `local_point2` for explicitness - Remove `normal1` and `normal2` from `ContactPoint`, since the normal is already stored in the `ContactManifold` ### Other - Many documentation improvements - Contact force debug rendering uses per-point forces instead of the total force for the contact pair --- ## Migration Guide There have been several changes to Avian's contact types to make them more optimized and clearer. ### `Contacts` - The `total_normal_impulse` property has been replaced with a `total_normal_impulse` helper method. - The `total_normal_force` helper has been deprecated. Instead, just divide the impulse by the substep timestep. - The `total_tangent_impulse` property and `total_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 to `ContactManifold::points`. - The local `normal1` and `normal2` have been replaced with a single world-space `normal`, pointing from the first shape to the second. ### `ContactData` - `ContactData` has been renamed to `ContactPoint`, since it specifically represents a point in a contact manifold, not general contact data. - `point1` and `point2` have been renamed to `local_point1` and `local_point2` for explicitness - `normal1` and `normal2` have been removed, since the normal is already stored in the `ContactManifold`.
- Loading branch information
Showing
14 changed files
with
270 additions
and
262 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Oops, something went wrong.