Skip to content

Commit

Permalink
Add a way to convert a parry shape to bevy mesh #628
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz authored Feb 3, 2025
2 parents 1873289 + c11fd65 commit a4e9343
Show file tree
Hide file tree
Showing 24 changed files with 525 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
- run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev
- run: cargo install cargo-all-features
- name: Clippy for bevy_rapier2d
run: cargo clippy --verbose -p bevy_rapier2d
run: cargo clippy --verbose -p bevy_rapier2d --examples
- name: Clippy for bevy_rapier3d
run: cargo clippy --verbose -p bevy_rapier3d
run: cargo clippy --verbose -p bevy_rapier3d --examples
- name: Clippy for bevy_rapier2d (debug-render, simd, serde)
run: cargo clippy --verbose -p bevy_rapier2d --features debug-render-2d,simd-stable,serde-serialize,picking-backend
- name: Clippy for bevy_rapier3d (debug-render, simd, serde)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Added optional feature `picking-backend` to support bevy_picking.
- See `picking_backend` module documentation for more details.
- Added `geometry::to_bevy_mesh` module behind the feature `to-bevy-mesh` to help with converting parry shapes into bevy meshes.

### Modified

Expand Down
9 changes: 8 additions & 1 deletion bevy_rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ rust.unexpected_cfgs = { level = "warn", check-cfg = [
clippy = { needless_lifetimes = "allow" }

[features]
default = ["dim2", "async-collider", "debug-render-2d", "picking-backend"]
default = [
"dim2",
"async-collider",
"debug-render-2d",
"picking-backend",
"to-bevy-mesh",
]
dim2 = []
debug-render-2d = [
"bevy/bevy_core_pipeline",
Expand Down Expand Up @@ -55,6 +61,7 @@ async-collider = [
"bevy/bevy_render",
"bevy/bevy_image",
]
to-bevy-mesh = ["bevy/bevy_render", "bevy/bevy_asset"]

[dependencies]
bevy = { version = "0.15", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/boxes2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
}

pub fn setup_graphics(mut commands: Commands) {
commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0)));
commands.spawn((Camera2d, Transform::from_xyz(0.0, 20.0, 0.0)));
}

pub fn setup_physics(mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/contact_filter2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() {
}

fn setup_graphics(mut commands: Commands) {
commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0)));
commands.spawn((Camera2d, Transform::from_xyz(0.0, 20.0, 0.0)));
}

pub fn setup_physics(mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/custom_system_setup2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn despawn_one_box(
}

fn setup_graphics(mut commands: Commands) {
commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0)));
commands.spawn((Camera2d, Transform::from_xyz(0.0, 20.0, 0.0)));
}

pub fn setup_physics(mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/debug_despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn setup_game(mut commands: Commands, mut game: ResMut<Game>) {
byte_rgb(255, 0, 0),
];

commands.spawn(Camera2d::default());
commands.spawn(Camera2d);

setup_board(&mut commands, &game);

Expand Down
10 changes: 5 additions & 5 deletions bevy_rapier2d/examples/debugdump2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ fn main() {
RapierDebugRenderPlugin::default(),
));

let mut debugdump_settings = schedule_graph::Settings::default();
// Filter out some less relevant systems.
debugdump_settings.include_system =
Some(Box::new(|system: &(dyn System<In = (), Out = ()>)| {
let debugdump_settings = schedule_graph::Settings {
include_system: Some(Box::new(|system: &(dyn System<In = (), Out = ()>)| {
if system.name().starts_with("bevy_pbr")
|| system.name().starts_with("bevy_render")
|| system.name().starts_with("bevy_gizmos")
Expand All @@ -27,7 +25,9 @@ fn main() {
return false;
}
true
}));
})),
..Default::default()
};
let dot = schedule_graph_dot(&mut app, PostUpdate, &debugdump_settings);
println!("{dot}");
}
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn setup_graphics(
resize.timer = Timer::from_seconds(6.0, TimerMode::Once);
despawn.timer = Timer::from_seconds(5.0, TimerMode::Once);

commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0)));
commands.spawn((Camera2d, Transform::from_xyz(0.0, 20.0, 0.0)));
}

pub fn setup_physics(mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/events2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {
}

pub fn setup_graphics(mut commands: Commands) {
commands.spawn(Camera2d::default());
commands.spawn(Camera2d);
}

pub fn display_events(
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/joints2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
}

pub fn setup_graphics(mut commands: Commands) {
commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, -200.0, 0.0)));
commands.spawn((Camera2d, Transform::from_xyz(0.0, -200.0, 0.0)));
}

