Skip to content

Commit

Permalink
Fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed Sep 27, 2024
1 parent bbbb640 commit a34a603
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 24 deletions.
5 changes: 4 additions & 1 deletion bevy_nannou_derive/tests/shader_model_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ struct TestShaderModel {}

#[test]
fn test_default_shaders() {
assert!(matches!(TestShaderModel::vertex_shader(), ShaderRef::Default));
assert!(matches!(
TestShaderModel::vertex_shader(),
ShaderRef::Default
));
assert!(matches!(
TestShaderModel::fragment_shader(),
ShaderRef::Default
Expand Down
2 changes: 1 addition & 1 deletion bevy_nannou_draw/src/draw/background.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::{Color};
use bevy::prelude::Color;

use crate::draw::{Draw, DrawCommand};
use crate::render::ShaderModel;
Expand Down
4 changes: 3 additions & 1 deletion bevy_nannou_draw/src/draw/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ where

let shader_model = map(shader_model.clone());
let mut state = state.write().unwrap();
state.shader_models.insert(new_id.clone(), Box::new(shader_model));
state
.shader_models
.insert(new_id.clone(), Box::new(shader_model));
// Mark the last shader model as the new model so that further drawings use the same model
// as the parent draw ref.
state.last_shader_model = Some(new_id.clone());
Expand Down
3 changes: 1 addition & 2 deletions bevy_nannou_draw/src/draw/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ where
SM::Data: PartialEq + Eq + Hash + Clone,
{
fn build(&self, app: &mut App) {
app
.sub_app_mut(RenderApp)
app.sub_app_mut(RenderApp)
.add_render_command::<Transparent3d, DrawIndirectShaderModel<SM>>()
.add_systems(
Render,
Expand Down
4 changes: 1 addition & 3 deletions bevy_nannou_draw/src/draw/instanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use crate::{
use bevy::{
core_pipeline::core_3d::Transparent3d,
ecs::system::{lifetimeless::*, SystemParamItem},
pbr::{
RenderMeshInstances, SetMeshBindGroup, SetMeshViewBindGroup,
},
pbr::{RenderMeshInstances, SetMeshBindGroup, SetMeshViewBindGroup},
prelude::*,
render::{
extract_component::{ExtractComponent, ExtractComponentPlugin},
Expand Down
26 changes: 17 additions & 9 deletions bevy_nannou_draw/src/render.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::{
draw::{
indirect::{IndirectShaderModelPlugin, IndirectMesh},
instanced::{InstanceRange, InstancedShaderModelPlugin, InstancedMesh},
indirect::{IndirectMesh, IndirectShaderModelPlugin},
instanced::{InstanceRange, InstancedMesh, InstancedShaderModelPlugin},
mesh::MeshExt,
render::{RenderContext, RenderPrimitive},
DrawCommand, DrawContext,
},
DrawHolder,
};
use bevy::render::storage::ShaderStorageBuffer;
use bevy::{
asset::{load_internal_asset, Asset, UntypedAssetId},
core_pipeline::core_3d::Transparent3d,
Expand All @@ -16,8 +17,7 @@ use bevy::{
system::{lifetimeless::SRes, SystemParamItem},
},
pbr::{
DefaultOpaqueRendererMethod, DrawMesh,
MeshPipeline, MeshPipelineKey, OpaqueRendererMethod,
DefaultOpaqueRendererMethod, DrawMesh, MeshPipeline, MeshPipelineKey, OpaqueRendererMethod,
RenderMeshInstances, SetMeshBindGroup, SetMeshViewBindGroup,
},
prelude::{TypePath, *},
Expand Down Expand Up @@ -53,7 +53,6 @@ use bevy::{
};
use lyon::lyon_tessellation::{FillTessellator, StrokeTessellator};
use std::{any::TypeId, hash::Hash, marker::PhantomData};
use bevy::render::storage::ShaderStorageBuffer;

pub const DEFAULT_NANNOU_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(3086880141013591);

Expand Down Expand Up @@ -136,7 +135,10 @@ where
IndirectShaderModelPlugin::<SM>::default(),
InstancedShaderModelPlugin::<SM>::default(),
))
.add_systems(PostUpdate, update_shader_model::<SM>.after(update_draw_mesh));
.add_systems(
PostUpdate,
update_shader_model::<SM>.after(update_draw_mesh),
);

app.sub_app_mut(RenderApp)
.add_render_command::<Transparent3d, DrawShaderModel<SM>>()
Expand Down Expand Up @@ -176,7 +178,11 @@ impl<SM: ShaderModel> RenderAsset for PreparedShaderModel<SM> {
shader_model: Self::SourceAsset,
(render_device, pipeline, ref mut shader_model_param): &mut SystemParamItem<Self::Param>,
) -> Result<Self, PrepareAssetError<Self::SourceAsset>> {
match shader_model.as_bind_group(&pipeline.shader_model_layout, render_device, shader_model_param) {
match shader_model.as_bind_group(
&pipeline.shader_model_layout,
render_device,
shader_model_param,
) {
Ok(prepared) => Ok(PreparedShaderModel {
bindings: prepared.bindings,
bind_group: prepared.bind_group,
Expand Down Expand Up @@ -638,7 +644,8 @@ fn update_draw_mesh(
let mut mesh = Mesh::init();
prim.render_primitive(ctxt, &mut mesh);
let mesh = meshes.add(mesh);
let model_id = last_shader_model.expect("No shader model set for instanced draw command");
let model_id =
last_shader_model.expect("No shader model set for instanced draw command");
commands.spawn((
InstancedMesh,
InstanceRange(range),
Expand Down Expand Up @@ -674,7 +681,8 @@ fn update_draw_mesh(
let mut mesh = Mesh::init();
prim.render_primitive(ctxt, &mut mesh);
let mesh = meshes.add(mesh);
let model_id = last_shader_model.expect("No shader model set for instanced draw command");
let model_id =
last_shader_model.expect("No shader model set for instanced draw command");
commands.spawn((
IndirectMesh,
indirect_buffer,
Expand Down
2 changes: 1 addition & 1 deletion bevy_nannou_isf/src/render.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::asset::embedded_asset;
use bevy::core_pipeline::core_3d::graph::{Core3d, Node3d};
use bevy::core_pipeline::core_3d::{CORE_3D_DEPTH_FORMAT};
use bevy::core_pipeline::core_3d::CORE_3D_DEPTH_FORMAT;
use bevy::core_pipeline::fullscreen_vertex_shader::{
fullscreen_shader_vertex_state, FULLSCREEN_SHADER_HANDLE,
};
Expand Down
3 changes: 1 addition & 2 deletions examples/draw/draw_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ fn view(app: &App, model: &Model) {
let draw = app.draw();
draw.background().color(BLACK);
let win = app.window_rect();
draw.rect().x_y(win.x(), win.y())
.texture(&model.texture);
draw.rect().x_y(win.x(), win.y()).texture(&model.texture);
}
7 changes: 3 additions & 4 deletions nannou/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use bevy_inspector_egui::DefaultInspectorConfigPlugin;
use crate::frame::{Frame, FramePlugin};
use crate::prelude::bevy_ecs::system::SystemState;
use crate::prelude::bevy_reflect::DynamicTyped;
use crate::prelude::render::{NannouShaderModelPlugin, NannouMesh, ShaderModel};
use crate::prelude::render::{NannouMesh, NannouShaderModelPlugin, ShaderModel};
use crate::render::{
compute::{Compute, ComputeModel, ComputePlugin, ComputeShaderHandle, ComputeState},
NannouRenderNode, RenderApp, RenderPlugin,
Expand Down Expand Up @@ -356,9 +356,8 @@ where
SM: ShaderModel,
SM::Data: PartialEq + Eq + Hash + Clone,
{
self.app.add_plugins((
NannouShaderModelPlugin::<SM>::default(),
));
self.app
.add_plugins((NannouShaderModelPlugin::<SM>::default(),));
self
}

Expand Down

0 comments on commit a34a603

Please sign in to comment.