Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bevy 0.14 #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 8 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ debug_lines = []
rapier = ["bevy_rapier3d"]

[dependencies]
bevy = { version = "0.11", default-features = false, features = [
bevy = { version = "0.14", default-features = false, features = [
"bevy_render",
"bevy_gizmos",
] }
bevy_rapier3d = { version = "0.22", default-features = false, features = [
bevy_rapier3d = { version = "0.27", default-features = false, features = [
"async-collider",
"dim3",
], optional = true }

[dev-dependencies]
bevy = "0.11"
aether_spyglass = "0.2"
bevy-inspector-egui = "0.19"
bevy_framepace = "0.13"
bevy_rapier3d = { version = "0.22", features = ["debug-render"] }
bevy = "0.14"
#aether_spyglass = "0.2"
bevy-inspector-egui = "0.25"
bevy_framepace = "0.17"
bevy_rapier3d = { version = "0.27", features = ["debug-render"] }

# Enable a small amount of optimization in debug mode
[profile.dev]
Expand All @@ -43,5 +43,4 @@ opt-level = 1
opt-level = 3

[patch.crates-io]
#bevy_rapier3d = { path = "../bevy_rapier/bevy_rapier3d" }
bevy_rapier3d = { git = "https://github.com/dimforge/bevy_rapier", rev = "0ea000b" }
#bevy_rapier3d = { path = "../bevy_rapier/bevy_rapier3d" }
86 changes: 32 additions & 54 deletions examples/first_person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use bevy::render::camera::Projection;
use bevy::window::CursorGrabMode;
use bevy::{
color::palettes::css,
input::mouse::MouseMotion,
prelude::*,
window::{Cursor, PrimaryWindow},
Expand Down Expand Up @@ -30,19 +31,19 @@ fn main() {
..default()
}),
RapierPhysicsPlugin::<NoUserData>::default(),
bevy_inspector_egui::quick::WorldInspectorPlugin::default(),
// This plugin was causing unhelpful glitchy orange planes, so it's commented out until
// it's working again
// RapierDebugRenderPlugin::default(),
RapierDebugRenderPlugin::default(),
WanderlustPlugin::default(),
aether_spyglass::SpyglassPlugin,
FramepacePlugin,
))
.insert_resource(RapierConfiguration {
timestep_mode: TimestepMode::Fixed {
dt: 0.008,
substeps: 4,
},
..default()
..RapierConfiguration::new(1.0)
})
.insert_resource(FramepaceSettings {
limiter: Limiter::Manual(std::time::Duration::from_secs_f64(0.008)),
Expand All @@ -58,7 +59,7 @@ fn main() {
toggle_cursor_lock,
),
)
.run()
.run();
}

#[derive(Component, Default, Reflect)]
Expand All @@ -77,16 +78,13 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut mats: ResMut<Assets<StandardMaterial>>,
) {
let mesh = meshes.add(
shape::Capsule {
radius: 0.5,
depth: 1.0,
..default()
}
.into(),
);
let mesh = meshes.add(Capsule3d {
radius: 0.5,
half_length: 0.5,
..default()
});

let material = mats.add(Color::WHITE.into());
let material = mats.add(Color::from(css::WHITE));

commands
.spawn((
Expand Down Expand Up @@ -127,7 +125,9 @@ fn setup(
PlayerCam,
))
.with_children(|commands| {
let mesh = meshes.add(shape::Cube { size: 0.5 }.into());
let mesh = meshes.add(Cuboid {
half_size: Vec3::splat(0.25),
});

commands.spawn(PbrBundle {
mesh,
Expand All @@ -138,13 +138,7 @@ fn setup(
});
});

let mesh = meshes.add(
shape::Plane {
size: 10.0,
..default()
}
.into(),
);
let mesh = meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(5.0)));

commands.spawn((
PbrBundle {
Expand All @@ -163,17 +157,9 @@ fn setup(
});

let (hw, hh, hl) = (1.5, 0.5, 5.0);
let mesh = meshes.add(
shape::Box {
min_x: -hw,
max_x: hw,
min_y: -hh,
max_y: hh,
min_z: -hl,
max_z: hl,
}
.into(),
);
let min = Vec3::new(-hw, -hh, -hl);
let max = Vec3::new(hw, hh, hl);
let mesh = meshes.add(Cuboid::from_corners(min, max));

commands.spawn((
PbrBundle {
Expand All @@ -192,17 +178,9 @@ fn setup(
));

let (hw, hh, hl) = (0.25, 3.0, 5.0);
let mesh = meshes.add(
shape::Box {
min_x: -hw,
max_x: hw,
min_y: -hh,
max_y: hh,
min_z: -hl,
max_z: hl,
}
.into(),
);
let min = Vec3::new(-hw, -hh, -hl);
let max = Vec3::new(hw, hh, hl);
let mesh = meshes.add(Cuboid::from_corners(min, max));

commands.spawn((
PbrBundle {
Expand Down Expand Up @@ -235,24 +213,24 @@ fn setup(
fn movement_input(
mut body: Query<&mut ControllerInput, With<PlayerBody>>,
camera: Query<&GlobalTransform, (With<PlayerCam>, Without<PlayerBody>)>,
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
) {
let tf = camera.single();

let mut player_input = body.single_mut();

let mut dir = Vec3::ZERO;
if input.pressed(KeyCode::A) {
dir += -tf.right();
if input.pressed(KeyCode::KeyA) {
dir += -tf.right().as_vec3();
}
if input.pressed(KeyCode::D) {
dir += tf.right();
if input.pressed(KeyCode::KeyD) {
dir += tf.right().as_vec3();
}
if input.pressed(KeyCode::S) {
dir += -tf.forward();
if input.pressed(KeyCode::KeyS) {
dir += -tf.forward().as_vec3();
}
if input.pressed(KeyCode::W) {
dir += tf.forward();
if input.pressed(KeyCode::KeyW) {
dir += tf.forward().as_vec3();
}
dir.y = 0.0;
player_input.movement = dir.normalize_or_zero();
Expand All @@ -271,7 +249,7 @@ fn mouse_look(

let sens = sensitivity.0;

let mut cumulative: Vec2 = -(input.iter().map(|motion| &motion.delta).sum::<Vec2>());
let mut cumulative: Vec2 = -(input.read().map(|motion| &motion.delta).sum::<Vec2>());

// Vertical
let rot = cam_tf.rotation;
Expand All @@ -295,7 +273,7 @@ fn mouse_look(
}

fn toggle_cursor_lock(
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
mut windows: Query<&mut Window, With<PrimaryWindow>>,
) {
if input.just_pressed(KeyCode::Escape) {
Expand Down
Loading
Loading