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

Update to Bevy 0.9 #168

Merged
merged 4 commits into from
Nov 13, 2022
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
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ categories = ["game-engines", "rendering"]
resolver = "2"

[dependencies]
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = [
"render",
] }
bevy = { version = "0.9", default-features = false, features = ["render"] }

bevy_mod_raycast = { git = "https://github.com/aevyrie/bevy_mod_raycast", branch = "main", default-features = false }
bevy_mod_raycast = "0.7"

[dev-dependencies]
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = [
bevy = { version = "0.9", default-features = false, features = [
"bevy_pbr",
"bevy_winit",
"bevy_ui",
Expand Down
58 changes: 32 additions & 26 deletions examples/deselection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ use bevy_mod_picking::{DefaultPickingPlugins, NoDeselect, PickableBundle, Pickin
/// clicked on, won't deselect everything else you have selected.
fn main() {
App::new()
.insert_resource(WindowDescriptor {
present_mode: PresentMode::AutoNoVsync, // Reduce input latency
..Default::default()
})
.add_plugins(DefaultPlugins)
.add_plugins(DefaultPickingPlugins) // <- Adds Picking, Interaction, and Highlighting plugins.
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
present_mode: PresentMode::AutoNoVsync, // Reduce input latency
..default()
},
..default()
}))
.add_plugins(DefaultPickingPlugins) // <- Adds picking, interaction, and highlighting
.add_startup_system(setup)
.run();
}
Expand All @@ -22,35 +24,38 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// plane
commands
.spawn_bundle(PbrBundle {
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..Default::default()
})
.insert_bundle(PickableBundle::default());
},
PickableBundle::default(),
));

// cube
commands
.spawn_bundle(PbrBundle {
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
material: materials.add(Color::rgb(0.0, 0.7, 0.6).into()),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
})
.insert_bundle(PickableBundle::default());
},
PickableBundle::default(),
));
// cube with NoDeselect
commands
.spawn_bundle(PbrBundle {
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
material: materials.add(Color::rgb(1.8, 0.7, 0.6).into()),
transform: Transform::from_xyz(1.5, 0.5, 0.0),
..Default::default()
})
.insert_bundle(PickableBundle::default())
.insert(NoDeselect);
},
PickableBundle::default(),
NoDeselect,
));
// light
commands.spawn_bundle(PointLightBundle {
commands.spawn(PointLightBundle {
transform: Transform::from_xyz(4.0, 8.0, 4.0),
point_light: PointLight {
intensity: 1500.0,
Expand All @@ -60,10 +65,11 @@ fn setup(
..Default::default()
});
// camera
commands
.spawn_bundle(Camera3dBundle {
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
})
.insert_bundle(PickingCameraBundle::default());
},
PickingCameraBundle::default(),
));
}
32 changes: 18 additions & 14 deletions examples/events.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use bevy::prelude::*;

use bevy_mod_picking::{DefaultPickingPlugins, PickableBundle, PickingCameraBundle, PickingEvent};

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(DefaultPickingPlugins) // <- Adds Picking, Interaction, and Highlighting plugins.
.add_plugins(DefaultPickingPlugins) // <- Adds picking, interaction, and highlighting
.add_startup_system(setup)
.add_system_to_stage(CoreStage::PostUpdate, print_events)
.run();
Expand All @@ -25,22 +26,24 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands
.spawn_bundle(PbrBundle {
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..Default::default()
})
.insert_bundle(PickableBundle::default()); // <- Makes the mesh pickable.
commands
.spawn_bundle(PbrBundle {
},
PickableBundle::default(), // <- Makes the mesh pickable.
));
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
})
.insert_bundle(PickableBundle::default()); // <- Makes the mesh pickable.
commands.spawn_bundle(PointLightBundle {
},
PickableBundle::default(), // <- Makes the mesh pickable.
));
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
Expand All @@ -49,10 +52,11 @@ fn setup(
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..Default::default()
});
commands
.spawn_bundle(Camera3dBundle {
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
})
.insert_bundle(PickingCameraBundle::default()); // <- Sets the camera to use for picking.
},
PickingCameraBundle::default(), // <- Sets the camera to use for picking.
));
}
52 changes: 27 additions & 25 deletions examples/minimal.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
use bevy::{prelude::*, window::PresentMode};

use bevy_mod_picking::{
DebugCursorPickingPlugin, DebugEventsPickingPlugin, DefaultPickingPlugins, PickableBundle,
PickingCameraBundle,
};

