From 012f23ba943680c2e3aa4ad49a2a92b10d86662b Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 27 Mar 2024 15:57:02 -0400 Subject: [PATCH] rustfmt --- studio/src/lib.rs | 2 +- studio/src/material/mod.rs | 39 +++++++++++++-------------- studio/src/material/short_material.rs | 23 ++++++++-------- studio/src/ui/inspector.rs | 3 +-- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/studio/src/lib.rs b/studio/src/lib.rs index 2e21503..aa0c9e1 100644 --- a/studio/src/lib.rs +++ b/studio/src/lib.rs @@ -34,6 +34,7 @@ mod ui; pub mod viewport; mod world_grid; +use crate::material::MaterialPlugin; pub use crate::{ anim::AnimPlugin, bvh::BvhPlugin, @@ -52,7 +53,6 @@ pub use crate::{ viewport::ViewportSize, world_grid::WorldGridPlugin, }; -use crate::material::MaterialPlugin; #[cfg(feature = "wasm")] mod wasm; diff --git a/studio/src/material/mod.rs b/studio/src/material/mod.rs index 148ec95..3088b26 100644 --- a/studio/src/material/mod.rs +++ b/studio/src/material/mod.rs @@ -1,38 +1,37 @@ +use crate::material::short_material::ShortMaterial; use bevy::app::{App, Plugin, PostUpdate}; use bevy::asset::{Assets, Handle}; use bevy::pbr::StandardMaterial; use bevy::prelude::{Commands, Entity, Query, ResMut}; use space_editor::prelude::EditorRegistryExt; -use crate::material::short_material::ShortMaterial; - pub mod short_material; pub struct MaterialPlugin; impl Plugin for MaterialPlugin { - fn build(&self, app: &mut App) { - app.register_type::() - .editor_registry::(); + fn build(&self, app: &mut App) { + app.register_type::() + .editor_registry::(); - app.add_systems(PostUpdate, apply_short_materials); - } + app.add_systems(PostUpdate, apply_short_materials); + } } fn apply_short_materials( - mut commands: Commands, - q_mats: Query<(Entity, &Handle, &ShortMaterial)>, - mut materials: ResMut>, + mut commands: Commands, + q_mats: Query<(Entity, &Handle, &ShortMaterial)>, + mut materials: ResMut>, ) { - for (entity, handle, short) in q_mats.iter() { - let Some(material) = materials.get_mut(handle) else { - continue; - }; + for (entity, handle, short) in q_mats.iter() { + let Some(material) = materials.get_mut(handle) else { + continue; + }; - material.base_color = short.base_color; - material.perceptual_roughness = short.perceptual_roughness; - material.metallic = short.metallic; - material.reflectance = short.reflectance; + material.base_color = short.base_color; + material.perceptual_roughness = short.perceptual_roughness; + material.metallic = short.metallic; + material.reflectance = short.reflectance; - commands.entity(entity).remove::(); - } + commands.entity(entity).remove::(); + } } diff --git a/studio/src/material/short_material.rs b/studio/src/material/short_material.rs index 0eefe4f..9ba7706 100644 --- a/studio/src/material/short_material.rs +++ b/studio/src/material/short_material.rs @@ -4,23 +4,22 @@ use bevy::prelude::{Color, Component, Reflect}; use bevy::ecs::reflect::ReflectComponent; use bevy::reflect::std_traits::ReflectDefault; - #[derive(Reflect, Default, Clone, Component)] #[reflect(Default, Component)] pub struct ShortMaterial { - pub base_color: Color, - pub perceptual_roughness: f32, - pub metallic: f32, - pub reflectance: f32, + pub base_color: Color, + pub perceptual_roughness: f32, + pub metallic: f32, + pub reflectance: f32, } impl ShortMaterial { - pub fn new(material: &StandardMaterial) -> Self { - Self { - base_color: material.base_color, - perceptual_roughness: material.perceptual_roughness, - metallic: material.metallic, - reflectance: material.reflectance, + pub fn new(material: &StandardMaterial) -> Self { + Self { + base_color: material.base_color, + perceptual_roughness: material.perceptual_roughness, + metallic: material.metallic, + reflectance: material.reflectance, + } } - } } diff --git a/studio/src/ui/inspector.rs b/studio/src/ui/inspector.rs index 5638be5..7cac5f5 100644 --- a/studio/src/ui/inspector.rs +++ b/studio/src/ui/inspector.rs @@ -20,11 +20,11 @@ use space_editor::{ }; use wasm_bindgen::prelude::*; +use crate::material::short_material::ShortMaterial; use crate::{ interaction::Selection, wasm::{self, StaticBuffer, WasmMessageBuffer}, }; -use crate::material::short_material::ShortMaterial; pub struct InspectorPlugin; @@ -572,7 +572,6 @@ fn auto_serialize_asset( ev_update_description.send(UpdateEntityDescription); } - fn serialize_standart_materal( r_selection: Option>, q_m: Query<&Handle>,