Skip to content

Commit

Permalink
Merge remote-tracking branch 'dimforge/master' into more-deterministi…
Browse files Browse the repository at this point in the history
…c-context
  • Loading branch information
cscorley committed Aug 6, 2023
2 parents 537b1b8 + a149ff5 commit c98a68f
Show file tree
Hide file tree
Showing 61 changed files with 1,213 additions and 1,334 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ jobs:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Clippy bevy_rapier2d
run: cd bevy_rapier2d && cargo clippy --verbose --features wasm-bindgen --target wasm32-unknown-unknown
run: cd bevy_rapier2d && cargo clippy --verbose --features wasm-bindgen,bevy/webgl2 --target wasm32-unknown-unknown
- name: Clippy bevy_rapier3d
run: cd bevy_rapier3d && cargo clippy --verbose --features wasm-bindgen --target wasm32-unknown-unknown
run: cd bevy_rapier3d && cargo clippy --verbose --features wasm-bindgen,bevy/webgl2 --target wasm32-unknown-unknown
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## Unreleased
### Added
- `ColliderView::as_typed_shape` and `::to_shared_shape` to convert a `ColliderView` to a parry’s
`TypedShape` or `SharedShape`. The `From` trait has also been implemented accordingly.
- Implement `Copy` for `ColliderView` and all the other non-mut shape views.
- Add `RapierContext::rigid_body_colliders` to retrieve all collider entities attached to this rigid-body.
- Add `RapierPhysicsPlugin::in_fixed_schedule`/`::in_schedude` to add rapier’s systems to a fixed/custom
schedule.

### Fix
- Fix debug-renderer lagging one frame behind.
- Fix Collider `Transform` rotation change not being taken into account by the physics engine.
- Fix automatic update of `ReadMassProperties`.

## 0.22.0 (10 July 2023)
### Modified
- Update to Bevy 0.11.
- Disabled rigid-bodies are no longer synchronized with the rapier backend.
- Switch to bevy’s gizmo system for the debug-renderer. This removes the vendored debug lines plugin.

### Added
- Add a joint for simulating ropes: the `RopeJoint`.
- Add `Velocity::linear_velocity_at_point` to calculate the linear velocity at the given world-space point.
- Add the `ComputedColliderShape::ConvexHull` variant to automatcially calculate the convex-hull of an imported mesh.
- Implement `Reflect` for the debug-renderer.

### Fix
- Fix broken interpolation for rigid-bodies with the `TransformInterpolation` component.
- Fix compilation when `bevy_rapier` is being used with headless bevy.
- Improved performance of the writeback system by not iterting on non-rigid-body entities.
- Fix typo by renaming `CuboidViewMut::sed_half_extents` to `set_half_extents`.
- Properly scale parented collider’s offset based on changes on its `ColliderScale`.

## 0.21.0 (07 March 2023)
### Modified
- Update to Bevy 0.10.
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
members = ["bevy_rapier2d", "bevy_rapier3d"]
resolver = "2"

[profile.dev]
# Use slightly better optimization by default, as examples otherwise seem laggy.
opt-level = 1

[profile.release]
codegen-units = 1

Expand Down
25 changes: 10 additions & 15 deletions bevy_rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_rapier2d"
version = "0.21.0"
version = "0.22.0"
authors = ["Sébastien Crozet <[email protected]>"]
description = "2-dimensional physics engine in Rust, official Bevy plugin."
documentation = "http://docs.rs/bevy_rapier2d"
Expand All @@ -19,26 +19,21 @@ required-features = [ "dim2" ]

[features]
default = [ "dim2", "async-collider", "debug-render-2d" ]
dim2 = ["bevy/bevy_render"]
debug-render-2d = [ "bevy/bevy_core_pipeline", "bevy/bevy_sprite", "bevy/bevy_render", "rapier2d/debug-render" ]
debug-render-3d = [ "bevy/bevy_core_pipeline", "bevy/bevy_pbr", "bevy/bevy_render", "rapier2d/debug-render" ]
dim2 = []
debug-render-2d = [ "bevy/bevy_core_pipeline", "bevy/bevy_sprite", "bevy/bevy_gizmos", "rapier2d/debug-render", "bevy/bevy_asset" ]
debug-render-3d = [ "bevy/bevy_core_pipeline", "bevy/bevy_pbr", "bevy/bevy_gizmos", "rapier2d/debug-render", "bevy/bevy_asset" ]
parallel = [ "rapier2d/parallel" ]
simd-stable = [ "rapier2d/simd-stable" ]
simd-nightly = [ "rapier2d/simd-nightly" ]
wasm-bindgen = [ "rapier2d/wasm-bindgen" ]
serde-serialize = [ "rapier2d/serde-serialize", "bevy/serialize", "serde" ]
enhanced-determinism = [ "rapier2d/enhanced-determinism" ]

