Skip to content

Commit faa0e07

Browse files
authored
Merge pull request #1 from hacknus/update_to_bevy_0.16
Update to bevy 0.16
2 parents 397b3d2 + 5d60a3b commit faa0e07

File tree

6 files changed

+23
-16
lines changed

6 files changed

+23
-16
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_voxel_plot"
3-
version = "1.0.0"
3+
version = "2.0.0"
44
edition = "2021"
55
authors = ["Linus Leo Stöckli"]
66
repository = "https://github.com/hacknus/bevy_voxel_plot"
@@ -13,9 +13,9 @@ homepage = "https://github.com/hacknus/bevy_voxel_plot"
1313
license = "Apache-2.0"
1414

1515
[dependencies]
16-
bevy = "0.15.3"
16+
bevy = "0.16"
1717
bytemuck = "1.22.0"
1818

1919
[dev-dependencies]
20-
bevy_panorbit_camera = { version = "0.22.0" }
21-
bevy_egui = { version = "0.33" }
20+
bevy_panorbit_camera = { version = "0.26" }
21+
bevy_egui = { version = "0.34" }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ texture, implemented with the `bevy_egui` crate.
3333

3434
- Bevy Pointcloud Bunny
3535

36-
Load the test file `bunny.pcd` from [pcl](https://github.com/PointCloudLibrary/pc) and display it as white voxels with
36+
Load the test file `bunny.pcd` from [pcl](https://github.com/PointCloudLibrary/pc) and display it as colorful voxels with
3737
low alpha.
3838

3939
## Version Compatibility
4040

4141
| bevy | bevy_voxel_plot |
4242
|------|-----------------|
43-
| 0.16 | TBD |
43+
| 0.16 | 2.0 |
4444
| 0.15 | 1.0 |
4545

4646
## Credits

examples/bevy_egui.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bevy::prelude::{
88
DetectChangesMut, Handle, Image, Mesh, Mesh3d, Query, Res, ResMut, Resource, Transform, Update,
99
Window, With,
1010
};
11-
use bevy::render::camera::RenderTarget;
11+
use bevy::render::camera::{ImageRenderTarget, RenderTarget};
1212
use bevy::render::render_resource::{
1313
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
1414
};
@@ -119,6 +119,7 @@ fn voxel_plot_setup(
119119
commands.insert_resource(AmbientLight {
120120
color: Color::WHITE,
121121
brightness: 2.0, // Increase this to wash out shadows
122+
affects_lightmapped_meshes: false,
122123
});
123124

124125
let size = Extent3d {
@@ -160,7 +161,7 @@ fn voxel_plot_setup(
160161
// render before the "main pass" camera
161162
clear_color: ClearColorConfig::Custom(Color::srgba(1.0, 1.0, 1.0, 0.0)),
162163
order: -1,
163-
target: RenderTarget::Image(image_handle.clone()),
164+
target: RenderTarget::Image(ImageRenderTarget::from(image_handle.clone())),
164165
..default()
165166
},
166167
Transform::from_translation(Vec3::new(0.0, -150.0, 15.0))
@@ -175,7 +176,7 @@ fn voxel_plot_setup(
175176
// Note: you probably want to update the `viewport_size` and `window_size` whenever they change,
176177
// I haven't done this here for simplicity.
177178
let primary_window = windows
178-
.get_single()
179+
.single()
179180
.expect("There is only ever one primary window");
180181
active_cam.set_if_neq(ActiveCameraData {
181182
// 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(
277278
.add(egui::Slider::new(&mut opacity_threshold.0, 0.01..=1.0).text("Opacity Threshold"))
278279
.changed()
279280
{
280-
if let Ok((mut instance_data, mut mesh3d)) = query.get_single_mut() {
281+
if let Ok((mut instance_data, mut mesh3d)) = query.single_mut() {
281282
instance_data.instances = instances;
282283
mesh3d.0 = new_mesh;
283284
instance_data
@@ -291,7 +292,7 @@ fn main() {
291292
App::new()
292293
.add_plugins((
293294
DefaultPlugins,
294-
EguiPlugin,
295+
EguiPlugin { enable_multipass_for_primary_context: false },
295296
VoxelMaterialPlugin,
296297
PanOrbitCameraPlugin,
297298
))

examples/bevy_pan_orbit_camera.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ fn voxel_plot_setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
9292
commands.insert_resource(AmbientLight {
9393
color: Color::WHITE,
9494
brightness: 2.0, // Increase this to wash out shadows
95+
affects_lightmapped_meshes: false,
9596
});
9697

9798
// camera

examples/bevy_pointcloud_bunny.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ fn load_pcd_file(path: &Path) -> (Vec<InstanceData>, f32, f32, f32) {
4949
let y: f32 = parts[1].parse().unwrap_or(0.0);
5050
let z: f32 = parts[2].parse().unwrap_or(0.0);
5151

52+
let (r,g,b) = jet_colormap(z*10.0);
53+
5254
let instance = InstanceData {
5355
pos_scale: [x, y, z, 1.0], // position + uniform scale
54-
color: LinearRgba::from(Color::srgba(1.0, 1.0, 1.0, 0.01)).to_f32_array(), // you can set color later if needed
56+
color: LinearRgba::from(Color::srgba(r,g,b, 0.01)).to_f32_array(), // you can set color later if needed
5557
};
5658

5759
instances.push(instance);
@@ -106,6 +108,7 @@ fn voxel_plot_setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
106108
commands.insert_resource(AmbientLight {
107109
color: Color::WHITE,
108110
brightness: 2.0, // Increase this to wash out shadows
111+
affects_lightmapped_meshes: false,
109112
});
110113

111114
// camera

src/bevy_voxel_plot.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ fn queue_custom(
102102
render_mesh_instances: Res<RenderMeshInstances>,
103103
material_meshes: Query<(Entity, &MainEntity), With<InstanceMaterialData>>,
104104
mut transparent_render_phases: ResMut<ViewSortedRenderPhases<Transparent3d>>,
105-
views: Query<(Entity, &ExtractedView, &Msaa)>,
105+
views: Query<(&ExtractedView, &Msaa)>,
106106
) {
107107
let draw_custom = transparent_3d_draw_functions.read().id::<DrawCustom>();
108108

109-
for (view_entity, view, msaa) in &views {
110-
let Some(transparent_phase) = transparent_render_phases.get_mut(&view_entity) else {
109+
for (view, msaa) in &views {
110+
let Some(transparent_phase) = transparent_render_phases.get_mut(&view.retained_view_entity)
111+
else {
111112
continue;
112113
};
113114

@@ -135,7 +136,8 @@ fn queue_custom(
135136
draw_function: draw_custom,
136137
distance: rangefinder.distance_translation(&mesh_instance.translation),
137138
batch_range: 0..1,
138-
extra_index: PhaseItemExtraIndex::NONE,
139+
extra_index: PhaseItemExtraIndex::None,
140+
indexed: false,
139141
});
140142
}
141143
}

0 commit comments

Comments
 (0)