PRs: #610
The BroadPhasePlugin, NarrowPhasePlugin, and many NarrowPhase methods now take generics for CollisionHooks. If you have no collision hooks, you can use ().
PRs: #632
The RenderLayers of cameras and collider entities no longer affect physics picking. Add the new PhysicsPickingFilter component to cameras to control which CollisionLayers and colliders are included in picking.
PRs: #649
ColliderConstructorHierarchy now defaults to one membership (the first layer) and all filters for the CollisionLayers of generated colliders. This is consistent with how the CollisionLayers component already works normally.
Previously, it was still using the old default of all memberships and all filters.
There have been several changes to Avian's contact types to make them more optimized and clear.
Contactshas been renamed toContactPair.- The
total_normal_impulseproperty has been replaced with atotal_normal_impulsehelper method. - The
total_normal_forcehelper has been deprecated. Instead, just divide the impulse by the substep timestep. - The
total_tangent_impulseproperty andtotal_friction_forcehelper have been removed for being inaccurate/misleading. The tangent impulse magnitudes of each individual point can still be accessed.
ContactManifold::contactshas been renamed toContactManifold::points.- The local
normal1andnormal2have been replaced with a single world-spacenormal, pointing from the first shape to the second.
ContactDatahas been renamed toContactPoint, since it specifically represents a point in a contact manifold, not general contact data.point1andpoint2have been renamed tolocal_point1andlocal_point2for explicitness.normal1andnormal2have been removed, since the normal is already stored in theContactManifold.
PRs: #665
AnyColliderimplementors now need to specify aContextassociatedSystemParam. If this is unnecessary,()should be used.- When trying to use methods from
AnyCollideron an implementation with()context,SimpleCollidershould be used instead. - Methods on
AnyColliderhave been suffixed with_with_context.
PRs: #670
Avian now uses Bevy 0.16.
The AncestorMarkerPlugin no longer requires a schedule or system set.
PRs: #671
The ColliderParent component has been renamed to ColliderOf, and it is now a Relationship. The ColliderHierarchyPlugin (included in PhysicsPlugins) must be enabled for colliders to be automatically attached to rigid bodies, but ColliderOf can also be inserted manually otherwise.
The transform management in ColliderHierarchyPlugin has been extracted into a new ColliderTransformPlugin. The ColliderHierarchyPlugin no longer takes a schedule.
PRs: #683
Avian's collision detection pipelines and contact pair management have been massively reworked for better performance and robustness.
The PostProcessCollisions schedule and NarrowPhaseSet::PostProcess system set have been removed, as it is incompatible with new optimizations to narrow phase collision detection. Instead, use CollisionHooks for contact modification.
The ContactReportingPlugin and PhysicsStepSet::ReportContacts system set have been removed. Contact reporting is now handled by the NarrowPhasePlugin directly.
The Collision event no longer exists. Instead, use Collisions directly, or get colliding entities using the CollidingEntities component.
The CollisionStarted and CollisionEnded events are now only sent if either entity in the collision has the CollisionEventsEnabled component. If you'd like to revert to the old behavior of having collision events for all entities, consider making CollisionEventsEnabled a required component for Collider:
app.register_required_components::<Collider, CollisionEventsEnabled>();The Collisions resource is now a SystemParam.
// Old
fn iter_collisions(collisions: Res<Collisions>) {
todo!()
}
// New
fn iter_collisions(collisions: Collisions) {
todo!()
}Internally, Collisions now stores a ContactGraph that stores both touching and non-touching contact pairs. The Collisions system parameter is just a wrapper that provides a simpler API and only returns touching contacts.
The collisions_with_entity method has also been renamed to collisions_with, and all methods that mutatate, add, or remove contact pairs have been removed from Collisions. However, the following mutating methods are available on ContactGraph:
get_mutiter_mutiter_touching_mutcollisions_with_mutadd_pair/add_pair_with_keyinsert_pair/insert_pair_with_keyremove_pairremove_collider_with
For most scenarios, contact modification and removal are intended to be handled with CollisionHooks.
The during_current_frame and during_previous_frame properties of ContactPair have been removed in favor of a flags property storing information in a more compact bitflag format. The is_sensor, is_touching, collision_started, and collision_ended helper methods can be used instead.
Methods such as AnyCollider::contact_manifolds_with_context now take &mut Vec<ContactManifold> instead of returning a new vector every time. This allows manifolds to be persisted more effectively, and reduces unnecessary allocations.
The BroadCollisionPairs resource has been removed. Use the ContactGraph resource instead.
The AabbIntersections component has been removed. Use ContactGraph::entities_colliding_with instead.
PRs: #693
CollisionLayers is now a required component for colliders and is inserted automatically. Collision detection may not work properly without it.
PRs: #698
Some collision detection modules and imports have been reorganized.
The following modules have been moved:
layersfromcollisiontocollision::collidercontact_queryfromcollisiontocollision::collider::parryfeature_idfromcollisiontocollision::contact_types
Previously, a lot of collision detection types were also re-exported directly from the collision module. Now, there is instead a prelude for the collision module.
PRs: #699
NarrowPhaseSet::GenerateConstraints has been removed. Contact constraints are now generated as part of NarrowPhaseSet::Update.
ContactPair: Theentity1andentity2properties are nowcollider1andcollider2, andbody_entity1andbody_entity2are nowbody1andbody2.ContactConstraint: Theentity1andentity2properties are nowbody1andbody2, andcollider_entity1andcollider_entity2are nowcollider1andcollider2.ColliderQuery: Therigid_bodyproperty has been renamed toof(forColliderOf) and there is a newbodyhelper to get the contained entity directly.