remove Inspect trait

This commit is contained in:
Dmitry
2022-11-01 21:38:13 +03:00
parent a62b3f0474
commit 8da3ea33a7
96 changed files with 423 additions and 1776 deletions
+1 -1
View File
@@ -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.
+5 -5
View File
@@ -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,
})
}
+2 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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
}
+2 -2
View File
@@ -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
}
@@ -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
}
+11 -11
View File
@@ -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::<fyrox::gui::inspector::Inspector>()
@@ -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<SerializationContext>,
@@ -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,
};
+2 -3
View File
@@ -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<PathBuf, SceneCameraSettings>,
}
+2 -5
View File
@@ -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,
+2 -8
View File
@@ -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,
+2 -8
View File
@@ -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<UiNode>,
}
#[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,
}
+3 -7
View File
@@ -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."
)]
+2 -5
View File
@@ -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,
+4 -7
View File
@@ -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,
}
+2 -5
View File
@@ -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,
+2 -3
View File
@@ -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,
}
+1 -1
View File
@@ -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,
+1 -3
View File
@@ -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<Node>,
follow_target: bool,
target: Vector3<f32>,
#[inspect(skip)]
#[reflect(hidden)]
machine: Option<BotAnimationMachine>,
}
+2 -4
View File
@@ -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<Node>,
#[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,
-73
View File
@@ -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)
}
-121
View File
@@ -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<VariantArgs, FieldArgs>;
pub type Fields = ast::Fields<FieldArgs>;
#[derive(FromDeriveInput)]
#[darling(attributes(inspect), supports(struct_any, enum_any))]
pub struct TypeArgs {
pub ident: Ident,
pub generics: Generics,
pub data: ast::Data<VariantArgs, FieldArgs>,
}
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<Ident>,
pub ty: Type,
/// `#[inspect(skip)]`
///
/// Do not expose property info
#[darling(default)]
pub skip: bool,
/// #[inspect(display_name = "<name>")]
///
/// A human-readable name.
#[darling(default)]
pub display_name: Option<String>,
/// `#[inspect(getter = "<expr>")]`
///
/// Method call syntax for converting the field reference to another reference
#[darling(default)]
pub getter: Option<Expr>,
/// `#[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<f64>,
/// `#[inspect(max_value = "1.0")]`
///
/// Maximal value of the field. Works only for numeric fields!
#[darling(default)]
pub max_value: Option<f64>,
/// `#[inspect(step = "0.1")]`
///
/// Increment/decrement step of the field. Works only for numeric fields!
#[darling(default)]
pub step: Option<f64>,
/// `#[inspect(precision = "3")]`
///
/// Maximum amount of decimal places for a numeric property.
#[darling(default)]
pub precision: Option<usize>,
/// `#[inspect(description = "This is a property description.")]`
///
/// Description of the property.
#[darling(default)]
pub description: Option<String>,
}
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<FieldArgs>,
}
-262
View File
@@ -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<args::VariantArgs>,
}
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<index>"
// }
// ```
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<Item = &'f args::FieldArgs>,
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<Item = &'f args::FieldArgs>,
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<PropertyInfo<'_>> {
#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<Item = &'a args::FieldArgs>,
) -> Generics {
generics.clone()
}
pub fn gen_inspect_fn_body(
field_prefix: FieldPrefix,
field_args: &ast::Fields<args::FieldArgs>,
) -> 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::<Self>(),
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(),
}
}
}
-19
View File
@@ -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 {
+1 -1
View File
@@ -66,7 +66,7 @@ pub fn gen_fields_metadata_body(
}
}
/// `PropertyInfo { .. }`
/// `FieldInfo { .. }`
fn quote_field_prop(
prop_key_name: &str,
nth_field: usize,
+7 -7
View File
@@ -152,43 +152,43 @@ pub struct FieldArgs {
#[darling(default)]
pub setter: Option<Path>,
/// #[inspect(display_name = "<name>")]
/// #[reflect(display_name = "<name>")]
///
/// A human-readable name.
#[darling(default)]
pub display_name: Option<String>,
/// `#[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<f64>,
/// `#[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<f64>,
/// `#[inspect(step = "0.1")]`
/// `#[reflect(step = "0.1")]`
///
/// Increment/decrement step of the field. Works only for numeric fields!
#[darling(default)]
pub step: Option<f64>,
/// `#[inspect(precision = "3")]`
/// `#[reflect(precision = "3")]`
///
/// Maximum amount of decimal places for a numeric property.
#[darling(default)]
pub precision: Option<usize>,
/// `#[inspect(description = "This is a property description.")]`
/// `#[reflect(description = "This is a property description.")]`
///
/// Description of the property.
#[darling(default)]
-306
View File
@@ -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::<Data>(),
name: "the_field",
display_name: "The Field",
value: &data.the_field,
..default_prop()
},
PropertyInfo {
owner_type_id: TypeId::of::<Data>(),
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::<Data>(),
name: "x",
display_name: "Super X",
value: &data.x,
..default_prop()
},
PropertyInfo {
owner_type_id: TypeId::of::<Data>(),
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::<Tuple>(),
name: "0",
display_name: "0",
value: &x.0,
..default_prop()
},
PropertyInfo {
owner_type_id: TypeId::of::<Tuple>(),
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::<Data>(),
name: "Named@x",
display_name: "X",
value: match data {
Data::Named { ref x, .. } => x,
_ => unreachable!(),
},
..default_prop()
},
PropertyInfo {
owner_type_id: TypeId::of::<Data>(),
name: "Named@y",
display_name: "Y",
value: match data {
Data::Named { ref y, .. } => y,
_ => unreachable!(),
},
..default_prop()
},
PropertyInfo {
owner_type_id: TypeId::of::<Data>(),
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::<Data>(),
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::<Data>(),
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>(T);
impl<T> Deref for D<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[derive(Inspect, Reflect)]
struct A(
#[inspect(getter = "deref()")] D<u32>,
#[inspect(deref)] D<u32>,
);
let a = A(D(10), D(11));
assert_eq!(
a.properties(),
vec![
PropertyInfo {
owner_type_id: TypeId::of::<A>(),
name: "0",
display_name: "0",
value: &*a.0,
..default_prop()
},
PropertyInfo {
owner_type_id: TypeId::of::<A>(),
name: "1",
display_name: "1",
value: &*a.1,
..default_prop()
}
]
);
}
-1
View File
@@ -5,6 +5,5 @@
// #![feature(trace_macros)]
// trace_macros!(true);
pub mod inspect;
pub mod reflect;
pub mod visit;
-243
View File
@@ -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<T: 'static> 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<f64>,
/// A minimal value of the property. Works only with numeric properties!
pub max_value: Option<f64>,
/// A minimal value of the property. Works only with numeric properties!
pub step: Option<f64>,
/// Maximum amount of decimal places for a numeric property.
pub precision: Option<usize>,
/// Description of the property.
pub description: String,
}
impl<'a> PartialEq<Self> 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<T: 'static>(&self) -> Result<&T, CastError> {
match self.value.as_any().downcast_ref::<T>() {
Some(value) => Ok(value),
None => Err(CastError::TypeMismatch {
property_name: self.name.to_string(),
expected_type_id: TypeId::of::<T>(),
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<PropertyInfo<'_>>;
}
impl_inspect! {
pub enum Option<T: Inspect + Debug + 'static> {
Some(T),
None
}
}
impl_inspect! {
pub struct Box<T: Inspect + Debug + 'static>;
}
macro_rules! impl_numeric_inspect {
($ty:ty, $min:expr, $max:expr, $step:expr, $precision:expr) => {
impl Inspect for $ty {
fn properties(&self) -> Vec<PropertyInfo<'_>> {
vec![PropertyInfo {
owner_type_id: TypeId::of::<Self>(),
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<PropertyInfo<'_>> {
vec![PropertyInfo {
owner_type_id: TypeId::of::<Self>(),
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<f32>);
impl_simple_inspect!(Vector3<f32>);
impl_simple_inspect!(Vector4<f32>);
impl_simple_inspect!(UnitQuaternion<f32>);
use crate::reflect::FieldInfo;
pub use fyrox_core_derive::Inspect;
-1
View File
@@ -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;
+1 -2
View File
@@ -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<P: PositionProvider>(
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,
+5 -36
View File
@@ -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<T: PartialEq> PartialEq for Pool<T> {
#[derive(Reflect)]
pub struct Handle<T> {
/// 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<T>,
}
impl<T: 'static> Inspect for Handle<T> {
fn properties(&self) -> Vec<PropertyInfo<'_>> {
vec![
PropertyInfo {
owner_type_id: TypeId::of::<Self>(),
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::<Self>(),
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<T> Send for Handle<T> {}
unsafe impl<T> Sync for Handle<T> {}
@@ -166,14 +135,14 @@ impl<T> Display for Handle<T> {
}
/// 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,
}
+32 -2
View File
@@ -77,7 +77,38 @@ pub struct FieldInfo<'a> {
pub precision: Option<usize>,
}
impl<'a> PartialEq<Self> for PropertyInfo<'a> {
impl<'a> FieldInfo<'a> {
/// Tries to cast a value to a given type.
pub fn cast_value<T: 'static>(&self) -> Result<&T, CastError> {
match self.value.as_any().downcast_ref::<T>() {
Some(value) => Ok(value),
None => Err(CastError::TypeMismatch {
property_name: self.name.to_string(),
expected_type_id: TypeId::of::<T>(),
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<Self> 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;
-10
View File
@@ -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<T> Inspect for InheritableVariable<T>
where
T: Inspect,
{
fn properties(&self) -> Vec<PropertyInfo<'_>> {
self.value.properties()
}
}
impl<T> Reflect for InheritableVariable<T>
where
T: Reflect + Clone + PartialEq + Debug,
+1 -12
View File
@@ -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 {
+3 -4
View File
@@ -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: <https://ccrma.stanford.edu/~jos/filters/BiQuad_Section.html>
#[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,
}
+1 -3
View File
@@ -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<hrtf::HrtfProcessor>,
}
-12
View File
@@ -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<PropertyInfo<'_>> {
match self {
Renderer::Default => {
vec![]
}
Renderer::HrtfRenderer(v) => v.properties(),
}
}
}
impl Default for Renderer {
fn default() -> Self {
Self::Default
+20 -21
View File
@@ -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<f32>,
#[inspect(skip)]
#[reflect(hidden)]
#[visit(skip)]
pub(crate) last_right_gain: Option<f32>,
#[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<f32>,
#[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<f32>,
#[inspect(skip)]
#[reflect(hidden)]
#[visit(skip)]
pub(crate) prev_right_samples: Vec<f32>,
#[inspect(skip)]
#[reflect(hidden)]
#[visit(skip)]
pub(crate) prev_sampling_vector: Vector3<f32>,
#[inspect(skip)]
#[reflect(hidden)]
#[visit(skip)]
pub(crate) prev_distance_gain: Option<f32>,
}
+8 -8
View File
@@ -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<Item = &'a T>,
{
widget_builder: WidgetBuilder,
@@ -106,7 +106,7 @@ fn create_items<'a, T, I>(
layer_index: usize,
) -> Vec<Item>
where
T: Inspect + 'static,
T: Reflect + 'static,
I: IntoIterator<Item = &'a T>,
{
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<Item = &'a T>,
{
pub fn new(widget_builder: WidgetBuilder) -> Self {
@@ -206,14 +206,14 @@ where
#[derive(Debug)]
pub struct ArrayPropertyEditorDefinition<T, const N: usize>
where
T: Inspect + Debug + 'static,
T: Reflect + Debug + 'static,
{
phantom: PhantomData<T>,
}
impl<T, const N: usize> ArrayPropertyEditorDefinition<T, N>
where
T: Inspect + Debug + 'static,
T: Reflect + Debug + 'static,
{
pub fn new() -> Self {
Self::default()
@@ -222,7 +222,7 @@ where
impl<T, const N: usize> Default for ArrayPropertyEditorDefinition<T, N>
where
T: Inspect + Debug + 'static,
T: Reflect + Debug + 'static,
{
fn default() -> Self {
Self {
@@ -233,7 +233,7 @@ where
impl<T, const N: usize> PropertyEditorDefinition for ArrayPropertyEditorDefinition<T, N>
where
T: Inspect + Debug + 'static,
T: Reflect + Debug + 'static,
{
fn value_type_id(&self) -> TypeId {
TypeId::of::<[T; N]>()
+3 -3
View File
@@ -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<UiNode>,
}
pub trait CollectionItem: Inspect + Clone + Reflect + Debug + Default + 'static {}
pub trait CollectionItem: Clone + Reflect + Debug + Default + 'static {}
impl<T: Inspect + Clone + Reflect + Debug + Default + 'static> CollectionItem for T {}
impl<T: Clone + Reflect + Debug + Default + 'static> CollectionItem for T {}
#[derive(Debug)]
pub struct CollectionEditor<T: CollectionItem> {
@@ -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<T: Debug + Inspect + Reflect + Clone + 'static> InspectableEnum for T {}
impl<T: Debug + Reflect + Clone + 'static> InspectableEnum for T {}
#[derive(Debug, Clone, PartialEq)]
pub enum EnumPropertyEditorMessage {
+9 -14
View File
@@ -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<T>
where
T: PropertyValue,
T: FieldValue,
{
phantom: PhantomData<T>,
}
impl<T> InheritablePropertyEditorDefinition<T>
where
T: PropertyValue,
T: FieldValue,
{
pub fn new() -> Self {
Self {
@@ -183,23 +180,21 @@ where
impl<T> Debug for InheritablePropertyEditorDefinition<T>
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<PropertyInfo<'a>, InspectorError>
fn make_proxy<'a, 'b, T>(property_info: &'b FieldInfo<'a>) -> Result<FieldInfo<'a>, InspectorError>
where
T: PropertyValue,
T: FieldValue,
'b: 'a,
{
let value = property_info.cast_value::<InheritableVariable<T>>()?;
Ok(PropertyInfo {
Ok(FieldInfo {
owner_type_id: TypeId::of::<T>(),
name: property_info.name,
display_name: property_info.display_name,
@@ -215,7 +210,7 @@ where
impl<T> PropertyEditorDefinition for InheritablePropertyEditorDefinition<T>
where
T: PropertyValue,
T: FieldValue,
{
fn value_type_id(&self) -> TypeId {
TypeId::of::<InheritableVariable<T>>()
@@ -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<T>
where
T: Inspect + 'static,
T: Reflect + 'static,
{
phantom: PhantomData<T>,
}
impl<T> InspectablePropertyEditorDefinition<T>
where
T: Inspect + 'static,
T: Reflect + 'static,
{
pub fn new() -> Self {
Self {
@@ -38,7 +38,7 @@ where
impl<T> Debug for InspectablePropertyEditorDefinition<T>
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<T> PropertyEditorDefinition for InspectablePropertyEditorDefinition<T>
where
T: Inspect + 'static,
T: Reflect + 'static,
{
fn value_type_id(&self) -> TypeId {
TypeId::of::<T>()
+7 -7
View File
@@ -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<Rc<dyn InspectorEnvironment>>,
pub definition_container: Rc<PropertyEditorDefinitionContainer>,
pub sync_flag: u64,
@@ -69,7 +69,7 @@ pub struct PropertyEditorMessageContext<'a, 'b> {
pub sync_flag: u64,
pub instance: Handle<UiNode>,
pub ui: &'b mut UserInterface,
pub property_info: &'a PropertyInfo<'a>,
pub property_info: &'a FieldInfo<'a>,
pub definition_container: Rc<PropertyEditorDefinitionContainer>,
pub layer_index: usize,
pub environment: Option<Rc<dyn InspectorEnvironment>>,
@@ -235,7 +235,7 @@ impl PropertyEditorDefinitionContainer {
pub fn register_inheritable_vec_collection<T>(&self)
where
T: CollectionItem + PropertyValue,
T: CollectionItem + FieldValue,
{
assert!(self
.insert(VecCollectionPropertyEditorDefinition::<T>::new())
@@ -247,7 +247,7 @@ impl PropertyEditorDefinitionContainer {
pub fn register_inheritable_inspectable<T>(&self)
where
T: Inspect + PropertyValue,
T: Reflect + FieldValue,
{
assert!(self
.insert(InspectablePropertyEditorDefinition::<T>::new())
@@ -259,7 +259,7 @@ impl PropertyEditorDefinitionContainer {
pub fn register_inheritable_enum<T, E: Debug>(&self)
where
T: InspectableEnum + PropertyValue + VariantNames + AsRef<str> + FromStr<Err = E> + Debug,
T: InspectableEnum + FieldValue + VariantNames + AsRef<str> + FromStr<Err = E> + Debug,
{
assert!(self
.insert(EnumPropertyEditorDefinition::<T>::new())
@@ -271,7 +271,7 @@ impl PropertyEditorDefinitionContainer {
pub fn register_inheritable_option<T>(&self)
where
T: InspectableEnum + PropertyValue + Default,
T: InspectableEnum + FieldValue + Default,
{
assert!(self
.insert(EnumPropertyEditorDefinition::<T>::new_optional())
+5 -9
View File
@@ -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<PropertyEditorDefinitionContainer>,
environment: Option<Rc<dyn InspectorEnvironment>>,
@@ -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<InspectorError>> {
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()
+6 -7
View File
@@ -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<PoseNode>,
}
#[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<PoseNodeDefinition>,
}
@@ -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<BlendPoseDefinition>,
@@ -172,10 +171,10 @@ pub struct IndexedBlendInput {
pub pose_source: Handle<PoseNode>,
}
#[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<PoseNodeDefinition>,
}
@@ -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,
+3 -4
View File
@@ -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<f32>,
#[inspect(skip)]
#[reflect(hidden)]
pub parent_state: Handle<StateDefinition>,
}
#[derive(Debug, Visit, Clone, Inspect, Reflect)]
#[derive(Debug, Visit, Clone, Reflect)]
pub enum PoseNodeDefinition {
PlayAnimation(PlayAnimationDefinition),
BlendAnimations(BlendAnimationsDefinition),
+2 -3
View File
@@ -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<f32>);
#[derive(Debug, Visit, Clone, Inspect, Reflect)]
#[derive(Debug, Visit, Clone, Reflect)]
pub struct PlayAnimationDefinition {
pub base: BasePoseNodeDefinition,
pub animation: String,
+5 -9
View File
@@ -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<String, Parameter>;
#[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<ParameterDefinition>,
}
+2 -3
View File
@@ -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<PoseNode>,
}
#[derive(Default, Debug, Visit, Clone, Inspect, Reflect)]
#[derive(Default, Debug, Visit, Clone, Reflect)]
pub struct StateDefinition {
pub position: Vector2<f32>,
pub name: String,
#[inspect(skip)]
#[reflect(hidden)]
pub root: Handle<PoseNodeDefinition>,
}
+8 -13
View File
@@ -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<StateDefinition>,
#[inspect(skip)]
#[reflect(hidden)]
pub dest: Handle<StateDefinition>,
/// 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)."
+5 -18
View File
@@ -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<u32>,
frames: Vec<Vector2<u32>>,
@@ -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<Texture>,
#[reflect(hidden)]
#[inspect(skip)]
#[visit(skip)]
events: VecDeque<Event>,
}
+2 -2
View File
@@ -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.
+3 -7
View File
@@ -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<Node>),
}
#[derive(Debug, Clone, Reflect, Inspect, Visit)]
#[derive(Debug, Clone, Reflect, Visit)]
struct MyScript {
#[reflect(hidden)]
#[inspect(skip)]
#[visit(skip)]
sender: Sender<Event>,
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<Event>,
}
+2 -5
View File
@@ -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,
+1 -2
View File
@@ -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<Mutex<Material>>);
impl Default for SharedMaterial {
+2 -4
View File
@@ -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<RenderPassStatistics> 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.
+1 -3
View File
@@ -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)]
+1 -6
View File
@@ -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,
+12 -24
View File
@@ -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<Node>);
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<LevelOfDetail>,
@@ -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<Node>,
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) script_message_sender: Option<Sender<ScriptMessage>>,
@@ -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<Option<f32>>,
#[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<f32>,
@@ -359,50 +353,44 @@ pub struct Base {
#[reflect(setter = "set_frustum_culling")]
frustum_culling: InheritableVariable<bool>,
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) transform_modified: Cell<bool>,
// 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<bool>,
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) parent: Handle<Node>,
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) children: Vec<Handle<Node>>,
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) global_transform: Cell<Matrix4<f32>>,
// Bone-specific matrix. Non-serializable.
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) inv_bind_pose_transform: Matrix4<f32>,
// 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<Model>,
// 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<Node>,
#[inspect(read_only)]
#[reflect(read_only)]
#[reflect(hidden)]
pub(crate) instance_id: InstanceId,
+17 -27
View File
@@ -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<bool>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
view_matrix: Matrix4<f32>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
projection_matrix: Matrix4<f32>,
/// 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<Texture>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
lut: Option<Texture>,
}
@@ -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<Texture>,
/// Cubemap texture
#[inspect(skip)]
#[visit(skip)]
#[reflect(hidden)]
#[visit(skip)]
pub(crate) cubemap: Option<Texture>,
}
+22 -34
View File
@@ -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<f32>,
/// End point of the capsule.
pub end: Vector3<f32>,
/// 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<f32>,
@@ -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<f32>,
@@ -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<Node>);
/// 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<GeometrySource>,
}
/// 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<PropertyInfo<'_>> {
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<geometry::InteractionGroups> 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<ColliderShape>,
#[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<f32>,
#[reflect(setter = "set_density")]
pub(crate) density: InheritableVariable<Option<f32>>,
#[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<f32>,
#[reflect(setter = "set_is_sensor")]
@@ -488,7 +477,6 @@ pub struct Collider {
pub(crate) restitution_combine_rule: InheritableVariable<CoefficientCombineRule>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) native: Cell<ColliderHandle>,
}
+2 -3
View File
@@ -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<Color>,
#[inspect(min_value = 0.0)]
#[reflect(min_value = 0.0)]
#[reflect(setter = "set_layer")]
layer: InheritableVariable<u8>,
}
+14 -20
View File
@@ -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<f32>,
/// End point of the capsule.
pub end: Vector2<f32>,
/// 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<f32>,
@@ -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<f32>,
@@ -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<Node>);
/// 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<GeometrySource>,
}
/// 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<ColliderShape>,
#[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<f32>,
#[reflect(setter = "set_density")]
pub(crate) density: InheritableVariable<Option<f32>>,
#[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<f32>,
#[reflect(setter = "set_is_sensor")]
@@ -264,7 +259,6 @@ pub struct Collider {
pub(crate) restitution_combine_rule: InheritableVariable<CoefficientCombineRule>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) native: Cell<ColliderHandle>,
}
+9 -14
View File
@@ -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<f32>,
}
@@ -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<f32>,
}
@@ -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<bool>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) native: Cell<ImpulseJointHandle>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) need_rebind: Cell<bool>,
}
+1 -15
View File
@@ -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<f32>) -> Matrix4<f32> {
/// 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<RigidBodySet, RigidBodyHandle>,
// A container of colliders.
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
colliders: Container<ColliderSet, ColliderHandle>,
// A container of impulse joints.
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
joints: Container<ImpulseJointSet, ImpulseJointHandle>,
// A container of multibody joints.
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
multibody_joints: Container<MultibodyJointSet, MultibodyJointHandle>,
// Event handler collects info about contacts and proximity events.
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
event_handler: Box<dyn EventHandler>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
query: RefCell<QueryPipeline>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
debug_render_pipeline: Mutex<DebugRenderPipeline>,
}
+1 -2
View File
@@ -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,
+2 -6
View File
@@ -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<RigidBodyType>,
#[inspect(min_value = 0.0, step = 0.05)]
#[reflect(min_value = 0.0, step = 0.05)]
#[reflect(setter = "set_mass")]
pub(crate) mass: InheritableVariable<f32>,
@@ -103,17 +102,14 @@ pub struct RigidBody {
pub(crate) gravity_scale: InheritableVariable<f32>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) sleeping: bool,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) native: Cell<RigidBodyHandle>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) actions: Mutex<VecDeque<ApplyAction>>,
}
+1 -10
View File
@@ -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<Node, NodeContainer>;
/// See module docs.
#[derive(Debug, Inspect, Reflect)]
#[derive(Debug, Reflect)]
pub struct Graph {
#[inspect(skip)]
#[reflect(hidden)]
root: Handle<Node>,
#[inspect(skip)]
#[reflect(hidden)]
pool: NodePool,
#[inspect(skip)]
#[reflect(hidden)]
stack: Vec<Handle<Node>>,
@@ -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<ScriptMessage>,
#[reflect(hidden)]
#[inspect(skip)]
pub(crate) script_message_receiver: Receiver<ScriptMessage>,
}
+18 -42
View File
@@ -8,7 +8,6 @@ use crate::{
Vector2, Vector3,
},
arrayvec::ArrayVec,
inspect::{Inspect, PropertyInfo},
instant,
math::Matrix4Ext,
pool::Handle,
@@ -103,17 +102,7 @@ impl From<rapier2d::geometry::FeatureId> 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<f32>,
@@ -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<RigidBodySet, RigidBodyHandle>,
// A container of colliders.
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
colliders: Container<ColliderSet, ColliderHandle>,
// A container of impulse joints.
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
joints: Container<ImpulseJointSet, ImpulseJointHandle>,
// A container of multibody joints.
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
multibody_joints: Container<MultibodyJointSet, MultibodyJointHandle>,
// Event handler collects info about contacts and proximity events.
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
event_handler: Box<dyn EventHandler>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
query: RefCell<QueryPipeline>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
debug_render_pipeline: Mutex<DebugRenderPipeline>,
}
+16 -21
View File
@@ -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<f32>,
/// 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<f32>,
/// 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<f32>,
}
@@ -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<f32>,
}
@@ -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<bool>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) native: Cell<ImpulseJointHandle>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) need_rebind: Cell<bool>,
}
+4 -7
View File
@@ -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`].
+2 -3
View File
@@ -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<bool>,
#[inspect(min_value = 0.0, step = 0.1)]
#[reflect(min_value = 0.0, step = 0.1)]
#[reflect(setter = "set_intensity")]
intensity: InheritableVariable<f32>,
}
+3 -4
View File
@@ -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<f32>,
#[inspect(min_value = 0.0, step = 0.1)]
#[reflect(min_value = 0.0, step = 0.1)]
#[reflect(setter = "set_radius")]
radius: InheritableVariable<f32>,
}
+5 -6
View File
@@ -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<f32>,
#[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<f32>,
#[inspect(min_value = 0.0, step = 0.001)]
#[reflect(min_value = 0.0, step = 0.001)]
#[reflect(setter = "set_shadow_bias")]
shadow_bias: InheritableVariable<f32>,
#[inspect(min_value = 0.0, step = 0.1)]
#[reflect(min_value = 0.0, step = 0.1)]
#[reflect(setter = "set_distance")]
distance: InheritableVariable<f32>,
+4 -9
View File
@@ -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<u8>,
#[inspect(skip)]
#[visit(skip)]
#[reflect(hidden)]
#[visit(skip)]
local_bounding_box: Cell<AxisAlignedBoundingBox>,
#[inspect(skip)]
#[visit(skip)]
#[reflect(hidden)]
#[visit(skip)]
local_bounding_box_dirty: Cell<bool>,
#[inspect(skip)]
#[visit(skip)]
#[reflect(hidden)]
#[visit(skip)]
world_bounding_box: Cell<AxisAlignedBoundingBox>,
}
+2 -4
View File
@@ -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<Mutex<SurfaceData>>);
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<SurfaceSharedData>,
@@ -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<VertexWeightSet>,
}
+1 -9
View File
@@ -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<Handle<Navmesh>> 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<Texture>,
/// 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<Lightmap>,
/// 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,
}
+2 -9
View File
@@ -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<Node>`. 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<Node>);
@@ -433,9 +432,3 @@ impl Visit for Node {
self.0.visit(name, visitor)
}
}
impl Inspect for Node {
fn properties(&self) -> Vec<PropertyInfo<'_>> {
self.0.properties()
}
}
+3 -10
View File
@@ -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<f32>,
@@ -42,18 +38,15 @@ pub struct BaseEmitter {
rotation_speed: Range<f32>,
/// Range of initial rotation for a particle
rotation: Range<f32>,
#[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,
}
+5 -10
View File
@@ -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,
}
@@ -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,
}
+2 -3
View File
@@ -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),
+3 -8
View File
@@ -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,
}
+3 -6
View File
@@ -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<bool>,
#[inspect(skip)]
#[reflect(hidden)]
particles: Vec<Particle>,
#[inspect(skip)]
#[reflect(hidden)]
free_particles: Vec<u32>,
}
+1 -2
View File
@@ -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,
}
+3 -18
View File
@@ -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<RigidBodyType>,
#[inspect(min_value = 0.0, step = 0.05)]
#[reflect(min_value = 0.0, step = 0.05)]
#[reflect(setter = "set_mass")]
pub(crate) mass: InheritableVariable<f32>,
@@ -185,15 +173,12 @@ pub struct RigidBody {
pub(crate) gravity_scale: InheritableVariable<f32>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) sleeping: bool,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) native: Cell<RigidBodyHandle>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) actions: Mutex<VecDeque<ApplyAction>>,
}
+2 -5
View File
@@ -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<Effect>,
#[inspect(read_only)]
#[reflect(read_only)]
// A model resource from which this context was instantiated from.
pub(crate) resource: Option<Model>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) native: fyrox_sound::context::SoundContext,
}
+5 -10
View File
@@ -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<Node>,
@@ -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<String>,
@@ -43,7 +39,6 @@ pub struct BaseEffect {
pub(crate) inputs: InheritableVariable<Vec<EffectInput>>,
#[visit(skip)]
#[inspect(skip)]
#[reflect(hidden)]
pub(crate) native: Cell<Handle<fyrox_sound::effects::Effect>>,
}
@@ -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,
+1 -2
View File
@@ -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,
}
+8 -10
View File
@@ -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<bool>,
#[inspect(min_value = 0.0, step = 0.05)]
#[reflect(min_value = 0.0, step = 0.05)]
#[reflect(setter = "set_gain")]
gain: InheritableVariable<f32>,
#[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<f32>,
@@ -69,19 +68,19 @@ pub struct Sound {
#[reflect(setter = "set_looping")]
looping: InheritableVariable<bool>,
#[inspect(min_value = 0.0, step = 0.05)]
#[reflect(min_value = 0.0, step = 0.05)]
#[reflect(setter = "set_pitch")]
pitch: InheritableVariable<f64>,
#[inspect(min_value = 0.0, step = 0.05)]
#[reflect(min_value = 0.0, step = 0.05)]
#[reflect(setter = "set_radius")]
radius: InheritableVariable<f32>,
#[inspect(min_value = 0.0, step = 0.05)]
#[reflect(min_value = 0.0, step = 0.05)]
#[reflect(setter = "set_max_distance")]
max_distance: InheritableVariable<f32>,
#[inspect(min_value = 0.0, step = 0.05)]
#[reflect(min_value = 0.0, step = 0.05)]
#[reflect(setter = "set_rolloff_factor")]
rolloff_factor: InheritableVariable<f32>,
@@ -91,9 +90,8 @@ pub struct Sound {
#[reflect(setter = "set_spatial_blend")]
spatial_blend: InheritableVariable<f32>,
#[inspect(skip)]
#[visit(skip)]
#[reflect(hidden)]
#[visit(skip)]
pub(crate) native: Cell<Handle<SoundSource>>,
}
+2 -3
View File
@@ -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<Color>,
#[inspect(min_value = 0.0, step = 0.1)]
#[reflect(min_value = 0.0, step = 0.1)]
#[reflect(setter = "set_size")]
size: InheritableVariable<f32>,
+12 -17
View File
@@ -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<Texture>,
}
@@ -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<u8>,
#[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<Chunk>,
#[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<bool>,
#[inspect(skip)]
#[reflect(hidden)]
bounding_box: Cell<AxisAlignedBoundingBox>,
}
@@ -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<f32>,
/// Shape of the brush.
pub shape: BrushShape,
+10 -14
View File
@@ -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<bool>,
#[inspect(description = "Local scale of the transform")]
#[reflect(description = "Local scale of the transform")]
#[reflect(setter = "set_scale_internal")]
local_scale: InheritableVariable<Vector3<f32>>,
#[inspect(description = "Local position of the transform")]
#[reflect(description = "Local position of the transform")]
#[reflect(setter = "set_position_internal")]
local_position: InheritableVariable<Vector3<f32>>,
#[inspect(description = "Local rotation of the transform")]
#[reflect(description = "Local rotation of the transform")]
#[reflect(setter = "set_rotation_internal")]
local_rotation: InheritableVariable<UnitQuaternion<f32>>,
#[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<UnitQuaternion<f32>>,
#[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<UnitQuaternion<f32>>,
#[inspect(description = "Rotation offset of the transform.")]
#[reflect(description = "Rotation offset of the transform.")]
#[reflect(setter = "set_rotation_offset_internal")]
rotation_offset: InheritableVariable<Vector3<f32>>,
#[inspect(description = "Rotation pivot of the transform.")]
#[reflect(description = "Rotation pivot of the transform.")]
#[reflect(setter = "set_rotation_pivot_internal")]
rotation_pivot: InheritableVariable<Vector3<f32>>,
#[inspect(description = "Scale offset of the transform.")]
#[reflect(description = "Scale offset of the transform.")]
#[reflect(setter = "set_scaling_offset_internal")]
scaling_offset: InheritableVariable<Vector3<f32>>,
#[inspect(description = "Scale pivot of the transform.")]
#[reflect(description = "Scale pivot of the transform.")]
#[reflect(setter = "set_scaling_pivot_internal")]
scaling_pivot: InheritableVariable<Vector3<f32>>,
// Combined transform. Final result of combination of other properties.
#[inspect(skip)]
#[reflect(hidden)]
matrix: Cell<Matrix4<f32>>,
#[inspect(skip)]
#[reflect(hidden)]
post_rotation_matrix: Matrix3<f32>,
}
+16 -24
View File
@@ -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<dyn ScriptTrait>;
}
@@ -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<FieldInfo> {
self.instance.fields_info()
}
fn into_any(self: Box<Self>) -> Box<dyn Any> {
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<FieldInfo> {
self.instance.fields_info()
}
}
impl Deref for Script {
@@ -276,12 +274,6 @@ impl DerefMut for Script {
}
}
impl Inspect for Script {
fn properties(&self) -> Vec<PropertyInfo<'_>> {
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<f32>,
}
+1 -1
View File
@@ -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.
}}