Skip to content

Commit a9701de

Browse files
committed
Fixing code broken by new bevy version
1 parent c99ef4f commit a9701de

File tree

9 files changed

+29
-23
lines changed

9 files changed

+29
-23
lines changed

crates/processing_render/src/geometry/attribute.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::ops::Range;
22

33
use bevy::{
4+
asset::AssetMut,
45
mesh::{Indices, MeshVertexAttribute, VertexAttributeValues},
56
prelude::*,
67
render::render_resource::VertexFormat,
@@ -31,7 +32,7 @@ fn get_mesh_mut<'a>(
3132
entity: Entity,
3233
geometries: &Query<&Geometry>,
3334
meshes: &'a mut Assets<Mesh>,
34-
) -> Result<&'a mut Mesh> {
35+
) -> Result<AssetMut<'a, Mesh>> {
3536
let geometry = geometries
3637
.get(entity)
3738
.map_err(|_| ProcessingError::GeometryNotFound)?;
@@ -89,7 +90,7 @@ macro_rules! impl_setter {
8990
geometries: Query<&Geometry>,
9091
mut meshes: ResMut<Assets<Mesh>>,
9192
) -> Result<()> {
92-
let mesh = get_mesh_mut(entity, &geometries, &mut meshes)?;
93+
let mut mesh = get_mesh_mut(entity, &geometries, &mut meshes)?;
9394
match mesh.attribute_mut($attr) {
9495
Some(VertexAttributeValues::$variant(data)) => {
9596
let idx = index as usize;
@@ -335,7 +336,7 @@ pub fn set_attribute(
335336
geometries: Query<&Geometry>,
336337
mut meshes: ResMut<Assets<Mesh>>,
337338
) -> Result<()> {
338-
let mesh = get_mesh_mut(entity, &geometries, &mut meshes)?;
339+
let mut mesh = get_mesh_mut(entity, &geometries, &mut meshes)?;
339340
let idx = index as usize;
340341

341342
let attr = mesh.attribute_mut(attribute_id).ok_or_else(|| {

crates/processing_render/src/geometry/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub fn vertex(
250250
.get(geometry.layout)
251251
.map_err(|_| ProcessingError::LayoutNotFound)?;
252252

253-
let mesh = meshes
253+
let mut mesh = meshes
254254
.get_mut(&geometry.handle)
255255
.ok_or(ProcessingError::GeometryNotFound)?;
256256

@@ -323,7 +323,7 @@ pub fn index(
323323
.get(entity)
324324
.map_err(|_| ProcessingError::GeometryNotFound)?;
325325

326-
let mesh = meshes
326+
let mut mesh = meshes
327327
.get_mut(&geometry.handle)
328328
.ok_or(ProcessingError::GeometryNotFound)?;
329329

crates/processing_render/src/graphics.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
//! configured to render to a specific surface (either a window or an offscreen image).
66
use bevy::{
77
camera::{
8-
CameraMainTextureUsages, CameraOutputMode, CameraProjection, ClearColorConfig,
8+
CameraMainTextureUsages, CameraOutputMode, CameraProjection, ClearColorConfig, Hdr,
99
ImageRenderTarget, MsaaWriteback, Projection, RenderTarget, visibility::RenderLayers,
1010
},
1111
core_pipeline::tonemapping::Tonemapping,
1212
ecs::{entity::EntityHashMap, query::QueryEntityError},
1313
math::{Mat4, Vec3A},
1414
prelude::*,
1515
render::{
16-
Render, RenderSystems,
16+
Render,
1717
render_resource::{
1818
CommandEncoderDescriptor, Extent3d, MapMode, Origin3d, PollType, TexelCopyBufferInfo,
1919
TexelCopyBufferLayout, TexelCopyTextureInfo, TextureFormat, TextureUsages,
2020
},
2121
renderer::{RenderDevice, RenderQueue},
2222
sync_world::MainEntity,
23-
view::{Hdr, ViewTarget, prepare_view_targets},
23+
view::{ViewTarget, prepare_view_targets},
2424
},
2525
window::WindowRef,
2626
};
@@ -48,12 +48,7 @@ impl Plugin for GraphicsPlugin {
4848

4949
let render_app = app.sub_app_mut(bevy::render::RenderApp);
5050
render_app
51-
.add_systems(
52-
Render,
53-
send_view_targets
54-
.in_set(RenderSystems::ManageViews)
55-
.after(prepare_view_targets),
56-
)
51+
.add_systems(Render, send_view_targets.after(prepare_view_targets))
5752
.insert_resource(GraphicsTargetSender(tx));
5853
}
5954
}
@@ -219,14 +214,14 @@ pub fn create(
219214
.spawn((
220215
Camera3d::default(),
221216
Camera {
222-
target,
223217
// always load the previous frame (provides sketch like behavior)
224218
clear_color: ClearColorConfig::None,
225219
// TODO: toggle this conditionally based on whether we need to write back MSAA
226220
// when doing manual pixel udpates
227221
msaa_writeback: MsaaWriteback::Always,
228222
..default()
229223
},
224+
target,
230225
// default to floating point texture format
231226
Hdr,
232227
// tonemapping prevents color accurate readback, so we disable it
@@ -293,6 +288,10 @@ pub fn mode_3d(
293288
let near = camera_z / 10.0;
294289
let far = camera_z * 10.0;
295290

291+
// TODO: Setting this as a default, but we need to think about API around
292+
// a user defined value
293+
let near_clip_plane = vec4(0.0, 0.0, -1.0, -near);
294+
296295
let mut projection = projections
297296
.get_mut(entity)
298297
.map_err(|_| ProcessingError::GraphicsNotFound)?;
@@ -302,6 +301,7 @@ pub fn mode_3d(
302301
aspect_ratio: aspect,
303302
near,
304303
far,
304+
near_clip_plane,
305305
});
306306

307307
let mut transform = transforms
@@ -351,6 +351,7 @@ pub fn perspective(
351351
aspect_ratio,
352352
near,
353353
far,
354+
near_clip_plane,
354355
},
355356
)): In<(Entity, PerspectiveProjection)>,
356357
mut projections: Query<&mut Projection>,
@@ -364,6 +365,7 @@ pub fn perspective(
364365
aspect_ratio,
365366
near,
366367
far,
368+
near_clip_plane,
367369
});
368370

369371
Ok(())
@@ -526,7 +528,8 @@ pub fn readback(
526528
});
527529

528530
render_device
529-
.poll(PollType::Wait)
531+
// TODO: should this have a timeout?
532+
.poll(PollType::wait_indefinitely())
530533
.expect("Failed to poll device for map async");
531534

532535
r.recv().expect("Failed to receive the map_async message");

crates/processing_render/src/image.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,15 @@ pub fn readback(
255255
});
256256

257257
render_device
258-
.poll(PollType::Wait)
258+
// TODO: Should this be a timeout instead?
259+
.poll(PollType::wait_indefinitely())
259260
.expect("Failed to poll device for map async");
260261

261262
r.recv().expect("Failed to receive the map_async message");
262263

263264
let data = buffer_slice.get_mapped_range().to_vec();
264265

265-
let image = images
266+
let mut image = images
266267
.get_mut(&p_image.handle)
267268
.ok_or(ProcessingError::ImageNotFound)?;
268269
image.data = Some(data.clone());

crates/processing_render/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ pub fn graphics_perspective(
517517
aspect_ratio: f32,
518518
near: f32,
519519
far: f32,
520+
near_clip_plane: Vec4,
520521
) -> error::Result<()> {
521522
app_mut(|app| {
522523
flush(app, graphics_entity)?;
@@ -530,6 +531,7 @@ pub fn graphics_perspective(
530531
aspect_ratio,
531532
near,
532533
far,
534+
near_clip_plane,
533535
},
534536
),
535537
)

crates/processing_render/src/material/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ pub fn set_property(
6666
.clone()
6767
.try_typed::<StandardMaterial>()
6868
.map_err(|_| ProcessingError::MaterialNotFound)?;
69-
let standard = standard_materials
69+
let mut standard = standard_materials
7070
.get_mut(&handle)
7171
.ok_or(ProcessingError::MaterialNotFound)?;
72-
pbr::set_property(standard, &name, &value)?;
72+
pbr::set_property(&mut standard, &name, &value)?;
7373
Ok(())
7474
}
7575

crates/processing_render/src/material/pbr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use bevy::prelude::*;
2-
use bevy::render::alpha::AlphaMode;
32

43
use super::MaterialValue;
54
use crate::error::{ProcessingError, Result};

crates/processing_render/src/render/material.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bevy::{prelude::*, render::alpha::AlphaMode};
1+
use bevy::prelude::*;
22
use std::ops::Deref;
33

44
/// A component that holds an untyped handle to a material. This allows the main render loop

crates/processing_render/src/sketch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub struct Sketch {
7373
///
7474
/// Currently supports `.py` files, but the loader is designed to be extended
7575
/// for other languages in the future.
76-
#[derive(Default)]
76+
#[derive(Default, TypePath)]
7777
pub struct SketchLoader;
7878

7979
impl AssetLoader for SketchLoader {

0 commit comments

Comments
 (0)