diff --git a/Cargo.toml b/Cargo.toml index 7f1f726..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" @@ -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 e28be1c..8a848a8 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 | 1.0 | ## 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, }); } }