diff --git a/CHANGELOG.md b/CHANGELOG.md index d00e39642..a476a48a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -303,7 +303,7 @@ picking restriction stack. - Light source for model previewer - Default skybox for editor and model previewer cameras - `Color` API improvements. -- `#[inspect(expand)]` and `#[inspect(expand_subtree)]` were removed from `Inspect` proc-macro +- `#[reflect(expand)]` and `#[reflect(expand_subtree)]` were removed from `Inspect` proc-macro - Correct field name generation for enum variants - Ability to draw Bézier curves in the UI. - Fix for navmesh agent navigation of multilayer navigational meshes. diff --git a/editor/src/absm/inspector/mod.rs b/editor/src/absm/inspector/mod.rs index acddc1547..ff4a64796 100644 --- a/editor/src/absm/inspector/mod.rs +++ b/editor/src/absm/inspector/mod.rs @@ -22,7 +22,7 @@ use fyrox::{ }, MachineDefinition, PoseWeight, }, - core::{inspect::Inspect, pool::Handle}, + core::{pool::Handle, reflect::prelude::*}, gui::{ inspector::{ editors::{ @@ -96,13 +96,13 @@ impl Inspector { fn first_selected_entity<'a>( &self, definition: &'a MachineDefinition, - ) -> Option<&'a dyn Inspect> { + ) -> Option<&'a dyn Reflect> { self.selection.first().map(|first| match first { SelectedEntity::Transition(transition) => { - &definition.transitions[*transition] as &dyn Inspect + &definition.transitions[*transition] as &dyn Reflect } - SelectedEntity::State(state) => &definition.states[*state] as &dyn Inspect, - SelectedEntity::PoseNode(pose) => &definition.nodes[*pose] as &dyn Inspect, + SelectedEntity::State(state) => &definition.states[*state] as &dyn Reflect, + SelectedEntity::PoseNode(pose) => &definition.nodes[*pose] as &dyn Reflect, }) } diff --git a/editor/src/asset/inspector/handlers/mod.rs b/editor/src/asset/inspector/handlers/mod.rs index 09c8f32da..10bf983c7 100644 --- a/editor/src/asset/inspector/handlers/mod.rs +++ b/editor/src/asset/inspector/handlers/mod.rs @@ -1,5 +1,5 @@ use fyrox::{ - core::inspect::Inspect, engine::resource_manager::ResourceManager, + core::reflect::prelude::*, engine::resource_manager::ResourceManager, gui::inspector::PropertyChanged, }; @@ -10,6 +10,6 @@ pub mod texture; pub trait ImportOptionsHandler { fn apply(&self, resource_manager: ResourceManager); fn revert(&mut self); - fn value(&self) -> &dyn Inspect; + fn value(&self) -> &dyn Reflect; fn handle_property_changed(&mut self, property_changed: &PropertyChanged); } diff --git a/editor/src/asset/inspector/handlers/model.rs b/editor/src/asset/inspector/handlers/model.rs index df260c794..7ef38f7ab 100644 --- a/editor/src/asset/inspector/handlers/model.rs +++ b/editor/src/asset/inspector/handlers/model.rs @@ -1,6 +1,6 @@ use crate::asset::inspector::handlers::ImportOptionsHandler; use fyrox::{ - core::{append_extension, futures::executor::block_on, inspect::Inspect}, + core::{append_extension, futures::executor::block_on, reflect::prelude::*}, engine::resource_manager::{ options::{try_get_import_settings, ImportOptions}, ResourceManager, @@ -37,7 +37,7 @@ impl ImportOptionsHandler for ModelImportOptionsHandler { self.options = block_on(try_get_import_settings(&self.resource_path)).unwrap_or_default(); } - fn value(&self) -> &dyn Inspect { + fn value(&self) -> &dyn Reflect { &self.options } diff --git a/editor/src/asset/inspector/handlers/sound.rs b/editor/src/asset/inspector/handlers/sound.rs index 39926324d..48bd47a17 100644 --- a/editor/src/asset/inspector/handlers/sound.rs +++ b/editor/src/asset/inspector/handlers/sound.rs @@ -1,6 +1,6 @@ use crate::asset::inspector::handlers::ImportOptionsHandler; use fyrox::{ - core::{append_extension, futures::executor::block_on, inspect::Inspect}, + core::{append_extension, futures::executor::block_on, reflect::prelude::*}, engine::resource_manager::{ loader::sound::SoundBufferImportOptions, options::{try_get_import_settings, ImportOptions}, @@ -42,7 +42,7 @@ impl ImportOptionsHandler for SoundBufferImportOptionsHandler { self.options = block_on(try_get_import_settings(&self.resource_path)).unwrap_or_default(); } - fn value(&self) -> &dyn Inspect { + fn value(&self) -> &dyn Reflect { &self.options } diff --git a/editor/src/asset/inspector/handlers/texture.rs b/editor/src/asset/inspector/handlers/texture.rs index 4b29e2a59..79f9cb014 100644 --- a/editor/src/asset/inspector/handlers/texture.rs +++ b/editor/src/asset/inspector/handlers/texture.rs @@ -1,6 +1,6 @@ use crate::asset::inspector::handlers::ImportOptionsHandler; use fyrox::{ - core::{append_extension, futures::executor::block_on, inspect::Inspect}, + core::{append_extension, futures::executor::block_on, reflect::prelude::*}, engine::resource_manager::{ options::{try_get_import_settings, ImportOptions}, ResourceManager, @@ -42,7 +42,7 @@ impl ImportOptionsHandler for TextureImportOptionsHandler { self.options = block_on(try_get_import_settings(&self.resource_path)).unwrap_or_default(); } - fn value(&self) -> &dyn Inspect { + fn value(&self) -> &dyn Reflect { &self.options } diff --git a/editor/src/inspector/mod.rs b/editor/src/inspector/mod.rs index ae003ce8a..dd8d863d5 100644 --- a/editor/src/inspector/mod.rs +++ b/editor/src/inspector/mod.rs @@ -13,7 +13,7 @@ use crate::{ }; use fyrox::engine::SerializationContext; use fyrox::{ - core::{color::Color, inspect::Inspect, pool::Handle}, + core::{color::Color, pool::Handle, reflect::prelude::*}, engine::resource_manager::ResourceManager, gui::{ grid::{Column, GridBuilder, Row}, @@ -158,7 +158,7 @@ impl Inspector { } } - fn sync_to(&mut self, obj: &dyn Inspect, ui: &mut UserInterface) { + fn sync_to(&mut self, obj: &dyn Reflect, ui: &mut UserInterface) { let ctx = ui .node(self.inspector) .cast::() @@ -181,17 +181,17 @@ impl Inspector { if self.needs_sync { if editor_scene.selection.is_single_selection() { - let obj: Option<&dyn Inspect> = match &editor_scene.selection { + let obj: Option<&dyn Reflect> = match &editor_scene.selection { Selection::Graph(selection) => scene .graph .try_get(selection.nodes()[0]) - .map(|n| n as &dyn Inspect), - Selection::SoundContext => Some(&scene.graph.sound_context as &dyn Inspect), + .map(|n| n.as_reflect()), + Selection::SoundContext => Some(&scene.graph.sound_context as &dyn Reflect), Selection::Effect(selection) => scene .graph .sound_context .try_get_effect(selection.effects[0]) - .map(|e| e as &dyn Inspect), + .map(|e| e as &dyn Reflect), _ => None, }; @@ -206,7 +206,7 @@ impl Inspector { fn change_context( &mut self, - obj: &dyn Inspect, + obj: &dyn Reflect, ui: &mut UserInterface, resource_manager: ResourceManager, serialization_context: Arc, @@ -252,17 +252,17 @@ impl Inspector { )); if !editor_scene.selection.is_empty() { - let obj: Option<&dyn Inspect> = match &editor_scene.selection { + let obj: Option<&dyn Reflect> = match &editor_scene.selection { Selection::Graph(selection) => scene .graph .try_get(selection.nodes()[0]) - .map(|n| n as &dyn Inspect), - Selection::SoundContext => Some(&scene.graph.sound_context as &dyn Inspect), + .map(|n| n.as_reflect()), + Selection::SoundContext => Some(&scene.graph.sound_context as &dyn Reflect), Selection::Effect(selection) => scene .graph .sound_context .try_get_effect(selection.effects[0]) - .map(|e| e as &dyn Inspect), + .map(|e| e as &dyn Reflect), _ => None, }; diff --git a/editor/src/settings/camera.rs b/editor/src/settings/camera.rs index dba86af66..16040d53b 100644 --- a/editor/src/settings/camera.rs +++ b/editor/src/settings/camera.rs @@ -1,5 +1,5 @@ use crate::camera; -use fyrox::core::{algebra::Vector3, inspect::prelude::*, reflect::prelude::*}; +use fyrox::core::{algebra::Vector3, reflect::prelude::*}; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf}; @@ -20,12 +20,11 @@ impl Default for SceneCameraSettings { } } -#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Inspect, Reflect)] +#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Reflect)] pub struct CameraSettings { pub speed: f32, pub invert_dragging: bool, pub drag_speed: f32, - #[inspect(skip)] #[reflect(hidden)] pub camera_settings: HashMap, } diff --git a/editor/src/settings/debugging.rs b/editor/src/settings/debugging.rs index cfe19c424..8e200cde4 100644 --- a/editor/src/settings/debugging.rs +++ b/editor/src/settings/debugging.rs @@ -1,10 +1,7 @@ -use fyrox::core::{ - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, -}; +use fyrox::core::reflect::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Inspect, Reflect, Eq)] +#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Reflect, Eq)] pub struct DebuggingSettings { pub show_physics: bool, pub show_bounds: bool, diff --git a/editor/src/settings/graphics.rs b/editor/src/settings/graphics.rs index 83767afbf..6e0fc5c19 100644 --- a/editor/src/settings/graphics.rs +++ b/editor/src/settings/graphics.rs @@ -1,13 +1,7 @@ -use fyrox::{ - core::{ - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, - }, - renderer::QualitySettings, -}; +use fyrox::{core::reflect::prelude::*, renderer::QualitySettings}; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Inspect, Reflect)] +#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Reflect)] pub struct GraphicsSettings { pub quality: QualitySettings, pub z_near: f32, diff --git a/editor/src/settings/mod.rs b/editor/src/settings/mod.rs index 14d8bb31a..59a2797d2 100644 --- a/editor/src/settings/mod.rs +++ b/editor/src/settings/mod.rs @@ -9,12 +9,7 @@ use crate::{ GameEngine, Message, MSG_SYNC_FLAG, }; use fyrox::{ - core::{ - inspect::{Inspect, PropertyInfo}, - pool::Handle, - reflect::prelude::*, - scope_profile, - }, + core::{pool::Handle, reflect::prelude::*, scope_profile}, gui::{ button::{ButtonBuilder, ButtonMessage}, grid::{Column, GridBuilder, Row}, @@ -57,7 +52,7 @@ pub struct SettingsWindow { inspector: Handle, } -#[derive(Deserialize, Serialize, PartialEq, Clone, Default, Debug, Inspect, Reflect)] +#[derive(Deserialize, Serialize, PartialEq, Clone, Default, Debug, Reflect)] pub struct Settings { pub selection: SelectionSettings, pub graphics: GraphicsSettings, @@ -67,7 +62,6 @@ pub struct Settings { pub model: ModelSettings, pub camera: CameraSettings, pub navmesh: NavmeshSettings, - #[inspect(skip)] #[reflect(hidden)] pub recent: RecentFiles, } diff --git a/editor/src/settings/model.rs b/editor/src/settings/model.rs index 4b20e1fca..f71423144 100644 --- a/editor/src/settings/model.rs +++ b/editor/src/settings/model.rs @@ -1,13 +1,9 @@ -use fyrox::core::{ - algebra::Vector3, - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, -}; +use fyrox::core::{algebra::Vector3, reflect::prelude::*}; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Inspect, Reflect)] +#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Reflect)] pub struct ModelSettings { - #[inspect( + #[reflect( description = "Initial scale the root of the instance will have after instantiation.\ Useful when you have lots of huge models and don't want to rescale them manually." )] diff --git a/editor/src/settings/move_mode.rs b/editor/src/settings/move_mode.rs index da70cc5f1..5c02179e9 100644 --- a/editor/src/settings/move_mode.rs +++ b/editor/src/settings/move_mode.rs @@ -1,10 +1,7 @@ -use fyrox::core::{ - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, -}; +use fyrox::core::reflect::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Inspect, Reflect)] +#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Reflect)] pub struct MoveInteractionModeSettings { pub grid_snapping: bool, pub x_snap_step: f32, diff --git a/editor/src/settings/navmesh.rs b/editor/src/settings/navmesh.rs index c22b73715..6345eb9b7 100644 --- a/editor/src/settings/navmesh.rs +++ b/editor/src/settings/navmesh.rs @@ -1,17 +1,14 @@ -use fyrox::core::{ - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, -}; +use fyrox::core::reflect::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Inspect, Reflect)] +#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Reflect)] pub struct NavmeshSettings { - #[inspect( + #[reflect( description = "Show all navigational meshes in scene. With this function turned off, only currently edited navmesh will be shown." )] pub draw_all: bool, - #[inspect(description = "Radius of a nav mesh vertex.")] + #[reflect(description = "Radius of a nav mesh vertex.")] pub vertex_radius: f32, } diff --git a/editor/src/settings/rotate_mode.rs b/editor/src/settings/rotate_mode.rs index 3f3501df4..0d70d115e 100644 --- a/editor/src/settings/rotate_mode.rs +++ b/editor/src/settings/rotate_mode.rs @@ -1,10 +1,7 @@ -use fyrox::core::{ - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, -}; +use fyrox::core::reflect::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Inspect, Reflect)] +#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, Reflect)] pub struct RotateInteractionModeSettings { pub angle_snapping: bool, pub x_snap_step: f32, diff --git a/editor/src/settings/selection.rs b/editor/src/settings/selection.rs index 18cef0a2d..2ca6caa07 100644 --- a/editor/src/settings/selection.rs +++ b/editor/src/settings/selection.rs @@ -1,12 +1,11 @@ -use fyrox::core::{inspect::prelude::*, reflect::prelude::*}; +use fyrox::core::reflect::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Inspect, Reflect, Eq)] +#[derive(Deserialize, Serialize, PartialEq, Clone, Debug, Reflect, Eq)] pub struct SelectionSettings { pub ignore_back_faces: bool, // Hidden because there's a separate switch in world viewer for this. - #[inspect(skip)] #[reflect(hidden)] pub track_selection: bool, } diff --git a/examples/inspector.rs b/examples/inspector.rs index 6bbb4296d..83e08e37a 100644 --- a/examples/inspector.rs +++ b/examples/inspector.rs @@ -138,7 +138,7 @@ fn main() { } = fyrox::core::futures::executor::block_on(create_scene(engine.resource_manager.clone())); let inspector_context = InspectorContext::from_object( - &scene.graph[model_handle], + scene.graph[model_handle].as_reflect(), &mut engine.user_interface.build_ctx(), interface.definition_container.clone(), None, diff --git a/examples/scripting/game/src/bot.rs b/examples/scripting/game/src/bot.rs index 975591bd3..3c720915a 100644 --- a/examples/scripting/game/src/bot.rs +++ b/examples/scripting/game/src/bot.rs @@ -6,7 +6,6 @@ use fyrox::{ }, core::{ algebra::{UnitQuaternion, Vector3}, - inspect::{Inspect, PropertyInfo}, pool::Handle, reflect::prelude::*, uuid::{uuid, Uuid}, @@ -23,13 +22,12 @@ use fyrox::{ script::{ScriptContext, ScriptTrait}, }; -#[derive(Visit, Inspect, Reflect, Default, Debug)] +#[derive(Visit, Reflect, Default, Debug)] pub struct Bot { collider: Handle, follow_target: bool, target: Vector3, - #[inspect(skip)] #[reflect(hidden)] machine: Option, } diff --git a/examples/scripting/game/src/lib.rs b/examples/scripting/game/src/lib.rs index 1874459f8..73191b473 100644 --- a/examples/scripting/game/src/lib.rs +++ b/examples/scripting/game/src/lib.rs @@ -4,7 +4,6 @@ use fyrox::{ core::{ algebra::{UnitQuaternion, Vector3}, futures::executor::block_on, - inspect::{Inspect, PropertyInfo}, pool::Handle, reflect::prelude::*, uuid::{uuid, Uuid}, @@ -108,7 +107,7 @@ pub struct InputController { jump: bool, } -#[derive(Visit, Inspect, Reflect, Debug, Clone)] +#[derive(Visit, Reflect, Debug, Clone)] struct Player { speed: f32, yaw: f32, @@ -116,7 +115,6 @@ struct Player { camera: Handle, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] controller: InputController, } @@ -249,7 +247,7 @@ impl ScriptTrait for Player { } } -#[derive(Visit, Inspect, Reflect, Debug, Clone)] +#[derive(Visit, Reflect, Debug, Clone)] struct Jumper { timer: f32, period: f32, diff --git a/fyrox-core-derive/src/inspect.rs b/fyrox-core-derive/src/inspect.rs deleted file mode 100644 index 645cf330a..000000000 --- a/fyrox-core-derive/src/inspect.rs +++ /dev/null @@ -1,73 +0,0 @@ -//! Implements `Inspect` trait - -mod args; -mod utils; - -use darling::{ast, FromDeriveInput}; -use proc_macro2::TokenStream as TokenStream2; -use quote::quote; -use syn::*; - -pub fn impl_inspect(ast: DeriveInput) -> TokenStream2 { - let mut ty_args = args::TypeArgs::from_derive_input(&ast).unwrap(); - ty_args.validate(); - - match &ty_args.data { - ast::Data::Struct(ref field_args) => self::impl_inspect_struct(&ty_args, field_args), - ast::Data::Enum(ref variant_args) => self::impl_inspect_enum(&ty_args, variant_args), - } -} - -fn impl_inspect_struct(ty_args: &args::TypeArgs, field_args: &args::Fields) -> TokenStream2 { - let field_prefix = utils::FieldPrefix::of_struct(field_args.style); - let body = utils::gen_inspect_fn_body(field_prefix, field_args); - utils::create_inspect_impl(ty_args, field_args.iter(), body) -} - -fn impl_inspect_enum(ty_args: &args::TypeArgs, variant_args: &[args::VariantArgs]) -> TokenStream2 { - let variant_matches = variant_args.iter().map(|variant| { - let variant_ident = &variant.ident; - - let field_prefix = utils::FieldPrefix::of_enum_variant(variant); - - let field_match_idents = variant.fields.fields.iter().enumerate().map(|(i, field)| { - let field_prefix = field_prefix.clone(); - field_prefix.field_match_ident(i, field, variant.fields.style) - }); - - let variant_match = match variant.fields.style { - ast::Style::Struct => { - quote! { - Self::#variant_ident { #(#field_match_idents),* } - } - } - ast::Style::Tuple => { - quote! { - Self::#variant_ident(#(#field_match_idents),*) - } - } - ast::Style::Unit => { - quote! { - Self::#variant_ident - } - } - }; - - let fields_inspects = utils::gen_inspect_fn_body(field_prefix, &variant.fields); - - quote! { - #variant_match => { - #fields_inspects - } - } - }); - - let body = quote! { - match self { - #(#variant_matches,)* - } - }; - - let field_args = variant_args.iter().flat_map(|v| v.fields.iter()); - utils::create_inspect_impl(ty_args, field_args, body) -} diff --git a/fyrox-core-derive/src/inspect/args.rs b/fyrox-core-derive/src/inspect/args.rs deleted file mode 100644 index 1fad0f0fa..000000000 --- a/fyrox-core-derive/src/inspect/args.rs +++ /dev/null @@ -1,121 +0,0 @@ -//! Derive input types defined with `darling`. -//! -//! They parse `#[attributes(..)]` syntax in a declartive style. - -use darling::*; -use syn::*; - -// pub type Data = ast::Data; -pub type Fields = ast::Fields; - -#[derive(FromDeriveInput)] -#[darling(attributes(inspect), supports(struct_any, enum_any))] -pub struct TypeArgs { - pub ident: Ident, - pub generics: Generics, - pub data: ast::Data, -} - -impl TypeArgs { - pub fn validate(&mut self) { - match &mut self.data { - ast::Data::Enum(vs) => { - vs.iter_mut() - .for_each(|v| v.fields.fields.iter_mut().for_each(|f| f.validate())); - } - ast::Data::Struct(s) => { - s.fields.iter_mut().for_each(|f| f.validate()); - } - } - } -} - -/// Parsed from struct's or enum variant's field -/// -/// NOTE: `#[derive(Inspect)]` is non-recursive by default. -#[derive(FromField, Clone, PartialEq)] -#[darling(attributes(inspect))] -pub struct FieldArgs { - pub ident: Option, - - pub ty: Type, - - /// `#[inspect(skip)]` - /// - /// Do not expose property info - #[darling(default)] - pub skip: bool, - - /// #[inspect(display_name = "")] - /// - /// A human-readable name. - #[darling(default)] - pub display_name: Option, - - /// `#[inspect(getter = "")]` - /// - /// Method call syntax for converting the field reference to another reference - #[darling(default)] - pub getter: Option, - - /// `#[inspect(deref)]` - /// - /// Sets `getter` field with `deref()` - #[darling(default)] - pub deref: bool, - - /// `#[inspect(read_only)]` - /// - /// The field is not meant to be edited. - #[darling(default)] - pub read_only: bool, - - /// `#[inspect(min_value = "0.0")]` - /// - /// Minimal value of the field. Works only for numeric fields! - #[darling(default)] - pub min_value: Option, - - /// `#[inspect(max_value = "1.0")]` - /// - /// Maximal value of the field. Works only for numeric fields! - #[darling(default)] - pub max_value: Option, - - /// `#[inspect(step = "0.1")]` - /// - /// Increment/decrement step of the field. Works only for numeric fields! - #[darling(default)] - pub step: Option, - - /// `#[inspect(precision = "3")]` - /// - /// Maximum amount of decimal places for a numeric property. - #[darling(default)] - pub precision: Option, - - /// `#[inspect(description = "This is a property description.")]` - /// - /// Description of the property. - #[darling(default)] - pub description: Option, -} - -impl FieldArgs { - pub fn validate(&mut self) { - if self.deref { - assert!(self.getter.is_none(), "can't use both `deref` and `getter`"); - - if self.deref { - self.getter = Some(parse_quote!(deref())); - } - } - } -} - -#[derive(FromVariant, Clone)] -#[darling(attributes(inspect))] -pub struct VariantArgs { - pub ident: Ident, - pub fields: ast::Fields, -} diff --git a/fyrox-core-derive/src/inspect/utils.rs b/fyrox-core-derive/src/inspect/utils.rs deleted file mode 100644 index 75c8a28b3..000000000 --- a/fyrox-core-derive/src/inspect/utils.rs +++ /dev/null @@ -1,262 +0,0 @@ -// NOTE: The `properties` impl does NOT use Self::PROP_KEY constants, but it's always safe - -use convert_case::*; -use darling::ast; -use proc_macro2::TokenStream as TokenStream2; -use quote::*; -use syn::*; - -use crate::inspect::args; - -/// Handles struct/enum variant field style differences in syntax -#[derive(Clone)] -pub struct FieldPrefix { - /// Struct | Enum - is_struct: bool, - /// Field style of the struct or the enum variant - style: ast::Style, - variant: Option, -} - -impl FieldPrefix { - pub fn of_struct(style: ast::Style) -> Self { - Self { - is_struct: true, - style, - variant: None, - } - } - - pub fn of_enum_variant(args: &args::VariantArgs) -> Self { - Self { - is_struct: false, - style: args.fields.style, - variant: Some(args.clone()), - } - } - - // Returns syntax for binding an enum variant's field on match: - // ``` - // match x { - // X::Struct { a, b, c } => { .. } - // // ~~~ use "field_name" - // X::Tuple(f0, f1, f2) => { .. } - // // ~~~ use "f" - // } - // ``` - pub fn field_match_ident(self, i: usize, field: &args::FieldArgs, style: ast::Style) -> Ident { - assert!(!self.is_struct); - - match style { - ast::Style::Struct => field.ident.clone().unwrap(), - ast::Style::Tuple => { - let i = Index::from(i); - format_ident!("f{}", i) - } - ast::Style::Unit => { - unreachable!() - } - } - } - - // Returns syntax that corresponds to `&self.field` for struct, `&variant.field` for structural - // enum variant, and `&variant.i` for tuple enum variant. - fn quote_field_ref( - &self, - i: usize, - field: &args::FieldArgs, - style: ast::Style, - ) -> TokenStream2 { - match style { - ast::Style::Struct => { - let field_ident = field.ident.as_ref().unwrap(); - - if self.is_struct { - quote! { (&self.#field_ident) } - } else { - // The `field` is of an enum variant - quote!(#field_ident) - } - } - ast::Style::Tuple => { - let index = Index::from(i); - - if self.is_struct { - quote! { (&self.#index) } - } else { - // The `field` is of an enum variant - let ident = format_ident!("f{}", index); - quote!(#ident) - } - } - ast::Style::Unit => { - unreachable!() - } - } - } - - // FIXME: Use shared function between `Inspect` and `Reflect` - fn property_key_name(&self, nth_field: usize, field: &args::FieldArgs) -> String { - let name = match self.style { - ast::Style::Struct => { - format!("{}", field.ident.as_ref().unwrap()) - } - ast::Style::Tuple => { - format!("{}", nth_field) - } - ast::Style::Unit => { - unreachable!() - } - }; - - if let Some(variant) = &self.variant { - format!("{}@{}", variant.ident, name) - } else { - name - } - } -} - -/// Creates `Inspect` trait impl and field prop keys -pub fn create_inspect_impl<'f>( - ty_args: &args::TypeArgs, - field_args: impl Iterator, - impl_body: TokenStream2, -) -> TokenStream2 { - let trait_impl = self::inspect_trait_impl(ty_args, field_args, impl_body); - - quote! { - #trait_impl - } -} - -/// `impl Inspect` -fn inspect_trait_impl<'f>( - ty_args: &args::TypeArgs, - field_args: impl Iterator, - impl_body: TokenStream2, -) -> TokenStream2 { - let ty_ident = &ty_args.ident; - let generics = self::impl_inspect_generics(&ty_args.generics, field_args); - let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); - - quote! { - impl #impl_generics Inspect for #ty_ident #ty_generics #where_clause { - fn properties(&self) -> Vec> { - #impl_body - } - } - } -} - -/// Creates `Generic` for `impl Inspect` block -/// -/// TODO: Add `where Field: Inspect` boundaries to support inspectable types with generics -fn impl_inspect_generics<'a>( - generics: &Generics, - _field_args: impl Iterator, -) -> Generics { - generics.clone() -} - -pub fn gen_inspect_fn_body( - field_prefix: FieldPrefix, - field_args: &ast::Fields, -) -> TokenStream2 { - // `inspect` function body, consisting of a sequence of quotes - let mut quotes = Vec::new(); - - let props = field_args - .fields - .iter() - // enumerate first, and then filter! - .enumerate() - .filter(|(_i, f)| !f.skip) - .map(|(i, field)| self::quote_field_prop(&field_prefix, i, field, field_args.style)); - - quotes.push(quote! { - let mut props = Vec::new(); - #(props.push(#props);)* - }); - - // concatenate the quotes - quote! { - #(#quotes)* - props - } -} - -/// `PropertyInfo { .. }` -fn quote_field_prop( - field_prefix: &FieldPrefix, - nth_field: usize, - field: &args::FieldArgs, - style: ast::Style, -) -> TokenStream2 { - let field_ident = match &field.ident { - Some(ident) => quote!(#ident), - None => { - let nth_field = Index::from(nth_field); - quote!(#nth_field) - } - }; - - let field_ref = field_prefix.quote_field_ref(nth_field, field, style); - - let getter = match &field.getter { - // use custom getter function to retrieve the target reference - Some(getter) => { - quote! { #field_ref.#getter } - } - // default: get reference of the field - None => field_ref, - }; - - let prop_key_name = field_prefix.property_key_name(nth_field, field); - - // consider #[inspect(display_name = ..)] - let display_name = field - .display_name - .clone() - .unwrap_or_else(|| field_ident.to_string()); - let display_name = display_name.to_case(Case::Title); - - let min_value = match field.min_value { - None => quote! { None }, - Some(v) => quote! { Some(#v)}, - }; - - let max_value = match field.max_value { - None => quote! { None }, - Some(v) => quote! { Some(#v)}, - }; - - let step = match field.step { - None => quote! { None }, - Some(v) => quote! { Some(#v) }, - }; - - let precision = match field.precision { - None => quote! { None }, - Some(v) => quote! { Some(#v) }, - }; - - let read_only = field.read_only; - - let description = field.description.clone().unwrap_or_default(); - - quote! { - PropertyInfo { - owner_type_id: std::any::TypeId::of::(), - name: #prop_key_name, - display_name: #display_name, - value: #getter, - read_only: #read_only, - min_value: #min_value, - max_value: #max_value, - step: #step, - precision: #precision, - description: (#description).to_string(), - } - } -} diff --git a/fyrox-core-derive/src/lib.rs b/fyrox-core-derive/src/lib.rs index ff6902335..069c8409b 100644 --- a/fyrox-core-derive/src/lib.rs +++ b/fyrox-core-derive/src/lib.rs @@ -1,4 +1,3 @@ -mod inspect; mod reflect; mod visit; @@ -15,24 +14,6 @@ pub fn visit(input: TokenStream) -> TokenStream { TokenStream::from(visit::impl_visit(ast)) } -/// Implements `Inspect` trait -/// -/// User has to import `Inspect` and `PropertyInfo` to use this macro. -#[proc_macro_derive(Inspect, attributes(inspect))] -pub fn inspect(input: TokenStream) -> TokenStream { - let ast = parse_macro_input!(input as DeriveInput); - TokenStream::from(inspect::impl_inspect(ast)) -} - -/// Implements `Inspect` trait -/// -/// User has to import `Inspect` and `PropertyInfo` to use this macro. -#[proc_macro] -pub fn impl_inspect(input: TokenStream) -> TokenStream { - let ast = parse_macro_input!(input as DeriveInput); - TokenStream::from(inspect::impl_inspect(ast)) -} - /// Implements `Reflect` trait #[proc_macro_derive(Reflect, attributes(reflect))] pub fn reflect(input: TokenStream) -> TokenStream { diff --git a/fyrox-core-derive/src/reflect.rs b/fyrox-core-derive/src/reflect.rs index 53d2e939a..9a619b154 100644 --- a/fyrox-core-derive/src/reflect.rs +++ b/fyrox-core-derive/src/reflect.rs @@ -66,7 +66,7 @@ pub fn gen_fields_metadata_body( } } -/// `PropertyInfo { .. }` +/// `FieldInfo { .. }` fn quote_field_prop( prop_key_name: &str, nth_field: usize, diff --git a/fyrox-core-derive/src/reflect/args.rs b/fyrox-core-derive/src/reflect/args.rs index 88b363f47..2810bc346 100644 --- a/fyrox-core-derive/src/reflect/args.rs +++ b/fyrox-core-derive/src/reflect/args.rs @@ -152,43 +152,43 @@ pub struct FieldArgs { #[darling(default)] pub setter: Option, - /// #[inspect(display_name = "")] + /// #[reflect(display_name = "")] /// /// A human-readable name. #[darling(default)] pub display_name: Option, - /// `#[inspect(read_only)]` + /// `#[reflect(read_only)]` /// /// The field is not meant to be edited. #[darling(default)] pub read_only: bool, - /// `#[inspect(min_value = "0.0")]` + /// `#[reflect(min_value = "0.0")]` /// /// Minimal value of the field. Works only for numeric fields! #[darling(default)] pub min_value: Option, - /// `#[inspect(max_value = "1.0")]` + /// `#[reflect(max_value = "1.0")]` /// /// Maximal value of the field. Works only for numeric fields! #[darling(default)] pub max_value: Option, - /// `#[inspect(step = "0.1")]` + /// `#[reflect(step = "0.1")]` /// /// Increment/decrement step of the field. Works only for numeric fields! #[darling(default)] pub step: Option, - /// `#[inspect(precision = "3")]` + /// `#[reflect(precision = "3")]` /// /// Maximum amount of decimal places for a numeric property. #[darling(default)] pub precision: Option, - /// `#[inspect(description = "This is a property description.")]` + /// `#[reflect(description = "This is a property description.")]` /// /// Description of the property. #[darling(default)] diff --git a/fyrox-core-derive/tests/it/inspect.rs b/fyrox-core-derive/tests/it/inspect.rs deleted file mode 100644 index e3ebec333..000000000 --- a/fyrox-core-derive/tests/it/inspect.rs +++ /dev/null @@ -1,306 +0,0 @@ -//! Test cases for `fyrox::gui::Inspect` - -use std::any::TypeId; - -use fyrox_core::{ - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, -}; - -fn default_prop() -> PropertyInfo<'static> { - PropertyInfo { - owner_type_id: TypeId::of::<()>(), - name: "", - display_name: "", - value: &(), - read_only: false, - min_value: None, - max_value: None, - step: None, - precision: None, - description: "".to_string(), - } -} - -#[test] -fn inspect_default() { - #[derive(Debug, Default, Inspect, Reflect)] - pub struct Data { - the_field: String, - another_field: f32, - } - - let data = Data::default(); - - let expected = vec![ - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "the_field", - display_name: "The Field", - value: &data.the_field, - ..default_prop() - }, - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "another_field", - display_name: "Another Field", - value: &data.another_field, - ..default_prop() - }, - ]; - - assert_eq!(data.properties(), expected); -} - -#[test] -fn inspect_attributes() { - #[derive(Debug, Default, Inspect, Reflect)] - pub struct AarGee { - aar: u32, - gee: u32, - } - - #[derive(Debug, Default, Inspect, Reflect)] - pub struct Data { - // NOTE: Even though this field is skipped, the next field is given index `1` for simplicity - #[inspect(skip)] - _skipped: u32, - #[inspect(display_name = "Super X")] - x: f32, - #[inspect( - read_only, - min_value = 0.1, - max_value = 1.1, - step = 0.1, - precision = 3, - description = "This is a property description." - )] - y: f32, - } - - let data = Data::default(); - - let expected = vec![ - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "x", - display_name: "Super X", - value: &data.x, - ..default_prop() - }, - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "y", - display_name: "Y", - value: &data.y, - read_only: true, - min_value: Some(0.1), - max_value: Some(1.1), - step: Some(0.1), - precision: Some(3), - description: "This is a property description.".to_string(), - }, - ]; - - assert_eq!(data.properties()[0..2], expected); -} - -#[test] -fn inspect_struct() { - #[derive(Debug, Default, Inspect, Reflect)] - struct Tuple(f32, f32); - - let x = Tuple::default(); - assert_eq!( - x.properties(), - vec![ - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "0", - display_name: "0", - value: &x.0, - ..default_prop() - }, - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "1", - display_name: "1", - value: &x.1, - ..default_prop() - }, - ] - ); - - #[derive(Debug, Default, Inspect, Reflect)] - struct Unit; - - let x = Unit::default(); - assert_eq!(x.properties(), vec![]); -} - -#[test] -fn inspect_enum() { - #[derive(Debug, Inspect, Reflect)] - pub struct NonCopy { - inner: u32, - } - - #[derive(Debug, Inspect, Reflect)] - pub enum Data { - Named { x: u32, y: u32, z: NonCopy }, - Tuple(f32, f32), - Unit, - } - - let data = Data::Named { - x: 0, - y: 1, - z: NonCopy { inner: 10 }, - }; - - assert_eq!( - data.properties(), - vec![ - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "Named@x", - display_name: "X", - value: match data { - Data::Named { ref x, .. } => x, - _ => unreachable!(), - }, - ..default_prop() - }, - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "Named@y", - display_name: "Y", - value: match data { - Data::Named { ref y, .. } => y, - _ => unreachable!(), - }, - ..default_prop() - }, - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "Named@z", - display_name: "Z", - value: match data { - Data::Named { ref z, .. } => z, - _ => unreachable!(), - }, - ..default_prop() - }, - ] - ); - - let data = Data::Tuple(10.0, 20.0); - - assert_eq!( - data.properties(), - vec![ - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "Tuple@0", - display_name: "0", - value: match data { - Data::Tuple(ref f0, ref _f1) => f0, - _ => unreachable!(), - }, - ..default_prop() - }, - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "Tuple@1", - display_name: "1", - value: match data { - Data::Tuple(ref _f0, ref f1) => f1, - _ => unreachable!(), - }, - ..default_prop() - }, - ] - ); - - // unit variants don't have fields - let data = Data::Unit; - assert_eq!(data.properties(), vec![]); -} - -#[test] -fn inspect_prop_key_constants() { - #[allow(dead_code)] - #[derive(Inspect, Reflect)] - pub struct SStruct { - field: usize, - #[inspect(skip)] - hidden: usize, - } - - // NOTE: property names are in snake_case (not Title Case) - assert_eq!(SStruct::FIELD, "field"); - - // hidden properties - // assert_eq!(SStruct::HIDDEN, "hidden"); - - #[derive(Inspect, Reflect)] - pub struct STuple(usize); - assert_eq!(STuple::F_0, "0"); - - #[derive(Inspect, Reflect)] - #[allow(unused)] - pub enum E { - Tuple(usize), - Struct { field: usize }, - Unit, - } - - assert_eq!(E::TUPLE_F_0, "Tuple@0"); - assert_eq!(E::TUPLE_F_0, E::Tuple(0).properties()[0].name); - - assert_eq!(E::STRUCT_FIELD, "Struct@field"); - assert_eq!(E::STRUCT_FIELD, E::Struct { field: 0 }.properties()[0].name); -} - -#[test] -fn inspect_with_custom_getter() { - use std::ops::Deref; - - #[derive(Reflect)] - struct D(T); - - impl Deref for D { - type Target = T; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - #[derive(Inspect, Reflect)] - struct A( - #[inspect(getter = "deref()")] D, - #[inspect(deref)] D, - ); - - let a = A(D(10), D(11)); - - assert_eq!( - a.properties(), - vec![ - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "0", - display_name: "0", - value: &*a.0, - ..default_prop() - }, - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "1", - display_name: "1", - value: &*a.1, - ..default_prop() - } - ] - ); -} diff --git a/fyrox-core-derive/tests/it/main.rs b/fyrox-core-derive/tests/it/main.rs index 387f4c2fd..547afb7ef 100644 --- a/fyrox-core-derive/tests/it/main.rs +++ b/fyrox-core-derive/tests/it/main.rs @@ -5,6 +5,5 @@ // #![feature(trace_macros)] // trace_macros!(true); -pub mod inspect; pub mod reflect; pub mod visit; diff --git a/fyrox-core/src/inspect.rs b/fyrox-core/src/inspect.rs deleted file mode 100644 index 69fdf9af0..000000000 --- a/fyrox-core/src/inspect.rs +++ /dev/null @@ -1,243 +0,0 @@ -//! Inspection allows you to obtain a metadata of an object. -//! -//! See [`Inspect`] for more info. - -#![warn(missing_docs)] - -use fyrox_core_derive::impl_inspect; -use nalgebra::{UnitQuaternion, Vector2, Vector3, Vector4}; -use std::{ - any::{Any, TypeId}, - fmt::{self, Debug}, -}; - -pub mod prelude { - //! Standard import for `Inspect` proc macro. - pub use super::{Inspect, PropertyInfo}; -} - -/// A value of a property. -pub trait PropertyValue: Any + 'static { - /// Casts `self` to a `&dyn Any` - fn as_any(&self) -> &dyn Any; -} - -impl PropertyValue for T { - fn as_any(&self) -> &dyn Any { - self - } -} - -/// An error that can occur during "type casting" -#[derive(Debug)] -pub enum CastError { - /// Given type does not match expected. - TypeMismatch { - /// A name of the property. - property_name: String, - - /// Expected type identifier. - expected_type_id: TypeId, - - /// Actual type identifier. - actual_type_id: TypeId, - }, -} - -/// Information about a property of an object. -pub struct PropertyInfo<'a> { - /// A type id of the owner of the property. - pub owner_type_id: TypeId, - - /// A name of the property. - pub name: &'a str, - - /// A human-readable name of the property. - pub display_name: &'static str, - - /// An reference to the actual value of the property. - pub value: &'a dyn PropertyValue, - - /// A property is not meant to be edited. - pub read_only: bool, - - /// A minimal value of the property. Works only with numeric properties! - pub min_value: Option, - - /// A minimal value of the property. Works only with numeric properties! - pub max_value: Option, - - /// A minimal value of the property. Works only with numeric properties! - pub step: Option, - - /// Maximum amount of decimal places for a numeric property. - pub precision: Option, - - /// Description of the property. - pub description: String, -} - -impl<'a> PartialEq for FieldInfo<'a> { - fn eq(&self, other: &Self) -> bool { - let value_ptr_a = self.value as *const _ as *const (); - let value_ptr_b = other.value as *const _ as *const (); - - self.owner_type_id == other.owner_type_id - && self.name == other.name - && self.display_name == other.display_name - && std::ptr::eq(value_ptr_a, value_ptr_b) - && self.read_only == other.read_only - && self.min_value == other.min_value - && self.max_value == other.max_value - && self.step == other.step - && self.precision == other.precision - && self.description == other.description - } -} - -impl<'a> fmt::Debug for FieldInfo<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("PropertyInfo") - .field("owner_type_id", &self.owner_type_id) - .field("name", &self.name) - .field("display_name", &self.display_name) - .field("value", &format_args!("{:?}", self.value as *const _)) - .field("read_only", &self.read_only) - .field("min_value", &self.min_value) - .field("max_value", &self.max_value) - .field("step", &self.step) - .field("precision", &self.precision) - .field("description", &self.description) - .finish() - } -} - -impl<'a> fmt::Debug for PropertyInfo<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("PropertyInfo") - .field("owner_type_id", &self.owner_type_id) - .field("name", &self.name) - .field("display_name", &self.display_name) - .field("value", &format_args!("{:?}", self.value as *const _)) - .field("read_only", &self.read_only) - .field("min_value", &self.min_value) - .field("max_value", &self.max_value) - .field("step", &self.step) - .field("precision", &self.precision) - .field("description", &self.description) - .finish() - } -} - -impl<'a> PropertyInfo<'a> { - /// Tries to cast a value to a given type. - pub fn cast_value(&self) -> Result<&T, CastError> { - match self.value.as_any().downcast_ref::() { - Some(value) => Ok(value), - None => Err(CastError::TypeMismatch { - property_name: self.name.to_string(), - expected_type_id: TypeId::of::(), - actual_type_id: self.value.type_id(), - }), - } - } -} - -/// A trait that allows you to "look inside" an object that implements it. It is used to get metadata -/// (such as name, description, precision, etc.) of object's properties. The most common use case for -/// it is various editors. -/// -/// ## Implementation -/// -/// It is not advised to manually implement this trait. You should use `#[derive(Inspect, Reflect)]` -/// whenever possible. -/// -/// ## `#[derive(Inspect)]` -/// -/// The proc macro reduces amount of boilerplate code to the minimum and significantly reduces a -/// change of error. -/// -/// ### Supported attributes -/// -/// - `#[inspect(display_name = "Human-readable Name")]` - override display name. -/// - `#[inspect(group = "Group Name")]` - override group name. -pub trait Inspect { - /// Returns information about "public" properties. - fn properties(&self) -> Vec>; -} - -impl_inspect! { - pub enum Option { - Some(T), - None - } -} - -impl_inspect! { - pub struct Box; -} - -macro_rules! impl_numeric_inspect { - ($ty:ty, $min:expr, $max:expr, $step:expr, $precision:expr) => { - impl Inspect for $ty { - fn properties(&self) -> Vec> { - vec![PropertyInfo { - owner_type_id: TypeId::of::(), - name: "self", - display_name: "Value", - value: self, - read_only: false, - min_value: Some($min), - max_value: Some($max), - step: Some($step), - precision: Some($precision), - description: "".to_string(), - }] - } - } - }; -} - -impl_numeric_inspect!(f32, f32::MIN as f64, f32::MAX as f64, 1.0, 7); -impl_numeric_inspect!(f64, f64::MIN, f64::MAX, 1.0, 15); -impl_numeric_inspect!(i64, i64::MIN as f64, i64::MAX as f64, 1.0, 0); -impl_numeric_inspect!(u64, u64::MIN as f64, u64::MAX as f64, 1.0, 0); -impl_numeric_inspect!(i32, i32::MIN as f64, i32::MAX as f64, 1.0, 0); -impl_numeric_inspect!(u32, u32::MIN as f64, u32::MAX as f64, 1.0, 0); -impl_numeric_inspect!(i16, i16::MIN as f64, i16::MAX as f64, 1.0, 0); -impl_numeric_inspect!(u16, u16::MIN as f64, u16::MAX as f64, 1.0, 0); -impl_numeric_inspect!(i8, i8::MIN as f64, i8::MAX as f64, 1.0, 0); -impl_numeric_inspect!(u8, u8::MIN as f64, u8::MAX as f64, 1.0, 0); -impl_numeric_inspect!(usize, usize::MIN as f64, usize::MAX as f64, 1.0, 0); -impl_numeric_inspect!(isize, isize::MIN as f64, isize::MAX as f64, 1.0, 0); - -macro_rules! impl_simple_inspect { - ($ty:ty) => { - impl Inspect for $ty { - fn properties(&self) -> Vec> { - vec![PropertyInfo { - owner_type_id: TypeId::of::(), - name: "self", - display_name: "Value", - value: self, - read_only: false, - min_value: None, - max_value: None, - step: None, - precision: None, - description: "".to_string(), - }] - } - } - }; -} - -impl_simple_inspect!(String); -impl_simple_inspect!(bool); -impl_simple_inspect!(Vector2); -impl_simple_inspect!(Vector3); -impl_simple_inspect!(Vector4); -impl_simple_inspect!(UnitQuaternion); - -use crate::reflect::FieldInfo; -pub use fyrox_core_derive::Inspect; diff --git a/fyrox-core/src/lib.rs b/fyrox-core/src/lib.rs index 2404a9ca6..aa7651ad9 100644 --- a/fyrox-core/src/lib.rs +++ b/fyrox-core/src/lib.rs @@ -30,7 +30,6 @@ use std::{ pub mod color; pub mod color_gradient; pub mod curve; -pub mod inspect; pub mod io; pub mod math; pub mod numeric_range; diff --git a/fyrox-core/src/math/mod.rs b/fyrox-core/src/math/mod.rs index 8df5e9b5c..db8f24333 100644 --- a/fyrox-core/src/math/mod.rs +++ b/fyrox-core/src/math/mod.rs @@ -11,7 +11,6 @@ use crate::{ algebra::{ Matrix3, Matrix4, RealField, Scalar, SimdRealField, UnitQuaternion, Vector2, Vector3, }, - inspect::prelude::*, math::ray::IntersectionResult, num_traits::{NumAssign, Zero}, reflect::prelude::*, @@ -848,7 +847,7 @@ pub fn get_closest_point_triangle_set( closest_index } -#[derive(Debug, PartialEq, Visit, Reflect, Inspect, Clone)] +#[derive(Debug, PartialEq, Visit, Reflect, Clone)] pub struct SmoothAngle { /// Current angle in radians. pub angle: f32, diff --git a/fyrox-core/src/pool.rs b/fyrox-core/src/pool.rs index 84e229078..53b7a3e14 100644 --- a/fyrox-core/src/pool.rs +++ b/fyrox-core/src/pool.rs @@ -23,13 +23,11 @@ #![allow(clippy::unneeded_field_pattern)] use crate::{ - inspect::{Inspect, PropertyInfo}, reflect::prelude::*, visitor::{Visit, VisitResult, Visitor}, }; use arrayvec::ArrayVec; use std::{ - any::TypeId, fmt::{Debug, Display, Formatter}, future::Future, hash::{Hash, Hasher}, @@ -116,46 +114,17 @@ impl PartialEq for Pool { #[derive(Reflect)] pub struct Handle { /// Index of object in pool. + #[reflect(read_only, description = "Index of an object in a pool.")] index: u32, /// Generation number, if it is same as generation of pool record at /// index of handle then this is valid handle. + #[reflect(read_only, description = "Generation of an object in a pool.")] generation: u32, /// Type holder. #[reflect(hidden)] type_marker: PhantomData, } -impl Inspect for Handle { - fn properties(&self) -> Vec> { - vec![ - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "index", - display_name: "Index", - value: &self.index, - read_only: true, - min_value: None, - max_value: None, - step: None, - precision: None, - description: "Index of an object in a pool.".to_string(), - }, - PropertyInfo { - owner_type_id: TypeId::of::(), - name: "generation", - display_name: "Generation", - value: &self.generation, - read_only: true, - min_value: None, - max_value: None, - step: None, - precision: None, - description: "Generation of an object in a pool.".to_string(), - }, - ] - } -} - unsafe impl Send for Handle {} unsafe impl Sync for Handle {} @@ -166,14 +135,14 @@ impl Display for Handle { } /// Type-erased handle. -#[derive(Copy, Clone, Debug, Ord, PartialOrd, PartialEq, Eq, Hash, Inspect, Reflect, Visit)] +#[derive(Copy, Clone, Debug, Ord, PartialOrd, PartialEq, Eq, Hash, Reflect, Visit)] pub struct ErasedHandle { /// Index of object in pool. - #[inspect(read_only)] + #[reflect(read_only)] index: u32, /// Generation number, if it is same as generation of pool record at /// index of handle then this is valid handle. - #[inspect(read_only)] + #[reflect(read_only)] generation: u32, } diff --git a/fyrox-core/src/reflect.rs b/fyrox-core/src/reflect.rs index 4ba24c5c5..a5cb319fb 100644 --- a/fyrox-core/src/reflect.rs +++ b/fyrox-core/src/reflect.rs @@ -77,7 +77,38 @@ pub struct FieldInfo<'a> { pub precision: Option, } -impl<'a> PartialEq for PropertyInfo<'a> { +impl<'a> FieldInfo<'a> { + /// Tries to cast a value to a given type. + pub fn cast_value(&self) -> Result<&T, CastError> { + match self.value.as_any().downcast_ref::() { + Some(value) => Ok(value), + None => Err(CastError::TypeMismatch { + property_name: self.name.to_string(), + expected_type_id: TypeId::of::(), + actual_type_id: self.value.type_id(), + }), + } + } +} + +impl<'a> fmt::Debug for FieldInfo<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("PropertyInfo") + .field("owner_type_id", &self.owner_type_id) + .field("name", &self.name) + .field("display_name", &self.display_name) + .field("value", &format_args!("{:?}", self.value as *const _)) + .field("read_only", &self.read_only) + .field("min_value", &self.min_value) + .field("max_value", &self.max_value) + .field("step", &self.step) + .field("precision", &self.precision) + .field("description", &self.description) + .finish() + } +} + +impl<'a> PartialEq for FieldInfo<'a> { fn eq(&self, other: &Self) -> bool { let value_ptr_a = self.value as *const _ as *const (); let value_ptr_b = other.value as *const _ as *const (); @@ -605,7 +636,6 @@ macro_rules! delegate_reflect { }; } -use crate::inspect::PropertyInfo; use crate::variable::{InheritError, VariableFlags}; pub use blank_reflect; pub use delegate_reflect; diff --git a/fyrox-core/src/variable.rs b/fyrox-core/src/variable.rs index 96f660292..f13898fbb 100644 --- a/fyrox-core/src/variable.rs +++ b/fyrox-core/src/variable.rs @@ -3,7 +3,6 @@ //! For more info see [`InheritableVariable`] use crate::{ - inspect::{Inspect, PropertyInfo}, reflect::{prelude::*, ReflectArray, ReflectInheritableVariable, ReflectList}, visitor::prelude::*, }; @@ -241,15 +240,6 @@ where } } -impl Inspect for InheritableVariable -where - T: Inspect, -{ - fn properties(&self) -> Vec> { - self.value.properties() - } -} - impl Reflect for InheritableVariable where T: Reflect + Clone + PartialEq + Debug, diff --git a/fyrox-sound/src/context.rs b/fyrox-sound/src/context.rs index 02f811bc7..3fa9b84f3 100644 --- a/fyrox-sound/src/context.rs +++ b/fyrox-sound/src/context.rs @@ -18,7 +18,6 @@ use crate::{ source::{SoundSource, Status}, }; use fyrox_core::{ - inspect::{Inspect, PropertyInfo}, pool::{Handle, Pool}, reflect::prelude::*, visitor::prelude::*, @@ -35,17 +34,7 @@ pub const SAMPLE_RATE: u32 = 44100; /// Distance model defines how volume of sound will decay when distance to listener changes. #[derive( - Copy, - Clone, - Debug, - Eq, - PartialEq, - Inspect, - Reflect, - Visit, - AsRefStr, - EnumString, - EnumVariantNames, + Copy, Clone, Debug, Eq, PartialEq, Reflect, Visit, AsRefStr, EnumString, EnumVariantNames, )] #[repr(u32)] pub enum DistanceModel { diff --git a/fyrox-sound/src/dsp/filters.rs b/fyrox-sound/src/dsp/filters.rs index 11f0a0af5..375cd013e 100644 --- a/fyrox-sound/src/dsp/filters.rs +++ b/fyrox-sound/src/dsp/filters.rs @@ -8,7 +8,6 @@ use crate::dsp::DelayLine; use fyrox_core::{ - inspect::{Inspect, PropertyInfo}, reflect::prelude::*, visitor::{Visit, VisitResult, Visitor}, }; @@ -197,7 +196,7 @@ pub enum BiquadKind { /// Generic second order digital filter. /// More info here: -#[derive(Clone, Debug, Inspect, Reflect, Visit, PartialEq)] +#[derive(Clone, Debug, Reflect, Visit, PartialEq)] pub struct Biquad { /// B0 Coefficient of the equation. pub b0: f32, @@ -209,9 +208,9 @@ pub struct Biquad { pub a1: f32, /// A2 Coefficient of the equation. pub a2: f32, - #[inspect(skip)] + #[reflect(hidden)] prev1: f32, - #[inspect(skip)] + #[reflect(hidden)] prev2: f32, } diff --git a/fyrox-sound/src/renderer/hrtf.rs b/fyrox-sound/src/renderer/hrtf.rs index bc49c1e71..1737c7006 100644 --- a/fyrox-sound/src/renderer/hrtf.rs +++ b/fyrox-sound/src/renderer/hrtf.rs @@ -58,7 +58,6 @@ use crate::{ source::SoundSource, }; use fyrox_core::{ - inspect::{Inspect, PropertyInfo}, reflect::prelude::*, visitor::{Visit, VisitResult, Visitor}, }; @@ -66,10 +65,9 @@ use hrtf::HrirSphere; use std::{fmt::Debug, path::PathBuf}; /// See module docs. -#[derive(Clone, Debug, Default, Inspect, Reflect)] +#[derive(Clone, Debug, Default, Reflect)] pub struct HrtfRenderer { hrir_path: PathBuf, - #[inspect(skip)] #[reflect(hidden)] processor: Option, } diff --git a/fyrox-sound/src/renderer/mod.rs b/fyrox-sound/src/renderer/mod.rs index 15214db8c..590e29ae7 100644 --- a/fyrox-sound/src/renderer/mod.rs +++ b/fyrox-sound/src/renderer/mod.rs @@ -13,7 +13,6 @@ use crate::{ }; use fyrox_core::math::lerpf; use fyrox_core::{ - inspect::{Inspect, PropertyInfo}, reflect::prelude::*, visitor::{Visit, VisitResult, Visitor}, }; @@ -35,17 +34,6 @@ pub enum Renderer { HrtfRenderer(HrtfRenderer), } -impl Inspect for Renderer { - fn properties(&self) -> Vec> { - match self { - Renderer::Default => { - vec![] - } - Renderer::HrtfRenderer(v) => v.properties(), - } - } -} - impl Default for Renderer { fn default() -> Self { Self::Default diff --git a/fyrox-sound/src/source.rs b/fyrox-sound/src/source.rs index 0f8c04773..66870e3e9 100644 --- a/fyrox-sound/src/source.rs +++ b/fyrox-sound/src/source.rs @@ -37,7 +37,6 @@ use crate::{ }; use fyrox_core::{ algebra::Vector3, - inspect::{Inspect, PropertyInfo}, reflect::prelude::*, visitor::{Visit, VisitResult, Visitor}, }; @@ -45,7 +44,7 @@ use fyrox_resource::ResourceState; use std::time::Duration; /// Status (state) of sound source. -#[derive(Eq, PartialEq, Copy, Clone, Debug, Inspect, Reflect, Visit)] +#[derive(Eq, PartialEq, Copy, Clone, Debug, Reflect, Visit)] #[repr(u32)] pub enum Status { /// Sound is stopped - it won't produces any sample and won't load mixer. This is default @@ -61,7 +60,7 @@ pub enum Status { } /// See module info. -#[derive(Debug, Clone, Inspect, Reflect, Visit)] +#[derive(Debug, Clone, Reflect, Visit)] pub struct SoundSource { name: String, #[reflect(hidden)] @@ -70,19 +69,19 @@ pub struct SoundSource { // In case of streaming buffer its maximum value will be some fixed value which is // implementation defined. It can be less than zero, this happens when we are in the process // of reading next block in streaming buffer (see also prev_buffer_sample). - #[inspect(skip)] + #[reflect(hidden)] buf_read_pos: f64, // Real playback position in samples. - #[inspect(skip)] + #[reflect(hidden)] playback_pos: f64, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] panning: f32, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pitch: f64, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] gain: f32, looping: bool, - #[inspect(min_value = 0.0, max_value = 1.0, step = 0.05)] + #[reflect(min_value = 0.0, max_value = 1.0, step = 0.05)] spatial_blend: f32, // Important coefficient for runtime resampling. It is used to modify playback speed // of a source in order to match output device sampling rate. PCM data can be stored @@ -92,7 +91,7 @@ pub struct SoundSource { // hear that sound will have high pitch (2.0), to fix that we'll just pre-multiply // playback speed by 0.5. // However such auto-resampling has poor quality, but it is fast. - #[inspect(read_only)] + #[reflect(read_only)] resampling_multiplier: f64, status: Status, play_once: bool, @@ -102,37 +101,37 @@ pub struct SoundSource { // can be with no respect to real distance attenuation (or what else affects channel // gain). So if these are None engine will set correct values first and only then it // will start interpolation of gain. - #[inspect(skip)] + #[reflect(hidden)] #[visit(skip)] pub(crate) last_left_gain: Option, - #[inspect(skip)] + #[reflect(hidden)] #[visit(skip)] pub(crate) last_right_gain: Option, - #[inspect(skip)] + #[reflect(hidden)] #[visit(skip)] pub(crate) frame_samples: Vec<(f32, f32)>, // This sample is used when doing linear interpolation between two blocks of streaming buffer. - #[inspect(skip)] + #[reflect(hidden)] #[visit(skip)] prev_buffer_sample: (f32, f32), - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] radius: f32, position: Vector3, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] max_distance: f32, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] rolloff_factor: f32, // Some data that needed for iterative overlap-save convolution. - #[inspect(skip)] + #[reflect(hidden)] #[visit(skip)] pub(crate) prev_left_samples: Vec, - #[inspect(skip)] + #[reflect(hidden)] #[visit(skip)] pub(crate) prev_right_samples: Vec, - #[inspect(skip)] + #[reflect(hidden)] #[visit(skip)] pub(crate) prev_sampling_vector: Vector3, - #[inspect(skip)] + #[reflect(hidden)] #[visit(skip)] pub(crate) prev_distance_gain: Option, } diff --git a/fyrox-ui/src/inspector/editors/array.rs b/fyrox-ui/src/inspector/editors/array.rs index 174b577db..bd64582c4 100644 --- a/fyrox-ui/src/inspector/editors/array.rs +++ b/fyrox-ui/src/inspector/editors/array.rs @@ -1,5 +1,5 @@ use crate::{ - core::{inspect::Inspect, pool::Handle}, + core::{pool::Handle, reflect::prelude::*}, inspector::{ editors::{ PropertyEditorBuildContext, PropertyEditorDefinition, @@ -66,7 +66,7 @@ impl Control for ArrayEditor { pub struct ArrayEditorBuilder<'a, T, I> where - T: Inspect + 'static, + T: Reflect + 'static, I: IntoIterator, { widget_builder: WidgetBuilder, @@ -106,7 +106,7 @@ fn create_items<'a, T, I>( layer_index: usize, ) -> Vec where - T: Inspect + 'static, + T: Reflect + 'static, I: IntoIterator, { iter.into_iter() @@ -131,7 +131,7 @@ where impl<'a, T, I> ArrayEditorBuilder<'a, T, I> where - T: Inspect + 'static, + T: Reflect + 'static, I: IntoIterator, { pub fn new(widget_builder: WidgetBuilder) -> Self { @@ -206,14 +206,14 @@ where #[derive(Debug)] pub struct ArrayPropertyEditorDefinition where - T: Inspect + Debug + 'static, + T: Reflect + Debug + 'static, { phantom: PhantomData, } impl ArrayPropertyEditorDefinition where - T: Inspect + Debug + 'static, + T: Reflect + Debug + 'static, { pub fn new() -> Self { Self::default() @@ -222,7 +222,7 @@ where impl Default for ArrayPropertyEditorDefinition where - T: Inspect + Debug + 'static, + T: Reflect + Debug + 'static, { fn default() -> Self { Self { @@ -233,7 +233,7 @@ where impl PropertyEditorDefinition for ArrayPropertyEditorDefinition where - T: Inspect + Debug + 'static, + T: Reflect + Debug + 'static, { fn value_type_id(&self) -> TypeId { TypeId::of::<[T; N]>() diff --git a/fyrox-ui/src/inspector/editors/collection.rs b/fyrox-ui/src/inspector/editors/collection.rs index c6320fa0c..556b1cadb 100644 --- a/fyrox-ui/src/inspector/editors/collection.rs +++ b/fyrox-ui/src/inspector/editors/collection.rs @@ -1,6 +1,6 @@ use crate::{ button::{ButtonBuilder, ButtonMessage}, - core::{inspect::Inspect, pool::Handle}, + core::pool::Handle, define_constructor, inspector::{ editors::{ @@ -33,9 +33,9 @@ pub struct Item { remove: Handle, } -pub trait CollectionItem: Inspect + Clone + Reflect + Debug + Default + 'static {} +pub trait CollectionItem: Clone + Reflect + Debug + Default + 'static {} -impl CollectionItem for T {} +impl CollectionItem for T {} #[derive(Debug)] pub struct CollectionEditor { diff --git a/fyrox-ui/src/inspector/editors/enumeration.rs b/fyrox-ui/src/inspector/editors/enumeration.rs index bb09b88c1..4d2d93300 100644 --- a/fyrox-ui/src/inspector/editors/enumeration.rs +++ b/fyrox-ui/src/inspector/editors/enumeration.rs @@ -1,6 +1,6 @@ use crate::{ border::BorderBuilder, - core::{inspect::Inspect, pool::Handle}, + core::pool::Handle, decorator::DecoratorBuilder, define_constructor, dropdown_list::{DropdownList, DropdownListBuilder, DropdownListMessage}, @@ -31,9 +31,9 @@ use strum::VariantNames; const LOCAL_SYNC_FLAG: u64 = 0xFF; -pub trait InspectableEnum: Debug + Inspect + Reflect + Clone + 'static {} +pub trait InspectableEnum: Debug + Reflect + Clone + 'static {} -impl InspectableEnum for T {} +impl InspectableEnum for T {} #[derive(Debug, Clone, PartialEq)] pub enum EnumPropertyEditorMessage { diff --git a/fyrox-ui/src/inspector/editors/inherit.rs b/fyrox-ui/src/inspector/editors/inherit.rs index df0baed87..1bdd3813d 100644 --- a/fyrox-ui/src/inspector/editors/inherit.rs +++ b/fyrox-ui/src/inspector/editors/inherit.rs @@ -3,11 +3,7 @@ use crate::{ button::{ButtonBuilder, ButtonMessage}, - core::{ - inspect::{PropertyInfo, PropertyValue}, - pool::Handle, - variable::InheritableVariable, - }, + core::{pool::Handle, reflect::prelude::*, variable::InheritableVariable}, define_constructor, grid::{Column, GridBuilder, Row}, inspector::{ @@ -24,6 +20,7 @@ use crate::{ BuildContext, Control, MessageDirection, Thickness, UiNode, UserInterface, VerticalAlignment, Widget, WidgetMessage, }; +use fyrox_core::reflect::FieldValue; use std::{ any::{Any, TypeId}, fmt::{Debug, Formatter}, @@ -165,14 +162,14 @@ impl InheritablePropertyEditorBuilder { pub struct InheritablePropertyEditorDefinition where - T: PropertyValue, + T: FieldValue, { phantom: PhantomData, } impl InheritablePropertyEditorDefinition where - T: PropertyValue, + T: FieldValue, { pub fn new() -> Self { Self { @@ -183,23 +180,21 @@ where impl Debug for InheritablePropertyEditorDefinition where - T: PropertyValue, + T: FieldValue, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { writeln!(f, "InheritablePropertyEditorDefinition") } } -fn make_proxy<'a, 'b, T>( - property_info: &'b PropertyInfo<'a>, -) -> Result, InspectorError> +fn make_proxy<'a, 'b, T>(property_info: &'b FieldInfo<'a>) -> Result, InspectorError> where - T: PropertyValue, + T: FieldValue, 'b: 'a, { let value = property_info.cast_value::>()?; - Ok(PropertyInfo { + Ok(FieldInfo { owner_type_id: TypeId::of::(), name: property_info.name, display_name: property_info.display_name, @@ -215,7 +210,7 @@ where impl PropertyEditorDefinition for InheritablePropertyEditorDefinition where - T: PropertyValue, + T: FieldValue, { fn value_type_id(&self) -> TypeId { TypeId::of::>() diff --git a/fyrox-ui/src/inspector/editors/inspectable.rs b/fyrox-ui/src/inspector/editors/inspectable.rs index cfac9a728..8e0b64766 100644 --- a/fyrox-ui/src/inspector/editors/inspectable.rs +++ b/fyrox-ui/src/inspector/editors/inspectable.rs @@ -1,5 +1,5 @@ use crate::{ - core::inspect::Inspect, + core::reflect::prelude::*, inspector::{ editors::{ PropertyEditorBuildContext, PropertyEditorDefinition, PropertyEditorInstance, @@ -20,14 +20,14 @@ use std::{ pub struct InspectablePropertyEditorDefinition where - T: Inspect + 'static, + T: Reflect + 'static, { phantom: PhantomData, } impl InspectablePropertyEditorDefinition where - T: Inspect + 'static, + T: Reflect + 'static, { pub fn new() -> Self { Self { @@ -38,7 +38,7 @@ where impl Debug for InspectablePropertyEditorDefinition where - T: Inspect + 'static, + T: Reflect + 'static, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { writeln!(f, "InspectablePropertyEditorDefinition") @@ -47,7 +47,7 @@ where impl PropertyEditorDefinition for InspectablePropertyEditorDefinition where - T: Inspect + 'static, + T: Reflect + 'static, { fn value_type_id(&self) -> TypeId { TypeId::of::() diff --git a/fyrox-ui/src/inspector/editors/mod.rs b/fyrox-ui/src/inspector/editors/mod.rs index add12e7e2..56f6c699b 100644 --- a/fyrox-ui/src/inspector/editors/mod.rs +++ b/fyrox-ui/src/inspector/editors/mod.rs @@ -2,9 +2,9 @@ use crate::{ core::{ algebra::{UnitQuaternion, Vector2, Vector3, Vector4}, color::Color, - inspect::{Inspect, PropertyInfo, PropertyValue}, math::{Rect, SmoothAngle}, pool::Handle, + reflect::{FieldInfo, FieldValue, Reflect}, }, inspector::{ editors::{ @@ -58,7 +58,7 @@ pub mod vec; pub struct PropertyEditorBuildContext<'a, 'b, 'c> { pub build_context: &'a mut BuildContext<'c>, - pub property_info: &'b PropertyInfo<'b>, + pub property_info: &'b FieldInfo<'b>, pub environment: Option>, pub definition_container: Rc, pub sync_flag: u64, @@ -69,7 +69,7 @@ pub struct PropertyEditorMessageContext<'a, 'b> { pub sync_flag: u64, pub instance: Handle, pub ui: &'b mut UserInterface, - pub property_info: &'a PropertyInfo<'a>, + pub property_info: &'a FieldInfo<'a>, pub definition_container: Rc, pub layer_index: usize, pub environment: Option>, @@ -235,7 +235,7 @@ impl PropertyEditorDefinitionContainer { pub fn register_inheritable_vec_collection(&self) where - T: CollectionItem + PropertyValue, + T: CollectionItem + FieldValue, { assert!(self .insert(VecCollectionPropertyEditorDefinition::::new()) @@ -247,7 +247,7 @@ impl PropertyEditorDefinitionContainer { pub fn register_inheritable_inspectable(&self) where - T: Inspect + PropertyValue, + T: Reflect + FieldValue, { assert!(self .insert(InspectablePropertyEditorDefinition::::new()) @@ -259,7 +259,7 @@ impl PropertyEditorDefinitionContainer { pub fn register_inheritable_enum(&self) where - T: InspectableEnum + PropertyValue + VariantNames + AsRef + FromStr + Debug, + T: InspectableEnum + FieldValue + VariantNames + AsRef + FromStr + Debug, { assert!(self .insert(EnumPropertyEditorDefinition::::new()) @@ -271,7 +271,7 @@ impl PropertyEditorDefinitionContainer { pub fn register_inheritable_option(&self) where - T: InspectableEnum + PropertyValue + Default, + T: InspectableEnum + FieldValue + Default, { assert!(self .insert(EnumPropertyEditorDefinition::::new_optional()) diff --git a/fyrox-ui/src/inspector/mod.rs b/fyrox-ui/src/inspector/mod.rs index 035954099..63194c2a6 100644 --- a/fyrox-ui/src/inspector/mod.rs +++ b/fyrox-ui/src/inspector/mod.rs @@ -1,11 +1,7 @@ use crate::{ border::BorderBuilder, check_box::CheckBoxBuilder, - core::{ - algebra::Vector2, - inspect::{CastError, Inspect}, - pool::Handle, - }, + core::{algebra::Vector2, pool::Handle, reflect::CastError}, define_constructor, expander::ExpanderBuilder, formatted_text::WrapMode, @@ -493,7 +489,7 @@ fn make_simple_property_container( impl InspectorContext { pub fn from_object( - object: &dyn Inspect, + object: &dyn Reflect, ctx: &mut BuildContext, definition_container: Rc, environment: Option>, @@ -503,7 +499,7 @@ impl InspectorContext { let mut entries = Vec::new(); let editors = object - .properties() + .fields_info() .iter() .enumerate() .map(|(i, info)| { @@ -597,13 +593,13 @@ impl InspectorContext { pub fn sync( &self, - object: &dyn Inspect, + object: &dyn Reflect, ui: &mut UserInterface, layer_index: usize, ) -> Result<(), Vec> { let mut sync_errors = Vec::new(); - for info in object.properties() { + for info in object.fields_info() { if let Some(constructor) = self .property_definitions .definitions() diff --git a/src/animation/machine/node/blend.rs b/src/animation/machine/node/blend.rs index c1fe4196e..6d03ac181 100644 --- a/src/animation/machine/node/blend.rs +++ b/src/animation/machine/node/blend.rs @@ -7,7 +7,6 @@ use crate::{ AnimationContainer, AnimationPose, }, core::{ - inspect::{Inspect, PropertyInfo}, pool::{Handle, Pool}, reflect::prelude::*, visitor::{Visit, VisitResult, Visitor}, @@ -25,10 +24,10 @@ pub struct BlendPose { pub pose_source: Handle, } -#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Visit, Clone, Reflect)] pub struct BlendPoseDefinition { pub weight: PoseWeight, - #[inspect(skip)] + #[reflect(hidden)] pub pose_source: Handle, } @@ -91,7 +90,7 @@ impl DerefMut for BlendAnimations { } } -#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Visit, Clone, Reflect)] pub struct BlendAnimationsDefinition { pub base: BasePoseNodeDefinition, pub pose_sources: Vec, @@ -172,10 +171,10 @@ pub struct IndexedBlendInput { pub pose_source: Handle, } -#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Visit, Clone, Reflect)] pub struct IndexedBlendInputDefinition { pub blend_time: f32, - #[inspect(skip)] + #[reflect(hidden)] pub pose_source: Handle, } @@ -204,7 +203,7 @@ impl DerefMut for BlendAnimationsByIndex { } } -#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Visit, Clone, Reflect)] pub struct BlendAnimationsByIndexDefinition { pub base: BasePoseNodeDefinition, pub index_parameter: String, diff --git a/src/animation/machine/node/mod.rs b/src/animation/machine/node/mod.rs index e70a59a68..faa4abd32 100644 --- a/src/animation/machine/node/mod.rs +++ b/src/animation/machine/node/mod.rs @@ -14,7 +14,6 @@ use crate::{ }, core::{ algebra::Vector2, - inspect::{Inspect, PropertyInfo}, pool::{Handle, Pool}, reflect::prelude::*, visitor::prelude::*, @@ -124,14 +123,14 @@ impl EvaluatePose for PoseNode { } } -#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Visit, Clone, Reflect)] pub struct BasePoseNodeDefinition { pub position: Vector2, - #[inspect(skip)] + #[reflect(hidden)] pub parent_state: Handle, } -#[derive(Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Debug, Visit, Clone, Reflect)] pub enum PoseNodeDefinition { PlayAnimation(PlayAnimationDefinition), BlendAnimations(BlendAnimationsDefinition), diff --git a/src/animation/machine/node/play.rs b/src/animation/machine/node/play.rs index 01a36e7cc..500ab7c05 100644 --- a/src/animation/machine/node/play.rs +++ b/src/animation/machine/node/play.rs @@ -7,7 +7,6 @@ use crate::{ Animation, AnimationContainer, AnimationPose, }, core::{ - inspect::{Inspect, PropertyInfo}, pool::{Handle, Pool}, reflect::prelude::*, visitor::prelude::*, @@ -42,10 +41,10 @@ impl DerefMut for PlayAnimation { } } -#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Visit, Clone, Reflect)] pub struct TimeSlice(pub Range); -#[derive(Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Debug, Visit, Clone, Reflect)] pub struct PlayAnimationDefinition { pub base: BasePoseNodeDefinition, pub animation: String, diff --git a/src/animation/machine/parameter.rs b/src/animation/machine/parameter.rs index bdcbe411a..31bb56b25 100644 --- a/src/animation/machine/parameter.rs +++ b/src/animation/machine/parameter.rs @@ -1,15 +1,11 @@ -use crate::core::{ - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, - visitor::prelude::*, -}; +use crate::core::{reflect::prelude::*, visitor::prelude::*}; use fxhash::FxHashMap; use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; /// Machine parameter. Machine uses various parameters for specific actions. For example /// Rule parameter is used to check where transition from a state to state is possible. /// See module docs for example. -#[derive(Copy, Clone, Debug, Inspect, Reflect, Visit, EnumVariantNames, EnumString, AsRefStr)] +#[derive(Copy, Clone, Debug, Reflect, Visit, EnumVariantNames, EnumString, AsRefStr)] pub enum Parameter { /// Weight parameter is used to control blend weight in BlendAnimation node. Weight(f32), @@ -28,7 +24,7 @@ impl Default for Parameter { } /// Specific animation pose weight. -#[derive(Debug, Visit, Clone, Inspect, Reflect, EnumVariantNames, EnumString, AsRefStr)] +#[derive(Debug, Visit, Clone, Reflect, EnumVariantNames, EnumString, AsRefStr)] pub enum PoseWeight { /// Fixed scalar value. Should not be negative (can't even realize what will happen /// with negative weight here) @@ -46,13 +42,13 @@ impl Default for PoseWeight { pub type ParameterContainer = FxHashMap; -#[derive(Debug, Default, Visit, Clone, Inspect, Reflect)] +#[derive(Debug, Default, Visit, Clone, Reflect)] pub struct ParameterDefinition { pub name: String, pub value: Parameter, } -#[derive(Debug, Default, Visit, Clone, Inspect, Reflect)] +#[derive(Debug, Default, Visit, Clone, Reflect)] pub struct ParameterContainerDefinition { pub container: Vec, } diff --git a/src/animation/machine/state.rs b/src/animation/machine/state.rs index 1a5ad0d43..64e96a704 100644 --- a/src/animation/machine/state.rs +++ b/src/animation/machine/state.rs @@ -5,7 +5,6 @@ use crate::{ }, core::{ algebra::Vector2, - inspect::{Inspect, PropertyInfo}, pool::{Handle, Pool}, reflect::prelude::*, visitor::prelude::*, @@ -22,11 +21,11 @@ pub struct State { pub(crate) root: Handle, } -#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Visit, Clone, Reflect)] pub struct StateDefinition { pub position: Vector2, pub name: String, - #[inspect(skip)] + #[reflect(hidden)] pub root: Handle, } diff --git a/src/animation/machine/transition.rs b/src/animation/machine/transition.rs index dbd1b6d9c..a23202cfc 100644 --- a/src/animation/machine/transition.rs +++ b/src/animation/machine/transition.rs @@ -1,11 +1,6 @@ use crate::{ animation::machine::{state::StateDefinition, State}, - core::{ - inspect::{Inspect, PropertyInfo}, - pool::Handle, - reflect::prelude::*, - visitor::prelude::*, - }, + core::{pool::Handle, reflect::prelude::*, visitor::prelude::*}, }; /// Transition is a connection between two states with a rule that defines possibility @@ -29,28 +24,28 @@ pub struct Transition { pub(crate) blend_factor: f32, } -#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Visit, Clone, Reflect)] pub struct TransitionDefinition { - #[inspect(description = "The name of the transition, it is used for debug output.")] + #[reflect(description = "The name of the transition, it is used for debug output.")] pub name: String, /// Total amount of time to transition from `src` to `dst` state. - #[inspect(description = "Total amount of time (in seconds) to transition \ + #[reflect(description = "Total amount of time (in seconds) to transition \ from source to destination state")] pub transition_time: f32, /// Identifier of Rule parameter which defines is transition should be activated or not. - #[inspect( + #[reflect( description = "Name of the Rule parameter which defines whether transition \ should be activated or not" )] pub rule: String, - #[inspect(skip)] + #[reflect(hidden)] pub source: Handle, - #[inspect(skip)] + #[reflect(hidden)] pub dest: Handle, /// If set, then fetched value from `rule` will be inverted. It is useful for cases when you /// have a pair of transitions that depend on a single Rule parameter, but have different /// directions (A -> B, B -> A). - #[inspect( + #[reflect( description = "If set, then fetched value from `rule` will be inverted. It is useful for cases when you have a pair of transitions that depend on a single Rule parameter, but have different directions (A -> B, B -> A)." diff --git a/src/animation/spritesheet/mod.rs b/src/animation/spritesheet/mod.rs index b5cda7fab..3b911991e 100644 --- a/src/animation/spritesheet/mod.rs +++ b/src/animation/spritesheet/mod.rs @@ -5,9 +5,7 @@ use crate::{ animation::spritesheet::signal::Signal, - core::{ - algebra::Vector2, inspect::prelude::*, math::Rect, reflect::prelude::*, visitor::prelude::*, - }, + core::{algebra::Vector2, math::Rect, reflect::prelude::*, visitor::prelude::*}, engine::resource_manager::ResourceManager, resource::texture::Texture, }; @@ -18,17 +16,7 @@ pub mod signal; /// Animation playback status. #[derive( - Visit, - Reflect, - Inspect, - Copy, - Clone, - Eq, - PartialEq, - Debug, - AsRefStr, - EnumString, - EnumVariantNames, + Visit, Reflect, Copy, Clone, Eq, PartialEq, Debug, AsRefStr, EnumString, EnumVariantNames, )] pub enum Status { /// Animation is playing. @@ -49,7 +37,7 @@ impl Default for Status { } /// Some animation event. -#[derive(Visit, Reflect, Inspect, Clone, Debug, Eq, PartialEq)] +#[derive(Visit, Reflect, Clone, Debug, Eq, PartialEq)] #[non_exhaustive] pub enum Event { /// A signal with an id was hit. @@ -63,7 +51,7 @@ impl Default for Event { } /// Container for a sprite sheet animation frames. -#[derive(Reflect, Inspect, Visit, Clone, Debug, PartialEq, Eq)] +#[derive(Reflect, Visit, Clone, Debug, PartialEq, Eq)] pub struct SpriteSheetFramesContainer { size: Vector2, frames: Vec>, @@ -142,7 +130,7 @@ impl Default for SpriteSheetFramesContainer { /// Sprite sheet animation is an animation based on key frames, where each key frame is packed into single image. Usually, all key /// frames have the same size, but this is not mandatory. -#[derive(Visit, Reflect, Inspect, Clone, Debug)] +#[derive(Visit, Reflect, Clone, Debug)] pub struct SpriteSheetAnimation { #[visit(rename = "Frames")] frames_container: SpriteSheetFramesContainer, @@ -155,7 +143,6 @@ pub struct SpriteSheetAnimation { #[reflect(setter = "set_texture")] texture: Option, #[reflect(hidden)] - #[inspect(skip)] #[visit(skip)] events: VecDeque, } diff --git a/src/animation/spritesheet/signal.rs b/src/animation/spritesheet/signal.rs index 0bdb98eec..06f1a72e1 100644 --- a/src/animation/spritesheet/signal.rs +++ b/src/animation/spritesheet/signal.rs @@ -1,11 +1,11 @@ //! Animation signal is used as a point at which to notify external observers that animation just //! started to play a specific frame. -use crate::core::{inspect::prelude::*, reflect::prelude::*, visitor::prelude::*}; +use crate::core::{reflect::prelude::*, visitor::prelude::*}; /// Animation signal is used as a point at which to notify external observers that animation just /// started to play a specific frame. -#[derive(Inspect, Visit, Reflect, Debug, Clone)] +#[derive(Visit, Reflect, Debug, Clone)] pub struct Signal { /// Signal id. It should be used to distinguish different signals. For example, `JUMP` signal /// can have `id = 0`, while `CROUCH` signal - `id = 1`, etc. diff --git a/src/engine/mod.rs b/src/engine/mod.rs index dc0f037df..d8cab7c49 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -987,9 +987,7 @@ impl Drop for Engine { #[cfg(test)] mod test { use crate::{ - core::{ - inspect::prelude::*, pool::Handle, reflect::prelude::*, uuid::Uuid, visitor::prelude::*, - }, + core::{pool::Handle, reflect::prelude::*, uuid::Uuid, visitor::prelude::*}, engine::{resource_manager::ResourceManager, ScriptProcessor}, impl_component_provider, scene::{base::BaseBuilder, node::Node, pivot::PivotBuilder, Scene, SceneContainer}, @@ -1005,10 +1003,9 @@ mod test { Destroyed(Handle), } - #[derive(Debug, Clone, Reflect, Inspect, Visit)] + #[derive(Debug, Clone, Reflect, Visit)] struct MyScript { #[reflect(hidden)] - #[inspect(skip)] #[visit(skip)] sender: Sender, spawned: bool, @@ -1064,10 +1061,9 @@ mod test { } } - #[derive(Debug, Clone, Reflect, Inspect, Visit)] + #[derive(Debug, Clone, Reflect, Visit)] struct MySubScript { #[reflect(hidden)] - #[inspect(skip)] #[visit(skip)] sender: Sender, } diff --git a/src/engine/resource_manager/loader/sound.rs b/src/engine/resource_manager/loader/sound.rs index 233a53c80..e131f19f3 100644 --- a/src/engine/resource_manager/loader/sound.rs +++ b/src/engine/resource_manager/loader/sound.rs @@ -1,10 +1,7 @@ //! Sound buffer loader. use crate::{ - core::{ - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, - }, + core::reflect::prelude::*, engine::resource_manager::{ container::event::ResourceEventBroadcaster, loader::{BoxedLoaderFuture, ResourceLoader}, @@ -18,7 +15,7 @@ use fyrox_sound::buffer::{ use serde::{Deserialize, Serialize}; /// Defines sound buffer resource import options. -#[derive(Clone, Deserialize, Serialize, Default, Inspect, Reflect)] +#[derive(Clone, Deserialize, Serialize, Default, Reflect)] pub struct SoundBufferImportOptions { /// Whether the buffer is streaming or not. pub stream: bool, diff --git a/src/material/mod.rs b/src/material/mod.rs index 50e6eb002..d65a1a049 100644 --- a/src/material/mod.rs +++ b/src/material/mod.rs @@ -6,7 +6,6 @@ use crate::{ asset::ResourceState, - core::inspect::prelude::*, core::reflect::prelude::*, core::{ algebra::{Matrix2, Matrix3, Matrix4, Vector2, Vector3, Vector4}, @@ -676,7 +675,7 @@ impl Material { /// Shared material is also tells a renderer that this material can be used for efficient rendering - /// the renderer will be able to optimize rendering when it knows that multiple objects share the /// same material. -#[derive(Reflect, Inspect, Clone, Debug)] +#[derive(Reflect, Clone, Debug)] pub struct SharedMaterial(#[reflect(hidden)] Arc>); impl Default for SharedMaterial { diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 525105a35..1df473451 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -37,7 +37,6 @@ use crate::{ core::{ algebra::{Matrix4, Vector2, Vector3}, color::Color, - inspect::{Inspect, PropertyInfo}, instant, math::Rect, pool::Handle, @@ -188,7 +187,6 @@ impl std::ops::AddAssign for Statistics { Debug, Serialize, Deserialize, - Inspect, Reflect, AsRefStr, EnumString, @@ -204,7 +202,7 @@ pub enum ShadowMapPrecision { } /// Cascaded-shadow maps settings. -#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Inspect, Reflect, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Reflect, Eq)] pub struct CsmSettings { /// Whether cascaded shadow maps enabled or not. pub enabled: bool, @@ -233,7 +231,7 @@ impl Default for CsmSettings { /// Quality settings allows you to find optimal balance between performance and /// graphics quality. -#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Inspect, Reflect)] +#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Reflect)] pub struct QualitySettings { /// Point shadows /// Size of cube map face of shadow map texture in pixels. diff --git a/src/resource/model.rs b/src/resource/model.rs index 6da9f9270..ee78a0e53 100644 --- a/src/resource/model.rs +++ b/src/resource/model.rs @@ -22,7 +22,6 @@ use crate::{ animation::{Animation, AnimationContainer}, asset::{define_new_resource, Resource, ResourceData}, core::{ - inspect::{Inspect, PropertyInfo}, pool::Handle, reflect::prelude::*, visitor::{Visit, VisitError, VisitResult, Visitor}, @@ -263,7 +262,6 @@ impl Default for ModelData { Eq, Deserialize, Serialize, - Inspect, Reflect, AsRefStr, EnumString, @@ -333,7 +331,7 @@ impl MaterialSearchOptions { /// ``` /// /// Check documentation of the field of the structure for more info about each parameter. -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default, Inspect, Reflect, Eq)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default, Reflect, Eq)] pub struct ModelImportOptions { /// See [`MaterialSearchOptions`] docs for more info. #[serde(default)] diff --git a/src/resource/texture.rs b/src/resource/texture.rs index 4dcce6914..c680909dc 100644 --- a/src/resource/texture.rs +++ b/src/resource/texture.rs @@ -24,7 +24,6 @@ use crate::{ asset::{define_new_resource, Resource, ResourceData, ResourceState}, core::{ futures::io::Error, - inspect::{Inspect, PropertyInfo}, io::{self, FileLoadError}, reflect::prelude::*, visitor::{PodVecView, Visit, VisitError, VisitResult, Visitor}, @@ -289,7 +288,7 @@ impl Default for TextureData { /// compression: NoCompression, /// ) /// ``` -#[derive(Clone, Deserialize, Serialize, Inspect, Reflect)] +#[derive(Clone, Deserialize, Serialize, Reflect)] pub struct TextureImportOptions { #[serde(default)] pub(crate) minification_filter: TextureMinificationFilter, @@ -489,7 +488,6 @@ impl Texture { PartialEq, Deserialize, Serialize, - Inspect, Reflect, EnumVariantNames, EnumString, @@ -525,7 +523,6 @@ impl Default for TextureMagnificationFilter { PartialEq, Deserialize, Serialize, - Inspect, Reflect, EnumVariantNames, EnumString, @@ -595,7 +592,6 @@ impl Default for TextureMinificationFilter { PartialEq, Deserialize, Serialize, - Inspect, Reflect, EnumVariantNames, EnumString, @@ -813,7 +809,6 @@ fn ceil_div_4(x: u32) -> u32 { PartialEq, Eq, Debug, - Inspect, Reflect, EnumVariantNames, EnumString, diff --git a/src/scene/base.rs b/src/scene/base.rs index 350e57f21..1224fec3d 100644 --- a/src/scene/base.rs +++ b/src/scene/base.rs @@ -5,7 +5,6 @@ use crate::{ core::{ algebra::{Matrix4, Vector3}, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, Matrix4Ext}, pool::{ErasedHandle, Handle}, reflect::prelude::*, @@ -27,7 +26,7 @@ use std::{ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; /// A handle to scene node that will be controlled by LOD system. -#[derive(Inspect, Reflect, Default, Debug, Clone, Copy, PartialEq, Hash, Eq)] +#[derive(Reflect, Default, Debug, Clone, Copy, PartialEq, Hash, Eq)] pub struct LodControlledObject(pub Handle); impl Deref for LodControlledObject { @@ -55,7 +54,7 @@ impl Visit for LodControlledObject { /// Normalized distance is a distance in (0; 1) range where 0 - closest to camera, /// 1 - farthest. Real distance can be obtained by multiplying normalized distance /// with z_far of current projection matrix. -#[derive(Debug, Default, Clone, Visit, Inspect, Reflect, PartialEq)] +#[derive(Debug, Default, Clone, Visit, Reflect, PartialEq)] pub struct LevelOfDetail { begin: f32, end: f32, @@ -119,7 +118,7 @@ impl LevelOfDetail { /// Lod group must contain non-overlapping cascades, each cascade with its own set of objects /// that belongs to level of detail. Engine does not care if you create overlapping cascades, /// it is your responsibility to create non-overlapping cascades. -#[derive(Debug, Default, Clone, Visit, Inspect, Reflect, PartialEq)] +#[derive(Debug, Default, Clone, Visit, Reflect, PartialEq)] pub struct LodGroup { /// Set of cascades. pub levels: Vec, @@ -135,7 +134,6 @@ pub struct LodGroup { Ord, Eq, Debug, - Inspect, Reflect, AsRefStr, EnumString, @@ -203,9 +201,7 @@ impl Visit for Mobility { } /// A property value. -#[derive( - Debug, Visit, Inspect, Reflect, PartialEq, Clone, AsRefStr, EnumString, EnumVariantNames, -)] +#[derive(Debug, Visit, Reflect, PartialEq, Clone, AsRefStr, EnumString, EnumVariantNames)] pub enum PropertyValue { /// A node handle. /// @@ -252,7 +248,7 @@ impl Default for PropertyValue { } /// A custom property. -#[derive(Debug, Visit, Inspect, Reflect, Default, Clone, PartialEq)] +#[derive(Debug, Visit, Reflect, Default, Clone, PartialEq)] pub struct Property { /// Name of the property. pub name: String, @@ -311,13 +307,11 @@ impl Visit for InstanceId { /// .build(graph) /// } /// ``` -#[derive(Debug, Inspect, Reflect)] +#[derive(Debug, Reflect)] pub struct Base { - #[inspect(skip)] #[reflect(hidden)] pub(crate) self_handle: Handle, - #[inspect(skip)] #[reflect(hidden)] pub(crate) script_message_sender: Option>, @@ -331,10 +325,10 @@ pub struct Base { // Maximum amount of Some(time) that node will "live" or None // if node has undefined lifetime. - #[inspect(skip)] // TEMPORARILY HIDDEN. It causes crashes when set from the editor. + #[reflect(hidden)] // TEMPORARILY HIDDEN. It causes crashes when set from the editor. pub(crate) lifetime: InheritableVariable>, - #[inspect(min_value = 0.0, max_value = 1.0, step = 0.1)] + #[reflect(min_value = 0.0, max_value = 1.0, step = 0.1)] #[reflect(setter = "set_depth_offset_factor")] depth_offset: InheritableVariable, @@ -359,50 +353,44 @@ pub struct Base { #[reflect(setter = "set_frustum_culling")] frustum_culling: InheritableVariable, - #[inspect(skip)] #[reflect(hidden)] pub(crate) transform_modified: Cell, // When `true` it means that this node is instance of `resource`. // More precisely - this node is root of whole descendant nodes // hierarchy which was instantiated from resource. - #[inspect(read_only)] + #[reflect(read_only)] pub(crate) is_resource_instance_root: bool, - #[inspect(skip)] #[reflect(hidden)] pub(crate) global_visibility: Cell, - #[inspect(skip)] #[reflect(hidden)] pub(crate) parent: Handle, - #[inspect(skip)] #[reflect(hidden)] pub(crate) children: Vec>, - #[inspect(skip)] #[reflect(hidden)] pub(crate) global_transform: Cell>, // Bone-specific matrix. Non-serializable. - #[inspect(skip)] #[reflect(hidden)] pub(crate) inv_bind_pose_transform: Matrix4, // A resource from which this node was instantiated from, can work in pair // with `original` handle to get corresponding node from resource. - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] pub(crate) resource: Option, // Handle to node in scene of model resource from which this node // was instantiated from. - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] pub(crate) original_handle_in_resource: Handle, - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] pub(crate) instance_id: InstanceId, diff --git a/src/scene/camera.rs b/src/scene/camera.rs index 962182db9..03c88b47f 100644 --- a/src/scene/camera.rs +++ b/src/scene/camera.rs @@ -17,7 +17,6 @@ use crate::{ core::{ algebra::{Matrix4, Point3, Vector2, Vector3, Vector4}, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, frustum::Frustum, ray::Ray, Rect}, pool::Handle, reflect::prelude::*, @@ -45,20 +44,20 @@ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; /// Perspective projection make parallel lines to converge at some point. Objects will be smaller /// with increasing distance. This the projection type "used" by human eyes, photographic lens and /// it looks most realistic. -#[derive(Inspect, Reflect, Clone, Debug, PartialEq, Visit)] +#[derive(Reflect, Clone, Debug, PartialEq, Visit)] pub struct PerspectiveProjection { /// Horizontal angle between look axis and a side of the viewing frustum. Larger values will /// increase field of view and create fish-eye effect, smaller values could be used to create /// "binocular" effect or scope effect. - #[inspect(min_value = 0.0, max_value = 3.14159, step = 0.1)] + #[reflect(min_value = 0.0, max_value = 3.14159, step = 0.1)] pub fov: f32, /// Location of the near clipping plane. If it is larger than [`Self::z_far`] then it will be /// treated like far clipping plane. - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] pub z_near: f32, /// Location of the far clipping plane. If it is less than [`Self::z_near`] then it will be /// treated like near clipping plane. - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] pub z_far: f32, } @@ -97,20 +96,20 @@ impl PerspectiveProjection { /// Parallel projection. Object's size won't be affected by distance from the viewer, it can be /// used for 2D games. -#[derive(Inspect, Reflect, Clone, Debug, PartialEq, Visit)] +#[derive(Reflect, Clone, Debug, PartialEq, Visit)] pub struct OrthographicProjection { /// Location of the near clipping plane. If it is larger than [`Self::z_far`] then it will be /// treated like far clipping plane. - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] pub z_near: f32, /// Location of the far clipping plane. If it is less than [`Self::z_near`] then it will be /// treated like near clipping plane. - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] pub z_far: f32, /// Vertical size of the "view box". Horizontal size is derived value and depends on the aspect /// ratio of the viewport. Any values very close to zero (from both sides) will be clamped to /// some minimal value to prevent singularities from occuring. - #[inspect(step = 0.1)] + #[reflect(step = 0.1)] pub vertical_size: f32, } @@ -168,9 +167,7 @@ impl OrthographicProjection { /// objects will look smaller with increasing distance. /// 2) Orthographic projection most useful for 2D games, objects won't look smaller with increasing /// distance. -#[derive( - Inspect, Reflect, Clone, Debug, PartialEq, Visit, AsRefStr, EnumString, EnumVariantNames, -)] +#[derive(Reflect, Clone, Debug, PartialEq, Visit, AsRefStr, EnumString, EnumVariantNames)] pub enum Projection { /// See [`PerspectiveProjection`] docs. Perspective(PerspectiveProjection), @@ -255,9 +252,7 @@ impl Default for Projection { /// Exposure is a parameter that describes how many light should be collected for one /// frame. The higher the value, the more brighter the final frame will be and vice versa. -#[derive( - Visit, Copy, Clone, PartialEq, Debug, Inspect, Reflect, AsRefStr, EnumString, EnumVariantNames, -)] +#[derive(Visit, Copy, Clone, PartialEq, Debug, Reflect, AsRefStr, EnumString, EnumVariantNames)] pub enum Exposure { /// Automatic exposure based on the frame luminance. High luminance values will result /// in lower exposure levels and vice versa. This is default option. @@ -267,13 +262,13 @@ pub enum Exposure { /// `exposure = key_value / clamp(avg_luminance, min_luminance, max_luminance)` Auto { /// A key value in the formula above. Default is 0.01556. - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] key_value: f32, /// A min luminance value in the formula above. Default is 0.00778. - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] min_luminance: f32, /// A max luminance value in the formula above. Default is 64.0. - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] max_luminance: f32, }, @@ -292,7 +287,7 @@ impl Default for Exposure { } /// See module docs. -#[derive(Debug, Visit, Inspect, Reflect, Clone)] +#[derive(Debug, Visit, Reflect, Clone)] pub struct Camera { base: Base, @@ -321,18 +316,15 @@ pub struct Camera { color_grading_enabled: InheritableVariable, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] view_matrix: Matrix4, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] projection_matrix: Matrix4, /// Visibility cache allows you to quickly check if object is visible from the camera or not. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub visibility_cache: VisibilityCache, } @@ -678,12 +670,11 @@ pub enum ColorGradingLutCreationError { /// games - this is achieved by color grading. /// /// See [more info in Unreal engine docs](https://docs.unrealengine.com/4.26/en-US/RenderingAndGraphics/PostProcessEffects/UsingLUTs/) -#[derive(Visit, Clone, Default, PartialEq, Debug, Inspect, Reflect, Eq)] +#[derive(Visit, Clone, Default, PartialEq, Debug, Reflect, Eq)] pub struct ColorGradingLut { unwrapped_lut: Option, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] lut: Option, } @@ -1024,7 +1015,7 @@ impl SkyBoxBuilder { /// skies and/or some other objects (mountains, buildings, etc.). Usually skyboxes used /// in outdoor scenes, however real use of it limited only by your imagination. Skybox /// will be drawn first, none of objects could be drawn before skybox. -#[derive(Debug, Clone, Default, PartialEq, Inspect, Reflect, Visit, Eq)] +#[derive(Debug, Clone, Default, PartialEq, Reflect, Visit, Eq)] pub struct SkyBox { /// Texture for front face. #[reflect(setter = "set_front")] @@ -1051,9 +1042,8 @@ pub struct SkyBox { pub(crate) bottom: Option, /// Cubemap texture - #[inspect(skip)] - #[visit(skip)] #[reflect(hidden)] + #[visit(skip)] pub(crate) cubemap: Option, } diff --git a/src/scene/collider.rs b/src/scene/collider.rs index 7d2f8e6b9..a2e8bd128 100644 --- a/src/scene/collider.rs +++ b/src/scene/collider.rs @@ -4,7 +4,6 @@ use crate::{ core::{ algebra::Vector3, - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, num_traits::{NumCast, One, ToPrimitive, Zero}, pool::Handle, @@ -34,10 +33,10 @@ use std::{ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; /// Ball is an idea sphere shape defined by a single parameters - its radius. -#[derive(Clone, Debug, PartialEq, Visit, Inspect, Reflect)] +#[derive(Clone, Debug, PartialEq, Visit, Reflect)] pub struct BallShape { /// Radius of the sphere. - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pub radius: f32, } @@ -48,13 +47,13 @@ impl Default for BallShape { } /// Cylinder shape aligned in Y axis. -#[derive(Clone, Debug, Visit, Inspect, Reflect, PartialEq)] +#[derive(Clone, Debug, Visit, Reflect, PartialEq)] pub struct CylinderShape { /// Half height of the cylinder, actual height will be 2 times bigger. - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pub half_height: f32, /// Radius of the cylinder. - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pub radius: f32, } @@ -68,13 +67,13 @@ impl Default for CylinderShape { } /// Cone shape aligned in Y axis. -#[derive(Clone, Debug, Visit, Inspect, Reflect, PartialEq)] +#[derive(Clone, Debug, Visit, Reflect, PartialEq)] pub struct ConeShape { /// Half height of the cone, actual height will be 2 times bigger. - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pub half_height: f32, /// Radius of the cone base. - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pub radius: f32, } @@ -88,7 +87,7 @@ impl Default for ConeShape { } /// Cuboid shape (box). -#[derive(Clone, Debug, Visit, Inspect, Reflect, PartialEq)] +#[derive(Clone, Debug, Visit, Reflect, PartialEq)] pub struct CuboidShape { /// Half extents of the box. X - half width, Y - half height, Z - half depth. /// Actual _size_ will be 2 times bigger. @@ -104,14 +103,14 @@ impl Default for CuboidShape { } /// Arbitrary capsule shape defined by 2 points (which forms axis) and a radius. -#[derive(Clone, Debug, Visit, Inspect, Reflect, PartialEq)] +#[derive(Clone, Debug, Visit, Reflect, PartialEq)] pub struct CapsuleShape { /// Begin point of the capsule. pub begin: Vector3, /// End point of the capsule. pub end: Vector3, /// Radius of the capsule. - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pub radius: f32, } @@ -127,7 +126,7 @@ impl Default for CapsuleShape { } /// Arbitrary segment shape defined by two points. -#[derive(Clone, Debug, Visit, Inspect, Reflect, PartialEq)] +#[derive(Clone, Debug, Visit, Reflect, PartialEq)] pub struct SegmentShape { /// Begin point of the capsule. pub begin: Vector3, @@ -145,7 +144,7 @@ impl Default for SegmentShape { } /// Arbitrary triangle shape. -#[derive(Clone, Debug, Visit, Inspect, Reflect, PartialEq)] +#[derive(Clone, Debug, Visit, Reflect, PartialEq)] pub struct TriangleShape { /// First point of the triangle shape. pub a: Vector3, @@ -170,25 +169,25 @@ impl Default for TriangleShape { /// # Notes /// /// Currently there is only one way to set geometry - using a scene node as a source of data. -#[derive(Default, Clone, Copy, PartialEq, Hash, Debug, Visit, Inspect, Reflect, Eq)] +#[derive(Default, Clone, Copy, PartialEq, Hash, Debug, Visit, Reflect, Eq)] pub struct GeometrySource(pub Handle); /// Arbitrary triangle mesh shape. -#[derive(Default, Clone, Debug, Visit, Inspect, Reflect, PartialEq, Eq)] +#[derive(Default, Clone, Debug, Visit, Reflect, PartialEq, Eq)] pub struct TrimeshShape { /// Geometry sources for the shape. pub sources: Vec, } /// Arbitrary height field shape. -#[derive(Default, Clone, Debug, Visit, Inspect, Reflect, PartialEq, Eq)] +#[derive(Default, Clone, Debug, Visit, Reflect, PartialEq, Eq)] pub struct HeightfieldShape { /// A handle to terrain scene node. pub geometry_source: GeometrySource, } /// Arbitrary convex polyhedron shape. -#[derive(Default, Clone, Debug, Visit, Inspect, Reflect, PartialEq, Eq)] +#[derive(Default, Clone, Debug, Visit, Reflect, PartialEq, Eq)] pub struct ConvexPolyhedronShape { /// A handle to a mesh node. pub geometry_source: GeometrySource, @@ -198,12 +197,6 @@ pub struct ConvexPolyhedronShape { #[derive(Clone, Copy, Default, PartialEq, Debug, Reflect, Eq)] pub struct BitMask(pub u32); -impl Inspect for BitMask { - fn properties(&self) -> Vec> { - self.0.properties() - } -} - impl Visit for BitMask { fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult { self.0.visit(name, visitor) @@ -305,7 +298,7 @@ impl NumCast for BitMask { /// ```ignore /// (self.memberships & rhs.filter) != 0 && (rhs.memberships & self.filter) != 0 /// ``` -#[derive(Visit, Debug, Clone, Copy, PartialEq, Inspect, Reflect, Eq)] +#[derive(Visit, Debug, Clone, Copy, PartialEq, Reflect, Eq)] pub struct InteractionGroups { /// Groups memberships. pub memberships: BitMask, @@ -342,9 +335,7 @@ impl From for InteractionGroups { } /// Possible collider shapes. -#[derive( - Clone, Debug, PartialEq, Visit, Inspect, Reflect, AsRefStr, EnumString, EnumVariantNames, -)] +#[derive(Clone, Debug, PartialEq, Visit, Reflect, AsRefStr, EnumString, EnumVariantNames)] pub enum ColliderShape { /// See [`BallShape`] docs. Ball(BallShape), @@ -454,22 +445,20 @@ impl ColliderShape { /// Collider is a geometric entity that can be attached to a rigid body to allow participate it /// participate in contact generation, collision response and proximity queries. -#[derive(Inspect, Reflect, Visit, Debug)] +#[derive(Reflect, Visit, Debug)] pub struct Collider { base: Base, #[reflect(setter = "set_shape")] pub(crate) shape: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] - #[reflect(setter = "set_friction")] + #[reflect(min_value = 0.0, step = 0.05, setter = "set_friction")] pub(crate) friction: InheritableVariable, #[reflect(setter = "set_density")] pub(crate) density: InheritableVariable>, - #[inspect(min_value = 0.0, step = 0.05)] - #[reflect(setter = "set_restitution")] + #[reflect(min_value = 0.0, step = 0.05, setter = "set_restitution")] pub(crate) restitution: InheritableVariable, #[reflect(setter = "set_is_sensor")] @@ -488,7 +477,6 @@ pub struct Collider { pub(crate) restitution_combine_rule: InheritableVariable, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) native: Cell, } diff --git a/src/scene/decal.rs b/src/scene/decal.rs index a20485cd6..3b062fa60 100644 --- a/src/scene/decal.rs +++ b/src/scene/decal.rs @@ -5,7 +5,6 @@ use crate::{ core::{ color::Color, - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -83,7 +82,7 @@ use std::ops::{Deref, DerefMut}; /// .build(graph) /// } /// ``` -#[derive(Debug, Visit, Default, Clone, Inspect, Reflect)] +#[derive(Debug, Visit, Default, Clone, Reflect)] pub struct Decal { base: Base, @@ -96,7 +95,7 @@ pub struct Decal { #[reflect(setter = "set_color")] color: InheritableVariable, - #[inspect(min_value = 0.0)] + #[reflect(min_value = 0.0)] #[reflect(setter = "set_layer")] layer: InheritableVariable, } diff --git a/src/scene/dim2/collider.rs b/src/scene/dim2/collider.rs index 6f0eb0d3b..7a6b8a88a 100644 --- a/src/scene/dim2/collider.rs +++ b/src/scene/dim2/collider.rs @@ -4,7 +4,6 @@ use crate::{ core::{ algebra::Vector2, - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -34,10 +33,10 @@ use std::{ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; /// Ball is an idea sphere shape defined by a single parameters - its radius. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct BallShape { /// Radius of the sphere. - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pub radius: f32, } @@ -48,7 +47,7 @@ impl Default for BallShape { } /// Cuboid shape (rectangle). -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct CuboidShape { /// Half extents of the box. X - half width, Y - half height. /// Actual _size_ will be 2 times bigger. @@ -64,14 +63,14 @@ impl Default for CuboidShape { } /// Arbitrary capsule shape defined by 2 points (which forms axis) and a radius. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct CapsuleShape { /// Begin point of the capsule. pub begin: Vector2, /// End point of the capsule. pub end: Vector2, /// Radius of the capsule. - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] pub radius: f32, } @@ -87,7 +86,7 @@ impl Default for CapsuleShape { } /// Arbitrary segment shape defined by two points. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct SegmentShape { /// Begin point of the capsule. pub begin: Vector2, @@ -105,7 +104,7 @@ impl Default for SegmentShape { } /// Arbitrary triangle shape. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct TriangleShape { /// First point of the triangle shape. pub a: Vector2, @@ -130,27 +129,25 @@ impl Default for TriangleShape { /// # Notes /// /// Currently there is only one way to set geometry - using a scene node as a source of data. -#[derive(Default, Clone, Copy, PartialEq, Hash, Debug, Visit, Inspect, Reflect, Eq)] +#[derive(Default, Clone, Copy, PartialEq, Hash, Debug, Visit, Reflect, Eq)] pub struct GeometrySource(pub Handle); /// Arbitrary triangle mesh shape. -#[derive(Default, Clone, Debug, PartialEq, Visit, Inspect, Reflect, Eq)] +#[derive(Default, Clone, Debug, PartialEq, Visit, Reflect, Eq)] pub struct TrimeshShape { /// Geometry sources for the shape. pub sources: Vec, } /// Arbitrary height field shape. -#[derive(Default, Clone, Debug, PartialEq, Visit, Inspect, Reflect, Eq)] +#[derive(Default, Clone, Debug, PartialEq, Visit, Reflect, Eq)] pub struct HeightfieldShape { /// A handle to terrain scene node. pub geometry_source: GeometrySource, } /// Possible collider shapes. -#[derive( - Clone, Debug, Visit, Inspect, Reflect, AsRefStr, PartialEq, EnumString, EnumVariantNames, -)] +#[derive(Clone, Debug, Visit, Reflect, AsRefStr, PartialEq, EnumString, EnumVariantNames)] pub enum ColliderShape { /// See [`BallShape`] docs. Ball(BallShape), @@ -230,22 +227,20 @@ impl ColliderShape { /// Collider is a geometric entity that can be attached to a rigid body to allow participate it /// participate in contact generation, collision response and proximity queries. -#[derive(Inspect, Reflect, Visit, Debug)] +#[derive(Reflect, Visit, Debug)] pub struct Collider { base: Base, #[reflect(setter = "set_shape")] pub(crate) shape: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] - #[reflect(setter = "set_friction")] + #[reflect(min_value = 0.0, step = 0.05, setter = "set_friction")] pub(crate) friction: InheritableVariable, #[reflect(setter = "set_density")] pub(crate) density: InheritableVariable>, - #[inspect(min_value = 0.0, step = 0.05)] - #[reflect(setter = "set_restitution")] + #[reflect(min_value = 0.0, step = 0.05, setter = "set_restitution")] pub(crate) restitution: InheritableVariable, #[reflect(setter = "set_is_sensor")] @@ -264,7 +259,6 @@ pub struct Collider { pub(crate) restitution_combine_rule: InheritableVariable, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) native: Cell, } diff --git a/src/scene/dim2/joint.rs b/src/scene/dim2/joint.rs index f0e118332..74015c891 100644 --- a/src/scene/dim2/joint.rs +++ b/src/scene/dim2/joint.rs @@ -3,7 +3,6 @@ use crate::{ core::{ algebra::Matrix4, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, m4x4_approx_eq}, pool::Handle, reflect::prelude::*, @@ -31,15 +30,15 @@ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; /// Ball joint locks any translational moves between two objects on the axis between objects, but /// allows rigid bodies to perform relative rotations. The real world example is a human shoulder, /// pendulum, etc. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct BallJoint { /// Whether angular limits are enabled or not. Default is `false` - #[inspect(description = "Whether angular limits are enabled or not.")] + #[reflect(description = "Whether angular limits are enabled or not.")] #[visit(optional)] // Backward compatibility pub limits_enabled: bool, /// Allowed angles range for the joint (in radians). - #[inspect(description = "Allowed angles range for the joint (in radians).")] + #[reflect(description = "Allowed angles range for the joint (in radians).")] #[visit(optional)] // Backward compatibility pub limits_angles: Range, } @@ -55,22 +54,22 @@ impl Default for BallJoint { /// A fixed joint ensures that two rigid bodies does not move relative to each other. There is no /// straightforward real-world example, but it can be thought as two bodies were "welded" together. -#[derive(Clone, Debug, Default, Visit, PartialEq, Inspect, Reflect, Eq)] +#[derive(Clone, Debug, Default, Visit, PartialEq, Reflect, Eq)] pub struct FixedJoint; /// Prismatic joint prevents any relative movement between two rigid-bodies, except for relative /// translations along one axis. The real world example is a sliders that used to support drawers. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct PrismaticJoint { /// Whether linear limits along local X axis of the joint are enabled or not. Default is `false` - #[inspect( + #[reflect( description = "Whether linear limits along local X axis of the joint are enabled or not." )] #[visit(optional)] // Backward compatibility pub limits_enabled: bool, /// Allowed linear distance range along local X axis of the joint. - #[inspect(description = "Allowed linear distance range along local X axis of the joint.")] + #[reflect(description = "Allowed linear distance range along local X axis of the joint.")] #[visit(optional)] // Backward compatibility pub limits: Range, } @@ -85,9 +84,7 @@ impl Default for PrismaticJoint { } /// The exact kind of the joint. -#[derive( - Clone, Debug, PartialEq, Visit, Inspect, Reflect, AsRefStr, EnumString, EnumVariantNames, -)] +#[derive(Clone, Debug, PartialEq, Visit, Reflect, AsRefStr, EnumString, EnumVariantNames)] pub enum JointParams { /// See [`BallJoint`] for more info. BallJoint(BallJoint), @@ -105,7 +102,7 @@ impl Default for JointParams { /// Joint is used to restrict motion of two rigid bodies. There are numerous examples of joints in /// real life: door hinge, ball joints in human arms, etc. -#[derive(Visit, Inspect, Reflect, Debug)] +#[derive(Visit, Reflect, Debug)] pub struct Joint { base: Base, @@ -123,12 +120,10 @@ pub struct Joint { pub(crate) contacts_enabled: InheritableVariable, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) native: Cell, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) need_rebind: Cell, } diff --git a/src/scene/dim2/physics.rs b/src/scene/dim2/physics.rs index c7a50ea38..9a5cd53cc 100644 --- a/src/scene/dim2/physics.rs +++ b/src/scene/dim2/physics.rs @@ -7,7 +7,6 @@ use crate::{ UnitComplex, UnitQuaternion, Vector2, Vector3, }, arrayvec::ArrayVec, - inspect::{Inspect, PropertyInfo}, instant, math::Matrix4Ext, parking_lot::Mutex, @@ -288,7 +287,7 @@ fn isometry2_to_mat4(isometry: &Isometry2) -> Matrix4 { /// Physics world is responsible for physics simulation in the engine. There is a very few public /// methods, mostly for ray casting. You should add physical entities using scene graph nodes, such /// as RigidBody, Collider, Joint. -#[derive(Visit, Inspect, Reflect)] +#[derive(Visit, Reflect)] pub struct PhysicsWorld { /// A flag that defines whether physics simulation is enabled or not. pub enabled: bool, @@ -301,67 +300,54 @@ pub struct PhysicsWorld { /// Performance statistics of a single simulation step. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub performance_statistics: PhysicsPerformanceStatistics, // Current physics pipeline. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pipeline: PhysicsPipeline, // Broad phase performs rough intersection checks. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] broad_phase: BroadPhase, // Narrow phase is responsible for precise contact generation. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] narrow_phase: NarrowPhase, // A continuous collision detection solver. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] ccd_solver: CCDSolver, // Structure responsible for maintaining the set of active rigid-bodies, and putting non-moving // rigid-bodies to sleep to save computation times. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] islands: IslandManager, // A container of rigid bodies. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] bodies: Container, // A container of colliders. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] colliders: Container, // A container of impulse joints. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] joints: Container, // A container of multibody joints. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] multibody_joints: Container, // Event handler collects info about contacts and proximity events. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] event_handler: Box, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] query: RefCell, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] debug_render_pipeline: Mutex, } diff --git a/src/scene/dim2/rectangle.rs b/src/scene/dim2/rectangle.rs index 3d1ce732b..4abcdd787 100644 --- a/src/scene/dim2/rectangle.rs +++ b/src/scene/dim2/rectangle.rs @@ -6,7 +6,6 @@ use crate::{ core::{ color::Color, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, Rect}, pool::Handle, reflect::prelude::*, @@ -100,7 +99,7 @@ use std::ops::{Deref, DerefMut}; /// image, but just changing portion for rendering. Keep in mind that the coordinates are normalized /// which means `[0; 0]` corresponds to top-left corner of the texture and `[1; 1]` corresponds to /// right-bottom corner. -#[derive(Visit, Inspect, Reflect, Debug, Clone)] +#[derive(Visit, Reflect, Debug, Clone)] pub struct Rectangle { base: Base, diff --git a/src/scene/dim2/rigidbody.rs b/src/scene/dim2/rigidbody.rs index ba66695bb..506ffe0a2 100644 --- a/src/scene/dim2/rigidbody.rs +++ b/src/scene/dim2/rigidbody.rs @@ -11,7 +11,6 @@ use crate::{ core::{ algebra::{Matrix4, Vector2}, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, m4x4_approx_eq}, parking_lot::Mutex, pool::Handle, @@ -61,7 +60,7 @@ pub(crate) enum ApplyAction { /// /// Rigid body that does not move for some time will go asleep. This means that the body will not /// move unless it is woken up by some other moving body. This feature allows to save CPU resources. -#[derive(Visit, Inspect, Reflect)] +#[derive(Visit, Reflect)] pub struct RigidBody { base: Base, @@ -80,7 +79,7 @@ pub struct RigidBody { #[reflect(setter = "set_body_type")] pub(crate) body_type: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] #[reflect(setter = "set_mass")] pub(crate) mass: InheritableVariable, @@ -103,17 +102,14 @@ pub struct RigidBody { pub(crate) gravity_scale: InheritableVariable, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) sleeping: bool, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) native: Cell, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) actions: Mutex>, } diff --git a/src/scene/graph/mod.rs b/src/scene/graph/mod.rs index 2097f1e7b..ccb103052 100644 --- a/src/scene/graph/mod.rs +++ b/src/scene/graph/mod.rs @@ -26,7 +26,6 @@ use crate::{ asset::ResourceState, core::{ algebra::{Matrix4, Rotation3, UnitQuaternion, Vector2, Vector3}, - inspect::{Inspect, PropertyInfo}, instant, math::Matrix4Ext, pool::{Handle, MultiBorrowContext, Pool, Ticket}, @@ -103,17 +102,14 @@ impl GraphPerformanceStatistics { pub type NodePool = Pool; /// See module docs. -#[derive(Debug, Inspect, Reflect)] +#[derive(Debug, Reflect)] pub struct Graph { - #[inspect(skip)] #[reflect(hidden)] root: Handle, - #[inspect(skip)] #[reflect(hidden)] pool: NodePool, - #[inspect(skip)] #[reflect(hidden)] stack: Vec>, @@ -124,25 +120,20 @@ pub struct Graph { pub physics2d: dim2::physics::PhysicsWorld, /// Backing sound context. It is responsible for sound rendering. - #[inspect(skip)] #[reflect(hidden)] pub sound_context: SoundContext, /// Performance statistics of a last [`Graph::update`] call. - #[inspect(skip)] #[reflect(hidden)] pub performance_statistics: GraphPerformanceStatistics, /// Allows you to "subscribe" for graph events. #[reflect(hidden)] - #[inspect(skip)] pub event_broadcaster: GraphEventBroadcaster, #[reflect(hidden)] - #[inspect(skip)] pub(crate) script_message_sender: Sender, #[reflect(hidden)] - #[inspect(skip)] pub(crate) script_message_receiver: Receiver, } diff --git a/src/scene/graph/physics.rs b/src/scene/graph/physics.rs index 50ff6b32b..ff65c61f1 100644 --- a/src/scene/graph/physics.rs +++ b/src/scene/graph/physics.rs @@ -8,7 +8,6 @@ use crate::{ Vector2, Vector3, }, arrayvec::ArrayVec, - inspect::{Inspect, PropertyInfo}, instant, math::Matrix4Ext, pool::Handle, @@ -103,17 +102,7 @@ impl From for FeatureId { /// between two colliders. Each collider has its combination rule of type `CoefficientCombineRule`, /// the rule actually used is given by `max(first_combine_rule, second_combine_rule)`. #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - Visit, - Inspect, - Reflect, - EnumVariantNames, - EnumString, - AsRefStr, + Copy, Clone, Debug, PartialEq, Eq, Visit, Reflect, EnumVariantNames, EnumString, AsRefStr, )] #[repr(u32)] pub enum CoefficientCombineRule { @@ -686,11 +675,11 @@ fn collider_shape_into_native_shape( /// /// This is almost one-to-one copy of Rapier's integration parameters with custom attributes for /// each parameter. -#[derive(Copy, Clone, Visit, Inspect, Reflect, Debug)] +#[derive(Copy, Clone, Visit, Reflect, Debug)] pub struct IntegrationParameters { /// The time step length, default is None - this means that physics simulation will use engine's /// time step. - #[inspect(min_value = 0.0, description = "The time step length (default: None)")] + #[reflect(min_value = 0.0, description = "The time step length (default: None)")] #[visit(optional)] pub dt: Option, @@ -702,7 +691,7 @@ pub struct IntegrationParameters { /// Setting this to a large value will reduce the opportunity to performing CCD substepping, /// resulting in potentially more time dropped by the motion-clamping mechanism. Setting this /// to an very small value may lead to numerical instabilities. - #[inspect( + #[reflect( min_value = 0.0, description = "Minimum timestep size when using CCD with multiple\ substeps (default `1.0 / 60.0 / 100.0`)" @@ -711,7 +700,7 @@ pub struct IntegrationParameters { /// The Error Reduction Parameter in `[0, 1]` is the proportion of the positional error to be /// corrected at each time step (default: `0.2`). - #[inspect( + #[reflect( min_value = 0.0, max_value = 1.0, description = "The Error Reduction Parameter in `[0, 1]` is the proportion of the \ @@ -723,7 +712,7 @@ pub struct IntegrationParameters { /// Lower values make the constraints more compliant (more "springy", allowing more visible penetrations /// before stabilization). /// (default `0.25`). - #[inspect( + #[reflect( min_value = 0.0, max_value = 1.0, description = "The damping ratio used by the springs in `[0, 1]` Lower values make the constraints more \ @@ -733,7 +722,7 @@ pub struct IntegrationParameters { /// The Error Reduction Parameter for joints in `[0, 1]` is the proportion of the positional /// error to be corrected at each time step (default: `0.2`). - #[inspect( + #[reflect( min_value = 0.0, max_value = 1.0, description = "The Error Reduction Parameter for joints in `[0, 1]` is the proportion \ @@ -743,7 +732,7 @@ pub struct IntegrationParameters { /// The fraction of critical damping applied to the joint for constraints regularization. /// (default `0.25`). - #[inspect( + #[reflect( min_value = 0.0, description = "The fraction of critical damping applied to the joint for \ constraints regularization (default: `0.25`)." @@ -751,21 +740,21 @@ pub struct IntegrationParameters { pub joint_damping_ratio: f32, /// Amount of penetration the engine wont attempt to correct (default: `0.005m`). - #[inspect( + #[reflect( min_value = 0.0, description = "Amount of penetration the engine wont attempt to correct (default: `0.005m`)." )] pub allowed_linear_error: f32, /// Maximum amount of penetration the solver will attempt to resolve in one timestep. - #[inspect( + #[reflect( min_value = 0.0, description = "Maximum amount of penetration the solver will attempt to resolve in one timestep." )] pub max_penetration_correction: f32, /// The maximal distance separating two objects that will generate predictive contacts (default: `0.002`). - #[inspect( + #[reflect( min_value = 0.0, description = "The maximal distance separating two objects that will generate \ predictive contacts (default: `0.002`)." @@ -773,7 +762,7 @@ pub struct IntegrationParameters { pub prediction_distance: f32, /// Maximum number of iterations performed by the velocity constraints solver (default: `4`). - #[inspect( + #[reflect( min_value = 0.0, description = "Maximum number of iterations performed by the \ velocity constraints solver (default: `4`)." @@ -781,14 +770,14 @@ pub struct IntegrationParameters { pub max_velocity_iterations: u32, /// Maximum number of iterations performed to solve friction constraints (default: `8`). - #[inspect( + #[reflect( min_value = 0.0, description = "Maximum number of iterations performed to solve friction constraints (default: `8`)" )] pub max_velocity_friction_iterations: u32, /// Maximum number of iterations performed to remove the energy introduced by penetration corrections (default: `1`). - #[inspect( + #[reflect( min_value = 0.0, description = "Maximum number of iterations performed to remove the energy introduced by penetration corrections (default: `1`)." )] @@ -796,21 +785,21 @@ pub struct IntegrationParameters { /// If `false`, friction and non-penetration constraints will be solved in the same loop. Otherwise, /// non-penetration constraints are solved first, and friction constraints are solved after (default: `true`). - #[inspect( + #[reflect( description = "If `false`, friction and non-penetration constraints will be solved in the same loop. Otherwise, \ non-penetration constraints are solved first, and friction constraints are solved after (default: `true`)." )] pub interleave_restitution_and_friction_resolution: bool, /// Minimum number of dynamic bodies in each active island (default: `128`). - #[inspect( + #[reflect( min_value = 0.0, description = "Minimum number of dynamic bodies in each active island (default: `128`)." )] pub min_island_size: u32, /// Maximum number of substeps performed by the solver (default: `1`). - #[inspect( + #[reflect( min_value = 0.0, description = "Maximum number of substeps performed by the solver (default: `1`)." )] @@ -842,7 +831,7 @@ impl Default for IntegrationParameters { /// Physics world is responsible for physics simulation in the engine. There is a very few public /// methods, mostly for ray casting. You should add physical entities using scene graph nodes, such /// as RigidBody, Collider, Joint. -#[derive(Visit, Inspect, Reflect)] +#[derive(Visit, Reflect)] pub struct PhysicsWorld { /// A flag that defines whether physics simulation is enabled or not. pub enabled: bool, @@ -855,67 +844,54 @@ pub struct PhysicsWorld { /// Performance statistics of a single simulation step. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub performance_statistics: PhysicsPerformanceStatistics, // Current physics pipeline. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pipeline: PhysicsPipeline, // Broad phase performs rough intersection checks. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] broad_phase: BroadPhase, // Narrow phase is responsible for precise contact generation. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] narrow_phase: NarrowPhase, // A continuous collision detection solver. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] ccd_solver: CCDSolver, // Structure responsible for maintaining the set of active rigid-bodies, and putting non-moving // rigid-bodies to sleep to save computation times. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] islands: IslandManager, // A container of rigid bodies. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] bodies: Container, // A container of colliders. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] colliders: Container, // A container of impulse joints. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] joints: Container, // A container of multibody joints. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] multibody_joints: Container, // Event handler collects info about contacts and proximity events. #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] event_handler: Box, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] query: RefCell, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] debug_render_pipeline: Mutex, } diff --git a/src/scene/joint.rs b/src/scene/joint.rs index 44c5a2f3b..1cad6801a 100644 --- a/src/scene/joint.rs +++ b/src/scene/joint.rs @@ -3,7 +3,6 @@ use crate::{ core::{ algebra::Matrix4, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, m4x4_approx_eq}, pool::Handle, reflect::prelude::*, @@ -31,35 +30,35 @@ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; /// Ball joint locks any translational moves between two objects on the axis between objects, but /// allows rigid bodies to perform relative rotations. The real world example is a human shoulder, /// pendulum, etc. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct BallJoint { /// Whether X angular limits are enabled or not. Default is `false` - #[inspect(description = "Whether X angular limits are enabled or not.")] + #[reflect(description = "Whether X angular limits are enabled or not.")] #[visit(optional)] // Backward compatibility pub x_limits_enabled: bool, /// Allowed angle range around local X axis of the joint (in radians). - #[inspect(description = "Allowed angle range around local X axis of the joint (in radians).")] + #[reflect(description = "Allowed angle range around local X axis of the joint (in radians).")] #[visit(optional)] // Backward compatibility pub x_limits_angles: Range, /// Whether Y angular limits are enabled or not. Default is `false` - #[inspect(description = "Whether Y angular limits are enabled or not.")] + #[reflect(description = "Whether Y angular limits are enabled or not.")] #[visit(optional)] // Backward compatibility pub y_limits_enabled: bool, /// Allowed angle range around local Y axis of the joint (in radians). - #[inspect(description = "Allowed angle range around local Y axis of the joint (in radians).")] + #[reflect(description = "Allowed angle range around local Y axis of the joint (in radians).")] #[visit(optional)] // Backward compatibility pub y_limits_angles: Range, /// Whether Z angular limits are enabled or not. Default is `false` - #[inspect(description = "Whether Z angular limits are enabled or not.")] + #[reflect(description = "Whether Z angular limits are enabled or not.")] #[visit(optional)] // Backward compatibility pub z_limits_enabled: bool, /// Allowed angle range around local Z axis of the joint (in radians). - #[inspect(description = "Allowed angle range around local Z axis of the joint (in radians).")] + #[reflect(description = "Allowed angle range around local Z axis of the joint (in radians).")] #[visit(optional)] // Backward compatibility pub z_limits_angles: Range, } @@ -79,20 +78,20 @@ impl Default for BallJoint { /// A fixed joint ensures that two rigid bodies does not move relative to each other. There is no /// straightforward real-world example, but it can be thought as two bodies were "welded" together. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect, Default, Eq)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect, Default, Eq)] pub struct FixedJoint; /// Prismatic joint prevents any relative movement between two rigid-bodies, except for relative /// translations along one axis. The real world example is a sliders that used to support drawers. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct PrismaticJoint { /// Whether linear limits along local joint X axis are enabled or not. Default is `false` - #[inspect(description = "Whether linear limits along local joint X axis are enabled or not.")] + #[reflect(description = "Whether linear limits along local joint X axis are enabled or not.")] #[visit(optional)] // Backward compatibility pub limits_enabled: bool, /// The min an max relative position of the attached bodies along local X axis of the joint. - #[inspect( + #[reflect( description = "The min an max relative position of the attached bodies along local X axis of the joint." )] #[visit(optional)] // Backward compatibility @@ -111,17 +110,17 @@ impl Default for PrismaticJoint { /// Revolute joint prevents any relative movement between two rigid bodies, except relative rotation /// along one axis. The real world example is wheels, fans, etc. It can also be used to simulate door /// hinge. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct RevoluteJoint { /// Whether angular limits around local X axis of the joint are enabled or not. Default is `false` - #[inspect( + #[reflect( description = "Whether angular limits around local X axis of the joint are enabled or not." )] #[visit(optional)] // Backward compatibility pub limits_enabled: bool, /// Allowed angle range around local X axis of the joint (in radians). - #[inspect(description = "Allowed angle range around local X axis of the joint (in radians).")] + #[reflect(description = "Allowed angle range around local X axis of the joint (in radians).")] #[visit(optional)] // Backward compatibility pub limits: Range, } @@ -136,9 +135,7 @@ impl Default for RevoluteJoint { } /// The exact kind of the joint. -#[derive( - Clone, Debug, PartialEq, Visit, Inspect, Reflect, AsRefStr, EnumString, EnumVariantNames, -)] +#[derive(Clone, Debug, PartialEq, Visit, Reflect, AsRefStr, EnumString, EnumVariantNames)] pub enum JointParams { /// See [`BallJoint`] for more info. BallJoint(BallJoint), @@ -158,7 +155,7 @@ impl Default for JointParams { /// Joint is used to restrict motion of two rigid bodies. There are numerous examples of joints in /// real life: door hinge, ball joints in human arms, etc. -#[derive(Visit, Inspect, Reflect, Debug)] +#[derive(Visit, Reflect, Debug)] pub struct Joint { base: Base, @@ -176,12 +173,10 @@ pub struct Joint { pub(crate) contacts_enabled: InheritableVariable, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) native: Cell, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) need_rebind: Cell, } diff --git a/src/scene/light/directional.rs b/src/scene/light/directional.rs index 9e91228be..ad7ae1e80 100644 --- a/src/scene/light/directional.rs +++ b/src/scene/light/directional.rs @@ -9,7 +9,6 @@ use crate::{ core::{ - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -32,9 +31,7 @@ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; pub const CSM_NUM_CASCADES: usize = 3; /// Frustum split options defines how to split camera's frustum to generate cascades. -#[derive( - Inspect, Reflect, Clone, Visit, Debug, PartialEq, AsRefStr, EnumString, EnumVariantNames, -)] +#[derive(Reflect, Clone, Visit, Debug, PartialEq, AsRefStr, EnumString, EnumVariantNames)] pub enum FrustumSplitOptions { /// Camera frustum will be split into a [`CSM_NUM_CASCADES`] splits where each sub-frustum /// will have fixed far plane location. @@ -69,12 +66,12 @@ impl Default for FrustumSplitOptions { } /// Cascade Shadow Mapping (CSM) options. -#[derive(Inspect, Reflect, Clone, Visit, PartialEq, Debug)] +#[derive(Reflect, Clone, Visit, PartialEq, Debug)] pub struct CsmOptions { /// See [`FrustumSplitOptions`]. pub split_options: FrustumSplitOptions, - #[inspect(min_value = 0.0, step = 0.000025)] + #[reflect(min_value = 0.0, step = 0.000025)] shadow_bias: f32, } @@ -102,7 +99,7 @@ impl CsmOptions { } /// See module docs. -#[derive(Default, Debug, Visit, Inspect, Reflect, Clone)] +#[derive(Default, Debug, Visit, Reflect, Clone)] pub struct DirectionalLight { base_light: BaseLight, /// See [`CsmOptions`]. diff --git a/src/scene/light/mod.rs b/src/scene/light/mod.rs index 0d4c5f3ad..502aa610e 100644 --- a/src/scene/light/mod.rs +++ b/src/scene/light/mod.rs @@ -20,7 +20,6 @@ use crate::{ core::{ algebra::Vector3, color::Color, - inspect::{Inspect, PropertyInfo}, reflect::prelude::*, variable::InheritableVariable, visitor::{Visit, VisitResult, Visitor}, @@ -49,7 +48,7 @@ pub const DEFAULT_SCATTER_B: f32 = 0.03; /// Light scene node. It contains common properties of light such as color, /// scattering factor (per color channel) and other useful properties. Exact /// behavior defined by specific light kind. -#[derive(Debug, Inspect, Reflect, Clone, Visit)] +#[derive(Debug, Reflect, Clone, Visit)] pub struct BaseLight { base: Base, @@ -66,7 +65,7 @@ pub struct BaseLight { #[reflect(setter = "enable_scatter")] scatter_enabled: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] #[reflect(setter = "set_intensity")] intensity: InheritableVariable, } diff --git a/src/scene/light/point.rs b/src/scene/light/point.rs index 5de247b82..94988cd18 100644 --- a/src/scene/light/point.rs +++ b/src/scene/light/point.rs @@ -19,7 +19,6 @@ use crate::{ core::{ - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -38,15 +37,15 @@ use crate::{ use std::ops::{Deref, DerefMut}; /// See module docs. -#[derive(Debug, Inspect, Reflect, Clone, Visit)] +#[derive(Debug, Reflect, Clone, Visit)] pub struct PointLight { base_light: BaseLight, - #[inspect(min_value = 0.0, step = 0.001)] + #[reflect(min_value = 0.0, step = 0.001)] #[reflect(setter = "set_shadow_bias")] shadow_bias: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] #[reflect(setter = "set_radius")] radius: InheritableVariable, } diff --git a/src/scene/light/spot.rs b/src/scene/light/spot.rs index b6a650dde..6bdc8f5de 100644 --- a/src/scene/light/spot.rs +++ b/src/scene/light/spot.rs @@ -24,7 +24,6 @@ use crate::{ core::{ - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -44,23 +43,23 @@ use crate::{ use std::ops::{Deref, DerefMut}; /// See module docs. -#[derive(Debug, Inspect, Reflect, Clone, Visit)] +#[derive(Debug, Reflect, Clone, Visit)] pub struct SpotLight { base_light: BaseLight, - #[inspect(min_value = 0.0, max_value = 3.14159, step = 0.1)] + #[reflect(min_value = 0.0, max_value = 3.14159, step = 0.1)] #[reflect(setter = "set_hotspot_cone_angle")] hotspot_cone_angle: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] #[reflect(setter = "set_falloff_angle_delta")] falloff_angle_delta: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.001)] + #[reflect(min_value = 0.0, step = 0.001)] #[reflect(setter = "set_shadow_bias")] shadow_bias: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] #[reflect(setter = "set_distance")] distance: InheritableVariable, diff --git a/src/scene/mesh/mod.rs b/src/scene/mesh/mod.rs index 71b77a88c..bec4ed5f7 100644 --- a/src/scene/mesh/mod.rs +++ b/src/scene/mesh/mod.rs @@ -11,7 +11,6 @@ use crate::{ core::{ algebra::{Matrix4, Point3, Vector3}, - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -51,7 +50,6 @@ pub mod vertex; Hash, Debug, Visit, - Inspect, Reflect, AsRefStr, EnumString, @@ -86,7 +84,7 @@ impl RenderPath { } /// See module docs. -#[derive(Debug, Inspect, Reflect, Clone, Visit)] +#[derive(Debug, Reflect, Clone, Visit)] pub struct Mesh { #[visit(rename = "Common")] base: Base, @@ -100,19 +98,16 @@ pub struct Mesh { #[reflect(setter = "set_decal_layer_index")] decal_layer_index: InheritableVariable, - #[inspect(skip)] - #[visit(skip)] #[reflect(hidden)] + #[visit(skip)] local_bounding_box: Cell, - #[inspect(skip)] - #[visit(skip)] #[reflect(hidden)] + #[visit(skip)] local_bounding_box_dirty: Cell, - #[inspect(skip)] - #[visit(skip)] #[reflect(hidden)] + #[visit(skip)] world_bounding_box: Cell, } diff --git a/src/scene/mesh/surface.rs b/src/scene/mesh/surface.rs index 14b0e6735..a511586c7 100644 --- a/src/scene/mesh/surface.rs +++ b/src/scene/mesh/surface.rs @@ -8,7 +8,6 @@ use crate::{ core::{ algebra::{Matrix4, Point3, Vector2, Vector3, Vector4}, hash_combine, - inspect::{Inspect, PropertyInfo}, math::TriangleDefinition, parking_lot::{Mutex, MutexGuard}, pool::{ErasedHandle, Handle}, @@ -954,7 +953,7 @@ impl VertexWeightSet { /// Surface shared data is a vertex and index buffer that can be shared across multiple objects. This is /// very useful memory optimization - you create a single data storage for a surface and then share it /// with any instance count you want. Memory usage does not increate with instance count in this case. -#[derive(Default, Debug, Clone, Inspect, Reflect)] +#[derive(Default, Debug, Clone, Reflect)] pub struct SurfaceSharedData(#[reflect(hidden)] Arc>); impl PartialEq for SurfaceSharedData { @@ -998,7 +997,7 @@ impl SurfaceSharedData { } /// See module docs. -#[derive(Debug, Clone, Inspect, Reflect, PartialEq)] +#[derive(Debug, Clone, Reflect, PartialEq)] pub struct Surface { data: InheritableVariable, @@ -1013,7 +1012,6 @@ pub struct Surface { // bones so we can use `bones` array as reference to get those indices. This could be done // like so: iterate over all vertices and weight data and calculate index of node handle that // associated with vertex in `bones` array and store it as bone index in vertex. - #[inspect(skip)] #[reflect(hidden)] pub(crate) vertex_weights: Vec, } diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 5cc3cb689..b925f2cb7 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -32,7 +32,6 @@ use crate::{ algebra::Vector2, color::Color, futures::future::join_all, - inspect::{Inspect, PropertyInfo}, instant, pool::{Handle, Pool, Ticket}, reflect::prelude::*, @@ -143,7 +142,7 @@ impl IndexMut> for NavMeshContainer { } /// See module docs. -#[derive(Debug, Inspect, Reflect)] +#[derive(Debug, Reflect)] pub struct Scene { /// Graph is main container for all scene nodes. It calculates global transforms for nodes, /// updates them and performs all other important work. See `graph` module docs for more @@ -152,7 +151,6 @@ pub struct Scene { /// Animations container controls all animation on scene. Each animation can have tracks which /// has handles to graph nodes. See `animation` module docs for more info. - #[inspect(skip)] #[reflect(hidden)] pub animations: AnimationContainer, @@ -163,27 +161,22 @@ pub struct Scene { /// main scene you can attach this texture to some quad which will be used as /// monitor. Other usage could be previewer of models, like pictogram of character /// in real-time strategies, in other words there are plenty of possible uses. - #[inspect(skip)] #[reflect(hidden)] pub render_target: Option, /// Drawing context for simple graphics. - #[inspect(skip)] #[reflect(hidden)] pub drawing_context: SceneDrawingContext, /// A container for navigational meshes. - #[inspect(skip)] #[reflect(hidden)] pub navmeshes: NavMeshContainer, /// Current lightmap. - #[inspect(skip)] #[reflect(hidden)] lightmap: Option, /// Performance statistics from last `update` call. - #[inspect(skip)] #[reflect(hidden)] pub performance_statistics: PerformanceStatistics, @@ -200,7 +193,6 @@ pub struct Scene { pub enabled: bool, /// A container for animation blending state machines. - #[inspect(skip)] #[reflect(hidden)] pub animation_machines: AnimationMachineContainer, } diff --git a/src/scene/node/mod.rs b/src/scene/node/mod.rs index cf3a31895..68645c1ae 100644 --- a/src/scene/node/mod.rs +++ b/src/scene/node/mod.rs @@ -8,7 +8,6 @@ use crate::scene::Scene; use crate::{ core::{ algebra::{Matrix4, Vector2}, - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -130,7 +129,7 @@ macro_rules! impl_query_component { } /// A main trait for any scene graph node. -pub trait NodeTrait: BaseNodeTrait + Reflect + Inspect + Visit { +pub trait NodeTrait: BaseNodeTrait + Reflect + Visit { /// Allows a node to provide access to inner components. fn query_component_ref(&self, type_id: TypeId) -> Option<&dyn Any>; @@ -199,7 +198,7 @@ pub trait NodeTrait: BaseNodeTrait + Reflect + Inspect + Visit { /// A small wrapper over `Handle`. Its main purpose is to provide a convenient way /// to handle arrays of handles in the editor. -#[derive(Reflect, Inspect, Default, Copy, Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Reflect, Default, Copy, Clone, Debug, PartialEq, Eq, Hash)] #[repr(transparent)] pub struct NodeHandle(pub Handle); @@ -433,9 +432,3 @@ impl Visit for Node { self.0.visit(name, visitor) } } - -impl Inspect for Node { - fn properties(&self) -> Vec> { - self.0.properties() - } -} diff --git a/src/scene/particle_system/emitter/base.rs b/src/scene/particle_system/emitter/base.rs index 3ecd81acc..ea817413b 100644 --- a/src/scene/particle_system/emitter/base.rs +++ b/src/scene/particle_system/emitter/base.rs @@ -2,11 +2,7 @@ use crate::{ core::{ - algebra::Vector3, - color::Color, - inspect::{Inspect, PropertyInfo}, - numeric_range::RangeExt, - reflect::prelude::*, + algebra::Vector3, color::Color, numeric_range::RangeExt, reflect::prelude::*, visitor::prelude::*, }, scene::particle_system::Particle, @@ -14,7 +10,7 @@ use crate::{ use std::ops::Range; /// See module docs. -#[derive(Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Debug, Visit, PartialEq, Reflect)] pub struct BaseEmitter { /// Offset from center of particle system. position: Vector3, @@ -42,18 +38,15 @@ pub struct BaseEmitter { rotation_speed: Range, /// Range of initial rotation for a particle rotation: Range, - #[inspect(skip)] + #[reflect(hidden)] pub(crate) alive_particles: u32, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] time: f32, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) particles_to_spawn: u32, resurrect_particles: bool, - #[inspect(skip)] #[reflect(hidden)] spawned_particles: u64, } diff --git a/src/scene/particle_system/emitter/cuboid.rs b/src/scene/particle_system/emitter/cuboid.rs index 76c3e9922..de337d449 100644 --- a/src/scene/particle_system/emitter/cuboid.rs +++ b/src/scene/particle_system/emitter/cuboid.rs @@ -3,12 +3,7 @@ use crate::core::numeric_range::RangeExt; use crate::{ - core::{ - algebra::Vector3, - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, - visitor::prelude::*, - }, + core::{algebra::Vector3, reflect::prelude::*, visitor::prelude::*}, scene::particle_system::{ emitter::{ base::{BaseEmitter, BaseEmitterBuilder}, @@ -20,14 +15,14 @@ use crate::{ use std::ops::{Deref, DerefMut}; /// See module docs. -#[derive(Debug, Clone, Visit, PartialEq, Inspect, Reflect)] +#[derive(Debug, Clone, Visit, PartialEq, Reflect)] pub struct CuboidEmitter { emitter: BaseEmitter, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] half_width: f32, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] half_height: f32, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] half_depth: f32, } diff --git a/src/scene/particle_system/emitter/cylinder.rs b/src/scene/particle_system/emitter/cylinder.rs index b11cc2781..6a38afe6c 100644 --- a/src/scene/particle_system/emitter/cylinder.rs +++ b/src/scene/particle_system/emitter/cylinder.rs @@ -2,12 +2,7 @@ use crate::core::numeric_range::RangeExt; use crate::{ - core::{ - algebra::Vector3, - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, - visitor::prelude::*, - }, + core::{algebra::Vector3, reflect::prelude::*, visitor::prelude::*}, scene::particle_system::{ emitter::{ base::{BaseEmitter, BaseEmitterBuilder}, @@ -19,12 +14,12 @@ use crate::{ use std::ops::{Deref, DerefMut}; /// See module docs. -#[derive(Clone, Debug, Visit, PartialEq, Inspect, Reflect)] +#[derive(Clone, Debug, Visit, PartialEq, Reflect)] pub struct CylinderEmitter { emitter: BaseEmitter, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] height: f32, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] radius: f32, } diff --git a/src/scene/particle_system/emitter/mod.rs b/src/scene/particle_system/emitter/mod.rs index 1d3512c22..082d27692 100644 --- a/src/scene/particle_system/emitter/mod.rs +++ b/src/scene/particle_system/emitter/mod.rs @@ -2,8 +2,7 @@ //! use BaseEmitter which contains base functionality. use crate::{ - asset::core::inspect::PropertyInfo, - core::{inspect::Inspect, reflect::prelude::*, visitor::prelude::*}, + core::{reflect::prelude::*, visitor::prelude::*}, scene::particle_system::{ emitter::{ base::BaseEmitter, cuboid::CuboidEmitter, cylinder::CylinderEmitter, @@ -27,7 +26,7 @@ pub trait Emit { } /// See module docs. -#[derive(PartialEq, Debug, Inspect, Reflect, AsRefStr, EnumString, EnumVariantNames)] +#[derive(PartialEq, Debug, Reflect, AsRefStr, EnumString, EnumVariantNames)] pub enum Emitter { /// See BoxEmitter docs. Cuboid(CuboidEmitter), diff --git a/src/scene/particle_system/emitter/sphere.rs b/src/scene/particle_system/emitter/sphere.rs index a43057072..c8fb802b2 100644 --- a/src/scene/particle_system/emitter/sphere.rs +++ b/src/scene/particle_system/emitter/sphere.rs @@ -3,12 +3,7 @@ use crate::core::numeric_range::RangeExt; use crate::{ - core::{ - algebra::Vector3, - inspect::{Inspect, PropertyInfo}, - reflect::prelude::*, - visitor::prelude::*, - }, + core::{algebra::Vector3, reflect::prelude::*, visitor::prelude::*}, scene::particle_system::{ emitter::{ base::{BaseEmitter, BaseEmitterBuilder}, @@ -20,10 +15,10 @@ use crate::{ use std::ops::{Deref, DerefMut}; /// See module docs. -#[derive(Debug, Clone, Inspect, Reflect, PartialEq, Visit)] +#[derive(Debug, Clone, Reflect, PartialEq, Visit)] pub struct SphereEmitter { emitter: BaseEmitter, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] radius: f32, } diff --git a/src/scene/particle_system/mod.rs b/src/scene/particle_system/mod.rs index 359845a6b..6b2f1d77d 100644 --- a/src/scene/particle_system/mod.rs +++ b/src/scene/particle_system/mod.rs @@ -75,7 +75,6 @@ use crate::{ algebra::{Vector2, Vector3}, color::Color, color_gradient::ColorGradient, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, TriangleDefinition}, pool::Handle, reflect::prelude::*, @@ -107,8 +106,8 @@ pub mod emitter; pub mod particle; #[doc(hidden)] -#[derive(PartialEq, Debug, Clone, Default, Inspect, Reflect)] -pub struct EmitterWrapper(#[inspect(display_name = "Emitter Type")] pub Emitter); +#[derive(PartialEq, Debug, Clone, Default, Reflect)] +pub struct EmitterWrapper(#[reflect(display_name = "Emitter Type")] pub Emitter); impl Deref for EmitterWrapper { type Target = Emitter; @@ -131,7 +130,7 @@ impl Visit for EmitterWrapper { } /// See module docs. -#[derive(Debug, Visit, Clone, Inspect, Reflect)] +#[derive(Debug, Visit, Clone, Reflect)] pub struct ParticleSystem { base: Base, @@ -154,11 +153,9 @@ pub struct ParticleSystem { #[reflect(setter = "set_enabled")] enabled: InheritableVariable, - #[inspect(skip)] #[reflect(hidden)] particles: Vec, - #[inspect(skip)] #[reflect(hidden)] free_particles: Vec, } diff --git a/src/scene/pivot.rs b/src/scene/pivot.rs index 3d1fcf481..30a9bbf5a 100644 --- a/src/scene/pivot.rs +++ b/src/scene/pivot.rs @@ -1,7 +1,6 @@ //! A simplest possible node which represents point in space. use crate::{ core::{ - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -18,7 +17,7 @@ use crate::{ use std::ops::{Deref, DerefMut}; /// A simplest possible node which represents point in space. -#[derive(Clone, Inspect, Reflect, Default, Debug)] +#[derive(Clone, Reflect, Default, Debug)] pub struct Pivot { base: Base, } diff --git a/src/scene/rigidbody.rs b/src/scene/rigidbody.rs index 67e443422..4f232a063 100644 --- a/src/scene/rigidbody.rs +++ b/src/scene/rigidbody.rs @@ -11,7 +11,6 @@ use crate::{ core::{ algebra::{Matrix4, Vector3}, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, m4x4_approx_eq}, parking_lot::Mutex, pool::Handle, @@ -39,18 +38,7 @@ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; /// A set of possible types of rigid body. #[derive( - Copy, - Clone, - Debug, - Inspect, - Reflect, - Visit, - PartialEq, - Eq, - Hash, - AsRefStr, - EnumString, - EnumVariantNames, + Copy, Clone, Debug, Reflect, Visit, PartialEq, Eq, Hash, AsRefStr, EnumString, EnumVariantNames, )] #[repr(u32)] pub enum RigidBodyType { @@ -137,7 +125,7 @@ pub(crate) enum ApplyAction { /// /// Rigid body that does not move for some time will go asleep. This means that the body will not /// move unless it is woken up by some other moving body. This feature allows to save CPU resources. -#[derive(Visit, Inspect, Reflect)] +#[derive(Visit, Reflect)] pub struct RigidBody { base: Base, @@ -156,7 +144,7 @@ pub struct RigidBody { #[reflect(setter = "set_body_type")] pub(crate) body_type: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] #[reflect(setter = "set_mass")] pub(crate) mass: InheritableVariable, @@ -185,15 +173,12 @@ pub struct RigidBody { pub(crate) gravity_scale: InheritableVariable, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) sleeping: bool, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) native: Cell, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) actions: Mutex>, } diff --git a/src/scene/sound/context.rs b/src/scene/sound/context.rs index 5e0821737..879309704 100644 --- a/src/scene/sound/context.rs +++ b/src/scene/sound/context.rs @@ -2,7 +2,6 @@ use crate::{ core::{ - inspect::{Inspect, PropertyInfo}, pool::{Handle, Pool, Ticket}, reflect::prelude::*, visitor::prelude::*, @@ -23,20 +22,18 @@ use fyrox_sound::{ use std::time::Duration; /// Sound context. -#[derive(Debug, Visit, Inspect, Reflect)] +#[derive(Debug, Visit, Reflect)] pub struct SoundContext { master_gain: f32, renderer: Renderer, distance_model: DistanceModel, paused: bool, - #[inspect(skip)] #[reflect(hidden)] pub(crate) effects: Pool, - #[inspect(read_only)] + #[reflect(read_only)] // A model resource from which this context was instantiated from. pub(crate) resource: Option, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) native: fyrox_sound::context::SoundContext, } diff --git a/src/scene/sound/effect.rs b/src/scene/sound/effect.rs index c372fcad6..d22810ab2 100644 --- a/src/scene/sound/effect.rs +++ b/src/scene/sound/effect.rs @@ -2,11 +2,7 @@ use crate::{ core::{ - define_is_as, - inspect::{Inspect, PropertyInfo}, - pool::Handle, - reflect::prelude::*, - variable::InheritableVariable, + define_is_as, pool::Handle, reflect::prelude::*, variable::InheritableVariable, visitor::prelude::*, }, define_with, @@ -22,7 +18,7 @@ use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; const DEFAULT_FC: f32 = 0.25615; // 11296 Hz at 44100 Hz sample rate /// Effect input allows you to setup a source of samples for an effect with an optional filtering. -#[derive(Visit, Inspect, Reflect, Debug, Default, Clone, PartialEq)] +#[derive(Visit, Reflect, Debug, Default, Clone, PartialEq)] pub struct EffectInput { /// A sound node that will be the source of samples for the effect. pub sound: Handle, @@ -31,7 +27,7 @@ pub struct EffectInput { } /// Base effect contains common properties for every effect (gain, inputs, etc.) -#[derive(Visit, Inspect, Reflect, Debug, Clone)] +#[derive(Visit, Reflect, Debug, Clone)] pub struct BaseEffect { #[reflect(setter = "set_name_internal")] pub(crate) name: InheritableVariable, @@ -43,7 +39,6 @@ pub struct BaseEffect { pub(crate) inputs: InheritableVariable>, #[visit(skip)] - #[inspect(skip)] #[reflect(hidden)] pub(crate) native: Cell>, } @@ -106,7 +101,7 @@ impl Default for BaseEffect { } /// All possible effects in the engine. -#[derive(Visit, Reflect, Inspect, Debug, AsRefStr, EnumString, EnumVariantNames, Clone)] +#[derive(Visit, Reflect, Debug, AsRefStr, EnumString, EnumVariantNames, Clone)] pub enum Effect { /// See [`ReverbEffect`] docs. Reverb(ReverbEffect), @@ -190,7 +185,7 @@ impl BaseEffectBuilder { } /// Reverb effect gives you multiple echoes. -#[derive(Visit, Inspect, Reflect, Debug, Clone)] +#[derive(Visit, Reflect, Debug, Clone)] pub struct ReverbEffect { pub(crate) base: BaseEffect, diff --git a/src/scene/sound/listener.rs b/src/scene/sound/listener.rs index dafdb24d2..5f6d0748e 100644 --- a/src/scene/sound/listener.rs +++ b/src/scene/sound/listener.rs @@ -5,7 +5,6 @@ use crate::{ core::{ - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, Matrix4Ext}, pool::Handle, reflect::prelude::*, @@ -35,7 +34,7 @@ use std::ops::{Deref, DerefMut}; /// /// 2D sound sources (with spatial blend == 0.0) are not influenced by listener's position and /// orientation. -#[derive(Visit, Inspect, Reflect, Default, Clone, Debug)] +#[derive(Visit, Reflect, Default, Clone, Debug)] pub struct Listener { base: Base, } diff --git a/src/scene/sound/mod.rs b/src/scene/sound/mod.rs index 52813e61a..338626763 100644 --- a/src/scene/sound/mod.rs +++ b/src/scene/sound/mod.rs @@ -3,7 +3,6 @@ use crate::{ core::{ algebra::Matrix4, - inspect::{Inspect, PropertyInfo}, math::{aabb::AxisAlignedBoundingBox, m4x4_approx_eq}, pool::Handle, reflect::prelude::*, @@ -45,7 +44,7 @@ pub mod effect; pub mod listener; /// Sound source. -#[derive(Visit, Inspect, Reflect, Debug)] +#[derive(Visit, Reflect, Debug)] pub struct Sound { base: Base, @@ -55,11 +54,11 @@ pub struct Sound { #[reflect(setter = "set_play_once")] play_once: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] #[reflect(setter = "set_gain")] gain: InheritableVariable, - #[inspect(min_value = -1.0, max_value = 1.0, step = 0.05)] + #[reflect(min_value = -1.0, max_value = 1.0, step = 0.05)] #[reflect(setter = "set_panning")] panning: InheritableVariable, @@ -69,19 +68,19 @@ pub struct Sound { #[reflect(setter = "set_looping")] looping: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] #[reflect(setter = "set_pitch")] pitch: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] #[reflect(setter = "set_radius")] radius: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] #[reflect(setter = "set_max_distance")] max_distance: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.05)] + #[reflect(min_value = 0.0, step = 0.05)] #[reflect(setter = "set_rolloff_factor")] rolloff_factor: InheritableVariable, @@ -91,9 +90,8 @@ pub struct Sound { #[reflect(setter = "set_spatial_blend")] spatial_blend: InheritableVariable, - #[inspect(skip)] - #[visit(skip)] #[reflect(hidden)] + #[visit(skip)] pub(crate) native: Cell>, } diff --git a/src/scene/sprite.rs b/src/scene/sprite.rs index 700e5f0de..02a3d7ee0 100644 --- a/src/scene/sprite.rs +++ b/src/scene/sprite.rs @@ -5,7 +5,6 @@ use crate::{ core::{ color::Color, - inspect::{Inspect, PropertyInfo}, math::aabb::AxisAlignedBoundingBox, pool::Handle, reflect::prelude::*, @@ -62,7 +61,7 @@ use std::ops::{Deref, DerefMut}; /// .build(graph) /// } /// ``` -#[derive(Debug, Inspect, Reflect, Clone, Visit)] +#[derive(Debug, Reflect, Clone, Visit)] pub struct Sprite { base: Base, @@ -72,7 +71,7 @@ pub struct Sprite { #[reflect(setter = "set_color")] color: InheritableVariable, - #[inspect(min_value = 0.0, step = 0.1)] + #[reflect(min_value = 0.0, step = 0.1)] #[reflect(setter = "set_size")] size: InheritableVariable, diff --git a/src/scene/terrain.rs b/src/scene/terrain.rs index 5806d25ea..e43c70b04 100644 --- a/src/scene/terrain.rs +++ b/src/scene/terrain.rs @@ -4,7 +4,6 @@ use crate::{ core::{ algebra::{Matrix4, Point3, Vector2, Vector3}, arrayvec::ArrayVec, - inspect::{Inspect, PropertyInfo}, math::{ aabb::AxisAlignedBoundingBox, ray::Ray, ray_rect_intersection, Rect, TriangleDefinition, }, @@ -38,7 +37,7 @@ use std::{ /// rendering. Terrain can have as many layers as you want, but each layer slightly decreases /// performance, so keep amount of layers on reasonable level (1 - 5 should be enough for most /// cases). -#[derive(Default, Debug, Clone, Visit, Inspect, Reflect)] +#[derive(Default, Debug, Clone, Visit, Reflect)] pub struct Layer { /// Material of the layer. #[reflect(hidden)] @@ -51,7 +50,6 @@ pub struct Layer { /// It will be used in the renderer to set appropriate chunk mask to the copy of the material. pub mask_property_name: String, - #[inspect(skip)] #[reflect(hidden)] pub(crate) chunk_masks: Vec, } @@ -250,7 +248,7 @@ pub struct TerrainRayCastResult { /// are inheritable. You cannot inherit width, height, chunks and other things because these cannot /// be modified at runtime because changing width (for example) will invalidate the entire height /// map which makes runtime modification useless. -#[derive(Visit, Debug, Default, Inspect, Reflect, Clone)] +#[derive(Visit, Debug, Default, Reflect, Clone)] pub struct Terrain { base: Base, @@ -260,39 +258,36 @@ pub struct Terrain { #[reflect(setter = "set_decal_layer_index")] decal_layer_index: InheritableVariable, - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] width: f32, - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] length: f32, - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] mask_resolution: f32, - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] height_map_resolution: f32, - #[inspect(skip)] #[reflect(hidden)] chunks: Vec, - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] width_chunks: u32, - #[inspect(read_only)] + #[reflect(read_only)] #[reflect(hidden)] length_chunks: u32, - #[inspect(skip)] #[reflect(hidden)] bounding_box_dirty: Cell, - #[inspect(skip)] #[reflect(hidden)] bounding_box: Cell, } @@ -679,7 +674,7 @@ impl NodeTrait for Terrain { } /// Shape of a brush. -#[derive(Copy, Clone, Inspect, Reflect, Debug)] +#[derive(Copy, Clone, Reflect, Debug)] pub enum BrushShape { /// Circle with given radius. Circle { @@ -711,7 +706,7 @@ impl BrushShape { } /// Paint mode of a brush. It defines operation that will be performed on the terrain. -#[derive(Clone, PartialEq, PartialOrd, Inspect, Reflect, Debug)] +#[derive(Clone, PartialEq, PartialOrd, Reflect, Debug)] pub enum BrushMode { /// Modifies height map. ModifyHeightMap { @@ -729,10 +724,10 @@ pub enum BrushMode { } /// Brush is used to modify terrain. It supports multiple shapes and modes. -#[derive(Clone, Inspect, Reflect, Debug)] +#[derive(Clone, Reflect, Debug)] pub struct Brush { /// Center of the brush. - #[inspect(skip)] + #[reflect(hidden)] pub center: Vector3, /// Shape of the brush. pub shape: BrushShape, diff --git a/src/scene/transform.rs b/src/scene/transform.rs index ade7dedb0..9586cf204 100644 --- a/src/scene/transform.rs +++ b/src/scene/transform.rs @@ -47,7 +47,6 @@ use crate::{ core::{ algebra::{Matrix3, Matrix4, UnitQuaternion, Vector3}, - inspect::{Inspect, PropertyInfo}, reflect::prelude::*, variable::InheritableVariable, visitor::{Visit, VisitResult, Visitor}, @@ -57,56 +56,53 @@ use crate::{ use std::cell::Cell; /// See module docs. -#[derive(Clone, Debug, Inspect, Reflect)] +#[derive(Clone, Debug, Reflect)] pub struct Transform { // Indicates that some property has changed and matrix must be // recalculated before use. This is some sort of lazy evaluation. - #[inspect(skip)] #[reflect(hidden)] dirty: Cell, - #[inspect(description = "Local scale of the transform")] + #[reflect(description = "Local scale of the transform")] #[reflect(setter = "set_scale_internal")] local_scale: InheritableVariable>, - #[inspect(description = "Local position of the transform")] + #[reflect(description = "Local position of the transform")] #[reflect(setter = "set_position_internal")] local_position: InheritableVariable>, - #[inspect(description = "Local rotation of the transform")] + #[reflect(description = "Local rotation of the transform")] #[reflect(setter = "set_rotation_internal")] local_rotation: InheritableVariable>, - #[inspect(description = "Pre rotation of the transform. Applied before local rotation.")] + #[reflect(description = "Pre rotation of the transform. Applied before local rotation.")] #[reflect(setter = "set_pre_rotation_internal")] pre_rotation: InheritableVariable>, - #[inspect(description = "Post rotation of the transform. Applied after local rotation.")] + #[reflect(description = "Post rotation of the transform. Applied after local rotation.")] #[reflect(setter = "set_post_rotation_internal")] post_rotation: InheritableVariable>, - #[inspect(description = "Rotation offset of the transform.")] + #[reflect(description = "Rotation offset of the transform.")] #[reflect(setter = "set_rotation_offset_internal")] rotation_offset: InheritableVariable>, - #[inspect(description = "Rotation pivot of the transform.")] + #[reflect(description = "Rotation pivot of the transform.")] #[reflect(setter = "set_rotation_pivot_internal")] rotation_pivot: InheritableVariable>, - #[inspect(description = "Scale offset of the transform.")] + #[reflect(description = "Scale offset of the transform.")] #[reflect(setter = "set_scaling_offset_internal")] scaling_offset: InheritableVariable>, - #[inspect(description = "Scale pivot of the transform.")] + #[reflect(description = "Scale pivot of the transform.")] #[reflect(setter = "set_scaling_pivot_internal")] scaling_pivot: InheritableVariable>, // Combined transform. Final result of combination of other properties. - #[inspect(skip)] #[reflect(hidden)] matrix: Cell>, - #[inspect(skip)] #[reflect(hidden)] post_rotation_matrix: Matrix3, } diff --git a/src/script/mod.rs b/src/script/mod.rs index 5f16bad65..9f5240c69 100644 --- a/src/script/mod.rs +++ b/src/script/mod.rs @@ -4,7 +4,6 @@ use crate::{ core::{ - inspect::{Inspect, PropertyInfo}, pool::Handle, reflect::{Reflect, ReflectArray, ReflectList}, uuid::Uuid, @@ -26,7 +25,7 @@ use std::{ pub mod constructor; /// Base script trait is used to automatically implement some trait to reduce amount of boilerplate code. -pub trait BaseScript: Visit + Inspect + Reflect + Send + Debug + 'static { +pub trait BaseScript: Visit + Reflect + Send + Debug + 'static { /// Creates exact copy of the script. fn clone_box(&self) -> Box; } @@ -161,14 +160,13 @@ pub trait ScriptTrait: BaseScript + ComponentProvider { /// use fyrox::{ /// scene::node::TypeUuidProvider, /// core::visitor::prelude::*, - /// core::inspect::{Inspect, PropertyInfo}, /// core::reflect::prelude::*, /// core::uuid::Uuid, /// script::ScriptTrait, /// core::uuid::uuid, impl_component_provider /// }; /// - /// #[derive(Inspect, Reflect, Visit, Debug, Clone)] + /// #[derive(Reflect, Visit, Debug, Clone)] /// struct MyScript { } /// /// // Implement TypeUuidProvider trait that will return type uuid of the type. @@ -201,6 +199,10 @@ pub struct Script { } impl Reflect for Script { + fn fields_info(&self) -> Vec { + self.instance.fields_info() + } + fn into_any(self: Box) -> Box { self.instance.into_any() } @@ -225,6 +227,14 @@ impl Reflect for Script { self.instance.deref_mut().set(value) } + fn fields(&self) -> Vec<&dyn Reflect> { + self.instance.deref().fields() + } + + fn fields_mut(&mut self) -> Vec<&mut dyn Reflect> { + self.instance.deref_mut().fields_mut() + } + fn field(&self, name: &str) -> Option<&dyn Reflect> { self.instance.deref().field(name) } @@ -248,18 +258,6 @@ impl Reflect for Script { fn as_list_mut(&mut self) -> Option<&mut dyn ReflectList> { self.instance.deref_mut().as_list_mut() } - - fn fields(&self) -> Vec<&dyn Reflect> { - self.instance.deref().fields() - } - - fn fields_mut(&mut self) -> Vec<&mut dyn Reflect> { - self.instance.deref_mut().fields_mut() - } - - fn fields_info(&self) -> Vec { - self.instance.fields_info() - } } impl Deref for Script { @@ -276,12 +274,6 @@ impl DerefMut for Script { } } -impl Inspect for Script { - fn properties(&self) -> Vec> { - self.instance.properties() - } -} - impl Visit for Script { fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult { let mut region_guard = visitor.enter_region(name)?; @@ -366,7 +358,7 @@ impl Script { mod test { use crate::{ core::{ - inspect::prelude::*, reflect::prelude::*, uuid::Uuid, variable::try_inherit_properties, + reflect::prelude::*, uuid::Uuid, variable::try_inherit_properties, variable::InheritableVariable, visitor::prelude::*, }, impl_component_provider, @@ -374,7 +366,7 @@ mod test { script::{Script, ScriptTrait}, }; - #[derive(Reflect, Inspect, Visit, Debug, Clone, Default)] + #[derive(Reflect, Visit, Debug, Clone, Default)] struct MyScript { field: InheritableVariable, } diff --git a/template/src/main.rs b/template/src/main.rs index ff98f51de..00c8c62ae 100644 --- a/template/src/main.rs +++ b/template/src/main.rs @@ -320,7 +320,7 @@ use fyrox::{{ script::{{ScriptContext, ScriptDeinitContext, ScriptTrait}}, }}; -#[derive(Visit, Reflect, Inspect, Default, Debug, Clone)] +#[derive(Visit, Reflect, Default, Debug, Clone)] pub struct {name} {{ // Add fields here. }}