# Enables the AsyncCollider and AsyncSceneCollider components that wait for specific
# assets to be loaded before creating the actual Collider.
# See https://github.com/dimforge/bevy_rapier/issues/296 for a workaround on how
# to use this when using bevy headless.
async-collider = [ ]

headless = []
async-collider = [ "bevy/bevy_asset", "bevy/bevy_scene" ]

[dependencies]
bevy = { version = "0.10", default-features = false, features = ["bevy_asset", "bevy_scene"] }
nalgebra = { version = "0.32.2", features = [ "convert-glam023" ] }
bevy = { version = "0.11", default-features = false }
nalgebra = { version = "0.32.3", features = [ "convert-glam024" ] }
# Don't enable the default features because we don't need the ColliderSet/RigidBodySet
rapier2d = "0.17.0"
bitflags = "1"
Expand All @@ -47,10 +42,10 @@ log = "0.4"
serde = { version = "1", features = [ "derive" ], optional = true}

[dev-dependencies]
bevy = { version = "0.10", default-features = false, features = ["x11"]}
bevy = { version = "0.11", default-features = false, features = ["x11"]}
oorandom = "11"
approx = "0.5.1"
glam = { version = "0.23", features = [ "approx" ] }
glam = { version = "0.24", features = [ "approx" ] }

[package.metadata.docs.rs]
# Enable all the features when building the docs on docs.rs
Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/boxes2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
11 changes: 5 additions & 6 deletions bevy_rapier2d/examples/contact_filter2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<SameUserDataFilter>::pixels_per_meter(
100.0,
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<SameUserDataFilter>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
73 changes: 26 additions & 47 deletions bevy_rapier2d/examples/custom_system_setup2.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use bevy::{core::FrameCount, ecs::schedule::ScheduleLabel, prelude::*};
use bevy::{core::FrameCount, prelude::*, transform::TransformSystem};
use bevy_rapier2d::prelude::*;

#[derive(ScheduleLabel, Hash, Debug, PartialEq, Eq, Clone)]
struct SpecialSchedule;

fn main() {
let mut app = App::new();

Expand All @@ -12,58 +9,40 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_system(
(|world: &mut World| {
world.run_schedule(SpecialSchedule);
})
.in_base_set(CoreSet::PostUpdate),
);

// Do the setup however we want, maybe in its very own schedule
let mut schedule = Schedule::new();

schedule.configure_sets(
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0).with_default_system_setup(false),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics));

app.configure_sets(
PostUpdate,
(
PhysicsSet::SyncBackend,
PhysicsSet::SyncBackendFlush,
PhysicsSet::StepSimulation,
PhysicsSet::Writeback,
)
.chain(),
);

schedule.add_systems(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackend)
.in_base_set(PhysicsSet::SyncBackend),
.chain()
.before(TransformSystem::TransformPropagate),
);

schedule.add_systems(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackendFlush)
.in_base_set(PhysicsSet::SyncBackendFlush),
);

schedule.add_systems(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::StepSimulation)
.in_base_set(PhysicsSet::StepSimulation),
);
schedule.add_system(despawn_one_box.in_base_set(PhysicsSet::StepSimulation));

schedule.add_systems(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::Writeback)
.in_base_set(PhysicsSet::Writeback),
app.add_systems(
PostUpdate,
(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackend)
.in_set(PhysicsSet::SyncBackend),
(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::StepSimulation),
despawn_one_box,
)
.in_set(PhysicsSet::StepSimulation),
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::Writeback)
.in_set(PhysicsSet::Writeback),
),
);

app.add_schedule(SpecialSchedule, schedule)
.add_plugin(
RapierPhysicsPlugin::<NoUserData>::default()
.with_physics_scale(100.)
.with_default_system_setup(false),
)
.run();
app.run();
}

fn despawn_one_box(
Expand Down
12 changes: 7 additions & 5 deletions bevy_rapier2d/examples/debug_despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ fn main() {
App::new()
.init_resource::<Game>()
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
.add_plugins(DefaultPlugins)
.add_startup_system(setup_game)
.add_system(cube_sleep_detection)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, setup_game)
.add_systems(Update, cube_sleep_detection)
.run();
}

Expand Down
14 changes: 7 additions & 7 deletions bevy_rapier2d/examples/despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ fn main() {
)))
.insert_resource(DespawnResource::default())
.insert_resource(ResizeResource::default())
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_system(despawn)
.add_system(resize)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, (despawn, resize))
.run();
}

Expand Down
13 changes: 7 additions & 6 deletions bevy_rapier2d/examples/events2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_system(display_events.in_base_set(CoreSet::PostUpdate))
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(PostUpdate, display_events)
.run();
}

Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/joints2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
13 changes: 7 additions & 6 deletions bevy_rapier2d/examples/joints_despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ fn main() {
0xFF as f32 / 255.0,
)))
.insert_resource(DespawnResource::default())
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_system(despawn)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, despawn)
.run();
}

Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/locked_rotations2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/multiple_colliders2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
Loading

0 comments on commit c98a68f

Please sign in to comment.