版本发布 8
**Avian Physics 0.5** has been released! 🪶 <a href="https://joonaa.dev/blog/11/avian-0-5"> <img width="640" src="https://github.com/user-attachments/assets/473942bd-0844-4bc9-a0c7-9297bd588d40" alt="Avian 0.5 cover image" /> </a> <br> <br> **Avian 0.5** is just an update to [Bevy 0.18](https://bevy.org/news/bevy-0-18/), with no other breaking changes. See Bevy's own release notes for more details. This was the first release under our [new release process](https://joonaa.dev/blog/10/evolving-avian-development), where we publish Bevy version updates separately from feature releases, to unblock users and third party crates that want to migrate to the latest Bevy release early. A separate **Avian 0.6** feature release with new functionality and improvements will be published *when it is ready*. See the **Avian 0.5** [announcement post](https://joonaa.dev/blog/11/avian-0-5) for more details.
**Avian Physics 0.3** has been released! 🪶 <a href="https://joonaa.dev/blog/08/avian-0-3"> <img width="640" src="https://github.com/user-attachments/assets/cc98d8ff-1f5d-40bd-8610-1ceab077020f" alt="Avian 0.3 cover image" /> </a> ## Highlights **Avian 0.3** is another huge release, with several new features, quality-of-life improvements, and important bug fixes. Highlights include: - **Opt-in contact reporting**: Collision events are now only sent for entities that have the `CollisionEventsEnabled` component, reducing unwanted overhead and iteration. - **Observable collision events**: Observers finally support collision events, making it easy to define per-entity collision handlers. - **Collision hooks**: Users can "hook into" the collision pipeline, making it possible to efficiently filter and modify contacts. - **Per-manifold material properties**: Friction, restitution, and tangent velocity can be modified for contact manifolds, allowing the simulation of non-uniform materials and conveyor belts. - **Collider context**: Custom colliders that implement `AnyCollider` have a `Context` for ECS access. - **Physics diagnostics**: Avian has built-in diagnostics and a debug UI for runtime physics profiling. - **Reworked contact pair management**: Contacts have been massively reworked to reduce allocations and unnecessary work while increasing parallelism. - **Faster collisions and spatial queries**: Collisions and spatial queries have much less overhead. - **Bevy 0.16 support**: Avian has been updated to the latest version of Bevy, and is taking advantage of relationships for attaching colliders to rigid bodies. Check out the [announcement blog post](http://joonaa.dev/blog/08/avian-0-3) for a more in-depth overview of what has changed and why. A more complete changelog can also be found after the migration guide below. ## Migration Guide ### Collision Hooks #610 The `BroadPhasePlugin`, `NarrowPhasePlugin`, and many `NarrowPhase` methods now take generics for `CollisionHooks`. If you have no collision hooks, you can use `()`. ### Physics Picking #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. ### Default Layers for `ColliderConstructorHierarchy` #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. ### Improved Contact Types #616 #685 There have been several changes to Avian's contact types to make them more optimized and clear. #### `Contacts` - `Contacts` has been renamed to `ContactPair`. - 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`. ### Add `Context` to `AnyCollider` #665 - `AnyCollider` implementors now need to specify a `Context` associated `SystemParam`. If this is unnecessary, `()` should be used. - When trying to use methods from `AnyCollider` on an implementation with `()` context, `SimpleCollider` should be used instead. - Methods on `AnyCollider` have been suffixed with `_with_context`. ### Bevy 0.16 Support #670 Avian now uses Bevy 0.16. The `AncestorMarkerPlugin` no longer requires a schedule or system set. ### Change `ColliderParent` to `ColliderOf` relationship #671 The `ColliderParent` component has been renamed to `ColliderOf`, and it is now a `Relationship`. The transform management in `ColliderHierarchyPlugin` has been extracted into a new `ColliderTransformPlugin`. The `ColliderHierarchyPlugin` no longer takes a schedule. ### Reworked Contact Pair Management #683 Avian's collision detection pipelines and contact pair management have been massively reworked for better performance and robustness. #### `PostProcessCollisions` 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. #### Contact Reporting 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`: ```rust app.register_required_components::<Collider, CollisionEventsEnabled>(); ``` #### `Collisions` The `Collisions` resource is now a `SystemParam`. ```rust // 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_mut` - `iter_mut` - `iter_touching_mut` - `collisions_with_mut` - `add_pair`/`add_pair_with_key` - `insert_pair`/`insert_pair_with_key` - `remove_pair` - `remove_collider_with` For most scenarios, contact modification and removal are intended to be handled with `CollisionHooks`. #### `ContactPair` (previously `Contacts`) 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. #### `ContactManifold` 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. #### `BroadCollisionPairs` The `BroadCollisionPairs` resource has been removed. Use the `ContactGraph` resource instead. #### `AabbIntersections` The `AabbIntersections` component has been removed. Use `ContactGraph::entities_colliding_with` instead. ### Change `CollisionLayers` to a Required Component #693 `CollisionLayers` is now a required component for colliders and is inserted automatically. Collision detection may not work properly without it. ### Reorganize Collision Detection Modules and Re-Exports #698 Some collision detection modules and imports have been reorganized. The following modules have been moved: - `layers` from `collision` to `collision::collider` - `contact_query` from `collision` to `collision::collider::parry` - `feature_id` from `collision` to `collision::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. ### Contact Constraint Generation System Ordering #699 `NarrowPhaseSet::GenerateConstraints` has been removed. Contact constraints are now generated as part of `NarrowPhaseSet::Update`. ### Rename Entity Properties #718 #719 - `ContactPair`: The `entity1` and `entity2` properties are now `collider1` and `collider2`, and `body_entity1` and `body_entity2` are now `body1` and `body2`. - `ContactConstraint`: The `entity1` and `entity2` properties are now `body1` and `body2`, and `collider_entity1` and `collider_entity2` are now `collider1` and `collider2`. - `ColliderQuery`: The `rigid_body` property has been renamed to `of` (for `ColliderOf`) and there is a new `body` helper to get the contained entity directly. --- ## What's Changed - Collision Hooks @Jondolf in <https://github.com/Jondolf/avian/pull/610> - Fix collisions not being cleared for immediately despawned entities by @Jondolf in <https://github.com/Jondolf/avian/pull/642> - Introduce `PhysicsPickingFilter` by @morgenthum in <https://github.com/Jondolf/avian/pull/632> - Remove unnecessary `cfg_attr` from `from_shape` mass helpers by @Jondolf in <https://github.com/Jondolf/avian/pull/644> - Fix the default layers used by `ColliderConstructorHierarchy` by @Jondolf in <https://github.com/Jondolf/avian/pull/649> - Physics Diagnostics by @Jondolf in <https://github.com/Jondolf/avian/pull/653> - Improved contact types by @Jondolf in <https://github.com/Jondolf/avian/pull/616> - Per-manifold material properties and tangent velocity by @Jondolf in <https://github.com/Jondolf/avian/pull/660> - Add Context to AnyCollider by @NiseVoid in <https://github.com/Jondolf/avian/pull/665> - Refactor to minimise `std` usage by @bushrat011899 in <https://github.com/Jondolf/avian/pull/668> - Remove unsafe `ColliderAabb` initialization by @Jondolf in <https://github.com/Jondolf/avian/pull/669> - Update to Bevy 0.16.0-rc.1 by @Jondolf in <https://github.com/Jondolf/avian/pull/670> - Change `ColliderParent` to a `ColliderOf` relationship and rework `ColliderHierarchyPlugin` by @Jondolf in <https://github.com/Jondolf/avian/pull/671> - Fix panic caused by despawning entity with `ColliderOf` by @Jondolf in <https://github.com/Jondolf/avian/pull/677> - Update to Bevy 0.16.0-rc.2 by @Jondolf in <https://github.com/Jondolf/avian/pull/680> - Make CI faster by caching Rust build outputs by @kristoff3r in <https://github.com/Jondolf/avian/pull/681> - Fix `ColliderOf` updates when a rigid body is added in the hierarchy by @Jondolf in <https://github.com/Jondolf/avian/pull/682> - Rework Contact Pair Management by @Jondolf in <https://github.com/Jondolf/avian/pull/683> - Rename `Contacts` to `ContactPair` by @Jondolf in <https://github.com/Jondolf/avian/pull/685> - Create thread-local contact status bit vecs with correct block count by @Jondolf in <https://github.com/Jondolf/avian/pull/686> - Fix removing colliders from contact graph `EntityDataIndex` by @Jondolf in <https://github.com/Jondolf/avian/pull/688> - Register some types by @janhohenheim in <https://github.com/Jondolf/avian/pull/691> - Refactor ChildOf from named to tuple struct by @austincummings in <https://github.com/Jondolf/avian/pull/692> - Fix contact pair removal bugs by @Jondolf in <https://github.com/Jondolf/avian/pull/693> - Handle entity disabling properly by @Jondolf in <https://github.com/Jondolf/avian/pull/694> - Use sparse entity-to-node mapping for `ContactGraph` by @Jondolf in <https://github.com/Jondolf/avian/pull/689> - Reduce `SpatialQueryPipeline` overhead by @Jondolf in <https://github.com/Jondolf/avian/pull/696> - Clean up collision detection module structure and re-exports by @Jondolf in <https://github.com/Jondolf/avian/pull/698> - Updated to Bevy 0.16.0-rc.5 by @lufog in <https://github.com/Jondolf/avian/pull/701> - Optimize contact constraint generation by @Jondolf in <https://github.com/Jondolf/avian/pull/699> - Add observable `OnCollisionStart` and `OnCollisionEnd` events by @Jondolf in <https://github.com/Jondolf/avian/pull/704> - Update to Bevy 0.16.0 by @Jondolf in <https://github.com/Jondolf/avian/pull/711> - Sort contact constraints for determinism when `parallel` feature is enabled by @Jondolf in <https://github.com/Jondolf/avian/pull/712> - Use try_remove to avoid errors on AncestorMarker removal by @ramirezmike in <https://github.com/Jondolf/avian/pull/714> - Fix `ColliderOf` not being inserted when `Collider` is added to child by @Jondolf in <https://github.com/Jondolf/avian/pull/716> - Include rigid body entity in `OnCollisionStart` and `OnCollisionEnd` by @Jondolf in <https://github.com/Jondolf/avian/pull/717> - Rename most `rigid_body` names to `body` by @Jondolf in <https://github.com/Jondolf/avian/pull/718> - Rename entity properties in `ContactPair` and `ContactConstraint` by @Jondolf in <https://github.com/Jondolf/avian/pull/719> - Fix wrong shape order in `shape_intersections_callback` by @Jondolf in <https://github.com/Jondolf/avian/pull/722> - Fix doc comment for `Rotation::from_sin_cos` by @Jondolf in <https://github.com/Jondolf/avian/pull/723> - Add Ease implementations on Position/Rotation by @cBournhonesque in <https://github.com/Jondolf/avian/pull/724> - Replaced Avian transform syncs with 0.16 Bevy versions by @ramirezmike in <https://github.com/Jondolf/avian/pull/725> ## New Contributors - @morgenthum made their first contribution in <https://github.com/Jondolf/avian/pull/632> - @bushrat011899 made their first contribution in <https://github.com/Jondolf/avian/pull/668> - @kristoff3r made their first contribution in <https://github.com/Jondolf/avian/pull/681> - @austincummings made their first contribution in <https://github.com/Jondolf/avian/pull/692> - @lufog made their first contribution in <https://github.com/Jondolf/avian/pull/701> **Full Changelog**: <https://github.com/Jondolf/avian/compare/v0.2.1...v0.3.0>
## What's Changed * Prevent panic when despawning entities with NoAuto components by @ramirezmike in https://github.com/Jondolf/avian/pull/608 * Fix effective inverse mass computation for 3D friction by @Jondolf in https://github.com/Jondolf/avian/pull/609 * Fix outdated mentions of the default schedule by @Jondolf in https://github.com/Jondolf/avian/pull/611 * PhysicsLayer import crate based on which crate (2d or 3d) is being used by @ironpeak in https://github.com/Jondolf/avian/pull/601 * Fix test after 0.15.1 breakage by @Jondolf in https://github.com/Jondolf/avian/pull/621 * Fix physics being run with zero delta time by @Jondolf in https://github.com/Jondolf/avian/pull/622 * Fix `From<Rotation>` implementation for `Rot2` by @Jondolf in https://github.com/Jondolf/avian/pull/623 * Fix `SleepingPlugin` not being optional and add `WakeUpBody` command by @Jondolf in https://github.com/Jondolf/avian/pull/624 * Fix use of unmaintaned crate proc-macro-error by @PhantomMorrigan in https://github.com/Jondolf/avian/pull/627 * Release `avian_derive` 0.2.2 by @Jondolf in https://github.com/Jondolf/avian/pull/628 * Simplify `transform_to_position` and fix rotation denormalization by @Jondolf in https://github.com/Jondolf/avian/pull/620 * clarify that collider-aabb is in world space by @cBournhonesque in https://github.com/Jondolf/avian/pull/636 * Fix SpatialPipeline with_predicate docs by @cBournhonesque in https://github.com/Jondolf/avian/pull/638 * Make avian3d::dynamics::rigid_body::forces public by @SetOfAllSets in https://github.com/Jondolf/avian/pull/630 * Improve docs for velocity components by @Jondolf in https://github.com/Jondolf/avian/pull/641 ## New Contributors * @ramirezmike made their first contribution in https://github.com/Jondolf/avian/pull/608 * @ironpeak made their first contribution in https://github.com/Jondolf/avian/pull/601 * @PhantomMorrigan made their first contribution in https://github.com/Jondolf/avian/pull/627 * @SetOfAllSets made their first contribution in https://github.com/Jondolf/avian/pull/630 **Full Changelog**: https://github.com/Jondolf/avian/compare/v0.2.0...v0.2.1
**Avian Physics 0.2** has been released! 🪶 <a href="https://joonaa.dev/blog/07/avian-0-2"> <img width="640" src="https://github.com/user-attachments/assets/156cb263-0880-4698-8d91-82cbe081160c" alt="Avian 0.2 cover image" /> </a> ## Highlights **Avian 0.2** is another massive release, with several new features, quality-of-life improvements, and important bug fixes. Highlights include: - **Reworked scheduling**: Avian now runs in Bevy's `FixedPostUpdate` instead of having its own fixed timestep in `PostUpdate`, simplifying scheduling and fixing several common footguns. - **Transform interpolation**: Movement at fixed timesteps can be visually smoothed with built-in transform interpolation or extrapolation. - **Mass property rework**: Mass properties have been overhauled from the ground up to be much more intuitive, flexible, and configurable. - **Physics picking**: Colliders have a picking backend for [`bevy_picking`](https://docs.rs/bevy_picking/0.15.0/bevy_picking/). - **Disabling physics entities**: Rigid bodies, colliders, and joints can be temporarily disabled with marker components. - **Better defaults**: Collision layers, friction, and restitution now have more sensible and configurable defaults. - **Improved 3D friction**: Friction behavior in 3D is much more stable and realistic than before. - **Limit maximum speeds**: The maximum speed of rigid bodies can be easily clamped for stability and gameplay purposes. - **[Bevy 0.15](https://bevyengine.org/news/bevy-0-15/) support**: Avian supports the latest version of Bevy. Check out the [announcement blog post](http://joonaa.dev/blog/07/avian-0-2) for a more in-depth overview of what has changed and why. A more complete changelog can also be found after the migration guide below. ## Migration Guide ### Take `SpatialQueryFilter` by reference in spatial queries #402 Spatial queries performed through `SpatialQuery` now take `SpatialQueryFilter` by reference. ### Use hooks for component initialization #483 `PrepareSet::PreInit` has been renamed to `PrepareSet::First`, and `PrepareSet::InitRigidBodies`, `PrepareSet::InitColliders`, and `PrepareSet::InitMassProperties` have been removed. Most missing components are now initialized by component lifecycle hooks. `CcdPlugin` and `SpatialQueryPipeline` no longer store a schedule and are now unit structs. Instead of `SpatialQueryPlugin::new(my_schedule)` or `SpatialQueryPlugin::default()`, just use `SpatialQueryPlugin`. ### Use `FixedPostUpdate` by default and simplify scheduling #457 Previously, physics was run in `PostUpdate` with a custom fixed timestep by default. The primary purpose of the fixed timestep is to make behavior consistent and frame rate independent. This custom scheduling logic has been removed, and physics now runs in Bevy's `FixedPostUpdate` by default. This further unifies physics with Bevy's own APIs and simplifies scheduling. However, it also means that physics now runs before `Update`, unlike before. For most users, no changes should be necessary, and systems that were running in `Update` can remain there. If you want to run systems at the same fixed timestep as physics, consider using `FixedUpdate`. The `Time<Physics>` clock now automatically follows the clock used by the schedule that physics is run in. In `FixedPostUpdate` and other schedules with a fixed timestep, `Time<Fixed>` is used, but if physics is instead configured to run in a schedule with a variable timestep, like `PostUpdate`, it will use `Time<Virtual>`. Previously, the physics timestep could be configured like this: ```rust app.insert_resource(Time::new_with(Physics::fixed_hz(60.0))); ``` Now, if you are running physics in `FixedPostUpdate`, you should simply configure `Time<Fixed>` directly: ```rust app.insert_resource(Time::<Fixed>::from_hz(60.0))); ``` The following types and methods have also been removed as a part of this rework: - `TimestepMode` - `Physics::from_timestep` - `Physics::fixed_hz` - `Physics::fixed_once_hz` - `Physics::variable` - `Time::<Physics>::from_timestep` - `Time::<Physics>::timestep_mode` - `Time::<Physics>::timestep_mode_mut` - `Time::<Physics>::set_timestep_mode` Previously, camera following logic had to be scheduled relative to both physics *and* transform propagation: ```rust // Run after physics, before transform propagation. app.add_systems( PostUpdate, camera_follow_player .after(PhysicsSet::Sync) .before(TransformSystem::TransformPropagate), ); ``` Since physics is now run in `FixedPostUpdate`, which is before `Update`, it is enough to order the system against just transform propagation: ```rust // Note: camera following could technically be in `Update` too now. app.add_systems( PostUpdate, camera_follow_player.before(TransformSystem::TransformPropagate), ); ``` ### Use a single layer as the default membership instead of all #476 #494 Previously, `CollisionLayers` defaulted to "all memberships, all filters", meaning that everything belonged to every layer and could interact with every layer. This turned out to be very limiting in practice, as it made it impossible to target things like ray casts to specific layers, unless the memberships of all colliders were set explicitly. Now, colliders only belong to the first layer by default. This means that the first bit `0b0001` in the layer mask is reserved for the default layer. This also applies to enum-based layers using the `PhysicsLayer` derive macro. To make the default layer explicit, physics layer enums must now implement `Default`, and specify which variant represents the default layer `0b0001`. ```rust #[derive(PhysicsLayer, Default)] enum GameLayer { #[default] Default, // The name doesn't matter, but Default is used here for clarity Player, Enemy, Ground, } ``` ### Rework mass properties #500 #532 #574 #### Inverse Mass Components - `InverseMass` and `InverseInertia` have been removed, and `Inertia` has been renamed to `AngularInertia`. - `RigidBodyQueryItem` methods `effective_inv_mass` and `effective_world_inv_inertia` have been renamed to `effective_inverse_mass` and `effective_global_inverse_inertia`. #### `MassPropertyPlugin` The `MassPropertyPlugin` is now needed to update mass properties automatically based on attached colliders. Most apps won't need to add it manually, as it is included in the `PhysicsPlugins` plugin group by default. #### Behavior Changes - `Mass`, `AngularInertia`, and `CenterOfMass` are now optional, and can be used to override the mass properties of an entity if present, ignoring the entity's collider. Mass properties that are not set are still computed from the entity's `Collider` and `ColliderDensity`. - Mass properties of child entities still contribute to the total mass properties of rigid bodies by default, but the total values are stored in `ComputedMass`, `ComputedAngularInertia`, and `ComputedCenterOfMass` instead of `Mass`, `AngularInertia`, and `CenterOfMass`. The latter components are now never modified by Avian directly. - To prevent colliders or descendants from contributing to the total mass properties, add the `NoAutoMass`, `NoAutoAngularInertia`, and `NoAutoCenterOfMass` marker components to the rigid body, giving you full manual control. - Previously, changing `Mass` at runtime did not affect angular inertia. Now, it is scaled accordingly, unless `NoAutoAngularInertia` is present. - Previously, specifying the `CenterOfMass` at spawn did nothing *unless* an initial `Mass` was specified, even if the entity had a collider that would give it mass. This has been fixed. - Previously, `Mass`, `AngularInertia`, and `CenterOfMass` did *nothing* on child colliders. Now, they effectively override `ColliderMassProperties` when computing the total mass properties for the rigid body. - Previously, zero mass and angular inertia were treated as invalid. It emitted warnings, which was especially problematic and spammy for runtime collider constructors. Now, they are treated as acceptable values, and interpreted as infinite mass, like in most other engines. #### API Changes - `Mass`, `AngularInertia`, `CenterOfMass`, `ColliderDensity`, and `ColliderMassProperties` now always use `f32` types, even with the `f64` feature. Total mass properties stored in `ComputedMass`, `ComputedAngularInertia`, and `ComputedCenterOfMass` still support `f64`. - In 3D, `AngularInertia` now stores a principal angular inertia (`Vec3`) and the orientation of the local inertial frame (`Quat`) instead of an inertia tensor (`Mat3`). However, several different constructors are provided, including `from_tensor`. - `MassPropertiesBundle::new_computed` and `ColliderMassProperties::from_collider` have been renamed to `from_shape`. - `ColliderMassProperties` now stores a `MassProperties2d`/`MassProperties3d` instead of separate properties. - Types implementing `AnyCollider` must now also implement the `ComputeMassProperties2d`/`ComputeMassProperties3d` trait instead of the `mass_properties` method. ### Collider Constructors #540 `Collider::regular_polygon` and `ColliderConstructor::RegularPolygon` now use a `u32` instead of `usize` for `sides`. ### Use required components for component initialization #541 The `CollidingEntities` component is no longer added automatically. To read entities that are colliding with a given entity, you must now add the `CollidingEntities` component for it manually. To revert to the old behavior, you can also make `CollidingEntities` a required component for colliders: ```rust app.register_required_components::<Collider, CollidingEntities>(); ``` ### Improvements to friction and restitution #551 `Friction` and `Restitution` are no longer inserted automatically for rigid bodies. Instead, there are now `DefaultFriction` and `DefaultRestitution` resources, which are used for bodies with no `Friction` or `Restitution` specified. These resources can be configured to change the global defaults for friction and restitution. The default restitution is now `0.0`, meaning that bodies are no longer bouncy by default. The default coefficients of friction have also been increased from `0.3` to `0.5`. ### Add `SolverSchedulePlugin` to encapsulate solver scheduling #577 System set configuration and scheduling related to the solver and substepping loop are now primarily in the new `SolverSchedulePlugin`. It is included in the `PhysicsPlugins` plugin group, so for most applications, this should not be a breaking change. ### Improve `SpatialQuery` APIs and docs, and add more configuration #510 #### Shape Casting Configuration `SpatialQuery` methods like `cast_shape` and `shape_hits` now take a `ShapeCastConfig`, which contains a lot of the existing configuration options, along with a few new options. ```rust // Before let hits = spatial.shape_hits( &Collider::sphere(0.5), Vec3::ZERO, Quat::default(), Dir3::ZERO, 100.0, 10, false, &SpatialQueryFilter::from_mask(LayerMask::ALL), ); // After let hits = spatial.shape_hits( &Collider::sphere(0.5), Vec3::ZERO, Quat::default(), Dir3::ZERO, 10, &ShapeCastConfig::from_max_distance(100.0), &SpatialQueryFilter::from_mask(LayerMask::ALL), ); ``` #### Time of Impact → Distance Spatial query APIs that mention the "time of impact" have been changed to refer to "distance". This affects names of properties and methods, such as: - `RayCaster::max_time_of_impact` → `RayCaster::max_distance` - `RayCaster::with_max_time_of_impact` → `RayCaster::with_max_distance` - `ShapeCaster::max_time_of_impact` → `ShapeCaster::max_distance` - `ShapeCaster::with_max_time_of_impact` → `ShapeCaster::with_max_distance` - `RayHitData::time_of_impact` → `RayHitData::distance` - `ShapeHitData::time_of_impact` → `ShapeHitData::distance` - `max_time_of_impact` on `SpatialQuery` methods → `RayCastConfig::max_distance` or `ShapeCastConfig::max_distance` This was changed because "distance" is clearer than "time of impact" for many users, and it is still an accurate term, as the cast directions in Avian are always normalized, so the "velocity" is of unit length. --- ## What's Changed * Take `SpatialQueryFilter` by reference in spatial queries by @Jondolf in https://github.com/Jondolf/avian/pull/402 * Use hooks for component initialization by @Jondolf in https://github.com/Jondolf/avian/pull/483 * Use `FixedPostUpdate` by default and simplify scheduling by @Jondolf in https://github.com/Jondolf/avian/pull/457 * Fix locked axes in gyro torque by @unpairedbracket in https://github.com/Jondolf/avian/pull/486 * Add predicate variants to all casts by @janhohenheim in https://github.com/Jondolf/avian/pull/493 * Only warn about 'overlapping at spawn' for dynamic bodies by @RJ in https://github.com/Jondolf/avian/pull/491 * Use a single layer as the default membership instead of all. by @Aceeri in https://github.com/Jondolf/avian/pull/476 * Make `PhysicsLayer` require a `#[default]` variant by @Jondolf in https://github.com/Jondolf/avian/pull/494 * Fix real part of quaternion derivatives by @unpairedbracket in https://github.com/Jondolf/avian/pull/488 * Fix default schedule in `IntegratorPlugin::new` docs by @Jondolf in https://github.com/Jondolf/avian/pull/495 * Make contacts deterministic across Worlds by @cBournhonesque in https://github.com/Jondolf/avian/pull/480 * Fix missing feature flag by @janhohenheim in https://github.com/Jondolf/avian/pull/502 * add some #[must_use] to LockedAxes builder fns by @RJ in https://github.com/Jondolf/avian/pull/506 * Optimize `wake_on_collision_ended` when large number of collisions are occurring by @datael in https://github.com/Jondolf/avian/pull/508 * experimentation with debugdump by @Vrixyz in https://github.com/Jondolf/avian/pull/383 * Fix 3D rotation update in `transform_to_position` by @Jondolf in https://github.com/Jondolf/avian/pull/520 * Make disabling joints possible. by @shanecelis in https://github.com/Jondolf/avian/pull/519 * Allow interpolation of scales by @janhohenheim in https://github.com/Jondolf/avian/pull/512 * Add convenience methods for determining if collisions are starting or stopping by @ndarilek in https://github.com/Jondolf/avian/pull/529 * Rework `Mass` and `Inertia` and add `GlobalAngularInertia` in 3D by @Jondolf in https://github.com/Jondolf/avian/pull/500 * Add `MassPropertyPlugin` by @Jondolf in https://github.com/Jondolf/avian/pull/532 * Update to Bevy 0.15 release candidate by @Jondolf in https://github.com/Jondolf/avian/pull/540 * Use required components for component initialization by @Jondolf in https://github.com/Jondolf/avian/pull/541 * Fix 3D friction by @Jondolf in https://github.com/Jondolf/avian/pull/542 * Use entity Display in messages instead of Debug by @NiseVoid in https://github.com/Jondolf/avian/pull/545 * Fix spatial query doc tests by @NiseVoid in https://github.com/Jondolf/avian/pull/546 * Fix overlap warnings: yeet edition by @NiseVoid in https://github.com/Jondolf/avian/pull/547 * Added missing deref and derefMut trait to AngularVelocity in 2D by @Lommix in https://github.com/Jondolf/avian/pull/544 * Improvements to friction and restitution by @Jondolf in https://github.com/Jondolf/avian/pull/551 * Add physics picking backend using `bevy_picking` by @Jondolf in https://github.com/Jondolf/avian/pull/554 * Replace snapshots with hash-based cross-platform determinism test by @Jondolf in https://github.com/Jondolf/avian/pull/555 * Add `find_deepest_contact` for `Contacts` and `ContactManifold` by @Jondolf in https://github.com/Jondolf/avian/pull/556 * Add helpers for `ContactData` and `SingleContact` to flip contact data by @Jondolf in https://github.com/Jondolf/avian/pull/557 * Fix plugin table by @Jondolf in https://github.com/Jondolf/avian/pull/565 * Fix new Rust 1.83.0 lints by @Jondolf in https://github.com/Jondolf/avian/pull/569 * Migrate from Bevy 0.15 RC to full 0.15 by @Jondolf in https://github.com/Jondolf/avian/pull/570 * Fix rotation multiplication order in `transform_to_position` by @Jondolf in https://github.com/Jondolf/avian/pull/575 * Make sure `Collider::triangle` is oriented CCW by @Jondolf in https://github.com/Jondolf/avian/pull/579 * Add `MaxLinearSpeed` and `MaxAngularSpeed` by @Jondolf in https://github.com/Jondolf/avian/pull/580 * Improve docs and heading consistency by @Jondolf in https://github.com/Jondolf/avian/pull/581 * Mass Property Rework by @Jondolf in https://github.com/Jondolf/avian/pull/574 * Add `SolverSchedulePlugin` to encapsulate solver scheduling by @Jondolf in https://github.com/Jondolf/avian/pull/577 * Physics Interpolation and Extrapolation by @Jondolf in https://github.com/Jondolf/avian/pull/566 * Add `RigidBodyDisabled` by @Jondolf in https://github.com/Jondolf/avian/pull/536 * Add `cargo doc` to CI and fix doc links by @Jondolf in https://github.com/Jondolf/avian/pull/582 * Improve `SpatialQuery` APIs and docs, and add more configuration by @Jondolf in https://github.com/Jondolf/avian/pull/510 * revert schedule change for debug render. fixes #496 by @Hellzbellz123 in https://github.com/Jondolf/avian/pull/497 * fix documentation for apply_force_at_point (local vs world space) by @johannesvollmer in https://github.com/Jondolf/avian/pull/430 * Add `ColliderDisabled` by @Jondolf in https://github.com/Jondolf/avian/pull/584 * Tweak disabling docs by @Jondolf in https://github.com/Jondolf/avian/pull/585 * Renormalize rotation in 2D integration and clean up `renormalize` by @Jondolf in https://github.com/Jondolf/avian/pull/590 * Fix missing `bevy_render/serialize` dependency. by @spectria-limina in https://github.com/Jondolf/avian/pull/592 * Expose `EllipseColliderShape` and `RegularPolygonColliderShape` by @Jondolf in https://github.com/Jondolf/avian/pull/596 * Documentation improvements by @Jondolf in https://github.com/Jondolf/avian/pull/598 * Release 0.2.0 by @Jondolf in https://github.com/Jondolf/avian/pull/599 ## New Contributors * @unpairedbracket made their first contribution in https://github.com/Jondolf/avian/pull/486 * @cBournhonesque made their first contribution in https://github.com/Jondolf/avian/pull/480 * @Vrixyz made their first contribution in https://github.com/Jondolf/avian/pull/383 * @ndarilek made their first contribution in https://github.com/Jondolf/avian/pull/529 * @Lommix made their first contribution in https://github.com/Jondolf/avian/pull/544 * @Hellzbellz123 made their first contribution in https://github.com/Jondolf/avian/pull/497 * @johannesvollmer made their first contribution in https://github.com/Jondolf/avian/pull/430 * @spectria-limina made their first contribution in https://github.com/Jondolf/avian/pull/592 **Full Changelog**: https://github.com/Jondolf/avian/compare/v0.1.2...v0.2.0
A full diff of what has been fixed can be seen here: [`v0.1.1...v0.1.2`](https://github.com/Jondolf/avian/compare/v0.1.1...v0.1.2)
A full diff of what has been fixed can be seen here: [`v0.1.0...v0.1.1`](https://github.com/bevyengine/bevy/compare/v0.1.0...v0.1.1)
**Avian Physics 0.1** has been released! 🪶  **Avian** is an ECS-driven physics engine for the Bevy game engine. It is the next evolution of Bevy XPBD, with a completely rewritten contact solver, improved performance, a reworked structure, and numerous other improvements and additions over its predecessor. See [#346](https://github.com/Jondolf/bevy_xpbd/issues/346) for background on the rebrand. ## Highlights **Avian 0.1** has a *ton* of improvements, additions, and fixes over Bevy XPBD 0.4. Some highlights: - **A solver rewrite**: Avian uses an impulse-based TGS Soft solver instead of XPBD for contacts. - **A reworked narrow phase**: Collision detection is much more performant and reliable. - **Continuous Collision Detection (CCD)**: Speculative collision and sweep-based CCD are implemented to prevent tunneling. - **Optional collision margins**: Extra thickness can be added for thin colliders such as trimeshes to improve stability and performance. - **Improved performance**: Overhead for large scenes is significantly smaller, and collision-heavy scenes can have over a 4-6x performance improvement in comparison to Bevy XPBD. - **Improved runtime collider constructors**: It is easier to define colliders and collider hierarchies statically to enable more powerful scene workflows. - **Structural improvements and polish**: The module structure has been heavily reworked, and tons of inconsistencies and bugs have been resolved. - **[Bevy 0.14](https://bevyengine.org/news/bevy-0-14/) support**: Avian supports the latest version of Bevy, and internally, it already takes advantage of new features such as observers and component lifecycle hooks. Check out the [announcement blog post](http://joonaa.dev/blog/06/avian-0-1) for a more in-depth overview of what has changed and why. A more complete changelog can also be found after the migration guide below. ## Migration Guide **Note**: This guide is for migration from Bevy XPBD 0.4 to Avian 0.1. The entries for [migration to Bevy XPBD 0.5](https://github.com/Jondolf/avian/releases/tag/xpbd-v0.5.0) (an easier migration path) still apply and are also listed here. ### New Contact Solver [#385](https://github.com/Jondolf/bevy_xpbd/issues/385) The contact solver has been rewritten. In practice, this has the following effects: - Collisions should be much more stable. - Resolving overlap is no longer nearly as explosive. - Less substeps are generally needed for stability. - Tunneling is much more rare. - Performance is better. However: - Contacts may even be *too* soft by default for some applications. This can be tuned with the `SolverConfig` resource. - Static friction is currently not considered separately from dynamic friction. This may be fixed in the future. - Restitution might not be quite as perfect in some instances (this is a tradeoff for speculative collision to avoid tunneling). - 2D applications may need to configure the `PhysicsLengthUnit` to get the best stability and behavior. The `PhysicsLengthUnit` can be thought of a pixels-per-meter scaling factor for the engine's internal length-based tolerances and thresholds, such as the maximum speed at which overlap is resolved, or the speed threshold for allowing bodies to sleep. It does *not* scale common user-facing inputs or outputs like colliders or velocities. To configure the `PhysicsLengthUnit`, you can insert it as a resource, or simply set it while adding `PhysicsPlugins`: ```rust fn main() { App::new() .add_plugins(( DefaultPlugins, // A 2D game with 20 pixels per meter PhysicsPlugins::default().with_length_unit(20.0), )) .run(); } ``` ### `Collider` Constructor Argument Order [#394](https://github.com/Jondolf/bevy_xpbd/issues/394) To match Bevy's `Cylinder`, `Capsule`, and `Cone`, the order of arguments has changed for some `Collider` constructors. - Use `Collider::cylinder(radius, height)` instead of `Collider::cylinder(height, radius)`. - Use `Collider::capsule(radius, height)` instead of `Collider::capsule(height, radius)`. - Use `Collider::capsule_endpoints(radius, a, b)` instead of `Collider::capsule_endpoints(a, b, radius)`. - Use `Collider::cone(radius, height)` instead of `Collider::cone(height, radius)`. This is a very heavily breaking change, but I believe it is important that we align ourselves with Bevy here, and it's better to do it sooner rather than later. ### `AsyncCollider` and `AsyncSceneCollider` [#378](https://github.com/Jondolf/bevy_xpbd/issues/378) `AsyncCollider`, `AsyncSceneCollider`, and `ComputedCollider` have been replaced by more powerful `ColliderConstructor` and `ColliderConstructorHierarchy` types. They work similarly, but also support primitive shapes and arbitrary hierarchies, not just colliders computed for meshes and scenes. Additionally, some naming changes have been made to improve consistency, such as renaming `TriMesh` to `Trimesh` to be consistent with `Collider::trimesh`. - Remove feature `async-collider`. If you need to use computed shapes, use the feature `collider-from-mesh`. If you depend on `ColliderConstructorHierarchy` waiting for a scene to load, use the feature `bevy_scene` - Remove `AsyncCollider` and use `ColliderConstructor` directly - Rename `AsyncSceneCollider` to `ColliderConstructorHierarchy` - Rename `AsyncSceneCollider::default_shape` to `ColliderConstructorHierarchy::default_constructor` - Rename `AsyncSceneCollider::meshes_by_name` to `ColliderConstructorHierarchy::config` - Rename `AsyncSceneCollider::with_shape_for_name` to `ColliderConstructorHierarchy::with_constructor_for_name` - Rename `AsyncSceneCollider::without_shape_for_name` to `ColliderConstructorHierarchy::without_constructor_for_name` - Rename `AsyncSceneColliderData` to `ColliderConstructorHierarchyConfig` - Rename `AsyncSceneColliderData::shape` to `ColliderConstructorHierarchyConfig::constructor` - Rename `ComputedCollider` to `ColliderConstructor`. - Rename `ComputedCollider::TriMesh` to `ColliderConstructor::TrimeshFromMesh` - Rename `ComputedCollider::TriMeshWithFlags` to `ColliderConstructor::TrimeshFromMeshWithConfig` - Rename `ComputedCollider::ConvexHull` to `ColliderConstructor::ConvexHullFromMesh` - Rename `ComputedCollider::ConvexDecomposition` to `ColliderConstructor::ConvexDecompositionFromMeshWithConfig` - Rename `VHACDParameters` to `VhacdParameters` - Rename `Collider::halfspace` to `Collider::half_space` ### Reworked Module Structure [#370](https://github.com/Jondolf/bevy_xpbd/issues/370) - The internal module structure has changed significantly, and types have moved around. Most imports from the `prelude` should work like before, but explicit import paths may be broken. - The `PhysicsSetupPlugin` has been split into `PhysicsSchedulePlugin` and `PhysicsTypeRegistrationPlugin`. ### Sensor Mass Properties [#381](https://github.com/Jondolf/bevy_xpbd/issues/381) Colliders with the `Sensor` component no longer contribute to the mass properties of rigid bodies. You can add mass for them by adding another collider that is *not* a sensor, or by manually adding mass properties with the `MassPropertiesBundle` or its components. Additionally, the mass properties of `Sensor` colliders are no longer updated automatically, unless the `Sensor` component is removed. ### Joints and Custom Constraints [#390](https://github.com/Jondolf/bevy_xpbd/issues3904) and [#385](https://github.com/Jondolf/bevy_xpbd/issues/385) - `SphericalJoint` no longer exists in 2D. Use `RevoluteJoint` instead. - `AngleLimit` properties `alpha` and `beta` are now named `min` and `max`. - `apply_positional_correction` has been renamed to `apply_positional_lagrange_update`. There is also an `apply_positional_impulse` method. - `apply_angular_correction` has been renamed to `apply_angular_lagrange_update`. There is also an `apply_angular_impulse` method. - `compute_lagrange_update` no longer takes a slice over gradients. For that, use `compute_lagrange_update_with_gradients`. - `Joint::align_orientation` has been moved to `AngularConstraint`. - XPBD traits and systems are now located in the `dynamics::solver::xpbd` module. - User constraints should run `solve_constraints` in `SubstepSolverSet::SolveUserConstraints` instead of `SubstepSet::SolveUserConstraints`. ### Scheduling Changes [#385](https://github.com/Jondolf/bevy_xpbd/issues3854) and [#380](https://github.com/Jondolf/bevy_xpbd/issues/380) Several scheduling internals have been changed. For example: - The narrow phase and `PostProcessCollisions` schedule are now run in `PhysicsStepSet::NarrowPhase` instead of `SubstepSet::NarrowPhase`. - Integration is now run in `IntegrationSet::Velocity` and `IntegrationSet::Position` instead of `SubstepSet::Integrate`. - `SubstepSet` has been removed. - The solver runs in `PhysicsStepSet::Solver`. - The solver's system sets are in `SolverSet`. - Substepping is performed in `SolverSet::Substep`. - The substepping loop's system sets are in `SubstepSolverSet`. Systems running in `PostProcessCollisions` may need to be modified to account for it being moved outside of the substepping loop. Some `PrepareSet` system sets have also changed order. Before: 1. `PreInit` 2. `PropagateTransforms` 3. `InitRigidBodies` 4. `InitMassProperties` 5. `InitColliders` 6. `InitTransforms` 7. `Finalize` After: 1. `PreInit` 2. `InitRigidBodies` 3. `InitColliders` 4. `PropagateTransforms` 5. `InitMassProperties` 6. `InitTransforms` 7. `Finalize` ### `ColliderHierarchyPlugin` [#377](https://github.com/Jondolf/bevy_xpbd/issues/377) Hierarchy and transform logic for colliders has been extracted from the `ColliderBackendPlugin` into a new `ColliderHierarchyPlugin`, which by default is included in the `PhysicsPlugins` plugin group. If you are adding plugins manually, make sure you have both if you want that functionality. ### `Rotation` Component [#370](https://github.com/Jondolf/bevy_xpbd/issues/370) The `Rotation` component has been updated to match the API of Bevy's new [`Rot2`](https://docs.rs/bevy/0.14.0/bevy/math/struct.Rot2.html) type more closely. The primary breaking changes are that `rotate` and `mul` have been deprecated in favor of `Mul` implementations, and the 2D `from_radians` and `from_degrees` have been renamed to just `radians` and `degrees`. ```rust // Before let rotation = Rotation::from_degrees(45.0); assert_eq!(rotation.mul(rotation).rotate(Vec2::X), Vec2::Y); // After let rotation = Rotation::degrees(45.0); assert_eq!(rotation * rotation * Vec2::X, Vec2::Y); ``` `Add` and `Sub` implementations have also been removed, as adding or subtracting quaternions in 3D is *not* quite equivalent to performing rotations, which can be a footgun, and having the 2D version function differently would also be inconsistent. --- ## What's Changed Note: These are changes made between Bevy XPBD 0.4 and Avian 0.1. - Fix time of impact description in `ShapeHits` by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/340> - Fix 2D heightfield scale and docs by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/343> - Fix 3D ShapeCaster global_rotation by @ramon-oliveira in <https://github.com/Jondolf/bevy_xpbd/pull/344> - Normalize rotations after solving constraints in solver by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/345> - Add feature to examples_common to enable PhysicsDebugPlugin by @jpedrick in <https://github.com/Jondolf/bevy_xpbd/pull/339> - Use `compile_error!` macro instead of panicking in `PhysicsLayer` derive macro by @doonv in <https://github.com/Jondolf/bevy_xpbd/pull/347> - Fix some doc tests by @yrns in <https://github.com/Jondolf/bevy_xpbd/pull/354> - various fixes in the `prepare/init_transforms` system by @exoexo-dev in <https://github.com/Jondolf/bevy_xpbd/pull/360> - Implement `RegularPolygon` colliders with a custom shape by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/367> - Rework module structure, and improve documentation and `Rotation` by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/370> - Improve trimesh docs by @janhohenheim in <https://github.com/Jondolf/bevy_xpbd/pull/373> - Apply collider scale before physics instead of afterwards by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/374> - Fix collider scale for child rigid bodies by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/375> - Update bevy-0.14 branch to crates.io release of nalgebra by @gmorenz in <https://github.com/Jondolf/bevy_xpbd/pull/372> - Speed up `ColliderTransform` propagation and extract collider hierarchy logic into `ColliderHierarchyPlugin` by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/377> - Refactor and speed up transform propagation and hierarchies further by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/380> - Make sensors not contribute to mass properties by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/381> - Rework deferred collider initialization by @janhohenheim in <https://github.com/Jondolf/bevy_xpbd/pull/378> - Fix angular corrections for some 3D joints by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/388> - Rework contact solver and collision detection, implement speculative collision by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/385> - Clean up and refactor joint logic by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/390> - Implement sweep-based CCD by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/391> - Fix inconsistency between collider constructors and Bevy's primitives by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/394> - Implement collision margin by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/393> - Add `#[reflect(Serialize, Deserialize)]` and register more types by @Jondolf in <https://github.com/Jondolf/bevy_xpbd/pull/395> ## New Contributors - @ramon-oliveira made their first contribution in <https://github.com/Jondolf/bevy_xpbd/pull/344> - @jpedrick made their first contribution in <https://github.com/Jondolf/bevy_xpbd/pull/339> - @doonv made their first contribution in <https://github.com/Jondolf/bevy_xpbd/pull/347> - @yrns made their first contribution in <https://github.com/Jondolf/bevy_xpbd/pull/354> - @exoexo-dev made their first contribution in <https://github.com/Jondolf/bevy_xpbd/pull/360> - @janhohenheim made their first contribution in <https://github.com/Jondolf/bevy_xpbd/pull/373> - @gmorenz made their first contribution in <https://github.com/Jondolf/bevy_xpbd/pull/372> **Full Changelog**: <https://github.com/Jondolf/bevy_xpbd/compare/xpbd-v0.4.0...v0.1.0>
**Bevy XPBD 0.5** is the final version of Bevy XPBD, and will be deprecated in favor of **Avian**, which is coming very, very soon. This release is primarily a Bevy 0.14 upgrade with very few breaking changes to ease migration. Avian 0.1 will have the majority of the changes. The main changes and improvements in Bevy XPBD 0.5 are: - Bevy 0.14 support. - Transform propagation has significantly less overhead, as it is only performed for physics entities. - Sensor colliders no longer contribute to mass properties. - 2D heightfields take a `Vec2` instead of a scalar value for scale. - Some bug fixes, like rotation normalization in constraints to prevent explosive behavior. ## Migration Guide ### Sensor Mass Properties (#381) Colliders with the `Sensor` component no longer contribute to the mass properties of rigid bodies. You can add mass for them by adding another collider that is *not* a sensor, or by manually adding mass properties with the `MassPropertiesBundle` or its components. Additionally, the mass properties of `Sensor` colliders are no longer updated automatically, unless the `Sensor` component is removed. ### `PrepareSet` System Set Order (#380) Some `PrepareSet` system sets have changed order. Before: 1. `PreInit` 2. `PropagateTransforms` 3. `InitRigidBodies` 4. `InitMassProperties` 5. `InitColliders` 6. `InitTransforms` 7. `Finalize` After: 1. `PreInit` 2. `InitRigidBodies` 3. `InitColliders` 4. `PropagateTransforms` 5. `InitMassProperties` 6. `InitTransforms` 7. `Finalize` ### `ColliderHierarchyPlugin` (#377) Hierarchy and transform logic for colliders has been extracted from the `ColliderBackendPlugin` into a new `ColliderHierarchyPlugin`, which by default is included in the `PhysicsPlugins` plugin group. If you are adding plugins manually, make sure you have both if you want that functionality. ## What's Changed * Fix time of impact description in `ShapeHits` by @Jondolf in https://github.com/Jondolf/bevy_xpbd/pull/340 * Fix 2D heightfield scale and docs by @Jondolf in https://github.com/Jondolf/bevy_xpbd/pull/343 * Fix 3D ShapeCaster global_rotation by @ramon-oliveira in https://github.com/Jondolf/bevy_xpbd/pull/344 * Normalize rotations after solving constraints in solver by @Jondolf in https://github.com/Jondolf/bevy_xpbd/pull/345 * Add feature to examples_common to enable PhysicsDebugPlugin by @jpedrick in https://github.com/Jondolf/bevy_xpbd/pull/339 * Use `compile_error!` macro instead of panicking in `PhysicsLayer` derive macro by @doonv in https://github.com/Jondolf/bevy_xpbd/pull/347 * Fix some doc tests by @yrns in https://github.com/Jondolf/bevy_xpbd/pull/354 * various fixes in the `prepare/init_transforms` system by @exoexo-dev in https://github.com/Jondolf/bevy_xpbd/pull/360 * Implement `RegularPolygon` colliders with a custom shape by @Jondolf in https://github.com/Jondolf/bevy_xpbd/pull/367 * Update bevy-0.14 branch to crates.io release of nalgebra by @gmorenz in https://github.com/Jondolf/bevy_xpbd/pull/372 * Speed up `ColliderTransform` propagation and extract collider hierarchy logic into `ColliderHierarchyPlugin` by @Jondolf in https://github.com/Jondolf/bevy_xpbd/pull/377 * Refactor and speed up transform propagation and hierarchies further by @Jondolf in https://github.com/Jondolf/bevy_xpbd/pull/380 * Make sensors not contribute to mass properties by @Jondolf in https://github.com/Jondolf/bevy_xpbd/pull/381 * Fix `GlobalTransform` updates for entities with non-physics children by @Jondolf in https://github.com/Jondolf/bevy_xpbd/pull/392 ## New Contributors * @ramon-oliveira made their first contribution in https://github.com/Jondolf/bevy_xpbd/pull/344 * @jpedrick made their first contribution in https://github.com/Jondolf/bevy_xpbd/pull/339 * @doonv made their first contribution in https://github.com/Jondolf/bevy_xpbd/pull/347 * @yrns made their first contribution in https://github.com/Jondolf/bevy_xpbd/pull/354 * @exoexo-dev made their first contribution in https://github.com/Jondolf/bevy_xpbd/pull/360 * @gmorenz made their first contribution in https://github.com/Jondolf/bevy_xpbd/pull/372 **Full Changelog**: https://github.com/Jondolf/bevy_xpbd/compare/v0.4.0...v0.5.0