Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Implement `Reflect` for `RaycastMesh`, `RaycastSource`, and `RaycastMethod`.
- Fix raycasting for non-indexed meshes.
- Update to bevy 0.10.

# 0.7.0

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ categories = ["game-engines", "rendering"]
resolver = "2"

[dependencies]
bevy = { version = "0.9", default-features = false, features = [
bevy = { version = "0.10", default-features = false, features = [
"bevy_render",
"bevy_asset",
] }

[dev-dependencies]
bevy = { version = "0.9", default-features = false, features = [
bevy = { version = "0.10", default-features = false, features = [
"bevy_pbr",
"bevy_winit",
"bevy_ui",
Expand Down
13 changes: 7 additions & 6 deletions examples/bounding_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@ use bevy_mod_raycast::{
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
primary_window: Some(Window {
present_mode: PresentMode::AutoNoVsync,
..default()
},
}),
..default()
}))
.add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(DefaultRaycastingPlugin::<MyRaycastSet>::default())
// You will need to pay attention to what order you add systems! Putting them in the wrong
// order can result in multiple frames of latency. Ray casting should probably happen after
// the positions of your meshes have been updated in the UPDATE stage.
.add_system_to_stage(
CoreStage::First,
update_raycast_with_cursor.before(RaycastSystem::BuildRays::<MyRaycastSet>),
.add_system(
update_raycast_with_cursor
.before(RaycastSystem::BuildRays::<MyRaycastSet>)
.in_base_set(CoreSet::First),
)
.add_startup_system(setup_scene)
.add_startup_system(setup_ui)
.add_system(update_fps)
.add_system(make_scene_pickable)
.add_system_to_stage(CoreStage::First, manage_aabb)
.add_system(manage_aabb.in_base_set(CoreSet::First))
.run();
}

Expand Down
6 changes: 3 additions & 3 deletions examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn setup(
));
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Icosphere::default())),
mesh: meshes.add(Mesh::try_from(shape::Icosphere::default()).unwrap()),
material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, -5.0)),
..Default::default()
Expand Down Expand Up @@ -81,8 +81,8 @@ fn intersection(query: Query<&Intersection<MyRaycastSet>>) {
fn rotator(time: Res<Time>, mut query: Query<&mut Transform, With<RaycastSource<MyRaycastSet>>>) {
for mut transform in &mut query {
*transform = Transform::from_rotation(
Quat::from_rotation_x(time.elapsed_seconds().sin() as f32 * 0.2)
* Quat::from_rotation_y((time.elapsed_seconds() * 1.5).sin() as f32 * 0.1),
Quat::from_rotation_x(time.elapsed_seconds().sin() * 0.2)
* Quat::from_rotation_y((time.elapsed_seconds() * 1.5).sin() * 0.1),
);
}
}
13 changes: 7 additions & 6 deletions examples/mouse_picking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use bevy_mod_raycast::{
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
primary_window: Some(Window {
present_mode: PresentMode::AutoNoVsync, // Reduces input lag.
..default()
},
}),
..default()
}))
// The DefaultRaycastingPlugin bundles all the functionality you might need into a single
Expand All @@ -28,9 +28,10 @@ fn main() {
// start of the frame. For example, we want to be sure this system runs before we construct
// any rays, hence the ".before(...)". You can use these provided RaycastSystem labels to
// order your systems with the ones provided by the raycasting plugin.
.add_system_to_stage(
CoreStage::First,
update_raycast_with_cursor.before(RaycastSystem::BuildRays::<MyRaycastSet>),
.add_system(
update_raycast_with_cursor
.in_base_set(CoreSet::First)
.before(RaycastSystem::BuildRays::<MyRaycastSet>),
)
.add_startup_system(setup)
.run();
Expand Down Expand Up @@ -76,7 +77,7 @@ fn setup(
.insert(RaycastSource::<MyRaycastSet>::new()); // Designate the camera as our source
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Icosphere::default())),
mesh: meshes.add(Mesh::try_from(shape::Icosphere::default()).unwrap()),
material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()),
..Default::default()
})
Expand Down
7 changes: 4 additions & 3 deletions examples/mouse_picking_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(DefaultRaycastingPlugin::<MyRaycastSet>::default())
.add_system_to_stage(
CoreStage::First,
update_raycast_with_cursor.before(RaycastSystem::BuildRays::<MyRaycastSet>),
.add_system(
update_raycast_with_cursor
.in_base_set(CoreSet::First)
.before(RaycastSystem::BuildRays::<MyRaycastSet>),
)
.add_system(intersection)
.add_startup_system(setup)
Expand Down
21 changes: 11 additions & 10 deletions examples/ray_intersection_over_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ use bevy_mod_raycast::{
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
primary_window: Some(Window {
present_mode: PresentMode::AutoNoVsync, // Reduces input latency
..default()
},
}),
..default()
}))
.add_plugin(DefaultRaycastingPlugin::<Ground>::default())
.add_startup_system(setup)
.add_startup_system(setup_ui)
.add_system_to_stage(
CoreStage::First,
update_raycast_with_cursor.before(RaycastSystem::BuildRays::<Ground>),
.add_system(
update_raycast_with_cursor
.before(RaycastSystem::BuildRays::<Ground>)
.in_base_set(CoreSet::First),
)
.add_system(check_path)
.add_system(move_origin)
Expand Down Expand Up @@ -122,7 +123,7 @@ fn setup(
// Spawn a plane that will represent the ground. It will be used to pick the mouse location in 3D space
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: 500.0 })),
mesh: meshes.add(Mesh::from(shape::Plane::from_size(500.0))),
material: materials.add(Color::DARK_GRAY.into()),
..Default::default()
})
Expand Down Expand Up @@ -171,14 +172,14 @@ fn setup(
// Spawn the intersection point, invisible by default until there is an intersection
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Icosphere::default())),
mesh: meshes.add(Mesh::try_from(shape::Icosphere::default()).unwrap()),
material: materials.add(StandardMaterial {
unlit: true,
base_color: Color::RED,
..Default::default()
}),
transform: Transform::from_scale(Vec3::splat(0.1)),
visibility: Visibility { is_visible: false },
visibility: Visibility::Hidden,
..Default::default()
})
.insert(PathObstaclePoint);
Expand Down Expand Up @@ -272,7 +273,7 @@ fn check_path(
// Set everything as OK in case there are no obstacle in path
text.sections[1].value = "Direct!".to_string();
text.sections[1].style.color = Color::GREEN;
visible.is_visible = false;
*visible = Visibility::Hidden;

let mut closest_hit = f32::MAX;

Expand All @@ -296,7 +297,7 @@ fn check_path(
text.sections[1].value = "Obstructed!".to_string();
text.sections[1].style.color = Color::RED;
intersection_transform.translation = intersection.position();
visible.is_visible = true;
*visible = Visibility::Inherited;
closest_hit = hit_distance;
}
}
Expand Down
11 changes: 6 additions & 5 deletions examples/simplified_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ use bevy_mod_raycast::{
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
primary_window: Some(Window {
present_mode: PresentMode::AutoNoVsync, // Reduces input lag.
..Default::default()
},
}),
..default()
}))
.add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(DefaultRaycastingPlugin::<MyRaycastSet>::default())
// You will need to pay attention to what order you add systems! Putting them in the wrong
// order can result in multiple frames of latency. Ray casting should probably happen after
// the positions of your meshes have been updated in the UPDATE stage.
.add_system_to_stage(
CoreStage::First,
update_raycast_with_cursor_position.before(RaycastSystem::BuildRays::<MyRaycastSet>),
.add_system(
update_raycast_with_cursor_position
.before(RaycastSystem::BuildRays::<MyRaycastSet>)
.in_base_set(CoreSet::First),
)
.add_startup_system(setup_scene)
.add_startup_system(setup_ui)
Expand Down
Loading