Skip to content

Commit c1a4e7a

Browse files
committed
Fmt.
1 parent 9c0234b commit c1a4e7a

5 files changed

Lines changed: 118 additions & 70 deletions

File tree

crates/processing_render/src/gltf.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ pub fn material(
243243
.resource_mut::<Assets<ProcessingExtendedMaterial>>()
244244
.add(ExtendedMaterial {
245245
base: standard,
246-
extension: ProcessingMaterial { blend_state: None, depth_write: None },
246+
extension: ProcessingMaterial {
247+
blend_state: None,
248+
depth_write: None,
249+
},
247250
});
248251
let entity = world.spawn(UntypedMaterial(handle.untyped())).id();
249252
Ok(entity)

crates/processing_render/src/material/mod.rs

Lines changed: 100 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ pub fn set_property(
140140
Err(ProcessingError::MaterialNotFound)
141141
}
142142

143-
144143
type PbrMaterial = ExtendedMaterial<StandardMaterial, ProcessingMaterial>;
145144

146145
enum MaterialMut<'a> {
@@ -218,24 +217,31 @@ pub fn set_alpha_mode(
218217
) -> error::Result<()> {
219218
let alpha_mode = resolve_alpha_mode(mode, cutoff)?;
220219
let opaque = matches!(alpha_mode, AlphaMode::Opaque);
221-
edit_material(entity, &material_handles, &mut pbr, &mut particles, &mut custom, |m| {
222-
match m {
223-
MaterialMut::Pbr(mat) => {
224-
mat.base.alpha_mode = alpha_mode;
225-
if opaque {
226-
mat.extension.blend_state = None;
220+
edit_material(
221+
entity,
222+
&material_handles,
223+
&mut pbr,
224+
&mut particles,
225+
&mut custom,
226+
|m| {
227+
match m {
228+
MaterialMut::Pbr(mat) => {
229+
mat.base.alpha_mode = alpha_mode;
230+
if opaque {
231+
mat.extension.blend_state = None;
232+
}
227233
}
228-
}
229-
MaterialMut::Particles(mat) => mat.base.alpha_mode = alpha_mode,
230-
MaterialMut::Custom(mat) => {
231-
mat.alpha_mode = alpha_mode;
232-
if opaque {
233-
mat.blend_state = None;
234+
MaterialMut::Particles(mat) => mat.base.alpha_mode = alpha_mode,
235+
MaterialMut::Custom(mat) => {
236+
mat.alpha_mode = alpha_mode;
237+
if opaque {
238+
mat.blend_state = None;
239+
}
234240
}
235241
}
236-
}
237-
Ok(())
238-
})
242+
Ok(())
243+
},
244+
)
239245
}
240246

241247
pub fn set_double_sided(
@@ -245,14 +251,21 @@ pub fn set_double_sided(
245251
mut particles: ResMut<Assets<crate::particles::material::ParticlesMaterial>>,
246252
mut custom: ResMut<Assets<custom::CustomMaterial>>,
247253
) -> error::Result<()> {
248-
edit_material(entity, &material_handles, &mut pbr, &mut particles, &mut custom, |m| {
249-
match m {
250-
MaterialMut::Pbr(mat) => set_base_double_sided(&mut mat.base, value),
251-
MaterialMut::Particles(mat) => set_base_double_sided(&mut mat.base, value),
252-
MaterialMut::Custom(mat) => mat.double_sided = Some(value),
253-
}
254-
Ok(())
255-
})
254+
edit_material(
255+
entity,
256+
&material_handles,
257+
&mut pbr,
258+
&mut particles,
259+
&mut custom,
260+
|m| {
261+
match m {
262+
MaterialMut::Pbr(mat) => set_base_double_sided(&mut mat.base, value),
263+
MaterialMut::Particles(mat) => set_base_double_sided(&mut mat.base, value),
264+
MaterialMut::Custom(mat) => mat.double_sided = Some(value),
265+
}
266+
Ok(())
267+
},
268+
)
256269
}
257270

258271
pub fn set_unlit(
@@ -262,20 +275,27 @@ pub fn set_unlit(
262275
mut particles: ResMut<Assets<crate::particles::material::ParticlesMaterial>>,
263276
mut custom: ResMut<Assets<custom::CustomMaterial>>,
264277
) -> error::Result<()> {
265-
edit_material(entity, &material_handles, &mut pbr, &mut particles, &mut custom, |m| match m {
266-
MaterialMut::Pbr(mat) => {
267-
mat.base.unlit = value;
268-
Ok(())
269-
}
270-
MaterialMut::Particles(mat) => {
271-
mat.base.unlit = value;
272-
Ok(())
273-
}
274-
MaterialMut::Custom(_) => Err(ProcessingError::InvalidArgument(
275-
"unlit is not applicable to custom-shader materials; the shader defines lighting"
276-
.to_string(),
277-
)),
278-
})
278+
edit_material(
279+
entity,
280+
&material_handles,
281+
&mut pbr,
282+
&mut particles,
283+
&mut custom,
284+
|m| match m {
285+
MaterialMut::Pbr(mat) => {
286+
mat.base.unlit = value;
287+
Ok(())
288+
}
289+
MaterialMut::Particles(mat) => {
290+
mat.base.unlit = value;
291+
Ok(())
292+
}
293+
MaterialMut::Custom(_) => Err(ProcessingError::InvalidArgument(
294+
"unlit is not applicable to custom-shader materials; the shader defines lighting"
295+
.to_string(),
296+
)),
297+
},
298+
)
279299
}
280300

281301
pub fn set_depth_write(
@@ -285,19 +305,26 @@ pub fn set_depth_write(
285305
mut particles: ResMut<Assets<crate::particles::material::ParticlesMaterial>>,
286306
mut custom: ResMut<Assets<custom::CustomMaterial>>,
287307
) -> error::Result<()> {
288-
edit_material(entity, &material_handles, &mut pbr, &mut particles, &mut custom, |m| match m {
289-
MaterialMut::Pbr(mat) => {
290-
mat.extension.depth_write = Some(value);
291-
Ok(())
292-
}
293-
MaterialMut::Particles(_) => Err(ProcessingError::InvalidArgument(
294-
"depth-write is not yet configurable on particle materials".to_string(),
295-
)),
296-
MaterialMut::Custom(mat) => {
297-
mat.depth_write = Some(value);
298-
Ok(())
299-
}
300-
})
308+
edit_material(
309+
entity,
310+
&material_handles,
311+
&mut pbr,
312+
&mut particles,
313+
&mut custom,
314+
|m| match m {
315+
MaterialMut::Pbr(mat) => {
316+
mat.extension.depth_write = Some(value);
317+
Ok(())
318+
}
319+
MaterialMut::Particles(_) => Err(ProcessingError::InvalidArgument(
320+
"depth-write is not yet configurable on particle materials".to_string(),
321+
)),
322+
MaterialMut::Custom(mat) => {
323+
mat.depth_write = Some(value);
324+
Ok(())
325+
}
326+
},
327+
)
301328
}
302329

303330
pub fn set_custom_blend(
@@ -307,21 +334,28 @@ pub fn set_custom_blend(
307334
mut particles: ResMut<Assets<crate::particles::material::ParticlesMaterial>>,
308335
mut custom: ResMut<Assets<custom::CustomMaterial>>,
309336
) -> error::Result<()> {
310-
edit_material(entity, &material_handles, &mut pbr, &mut particles, &mut custom, |m| match m {
311-
MaterialMut::Pbr(mat) => {
312-
mat.extension.blend_state = Some(blend);
313-
mat.base.alpha_mode = AlphaMode::Blend;
314-
Ok(())
315-
}
316-
MaterialMut::Particles(_) => Err(ProcessingError::InvalidArgument(
317-
"custom blend is not yet configurable on particle materials".to_string(),
318-
)),
319-
MaterialMut::Custom(mat) => {
320-
mat.blend_state = Some(blend);
321-
mat.alpha_mode = AlphaMode::Blend;
322-
Ok(())
323-
}
324-
})
337+
edit_material(
338+
entity,
339+
&material_handles,
340+
&mut pbr,
341+
&mut particles,
342+
&mut custom,
343+
|m| match m {
344+
MaterialMut::Pbr(mat) => {
345+
mat.extension.blend_state = Some(blend);
346+
mat.base.alpha_mode = AlphaMode::Blend;
347+
Ok(())
348+
}
349+
MaterialMut::Particles(_) => Err(ProcessingError::InvalidArgument(
350+
"custom blend is not yet configurable on particle materials".to_string(),
351+
)),
352+
MaterialMut::Custom(mat) => {
353+
mat.blend_state = Some(blend);
354+
mat.alpha_mode = AlphaMode::Blend;
355+
Ok(())
356+
}
357+
},
358+
)
325359
}
326360

327361
pub fn destroy(

crates/processing_render/src/render/material.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ impl MaterialKey {
169169
let base = self.to_standard_material();
170170
let extended = ProcessingExtendedMaterial {
171171
base,
172-
extension: ProcessingMaterial { blend_state, depth_write: None },
172+
extension: ProcessingMaterial {
173+
blend_state,
174+
depth_write: None,
175+
},
173176
};
174177
materials.add(extended).untyped()
175178
}

examples/particles_scatter.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ fn sketch() -> error::Result<()> {
7373
let aging = compute_create(age_shader)?;
7474

7575
let mat = material_create_pbr()?;
76-
material_set(mat, "color", shader_value::ShaderValue::Float4([0.9, 0.85, 1.0, 1.0]))?;
76+
material_set(
77+
mat,
78+
"color",
79+
shader_value::ShaderValue::Float4([0.9, 0.85, 1.0, 1.0]),
80+
)?;
7781

7882
let burst: u32 = 600;
7983
let dt: f32 = 1.0 / 60.0;

examples/particles_scatter_volume.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ fn sketch() -> error::Result<()> {
7272
let aging = compute_create(age_shader)?;
7373

7474
let mat = material_create_unlit()?;
75-
material_set(mat, "color", shader_value::ShaderValue::Float4([1.0, 1.0, 1.0, 1.0]))?;
75+
material_set(
76+
mat,
77+
"color",
78+
shader_value::ShaderValue::Float4([1.0, 1.0, 1.0, 1.0]),
79+
)?;
7680

7781
let burst: u32 = 250;
7882
let dt: f32 = 1.0 / 60.0;

0 commit comments

Comments
 (0)