From 051196257924f948ca7f728ce8ded22cbf8c4157 Mon Sep 17 00:00:00 2001 From: hacknus Date: Tue, 29 Apr 2025 00:48:41 +0200 Subject: [PATCH 1/4] update to bevy 0.16 --- Cargo.toml | 6 +++--- README.md | 4 ++-- examples/bevy_egui.rs | 11 ++++++----- examples/bevy_pan_orbit_camera.rs | 1 + examples/bevy_pointcloud_bunny.rs | 5 ++++- src/bevy_voxel_plot.rs | 10 ++++++---- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7f1f726..356eb91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,9 @@ homepage = "https://github.com/hacknus/bevy_voxel_plot" license = "Apache-2.0" [dependencies] -bevy = "0.15.3" +bevy = "0.16" bytemuck = "1.22.0" [dev-dependencies] -bevy_panorbit_camera = { version = "0.22.0" } -bevy_egui = { version = "0.33" } +bevy_panorbit_camera = { version = "0.26" } +bevy_egui = { version = "0.34" } diff --git a/README.md b/README.md index b2f4427..04ad618 100644 --- a/README.md +++ b/README.md @@ -33,14 +33,14 @@ texture, implemented with the `bevy_egui` crate. - Bevy Pointcloud Bunny -Load the test file `bunny.pcd` from [pcl](https://github.com/PointCloudLibrary/pc) and display it as white voxels with +Load the test file `bunny.pcd` from [pcl](https://github.com/PointCloudLibrary/pc) and display it as colorful voxels with low alpha. ## Version Compatibility | bevy | bevy_voxel_plot | |------|-----------------| -| 0.16 | TBD | +| 0.16 | 2.0 | | 0.15 | 0.1 | ## Credits diff --git a/examples/bevy_egui.rs b/examples/bevy_egui.rs index a7bf948..6c329b7 100644 --- a/examples/bevy_egui.rs +++ b/examples/bevy_egui.rs @@ -8,7 +8,7 @@ use bevy::prelude::{ DetectChangesMut, Handle, Image, Mesh, Mesh3d, Query, Res, ResMut, Resource, Transform, Update, Window, With, }; -use bevy::render::camera::RenderTarget; +use bevy::render::camera::{ImageRenderTarget, RenderTarget}; use bevy::render::render_resource::{ Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, }; @@ -119,6 +119,7 @@ fn voxel_plot_setup( commands.insert_resource(AmbientLight { color: Color::WHITE, brightness: 2.0, // Increase this to wash out shadows + affects_lightmapped_meshes: false, }); let size = Extent3d { @@ -160,7 +161,7 @@ fn voxel_plot_setup( // render before the "main pass" camera clear_color: ClearColorConfig::Custom(Color::srgba(1.0, 1.0, 1.0, 0.0)), order: -1, - target: RenderTarget::Image(image_handle.clone()), + target: RenderTarget::Image(ImageRenderTarget::from(image_handle.clone())), ..default() }, Transform::from_translation(Vec3::new(0.0, -150.0, 15.0)) @@ -175,7 +176,7 @@ fn voxel_plot_setup( // Note: you probably want to update the `viewport_size` and `window_size` whenever they change, // I haven't done this here for simplicity. let primary_window = windows - .get_single() + .single() .expect("There is only ever one primary window"); active_cam.set_if_neq(ActiveCameraData { // Set the entity to the entity ID of the camera you want to control. In this case, it's @@ -277,7 +278,7 @@ fn show_plot( .add(egui::Slider::new(&mut opacity_threshold.0, 0.01..=1.0).text("Opacity Threshold")) .changed() { - if let Ok((mut instance_data, mut mesh3d)) = query.get_single_mut() { + if let Ok((mut instance_data, mut mesh3d)) = query.single_mut() { instance_data.instances = instances; mesh3d.0 = new_mesh; instance_data @@ -291,7 +292,7 @@ fn main() { App::new() .add_plugins(( DefaultPlugins, - EguiPlugin, + EguiPlugin { enable_multipass_for_primary_context: false }, VoxelMaterialPlugin, PanOrbitCameraPlugin, )) diff --git a/examples/bevy_pan_orbit_camera.rs b/examples/bevy_pan_orbit_camera.rs index bcd577c..e1bdf4d 100644 --- a/examples/bevy_pan_orbit_camera.rs +++ b/examples/bevy_pan_orbit_camera.rs @@ -92,6 +92,7 @@ fn voxel_plot_setup(mut commands: Commands, mut meshes: ResMut>) { commands.insert_resource(AmbientLight { color: Color::WHITE, brightness: 2.0, // Increase this to wash out shadows + affects_lightmapped_meshes: false, }); // camera diff --git a/examples/bevy_pointcloud_bunny.rs b/examples/bevy_pointcloud_bunny.rs index d2613a6..41907e8 100644 --- a/examples/bevy_pointcloud_bunny.rs +++ b/examples/bevy_pointcloud_bunny.rs @@ -49,9 +49,11 @@ fn load_pcd_file(path: &Path) -> (Vec, f32, f32, f32) { let y: f32 = parts[1].parse().unwrap_or(0.0); let z: f32 = parts[2].parse().unwrap_or(0.0); + let (r,g,b) = jet_colormap(z*10.0); + let instance = InstanceData { pos_scale: [x, y, z, 1.0], // position + uniform scale - color: LinearRgba::from(Color::srgba(1.0, 1.0, 1.0, 0.01)).to_f32_array(), // you can set color later if needed + color: LinearRgba::from(Color::srgba(r,g,b, 0.01)).to_f32_array(), // you can set color later if needed }; instances.push(instance); @@ -106,6 +108,7 @@ fn voxel_plot_setup(mut commands: Commands, mut meshes: ResMut>) { commands.insert_resource(AmbientLight { color: Color::WHITE, brightness: 2.0, // Increase this to wash out shadows + affects_lightmapped_meshes: false, }); // camera diff --git a/src/bevy_voxel_plot.rs b/src/bevy_voxel_plot.rs index 991e897..61960ea 100644 --- a/src/bevy_voxel_plot.rs +++ b/src/bevy_voxel_plot.rs @@ -102,12 +102,13 @@ fn queue_custom( render_mesh_instances: Res, material_meshes: Query<(Entity, &MainEntity), With>, mut transparent_render_phases: ResMut>, - views: Query<(Entity, &ExtractedView, &Msaa)>, + views: Query<(&ExtractedView, &Msaa)>, ) { let draw_custom = transparent_3d_draw_functions.read().id::(); - for (view_entity, view, msaa) in &views { - let Some(transparent_phase) = transparent_render_phases.get_mut(&view_entity) else { + for (view, msaa) in &views { + let Some(transparent_phase) = transparent_render_phases.get_mut(&view.retained_view_entity) + else { continue; }; @@ -135,7 +136,8 @@ fn queue_custom( draw_function: draw_custom, distance: rangefinder.distance_translation(&mesh_instance.translation), batch_range: 0..1, - extra_index: PhaseItemExtraIndex::NONE, + extra_index: PhaseItemExtraIndex::None, + indexed: false, }); } } From 7b295807d29f811e51d1ae53e3bc1d5d396c1f92 Mon Sep 17 00:00:00 2001 From: hacknus Date: Tue, 29 Apr 2025 00:50:03 +0200 Subject: [PATCH 2/4] bump to version 2.0.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 356eb91..3ed54d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_voxel_plot" -version = "1.0.0" +version = "2.0.0" edition = "2021" authors = ["Linus Leo Stöckli"] repository = "https://github.com/hacknus/bevy_voxel_plot" From c9d47efe1778b3872a02c41350862fae928587a7 Mon Sep 17 00:00:00 2001 From: hacknus Date: Tue, 29 Apr 2025 01:58:35 +0200 Subject: [PATCH 3/4] update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 4fffb2f..910c172 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /target /Cargo.lock +.DS_Store +./.idea \ No newline at end of file From e1405317864270dcea675f77e3acc1b2ab35c054 Mon Sep 17 00:00:00 2001 From: hacknus Date: Tue, 29 Apr 2025 01:59:01 +0200 Subject: [PATCH 4/4] update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 910c172..29690e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /target /Cargo.lock .DS_Store -./.idea \ No newline at end of file +/.idea \ No newline at end of file