Skip to content

Commit

Permalink
Merge pull request #540 from johnny-smitherson/bevy-0.11
Browse files Browse the repository at this point in the history
update bevy 0.11 - fix compile errors
  • Loading branch information
sebcrozet authored Nov 4, 2023
2 parents dbc540d + 1886c6f commit e9ea2ca
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 917 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Make `Wheel::friction_slip` public to customize the front friction applied to the vehicle controller’s wheels.
- Add the `DebugRenderBackend::filter_object` predicate that can be implemented to apply custom filtering rules
on the objects being rendered.
- Switch the testbed to `bevy 0.11` and use its new Gizmos API for rendering lines.

## v0.17.2 (26 Feb. 2023)
### Fix
Expand Down
13 changes: 8 additions & 5 deletions crates/rapier_testbed2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,24 @@ bincode = "1"
Inflector = "0.11"
md5 = "0.7"

bevy_egui = "0.18"
bevy_ecs = "0.9"
bevy_egui = "0.22"
bevy_ecs = "0.11"
bevy_core_pipeline = "0.11"
bevy_pbr = "0.11"
bevy_sprite = "0.11"
#bevy_prototype_debug_lines = "0.7"

# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render", "x11"]}
bevy = {version = "0.11", default-features = false, features = ["bevy_asset", "bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render"]}
bevy = {version = "0.11", default-features = false, features = ["bevy_asset", "bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
#bevy_webgl2 = "0.5"

[dependencies.rapier]
package = "rapier2d-f64"
path = "../rapier2d-f64"
version = "0.17.0"
version = "0.17.2"
features = [ "serde-serialize", "debug-render", "profiler" ]
13 changes: 8 additions & 5 deletions crates/rapier_testbed2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,24 @@ bincode = "1"
Inflector = "0.11"
md5 = "0.7"

bevy_egui = "0.18"
bevy_ecs = "0.9"
bevy_egui = "0.22"
bevy_ecs = "0.11"
bevy_core_pipeline = "0.11"
bevy_pbr = "0.11"
bevy_sprite = "0.11"
#bevy_prototype_debug_lines = "0.7"

# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render", "x11"]}
bevy = {version = "0.11", default-features = false, features = ["bevy_sprite", "bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render"]}
bevy = {version = "0.11", default-features = false, features = ["bevy_sprite", "bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
#bevy_webgl2 = "0.5"

[dependencies.rapier]
package = "rapier2d"
path = "../rapier2d"
version = "0.17.0"
version = "0.17.2"
features = [ "serde-serialize", "debug-render", "profiler" ]
13 changes: 8 additions & 5 deletions crates/rapier_testbed3d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,24 @@ md5 = "0.7"
Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] }

bevy_egui = "0.18"
bevy_ecs = "0.9"
bevy_egui = "0.22"
bevy_ecs = "0.11"
bevy_core_pipeline = "0.11"
bevy_pbr = "0.11"
bevy_sprite = "0.11"
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }

# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render", "x11"]}
bevy = {version = "0.11", default-features = false, features = ["bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render"]}
bevy = {version = "0.11", default-features = false, features = ["bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
#bevy_webgl2 = "0.5"

[dependencies.rapier]
package = "rapier3d-f64"
path = "../rapier3d-f64"
version = "0.17.0"
version = "0.17.2"
features = [ "serde-serialize", "debug-render", "profiler" ]
19 changes: 11 additions & 8 deletions crates/rapier_testbed3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,34 @@ rand = "0.8"
rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]}
bitflags = "1"
glam = { version = "0.20", optional = true } # For Physx
glam = { version = "0.24", optional = true } # For Physx
num_cpus = { version = "1", optional = true }
physx = { version = "0.16", features = [ "glam" ], optional = true }
physx-sys = { version = "0.8", optional = true }
physx = { version = "0.19", features = [ "glam" ], optional = true }
physx-sys = { version = "0.11", optional = true }
crossbeam = "0.8"
bincode = "1"
md5 = "0.7"
Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] }

bevy_egui = "0.18"
bevy_ecs = "0.9"
bevy_egui = "0.22"
bevy_ecs = "0.11"
bevy_core_pipeline = "0.11"
bevy_pbr = "0.11"
bevy_sprite = "0.11"
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }

# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render", "x11"]}
bevy = {version = "0.11", default-features = false, features = ["bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render"]}
bevy = {version = "0.11", default-features = false, features = ["bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
#bevy_webgl2 = "0.5"

[dependencies.rapier]
package = "rapier3d"
path = "../rapier3d"
version = "0.17.0"
version = "0.17.2"
features = [ "serde-serialize", "debug-render", "profiler" ]
2 changes: 1 addition & 1 deletion examples3d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rand = "0.8"
getrandom = { version = "0.2", features = [ "js" ] }
Inflector = "0.11"
wasm-bindgen = "0.2"
obj-rs = { version = "0.6", default-features = false }
obj-rs = { version = "0.7", default-features = false }
bincode = "1"
serde = "1"

Expand Down
2 changes: 1 addition & 1 deletion examples3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rand = "0.8"
getrandom = { version = "0.2", features = [ "js" ] }
Inflector = "0.11"
wasm-bindgen = "0.2"
obj-rs = { version = "0.6", default-features = false }
obj-rs = { version = "0.7", default-features = false }
serde = "1"
bincode = "1"

Expand Down
6 changes: 3 additions & 3 deletions src_testbed/camera2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ impl OrbitCameraPlugin {
}
impl Plugin for OrbitCameraPlugin {
fn build(&self, app: &mut App) {
app.add_system(Self::mouse_motion_system)
.add_system(Self::zoom_system)
.add_system(Self::update_transform_system);
app.add_systems(Update, Self::mouse_motion_system)
.add_systems(Update, Self::zoom_system)
.add_systems(Update, Self::update_transform_system);
}
}
6 changes: 3 additions & 3 deletions src_testbed/camera3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ impl OrbitCameraPlugin {
}
impl Plugin for OrbitCameraPlugin {
fn build(&self, app: &mut App) {
app.add_system(Self::mouse_motion_system)
.add_system(Self::zoom_system)
.add_system(Self::update_transform_system);
app.add_systems(Update, Self::mouse_motion_system)
.add_systems(Update, Self::zoom_system)
.add_systems(Update, Self::update_transform_system);
}
}
66 changes: 30 additions & 36 deletions src_testbed/debug_render.rs
Original file line number Diff line number Diff line change
@@ -1,76 +1,70 @@
use crate::harness::Harness;
use crate::lines::DebugLines;
use bevy::gizmos::gizmos::Gizmos;
use bevy::prelude::*;
use rapier::math::{Point, Real};
use rapier::pipeline::{
DebugRenderBackend, DebugRenderMode, DebugRenderObject, DebugRenderPipeline,
};

#[derive(Resource)]
pub struct DebugRenderPipelineResource(pub DebugRenderPipeline);

pub struct RapierDebugRenderPlugin {
depth_test: bool,
pub struct DebugRenderPipelineResource {
pub pipeline: DebugRenderPipeline,
pub enabled: bool,
}

impl Default for RapierDebugRenderPlugin {
fn default() -> Self {
Self {
depth_test: cfg!(feature = "dim3"),
}
}
}
#[derive(Default)]
pub struct RapierDebugRenderPlugin {}

impl Plugin for RapierDebugRenderPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(crate::lines::DebugLinesPlugin::with_depth_test(
self.depth_test,
))
.insert_resource(DebugRenderPipelineResource(DebugRenderPipeline::new(
Default::default(),
!DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS,
)))
.add_system_to_stage(CoreStage::Update, debug_render_scene);
app.insert_resource(DebugRenderPipelineResource {
pipeline: DebugRenderPipeline::new(
Default::default(),
!DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS,
),
enabled: false,
})
.add_systems(Update, debug_render_scene);
}
}

struct BevyLinesRenderBackend<'a> {
lines: &'a mut DebugLines,
gizmos: Gizmos<'a>,
}

impl<'a> DebugRenderBackend for BevyLinesRenderBackend<'a> {
#[cfg(feature = "dim2")]
fn draw_line(&mut self, _: DebugRenderObject, a: Point<Real>, b: Point<Real>, color: [f32; 4]) {
self.lines.line_colored(
self.gizmos.line(
[a.x as f32, a.y as f32, 1.0e-8 as f32].into(),
[b.x as f32, b.y as f32, 1.0e-8 as f32].into(),
0.0,
Color::hsla(color[0], color[1], color[2], color[3]),
)
}
#[cfg(feature = "dim3")]
fn draw_line(&mut self, _: DebugRenderObject, a: Point<Real>, b: Point<Real>, color: [f32; 4]) {
self.lines.line_colored(
self.gizmos.line(
[a.x as f32, a.y as f32, a.z as f32].into(),
[b.x as f32, b.y as f32, b.z as f32].into(),
0.0,
Color::hsla(color[0], color[1], color[2], color[3]),
)
}
}

fn debug_render_scene(
mut pipeline: ResMut<DebugRenderPipelineResource>,
mut debug_render: ResMut<DebugRenderPipelineResource>,
harness: NonSend<Harness>,
mut lines: ResMut<DebugLines>,
gizmos: Gizmos,
) {
let mut backend = BevyLinesRenderBackend { lines: &mut *lines };
pipeline.0.render(
&mut backend,
&harness.physics.bodies,
&harness.physics.colliders,
&harness.physics.impulse_joints,
&harness.physics.multibody_joints,
&harness.physics.narrow_phase,
);
if debug_render.enabled {
let mut backend = BevyLinesRenderBackend { gizmos };
debug_render.pipeline.render(
&mut backend,
&harness.physics.bodies,
&harness.physics.colliders,
&harness.physics.impulse_joints,
&harness.physics.multibody_joints,
&harness.physics.narrow_phase,
);
}
}
1 change: 0 additions & 1 deletion src_testbed/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ mod camera3d;
mod debug_render;
mod graphics;
pub mod harness;
mod lines;
pub mod objects;
pub mod physics;
#[cfg(all(feature = "dim3", feature = "other-backends"))]
Expand Down
53 changes: 0 additions & 53 deletions src_testbed/lines/debuglines.wgsl

This file was deleted.

32 changes: 0 additions & 32 deletions src_testbed/lines/debuglines2d.wgsl

This file was deleted.

Loading

0 comments on commit e9ea2ca

Please sign in to comment.