Skip to content

Update to bevy 0.16 #1

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

Merged
merged 5 commits into from
Apr 29, 2025
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: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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" }
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions examples/bevy_egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -291,7 +292,7 @@ fn main() {
App::new()
.add_plugins((
DefaultPlugins,
EguiPlugin,
EguiPlugin { enable_multipass_for_primary_context: false },
VoxelMaterialPlugin,
PanOrbitCameraPlugin,
))
Expand Down
1 change: 1 addition & 0 deletions examples/bevy_pan_orbit_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ fn voxel_plot_setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
commands.insert_resource(AmbientLight {
color: Color::WHITE,
brightness: 2.0, // Increase this to wash out shadows
affects_lightmapped_meshes: false,
});

// camera
Expand Down
5 changes: 4 additions & 1 deletion examples/bevy_pointcloud_bunny.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ fn load_pcd_file(path: &Path) -> (Vec<InstanceData>, 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);
Expand Down Expand Up @@ -106,6 +108,7 @@ fn voxel_plot_setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
commands.insert_resource(AmbientLight {
color: Color::WHITE,
brightness: 2.0, // Increase this to wash out shadows
affects_lightmapped_meshes: false,
});

// camera
Expand Down
10 changes: 6 additions & 4 deletions src/bevy_voxel_plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ fn queue_custom(
render_mesh_instances: Res<RenderMeshInstances>,
material_meshes: Query<(Entity, &MainEntity), With<InstanceMaterialData>>,
mut transparent_render_phases: ResMut<ViewSortedRenderPhases<Transparent3d>>,
views: Query<(Entity, &ExtractedView, &Msaa)>,
views: Query<(&ExtractedView, &Msaa)>,
) {
let draw_custom = transparent_3d_draw_functions.read().id::<DrawCustom>();

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;
};

Expand Down Expand Up @@ -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,
});
}
}
Expand Down