fn main() {
App::new()
.insert_resource(WindowDescriptor {
present_mode: PresentMode::AutoNoVsync, // Reduce input latency
..Default::default()
})
.add_plugins(DefaultPlugins)
.add_plugins(DefaultPickingPlugins) // <- Adds Picking, Interaction, and Highlighting plugins.
.add_plugin(DebugCursorPickingPlugin) // <- Adds the green debug cursor.
.add_plugin(DebugEventsPickingPlugin) // <- Adds debug event logging.
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
present_mode: PresentMode::AutoNoVsync, // Reduce input latency
..default()
},
..default()
}))
.add_plugins(DefaultPickingPlugins) // <- Adds picking, interaction, and highlighting
.add_plugin(DebugCursorPickingPlugin) // <- Adds the debug cursor (optional)
.add_plugin(DebugEventsPickingPlugin) // <- Adds debug event logging (optional)
.add_startup_system(setup)
.run();
}
Expand All @@ -24,25 +27,24 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// plane
commands
.spawn_bundle(PbrBundle {
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..Default::default()
})
.insert_bundle(PickableBundle::default()); // <- Makes the mesh pickable.
// cube
commands
.spawn_bundle(PbrBundle {
},
PickableBundle::default(), // <- Makes the mesh pickable.
));
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
})
.insert_bundle(PickableBundle::default()); // <- Makes the mesh pickable.
// light
commands.spawn_bundle(PointLightBundle {
},
PickableBundle::default(), // <- Makes the mesh pickable.
));
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
Expand All @@ -51,11 +53,11 @@ fn setup(
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..Default::default()
});
// camera
commands
.spawn_bundle(Camera3dBundle {
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
})
.insert_bundle(PickingCameraBundle::default()); // <- Sets the camera to use for picking.
},
PickingCameraBundle::default(), // <- Sets the camera to use for picking.
));
}
19 changes: 10 additions & 9 deletions examples/minimal_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy_mod_picking::{
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(DefaultPickingPlugins) // <- Adds Picking, Interaction, and Highlighting plugins.
.add_plugins(DefaultPickingPlugins) // <- Adds picking, interaction, and highlighting
.add_plugin(DebugEventsPickingPlugin) // <- Adds debug event logging.
.add_startup_system(setup)
.run();
Expand All @@ -18,16 +18,17 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
commands
.spawn_bundle(MaterialMesh2dBundle {
commands.spawn((
MaterialMesh2dBundle {
mesh: meshes.add(Mesh::from(shape::Quad::default())).into(),
transform: Transform::default().with_scale(Vec3::splat(128.)),
material: materials.add(ColorMaterial::from(Color::PURPLE)),
..default()
})
.insert_bundle(PickableBundle::default()); // <- Makes the mesh pickable.
// camera
commands
.spawn_bundle(Camera2dBundle::default())
.insert_bundle(PickingCameraBundle::default()); // <- Sets the camera to use for picking.
},
PickableBundle::default(), // <- Makes the mesh pickable.
));
// camera
commands.spawn(
(Camera2dBundle::default(), PickingCameraBundle::default()), // <- Sets the camera to use for picking.
);
}
40 changes: 22 additions & 18 deletions examples/stress_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ use bevy_mod_picking::*;

fn main() {
App::new()
.insert_resource(WindowDescriptor {
title: "bevy_mod_picking stress test".to_string(),
width: 800.,
height: 600.,
present_mode: PresentMode::AutoNoVsync, // Reduce input latency
..Default::default()
})
.add_plugins(DefaultPlugins)
.add_plugins(DefaultPickingPlugins) // <- Adds Picking, Interaction, and Highlighting plugins.
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
title: "bevy_mod_picking stress test".to_string(),
width: 800.,
height: 600.,
present_mode: PresentMode::AutoNoVsync, // Reduce input latency
..default()
},
..default()
}))
.add_plugins(DefaultPickingPlugins) // <- Adds picking, interaction, and highlighting
.add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(LogDiagnosticsPlugin::default())
.add_startup_system(setup)
Expand Down Expand Up @@ -47,20 +49,21 @@ fn setup(
});

// Camera
commands
.spawn_bundle(Camera3dBundle {
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(half_width as f32, half_width as f32, half_width as f32)
.looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
})
.insert_bundle(PickingCameraBundle::default());
},
PickingCameraBundle::default(),
));

// Spawn a cube of spheres.
for x in -half_width..half_width {
for y in -half_width..half_width {
for z in -half_width..half_width {
commands
.spawn_bundle(PbrBundle {
commands.spawn((
PbrBundle {
mesh: mesh_handle.clone(),
material: matl_handle.clone(),
transform: Transform::from_translation(Vec3::new(
Expand All @@ -69,14 +72,15 @@ fn setup(
z as f32,
)),
..Default::default()
})
.insert_bundle(PickableBundle::default());
},
PickableBundle::default(),
));
}
}
}

// Light
commands.spawn_bundle(PointLightBundle {
commands.spawn(PointLightBundle {
transform: Transform::from_xyz(half_width as f32, half_width as f32, half_width as f32),
point_light: PointLight {
intensity: 2500.0,
Expand Down
Loading