Skip to content

Commit

Permalink
Upgrade to Bevy 0.12 (#187)
Browse files Browse the repository at this point in the history
# Objective

Add Bevy 0.12 support.

## Solution

- Update Bevy (and Criterion)
- Migrate to `Interned` `ScheduleLabel`s (#204)
- Fix deprecated methods
- Unify time and simulation loop APIs under `Time<Physics>` and `Time<Substeps>` (#214)
- Update `README.md` (and its feature list)
  • Loading branch information
Jondolf authored Nov 4, 2023
1 parent b6ef160 commit 38d166b
Show file tree
Hide file tree
Showing 28 changed files with 1,213 additions and 867 deletions.
55 changes: 31 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,37 @@ with their own implementations.
Below are some of the current features of Bevy XPBD.

- Dynamic, kinematic and static rigid bodies
- Colliders powered by [parry](https://parry.rs)
- Collision events: `Collision`, `CollisionStarted`, `CollisionEnded`
- Access to colliding entities with `CollidingEntities`
- Sensor colliders
- Collision layers
- Linear and angular velocity
- External forces, torque and impulses
- Gravity and gravity scale
- Linear and angular damping
- Locking translational and rotational axes
- Rigid body dominance
- Automatic deactivation with sleeping
- Collision detection powered by [Parry](https://parry.rs)
- Colliders with configurable collision layers, density, material properties and more
- Collision events
- Access to colliding entities
- Filtering and modifying collisions with custom systems
- Material properties like restitution and friction
- Linear and angular velocity damping for simulating drag
- External forces, torque and impulses
- Gravity and gravity scale for specific entities
- Locking translational and rotational axes with `LockedAxes`
- Rigid body dominance
- Joints
- Built-in constraints and support for custom constraints
- Manual contact queries and intersection tests
- Constraints and joints
- Flexible API for creating position-based constraints
- Several built-in joint types: fixed, distance, prismatic, revolute, spherical
- Support for custom joints and other constraints
- Spatial queries
- Raycasting
- Shapecasting
- Point projection
- Intersection tests
- Debug rendering colliders, AABBs, contacts, joints, rigid body axes, and spatial queries
- Automatically deactivating bodies with `Sleeping`
- Configurable timesteps and substepping
- Raycasting, shapecasting, point projection and intersection tests
- Ergonomic component-based API for raycasts and shapecasts
- Flexible `SpatialQuery` system parameter
- Spatial query filters
- Debug rendering for colliders, AABBs, contacts, joints, sleeping, axes and spatial queries
- Configurable scheduling and high customizability
- Highly modular plugin architecture, freely extend and replace parts of the engine
- `f32`/`f64` precision (`f32` by default)

You can find a more complete list along with documentation in the
[Table of contents](https://docs.rs/bevy_xpbd_3d/0.3.0/bevy_xpbd_3d/#table-of-contents)
on docs.rs.

## Documentation

- [2D documentation](https://docs.rs/bevy_xpbd_2d)
Expand All @@ -63,11 +70,11 @@ First, add `bevy_xpbd_2d` or `bevy_xpbd_3d` to your dependencies in `Cargo.toml`
```toml
# For 2D applications:
[dependencies]
bevy_xpbd_2d = "0.2"
bevy_xpbd_2d = "0.3"

# For 3D applications:
[dependencies]
bevy_xpbd_3d = "0.2"
bevy_xpbd_3d = "0.3"

# If you want to use the most up-to-date version, you can follow the main branch:
[dependencies]
Expand All @@ -76,7 +83,7 @@ bevy_xpbd_3d = { git = "https://github.com/Jondolf/bevy_xpbd", branch = "main" }

Below is a very simple example where a box with initial angular velocity falls onto a plane. This is a modified version of Bevy's [3d_scene](https://bevyengine.org/examples/3d/3d-scene/) example.

```rs
```rust
use bevy::prelude::*;
use bevy_xpbd_3d::prelude::*;

Expand Down Expand Up @@ -152,12 +159,12 @@ cargo run --example cubes --no-default-features --features "3d f64"

| Bevy | Bevy XPBD |
| ---- | --------- |
| 0.12 | 0.3 |
| 0.11 | 0.2 |
| 0.10 | 0.1 |

## Future features

- On-demand simulation stepping
- Joint motors
- Articulations, aka. multibody joints
- Continuous collision detection (CCD)
Expand Down
4 changes: 2 additions & 2 deletions crates/benches_common_3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"

[dependencies]
bevy = { version = "0.11", default-features = false }
bevy = { version = "0.12", default-features = false }
bevy_xpbd_3d = { path = "../bevy_xpbd_3d", default-features = false }
criterion = "0.4"
criterion = "0.5"
6 changes: 3 additions & 3 deletions crates/benches_common_3d/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{app::PluginsState, prelude::*};
use bevy_xpbd_3d::prelude::*;
use criterion::{measurement::Measurement, BatchSize, Bencher};

Expand All @@ -18,11 +18,11 @@ pub fn bench_app<M: Measurement>(
PhysicsPlugins::default(),
));

app.insert_resource(PhysicsTimestep::FixedOnce(1.0 / 60.0));
app.insert_resource(Time::new_with(Physics::fixed_once_hz(1.0 / 60.0)));

setup(&mut app);

while !app.ready() {
while app.plugins_state() != PluginsState::Ready {
bevy::tasks::tick_global_task_pools_on_main_thread();
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ required-features = ["2d"]

[dependencies]
bevy_xpbd_derive = { path = "../bevy_xpbd_derive", version = "0.1" }
bevy = { version = "0.11", default-features = false }
bevy = { version = "0.12", default-features = false }
parry2d = { version = "0.13", optional = true }
parry2d-f64 = { version = "0.13", optional = true }
nalgebra = { version = "0.32", features = ["convert-glam024"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ fn movement(
// both the `f32` and `f64` features. Otherwise you don't need this.
let delta_time = time.delta_seconds_f64().adjust_precision();

for event in movement_event_reader.iter() {
for event in movement_event_reader.read() {
for (movement_acceleration, jump_impulse, mut linear_velocity, is_grounded) in
&mut controllers
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ fn movement(
// both the `f32` and `f64` features. Otherwise you don't need this.
let delta_time = time.delta_seconds_f64().adjust_precision();

for event in movement_event_reader.iter() {
for event in movement_event_reader.read() {
for (movement_acceleration, jump_impulse, mut linear_velocity, is_grounded) in
&mut controllers
{
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_xpbd_3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ required-features = ["3d"]

[dependencies]
bevy_xpbd_derive = { path = "../bevy_xpbd_derive", version = "0.1" }
bevy = { version = "0.11", default-features = false }
bevy = { version = "0.12", default-features = false }
parry3d = { version = "0.13", optional = true }
parry3d-f64 = { version = "0.13", optional = true }
nalgebra = { version = "0.32", features = ["convert-glam024"] }
Expand All @@ -48,7 +48,7 @@ itertools = "0.11"
examples_common_3d = { path = "../examples_common_3d" }
benches_common_3d = { path = "../benches_common_3d" }
approx = "0.5"
criterion = { version = "0.4", features = ["html_reports"] }
criterion = { version = "0.5", features = ["html_reports"] }
insta = "1.0"

[[example]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ fn movement(
// both the `f32` and `f64` features. Otherwise you don't need this.
let delta_time = time.delta_seconds_f64().adjust_precision();

for event in movement_event_reader.iter() {
for event in movement_event_reader.read() {
for (movement_acceleration, jump_impulse, mut linear_velocity, is_grounded) in
&mut controllers
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn movement(
// both the `f32` and `f64` features. Otherwise you don't need this.
let delta_time = time.delta_seconds_f64().adjust_precision();

for event in movement_event_reader.iter() {
for event in movement_event_reader.read() {
for (movement_acceleration, jump_impulse, mut linear_velocity, is_grounded) in
&mut controllers
{
Expand Down
Loading

0 comments on commit 38d166b

Please sign in to comment.