pub fn setup_physics(mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/joints_despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
}

pub fn setup_graphics(mut commands: Commands) {
commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, -200.0, 0.0)));
commands.spawn((Camera2d, Transform::from_xyz(0.0, -200.0, 0.0)));
}

pub fn setup_physics(mut commands: Commands, mut despawn: ResMut<DespawnResource>) {
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/locked_rotations2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
}

pub fn setup_graphics(mut commands: Commands) {
commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 200.0, 0.0)));
commands.spawn((Camera2d, Transform::from_xyz(0.0, 200.0, 0.0)));
}

pub fn setup_physics(mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/multiple_colliders2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
}

pub fn setup_graphics(mut commands: Commands) {
commands.spawn(Camera2d::default());
commands.spawn(Camera2d);
}

pub fn setup_physics(mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/player_movement2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn spawn_player(mut commands: Commands, mut rapier_config: Query<&mut Rapier
let mut rapier_config = rapier_config.single_mut();
// Set gravity to 0.0 and spawn camera.
rapier_config.gravity = Vec2::ZERO;
commands.spawn(Camera2d::default());
commands.spawn(Camera2d);

let sprite_size = 100.0;

Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier2d/examples/rope_joint2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
}

pub fn setup_graphics(mut commands: Commands) {
commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, -200.0, 0.0)));
commands.spawn((Camera2d, Transform::from_xyz(0.0, -200.0, 0.0)));
}

pub fn setup_physics(mut commands: Commands) {
Expand Down
13 changes: 10 additions & 3 deletions bevy_rapier3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ rust.unexpected_cfgs = { level = "warn", check-cfg = [
clippy = { needless_lifetimes = "allow" }

[features]
default = ["dim3", "async-collider", "debug-render-3d", "picking-backend"]
default = [
"dim3",
"async-collider",
"debug-render-3d",
"picking-backend",
"to-bevy-mesh",
]
dim3 = []
debug-render = ["debug-render-3d"]
debug-render-2d = [
Expand Down Expand Up @@ -56,6 +62,7 @@ async-collider = [
"bevy/bevy_render",
"bevy/bevy_image",
]
to-bevy-mesh = ["bevy/bevy_render", "bevy/bevy_asset"]

[dependencies]
bevy = { version = "0.15", default-features = false }
Expand Down Expand Up @@ -83,7 +90,7 @@ bevy_egui = "0.31"

[package.metadata.docs.rs]
# Enable all the features when building the docs on docs.rs
features = ["debug-render-3d", "serde-serialize"]
features = ["debug-render-3d", "serde-serialize", "async-collider"]

[package.metadata.cargo-all-features]

Expand All @@ -97,8 +104,8 @@ always_include_features = ["dim3"]
# The maximum number of features to try at once. Does not count features from `always_include_features`.
# This is useful for reducing the number of combinations run for a crate with a large amount of features,
# since in most cases a bug just needs a small set of 2-3 features to reproduce.
max_combination_size = 1

max_combination_size = 1
[[example]]
name = "picking3"
required-features = ["picking-backend"]
Expand Down
15 changes: 6 additions & 9 deletions bevy_rapier3d/examples/joints3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,12 @@ pub fn print_impulse_revolute_joints(
joints: Query<(Entity, &ImpulseJoint)>,
) {
for (entity, impulse_joint) in joints.iter() {
match &impulse_joint.data {
TypedJoint::RevoluteJoint(_revolute_joint) => {
println!(
"angle for {}: {:?}",
entity,
context.single().impulse_revolute_joint_angle(entity),
);
}
_ => {}
if let TypedJoint::RevoluteJoint(_revolute_joint) = &impulse_joint.data {
println!(
"angle for {}: {:?}",
entity,
context.single().impulse_revolute_joint_angle(entity),
);
}
}
}
2 changes: 1 addition & 1 deletion bevy_rapier3d/examples/picking3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::default(),
RapierDebugRenderPlugin::default(),
RapierPickingPlugin::default(),
RapierPickingPlugin,
))
.insert_resource(RapierPickingSettings {
// Optional: only needed when you want fine-grained control
Expand Down
Loading

0 comments on commit a4e9343

Please sign in to comment.