Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exclude = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { version = "^0.18", default-features = false, features = [
bevy = { version = "^0.19", default-features = false, features = [
"bevy_log",
"bevy_asset",
]}
Expand All @@ -45,7 +45,7 @@ serde = { version = "^1", features = ["derive"] }
ron = "0.12.0"

[dev-dependencies]
bevy = { version = "^0.18", default-features = false, features = [
bevy = { version = "^0.19", default-features = false, features = [
"gltf_animation",
# "bevy_audio",
"bevy_gilrs",
Expand All @@ -66,7 +66,7 @@ bevy = { version = "^0.18", default-features = false, features = [
"x11",
# "filesystem_watcher",
] }
avian3d = { version = "^0.6", features = ["3d", "debug-plugin", "parallel", "parry-f32"] }
avian3d = { version = "^0.7", features = ["3d", "debug-plugin", "parallel", "parry-f32"] }
bevy-tnua-avian3d = { path = "avian3d" }

[package.metadata.docs.rs]
Expand Down
4 changes: 2 additions & 2 deletions avian2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ documentation = "https://docs.rs/bevy-tnua-avian2d"
readme = "../README.md"

[dependencies]
bevy = { version = "^0.18", default-features = false }
avian2d = { version = "^0.6", default-features = false, features = ["2d", "debug-plugin", "parallel"]}
bevy = { version = "^0.19", default-features = false }
avian2d = { version = "^0.7", default-features = false, features = ["2d", "debug-plugin", "parallel"]}
bevy-tnua-physics-integration-layer = { version = "^0.12", path = "../physics-integration-layer" }
ordered-float = "5.3.0"

Expand Down
5 changes: 3 additions & 2 deletions avian2d/src/spatial_ext.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use avian2d::prelude::*;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the prelude import? This is the usual way to do import these things in Rust.

use bevy::{ecs::system::SystemParam, prelude::*};
use crate::{Collider, Position, Rotation};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait what? These are Avian types - why are you importing them from crate?

use avian2d::collision::collider::{CollisionLayers, Sensor};
use bevy::ecs::{query::Has, system::Query};
use bevy_tnua_physics_integration_layer::{
math::{Float, Vector3},
spatial_ext::{TnuaPointProjectionResult, TnuaSpatialExt},
Expand Down
4 changes: 2 additions & 2 deletions avian3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ documentation = "https://docs.rs/bevy-tnua-avian3d"
readme = "../README.md"

[dependencies]
bevy = { version = "^0.18", default-features = false }
avian3d = { version = "^0.6", default-features = false, features = ["3d", "debug-plugin", "parallel"] }
bevy = { version = "^0.19", default-features = false }
avian3d = { version = "^0.7", default-features = false, features = ["3d", "debug-plugin", "parallel"] }
bevy-tnua-physics-integration-layer = { version = "^0.12", path = "../physics-integration-layer" }
ordered-float = "5.3.0"

Expand Down
6 changes: 4 additions & 2 deletions avian3d/src/spatial_ext.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use avian3d::prelude::*;
use bevy::{ecs::system::SystemParam, prelude::*};
use crate::{Position, Rotation};
use avian3d::collision::collider::{CollisionLayers, Sensor};
use avian3d::prelude::Collider;
use bevy::ecs::{entity::Entity, query::Has, system::Query, system::SystemParam};
use bevy_tnua_physics_integration_layer::{
math::{Float, Vector3},
spatial_ext::{TnuaPointProjectionResult, TnuaSpatialExt},
Expand Down
19 changes: 11 additions & 8 deletions demos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ avian2d = ["avian", "dep:avian2d", "dep:bevy-tnua-avian2d"]
avian3d = ["avian", "dep:avian3d", "dep:bevy-tnua-avian3d"]

[dependencies]
bevy = { version = "^0.18", default-features = false, features = [
bevy = { version = "^0.19", default-features = false, features = [
"gltf_animation",
"bevy_asset",
# "bevy_audio",
Expand All @@ -52,6 +52,8 @@ bevy = { version = "^0.18", default-features = false, features = [
# "bevy_winit",
"bevy_render",
"bevy_gltf",
"system_font_discovery",
"bevy_pbr",
"ktx2",
"zstd_rust",
"tonemapping_luts",
Expand All @@ -71,27 +73,28 @@ bevy = { version = "^0.18", default-features = false, features = [
bevy-tnua = { path = ".." }
bevy-tnua-physics-integration-layer = { path = "../physics-integration-layer" }

bevy_rapier2d = { version = "^0.33", features = ["debug-render-2d"], optional = true }
bevy_rapier2d = { version = "^0.34", features = ["debug-render-2d"], optional = true }
bevy-tnua-rapier2d = { path = "../rapier2d", optional = true }

bevy_rapier3d = { version = "^0.33", features = ["debug-render-3d"], optional = true }
bevy_rapier3d = { version = "^0.34", features = ["debug-render-3d"], optional = true }
bevy-tnua-rapier3d = { path = "../rapier3d", optional = true }
avian2d = { version = "^0.7", default-features = false, features = ["2d","debug-plugin", "parry-f32", "parallel"], optional = true}

avian2d = { version = "^0.6", default-features = false, features = ["2d","debug-plugin", "parallel"], optional = true}
bevy-tnua-avian2d = { path = "../avian2d", default-features = false, optional = true }

avian3d = { version = "^0.6", default-features = false, features = ["3d","debug-plugin", "parallel"], optional = true }
avian3d = { version = "^0.7", default-features = false, features = ["3d", "debug-plugin", "parallel", "parry-f32"], optional=true }
bevy-tnua-avian3d = { path = "../avian3d", default-features = false, optional = true }

bevy_egui = { version = "0.39", optional = true, default-features = false, features = ["default_fonts", "render"] }
egui_plot = { version = "0.34", optional = true }
egui_extras = { version = "0.33", optional = true }
bevy_egui = { version = "0.40", optional = true, default-features = false, features = ["bevy_ui", "default_fonts", "render"] }
egui_plot = { version = "0.35", optional = true }
egui_extras = { version = "0.34", optional = true }

bevy_framepace = { version = "0.21", optional = true }

clap = { version = "^4", features = ["derive"] }
ordered-float = "5.0.0"
serde = { version = "1.0.228", features = ["derive"] }
bevy_ecs = "0.19.0"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't. When you need to import something from bevy_ecs (and you don't) just use the bevy::ecs re-export.


[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "^0.3", features = ["Window", "Location", "Url", "UrlSearchParams"] }
16 changes: 8 additions & 8 deletions demos/src/bin/platformer_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ fn setup_player(
"Sensor Shape",
1,
&[
("Point", |mut cmd| {
("Point", |_cmd| {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh... no? cmd is used inside the closure body. I assume, when you try to build with neither physics backend --features flag the compiler will complain - but the demo would be useless when built that way...

#[cfg(feature = "rapier2d")]
cmd.remove::<TnuaRapier2dSensorShape>();
#[cfg(feature = "avian2d")]
cmd.remove::<TnuaAvian2dSensorShape>();
}),
("Flat (underfit)", |mut cmd| {
("Flat (underfit)", |_cmd| {
#[cfg(feature = "rapier2d")]
cmd.insert(TnuaRapier2dSensorShape(
bevy_rapier2d::parry::shape::SharedShape::cuboid(0.49, 0.0),
Expand All @@ -219,15 +219,15 @@ fn setup_player(
0.99, 0.0,
)));
}),
("Flat (exact)", |mut cmd| {
("Flat (exact)", |_cmd| {
#[cfg(feature = "rapier2d")]
cmd.insert(TnuaRapier2dSensorShape(
bevy_rapier2d::parry::shape::SharedShape::cuboid(0.5, 0.0),
));
#[cfg(feature = "avian2d")]
cmd.insert(TnuaAvian2dSensorShape(avian::Collider::rectangle(1.0, 0.0)));
}),
("flat (overfit)", |mut cmd| {
("flat (overfit)", |_cmd| {
#[cfg(feature = "rapier2d")]
cmd.insert(TnuaRapier2dSensorShape(
bevy_rapier2d::parry::shape::SharedShape::cuboid(0.51, 0.0),
Expand All @@ -237,15 +237,15 @@ fn setup_player(
1.01, 0.0,
)));
}),
("Ball (underfit)", |mut cmd| {
("Ball (underfit)", |_cmd| {
#[cfg(feature = "rapier2d")]
cmd.insert(TnuaRapier2dSensorShape(
bevy_rapier2d::parry::shape::SharedShape::ball(0.49),
));
#[cfg(feature = "avian2d")]
cmd.insert(TnuaAvian2dSensorShape(avian::Collider::circle(0.49)));
}),
("Ball (exact)", |mut cmd| {
("Ball (exact)", |_cmd| {
#[cfg(feature = "rapier2d")]
cmd.insert(TnuaRapier2dSensorShape(
bevy_rapier2d::parry::shape::SharedShape::ball(0.5),
Expand All @@ -255,7 +255,7 @@ fn setup_player(
}),
],
)
.with_checkbox("Lock Tilt", false, |mut cmd, lock_tilt| {
.with_checkbox("Lock Tilt", false, |_cmd, lock_tilt| {
// Tnua will automatically apply angular impulses/forces to fix the tilt and make
// the character stand upward, but it is also possible to just let the physics
// engine prevent rotation (other than around the Y axis, for turning)
Expand All @@ -274,7 +274,7 @@ fn setup_player(
.with_checkbox(
"Phase Through Collision Groups",
true,
|mut cmd, use_collision_groups| {
|_cmd, _use_collision_groups| {
#[cfg(feature = "rapier2d")]
if use_collision_groups {
cmd.insert(CollisionGroups {
Expand Down
20 changes: 10 additions & 10 deletions demos/src/bin/platformer_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn setup_camera_and_lights(mut commands: Commands) {
commands.spawn((
DirectionalLight {
illuminance: 4000.0,
shadows_enabled: true,
shadow_maps_enabled: true,
..Default::default()
},
Transform::default().looking_at(-Vec3::Y, Vec3::Z),
Expand Down Expand Up @@ -165,7 +165,7 @@ fn setup_player(
mut control_scheme_config_assets: ResMut<Assets<DemoControlSchemeConfig>>,
) {
let mut cmd = commands.spawn(IsPlayer);
cmd.insert(SceneRoot(asset_server.load("player.glb#Scene0")));
cmd.insert(WorldAssetRoot(asset_server.load("player.glb#Scene0")));
cmd.insert(GltfSceneHandler {
names_from: asset_server.load("player.glb"),
});
Expand Down Expand Up @@ -231,45 +231,45 @@ fn setup_player(
"Sensor Shape",
1,
&[
("no", |mut cmd| {
("no", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.remove::<TnuaRapier3dSensorShape>();
#[cfg(feature = "avian3d")]
cmd.remove::<TnuaAvian3dSensorShape>();
}),
("flat (underfit)", |mut cmd| {
("flat (underfit)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::cylinder(0.0, 0.49),
));
#[cfg(feature = "avian3d")]
cmd.insert(TnuaAvian3dSensorShape(avian::Collider::cylinder(0.49, 0.0)));
}),
("flat (exact)", |mut cmd| {
("flat (exact)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::cylinder(0.0, 0.5),
));
#[cfg(feature = "avian3d")]
cmd.insert(TnuaAvian3dSensorShape(avian::Collider::cylinder(0.5, 0.0)));
}),
("flat (overfit)", |mut cmd| {
("flat (overfit)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::cylinder(0.0, 0.51),
));
#[cfg(feature = "avian3d")]
cmd.insert(TnuaAvian3dSensorShape(avian::Collider::cylinder(0.51, 0.0)));
}),
("ball (underfit)", |mut cmd| {
("ball (underfit)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::ball(0.49),
));
#[cfg(feature = "avian3d")]
cmd.insert(TnuaAvian3dSensorShape(avian::Collider::sphere(0.49)));
}),
("ball (exact)", |mut cmd| {
("ball (exact)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::ball(0.5),
Expand All @@ -279,7 +279,7 @@ fn setup_player(
}),
],
)
.with_checkbox("Lock Tilt", true, |mut cmd, lock_tilt| {
.with_checkbox("Lock Tilt", true, |cmd, lock_tilt| {
// Tnua will automatically apply angular impulses/forces to fix the tilt and make
// the character stand upward, but it is also possible to just let the physics
// engine prevent rotation (other than around the Y axis, for turning)
Expand All @@ -301,7 +301,7 @@ fn setup_player(
.with_checkbox(
"Phase Through Collision Groups",
true,
|mut cmd, use_collision_groups| {
|cmd, use_collision_groups| {
#[cfg(feature = "rapier3d")]
if use_collision_groups {
cmd.insert(CollisionGroups {
Expand Down
22 changes: 11 additions & 11 deletions demos/src/bin/shooter_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn setup_camera_and_lights(mut commands: Commands) {
commands.spawn((
DirectionalLight {
illuminance: 4000.0,
shadows_enabled: true,
shadow_maps_enabled: true,
..Default::default()
},
Transform::default().looking_at(-Vec3::Y, Vec3::Z),
Expand All @@ -166,7 +166,7 @@ fn setup_player(
mut control_scheme_config_assets: ResMut<Assets<DemoControlSchemeConfig>>,
) {
let mut cmd = commands.spawn(IsPlayer);
cmd.insert(SceneRoot(asset_server.load("player.glb#Scene0")));
cmd.insert(WorldAssetRoot(asset_server.load("player.glb#Scene0")));
cmd.insert(GltfSceneHandler {
names_from: asset_server.load("player.glb"),
});
Expand Down Expand Up @@ -231,45 +231,45 @@ fn setup_player(
"Sensor Shape",
1,
&[
("no", |mut cmd| {
("no", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.remove::<TnuaRapier3dSensorShape>();
#[cfg(feature = "avian3d")]
cmd.remove::<TnuaAvian3dSensorShape>();
}),
("flat (underfit)", |mut cmd| {
("flat (underfit)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::cylinder(0.0, 0.49),
));
#[cfg(feature = "avian3d")]
cmd.insert(TnuaAvian3dSensorShape(avian::Collider::cylinder(0.49, 0.0)));
}),
("flat (exact)", |mut cmd| {
("flat (exact)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::cylinder(0.0, 0.5),
));
#[cfg(feature = "avian3d")]
cmd.insert(TnuaAvian3dSensorShape(avian::Collider::cylinder(0.5, 0.0)));
}),
("flat (overfit)", |mut cmd| {
("flat (overfit)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::cylinder(0.0, 0.51),
));
#[cfg(feature = "avian3d")]
cmd.insert(TnuaAvian3dSensorShape(avian::Collider::cylinder(0.51, 0.0)));
}),
("ball (underfit)", |mut cmd| {
("ball (underfit)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::ball(0.49),
));
#[cfg(feature = "avian3d")]
cmd.insert(TnuaAvian3dSensorShape(avian::Collider::sphere(0.49)));
}),
("ball (exact)", |mut cmd| {
("ball (exact)", |cmd| {
#[cfg(feature = "rapier3d")]
cmd.insert(TnuaRapier3dSensorShape(
bevy_rapier3d::parry::shape::SharedShape::ball(0.5),
Expand All @@ -279,7 +279,7 @@ fn setup_player(
}),
],
)
.with_checkbox("Lock Tilt", false, |mut cmd, lock_tilt| {
.with_checkbox("Lock Tilt", false, |cmd, lock_tilt| {
// Tnua will automatically apply angular impulses/forces to fix the tilt and make
// the character stand upward, but it is also possible to just let the physics
// engine prevent rotation (other than around the Y axis, for turning)
Expand All @@ -301,7 +301,7 @@ fn setup_player(
.with_checkbox(
"Phase Through Collision Groups",
true,
|mut cmd, use_collision_groups| {
|cmd, use_collision_groups| {
#[cfg(feature = "rapier3d")]
if use_collision_groups {
cmd.insert(CollisionGroups {
Expand Down Expand Up @@ -381,7 +381,7 @@ fn grab_ungrab_mouse(
if cursor_options.visible {
if mouse_buttons.just_pressed(MouseButton::Left) {
#[cfg(feature = "egui")]
if egui_context.ctx_mut().unwrap().is_pointer_over_area() {
if egui_context.ctx_mut().unwrap().is_pointer_over_egui() {
return;
}
cursor_options.grab_mode = CursorGrabMode::Locked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn apply_platformer_controls(
ghost_sensors_query: Query<&TnuaGhostSensor>,
) {
#[cfg(feature = "egui")]
if egui_context.ctx_mut().unwrap().wants_keyboard_input() {
if egui_context.ctx_mut().unwrap().egui_wants_keyboard_input() {
for (mut controller, ..) in query.iter_mut() {
// The basis remembers its last frame status, so if we cannot feed it proper input this
// frame (for example - because the GUI takes the input focus) we need to neutralize
Expand Down
Loading
Loading