mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-11 22:50:08 +00:00
merged TypeUuidProvider trait into Reflect
This commit is contained in:
@@ -146,7 +146,11 @@ use winit::{
|
||||
/// Serialization context holds runtime type information that allows to create unknown types using
|
||||
/// their UUIDs and a respective constructors.
|
||||
#[derive(Reflect)]
|
||||
#[reflect(hide_all, non_cloneable)] // TODO
|
||||
#[reflect(
|
||||
hide_all,
|
||||
non_cloneable,
|
||||
type_uuid = "1973a8c9-6ac6-48a2-bca1-9b4f3cce0774"
|
||||
)] // TODO
|
||||
pub struct SerializationContext {
|
||||
/// A node constructor container.
|
||||
pub node_constructors: NodeConstructorContainer,
|
||||
@@ -2865,10 +2869,7 @@ mod test {
|
||||
use crate::scene::pivot::Pivot;
|
||||
use crate::{
|
||||
asset::manager::ResourceManager,
|
||||
core::{
|
||||
pool::Handle, reflect::prelude::*, task::TaskPool, type_traits::prelude::*,
|
||||
visitor::prelude::*,
|
||||
},
|
||||
core::{pool::Handle, reflect::prelude::*, task::TaskPool, visitor::prelude::*},
|
||||
engine::{task::TaskPoolHandler, GraphicsContext, ScriptProcessor},
|
||||
graph::SceneGraph,
|
||||
scene::{base::BaseBuilder, node::Node, pivot::PivotBuilder, Scene, SceneContainer},
|
||||
@@ -2924,8 +2925,8 @@ mod test {
|
||||
EventReceived(Source),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "2569de84-d4b2-427d-969b-d5c7b31a0ba6")]
|
||||
#[derive(Debug, Clone, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "2569de84-d4b2-427d-969b-d5c7b31a0ba6")]
|
||||
struct MyScript {
|
||||
#[reflect(hidden)]
|
||||
#[visit(skip)]
|
||||
@@ -2991,8 +2992,8 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "1cebacd9-b500-4753-93be-39db344add21")]
|
||||
#[derive(Debug, Clone, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "1cebacd9-b500-4753-93be-39db344add21")]
|
||||
struct MySubScript {
|
||||
#[reflect(hidden)]
|
||||
#[visit(skip)]
|
||||
@@ -3150,8 +3151,8 @@ mod test {
|
||||
Bar(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "bf2976ad-f41d-4de6-9a32-b1a293956058")]
|
||||
#[derive(Debug, Clone, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "bf2976ad-f41d-4de6-9a32-b1a293956058")]
|
||||
struct ScriptListeningToMessages {
|
||||
index: u32,
|
||||
#[reflect(hidden)]
|
||||
@@ -3201,8 +3202,8 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "6bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
#[derive(Debug, Clone, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "6bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
struct ScriptSendingMessages {
|
||||
index: u32,
|
||||
}
|
||||
@@ -3290,8 +3291,8 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "7bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "7bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
pub struct ScriptSpawningAsyncTasks {
|
||||
num: Option<u32>,
|
||||
}
|
||||
@@ -3313,8 +3314,8 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "8bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "8bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
pub struct ScriptWithoutAsyncTasks {}
|
||||
|
||||
impl ScriptTrait for ScriptWithoutAsyncTasks {}
|
||||
@@ -3390,8 +3391,8 @@ mod test {
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "9bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
#[derive(Clone, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "9bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
pub struct ScriptThatDeletesItself {
|
||||
#[reflect(hidden)]
|
||||
#[visit(skip)]
|
||||
@@ -3431,8 +3432,8 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "9bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
#[derive(Clone, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "9bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
pub struct ScriptThatAddsScripts {
|
||||
num: usize,
|
||||
#[reflect(hidden)]
|
||||
@@ -3480,8 +3481,8 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "9bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
#[derive(Clone, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "9bcbf9b4-9546-42d3-965a-de055ab85475")]
|
||||
pub struct SimpleScript {
|
||||
stuff: usize,
|
||||
#[reflect(hidden)]
|
||||
|
||||
@@ -104,7 +104,7 @@ impl TaskPoolHandler {
|
||||
/// # use std::{fs::File, io::Read};
|
||||
///
|
||||
/// #[derive(Visit, Reflect, Debug)]
|
||||
/// #[reflect(non_cloneable)]
|
||||
/// #[reflect(non_cloneable, type_uuid = "a7ba17c1-6104-4938-9ba7-ba479acf716a")]
|
||||
/// struct MyGame {
|
||||
/// data: Option<Vec<u8>>,
|
||||
/// }
|
||||
@@ -178,14 +178,13 @@ impl TaskPoolHandler {
|
||||
/// # resource::model::{Model, ModelResourceExtension},
|
||||
/// # script::{ScriptContext, ScriptTrait},
|
||||
/// # };
|
||||
/// # use fyrox_core::uuid_provider;
|
||||
/// #
|
||||
/// # use fyrox_impl::plugin::error::GameResult;
|
||||
/// #
|
||||
/// #[derive(Reflect, Visit, Default, Debug, Clone)]
|
||||
/// #[reflect(type_uuid = "f5ded79e-6101-4e23-b20d-48cbdb25d87a")]
|
||||
/// struct MyScript;
|
||||
///
|
||||
/// # uuid_provider!(MyScript = "f5ded79e-6101-4e23-b20d-48cbdb25d87a");
|
||||
///
|
||||
/// impl ScriptTrait for MyScript {
|
||||
/// fn on_start(&mut self, ctx: &mut ScriptContext) -> GameResult {
|
||||
/// ctx.task_pool.spawn_script_task(
|
||||
|
||||
@@ -245,7 +245,7 @@ impl<'a, 'b> PluginContext<'a, 'b> {
|
||||
/// # use std::str::FromStr;
|
||||
///
|
||||
/// #[derive(Default, Visit, Reflect, Debug)]
|
||||
/// #[reflect(non_cloneable)]
|
||||
/// #[reflect(non_cloneable, type_uuid = "ce9c7ff9-f490-4274-89c9-0b53b9f80532")]
|
||||
/// struct MyGame {}
|
||||
///
|
||||
/// impl Plugin for MyGame {
|
||||
@@ -316,7 +316,7 @@ impl<'a, 'b> PluginContext<'a, 'b> {
|
||||
/// # use std::str::FromStr;
|
||||
/// #
|
||||
/// #[derive(Default, Visit, Reflect, Debug)]
|
||||
/// #[reflect(non_cloneable)]
|
||||
/// #[reflect(non_cloneable, type_uuid = "65b2da10-3926-48e4-93b4-01193cdc11ca")]
|
||||
/// struct MyGame {}
|
||||
///
|
||||
/// impl MyGame {
|
||||
@@ -494,7 +494,7 @@ impl dyn Plugin {
|
||||
/// # use std::str::FromStr;
|
||||
///
|
||||
/// #[derive(Default, Visit, Reflect, Debug)]
|
||||
/// #[reflect(non_cloneable)]
|
||||
/// #[reflect(non_cloneable, type_uuid = "342b2ef7-210d-465f-bcae-f59aa3a96420")]
|
||||
/// struct MyPlugin {}
|
||||
///
|
||||
/// impl Plugin for MyPlugin {
|
||||
@@ -536,7 +536,7 @@ impl dyn Plugin {
|
||||
/// # };
|
||||
/// # use std::str::FromStr;
|
||||
/// #[derive(Default, Visit, Reflect, Debug)]
|
||||
/// #[reflect(non_cloneable)]
|
||||
/// #[reflect(non_cloneable, type_uuid = "94801cca-3f50-4bef-9b6f-ee2edd9dcb2b")]
|
||||
/// struct MyPlugin {
|
||||
/// scene: Handle<Scene>,
|
||||
/// player: Handle<Node>,
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::core::{reflect::prelude::*, type_traits::prelude::*};
|
||||
use crate::core::reflect::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
|
||||
/// Bloom effect settings.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Reflect)]
|
||||
#[reflect(type_uuid = "6862fea7-10a9-4a8a-8701-c003415aa3b3")]
|
||||
pub struct BloomSettings {
|
||||
/// Whether to use bloom effect.
|
||||
pub use_bloom: bool,
|
||||
@@ -56,9 +57,8 @@ impl Default for BloomSettings {
|
||||
AsRefStr,
|
||||
EnumString,
|
||||
VariantNames,
|
||||
TypeUuidProvider,
|
||||
)]
|
||||
#[type_uuid(id = "b1994c1c-bc2f-497c-a05d-062a02b69ff1")]
|
||||
#[reflect(type_uuid = "b1994c1c-bc2f-497c-a05d-062a02b69ff1")]
|
||||
pub enum LuminanceCalculationMethod {
|
||||
/// Simplest and fastest luminance calculation method based on average of luminance of all
|
||||
/// pixels of the frame.
|
||||
@@ -71,6 +71,7 @@ pub enum LuminanceCalculationMethod {
|
||||
|
||||
/// Settings of high dynamic range rendering pipeline.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Reflect)]
|
||||
#[reflect(type_uuid = "15a2975b-0f2d-4839-ba20-951e4625ee75")]
|
||||
pub struct HdrSettings {
|
||||
/// Whether the HDR pipeline enabled or not.
|
||||
pub use_hdr: bool,
|
||||
@@ -96,6 +97,7 @@ impl Default for HdrSettings {
|
||||
/// Quality settings allows you to find optimal balance between performance and
|
||||
/// graphics quality.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Reflect)]
|
||||
#[reflect(type_uuid = "ef3c1b91-dd8a-49b9-9249-1ba4c03f7176")]
|
||||
pub struct QualitySettings {
|
||||
/// Point shadows
|
||||
/// Size of cube map face of shadow map texture in pixels.
|
||||
@@ -339,6 +341,7 @@ impl QualitySettings {
|
||||
|
||||
/// Cascaded-shadow maps settings.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "f3dc86da-f1d4-499a-89bb-7d784eebc32d")]
|
||||
pub struct CsmSettings {
|
||||
/// Whether cascaded shadow maps enabled or not.
|
||||
pub enabled: bool,
|
||||
@@ -381,9 +384,8 @@ impl Default for CsmSettings {
|
||||
AsRefStr,
|
||||
EnumString,
|
||||
VariantNames,
|
||||
TypeUuidProvider,
|
||||
)]
|
||||
#[type_uuid(id = "f9b2755b-248e-46ba-bcab-473eac1acdb8")]
|
||||
#[reflect(type_uuid = "f9b2755b-248e-46ba-bcab-473eac1acdb8")]
|
||||
pub enum ShadowMapPrecision {
|
||||
/// Shadow map will use 2 times less memory by switching to 16bit pixel format,
|
||||
/// but "shadow acne" may occur.
|
||||
|
||||
@@ -25,9 +25,10 @@ use crate::{
|
||||
io::ResourceIo,
|
||||
loader::{BoxedLoaderFuture, LoaderPayload, ResourceLoader},
|
||||
},
|
||||
core::{uuid::Uuid, TypeUuidProvider},
|
||||
core::uuid::Uuid,
|
||||
resource::curve::CurveResourceState,
|
||||
};
|
||||
use fyrox_core::reflect::Reflect;
|
||||
use fyrox_resource::state::LoadError;
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
@@ -45,7 +46,7 @@ impl ResourceLoader for CurveLoader {
|
||||
}
|
||||
|
||||
fn data_type_uuid(&self) -> Uuid {
|
||||
CurveResourceState::type_uuid()
|
||||
<CurveResourceState as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn load(&self, path: PathBuf, io: Arc<dyn ResourceIo>) -> BoxedLoaderFuture {
|
||||
|
||||
@@ -22,10 +22,7 @@
|
||||
|
||||
use crate::{
|
||||
asset::{io::ResourceIo, Resource, ResourceData},
|
||||
core::{
|
||||
io::FileError, math::curve::Curve, reflect::prelude::*, uuid::Uuid, visitor::prelude::*,
|
||||
TypeUuidProvider,
|
||||
},
|
||||
core::{io::FileError, math::curve::Curve, reflect::prelude::*, visitor::prelude::*},
|
||||
};
|
||||
use std::error::Error;
|
||||
use std::{
|
||||
@@ -76,16 +73,13 @@ impl From<VisitError> for CurveResourceError {
|
||||
|
||||
/// State of the [`CurveResource`]
|
||||
#[derive(Debug, Clone, Visit, Default, Reflect)]
|
||||
#[reflect(type_uuid = "f28b949f-28a2-4b68-9089-59c234f58b6b")]
|
||||
pub struct CurveResourceState {
|
||||
/// Actual curve.
|
||||
pub curve: Curve,
|
||||
}
|
||||
|
||||
impl ResourceData for CurveResourceState {
|
||||
fn type_uuid(&self) -> Uuid {
|
||||
<Self as TypeUuidProvider>::type_uuid()
|
||||
}
|
||||
|
||||
fn save(&mut self, _path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
// TODO: Add saving.
|
||||
Err("Saving is not supported!".to_string().into())
|
||||
@@ -100,12 +94,6 @@ impl ResourceData for CurveResourceState {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for CurveResourceState {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("f28b949f-28a2-4b68-9089-59c234f58b6b")
|
||||
}
|
||||
}
|
||||
|
||||
impl CurveResourceState {
|
||||
/// Load a curve resource from the specific file path.
|
||||
pub async fn from_file(path: &Path, io: &dyn ResourceIo) -> Result<Self, CurveResourceError> {
|
||||
|
||||
@@ -80,12 +80,13 @@ use crate::{
|
||||
};
|
||||
use fxhash::{FxHashMap, FxHashSet};
|
||||
use fyrox_animation::track::TrackBinding;
|
||||
use fyrox_core::{err, Uuid};
|
||||
use fyrox_core::err;
|
||||
use fyrox_material::shader::{ShaderResource, ShaderResourceExtension};
|
||||
use fyrox_material::MaterialResource;
|
||||
use fyrox_resource::io::ResourceIo;
|
||||
use fyrox_resource::untyped::ResourceKind;
|
||||
use std::{cmp::Ordering, path::Path};
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Input angles in degrees
|
||||
fn quat_from_euler(euler: Vector3<f32>) -> UnitQuaternion<f32> {
|
||||
|
||||
@@ -83,11 +83,10 @@ fn convert_mag(filter: GltfMagFilter) -> FyroxMagFilter {
|
||||
|
||||
use crate::material::{MaterialResourceBinding, MaterialTextureBinding};
|
||||
use crate::resource::texture::TextureWrapMode as FyroxWrapMode;
|
||||
use fyrox_core::Uuid;
|
||||
use fyrox_resource::builtin::BuiltInResource;
|
||||
use fyrox_resource::embedded_data_source;
|
||||
use gltf::texture::WrappingMode as GltfWrapMode;
|
||||
use uuid::uuid;
|
||||
use uuid::{uuid, Uuid};
|
||||
|
||||
fn convert_wrap(mode: GltfWrapMode) -> FyroxWrapMode {
|
||||
match mode {
|
||||
|
||||
@@ -28,7 +28,6 @@ use crate::asset::state::LoadError;
|
||||
use crate::core::algebra::{Matrix4, Unit};
|
||||
use crate::core::log::Log;
|
||||
use crate::core::pool::Handle;
|
||||
use crate::core::TypeUuidProvider;
|
||||
use crate::graph::NodeMapping;
|
||||
use crate::graph::SceneGraph;
|
||||
use crate::gui::core::io::FileError;
|
||||
@@ -61,6 +60,7 @@ mod surface;
|
||||
mod uri;
|
||||
|
||||
use animation::import_animations;
|
||||
use fyrox_core::reflect::Reflect;
|
||||
use fyrox_resource::untyped::ResourceKind;
|
||||
use material::*;
|
||||
pub use surface::SurfaceDataError;
|
||||
@@ -295,8 +295,8 @@ impl loader::ResourceLoader for GltfLoader {
|
||||
&["gltf", "glb"]
|
||||
}
|
||||
|
||||
fn data_type_uuid(&self) -> crate::core::type_traits::prelude::Uuid {
|
||||
Model::type_uuid()
|
||||
fn data_type_uuid(&self) -> Uuid {
|
||||
<Model as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn load(&self, path: PathBuf, io: Arc<dyn ResourceIo>) -> loader::BoxedLoaderFuture {
|
||||
|
||||
@@ -29,11 +29,12 @@ use crate::{
|
||||
manager::ResourceManager,
|
||||
options::{try_get_import_settings, try_get_import_settings_opaque, BaseImportOptions},
|
||||
},
|
||||
core::{uuid::Uuid, TypeUuidProvider},
|
||||
core::uuid::Uuid,
|
||||
engine::SerializationContext,
|
||||
resource::model::{Model, ModelImportOptions},
|
||||
};
|
||||
use fyrox_core::dyntype::DynTypeConstructorContainer;
|
||||
use fyrox_core::reflect::Reflect;
|
||||
use fyrox_resource::state::LoadError;
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
@@ -60,7 +61,7 @@ impl ResourceLoader for ModelLoader {
|
||||
}
|
||||
|
||||
fn data_type_uuid(&self) -> Uuid {
|
||||
Model::type_uuid()
|
||||
<Model as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn load(&self, path: PathBuf, io: Arc<dyn ResourceIo>) -> BoxedLoaderFuture {
|
||||
|
||||
@@ -51,11 +51,10 @@ use crate::{
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
uuid::Uuid,
|
||||
uuid_provider,
|
||||
variable::InheritableVariable,
|
||||
visitor::error::VisitError,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
NameProvider, TypeUuidProvider,
|
||||
NameProvider,
|
||||
},
|
||||
engine::SerializationContext,
|
||||
generic_animation::AnimationContainer,
|
||||
@@ -83,6 +82,7 @@ pub mod loader;
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Debug, Clone, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "44cd768f-b4ca-4804-a98c-0adf85577ada")]
|
||||
pub struct Model {
|
||||
#[visit(skip)]
|
||||
pub(crate) mapping: NodeMapping,
|
||||
@@ -104,12 +104,6 @@ impl PrefabData for Model {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Model {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("44cd768f-b4ca-4804-a98c-0adf85577ada")
|
||||
}
|
||||
}
|
||||
|
||||
/// Instantiation context holds additional data that could be useful for a prefab instantiation.
|
||||
pub struct InstantiationContext<'a> {
|
||||
model: &'a ModelResource,
|
||||
@@ -620,10 +614,6 @@ impl ModelResourceExtension for ModelResource {
|
||||
}
|
||||
|
||||
impl ResourceData for Model {
|
||||
fn type_uuid(&self) -> Uuid {
|
||||
<Self as TypeUuidProvider>::type_uuid()
|
||||
}
|
||||
|
||||
fn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
let mut visitor = Visitor::new();
|
||||
self.scene.save("Scene", &mut visitor)?;
|
||||
@@ -674,6 +664,7 @@ impl Default for Model {
|
||||
VariantNames,
|
||||
Default,
|
||||
)]
|
||||
#[reflect(type_uuid = "11634aa0-cf8f-4532-a8cd-c0fa6ef804f1")]
|
||||
pub enum MaterialSearchOptions {
|
||||
/// Search in specified materials directory. It is suitable for cases when
|
||||
/// your model resource use shared textures.
|
||||
@@ -711,8 +702,6 @@ pub enum MaterialSearchOptions {
|
||||
UsePathDirectly,
|
||||
}
|
||||
|
||||
uuid_provider!(MaterialSearchOptions = "11634aa0-cf8f-4532-a8cd-c0fa6ef804f1");
|
||||
|
||||
impl MaterialSearchOptions {
|
||||
/// A helper to create MaterialsDirectory variant.
|
||||
pub fn materials_directory<P: AsRef<Path>>(path: P) -> Self {
|
||||
@@ -736,6 +725,7 @@ impl MaterialSearchOptions {
|
||||
///
|
||||
/// Check documentation of the field of the structure for more info about each parameter.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "9b1c3667-f571-4aac-81cf-bcec0dbf0e11")]
|
||||
pub struct ModelImportOptions {
|
||||
/// See [`MaterialSearchOptions`] docs for more info.
|
||||
#[serde(default)]
|
||||
|
||||
@@ -27,7 +27,6 @@ use crate::{
|
||||
math::aabb::AxisAlignedBoundingBox,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -221,7 +220,10 @@ type AnimationPlayerHandle = InheritableVariable<Handle<AnimationPlayer>>;
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Visit, Reflect, Clone, Debug, Default)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "4b08c753-2a10-41e3-8fb2-4fd0517e86bc"
|
||||
)]
|
||||
pub struct AnimationBlendingStateMachine {
|
||||
base: Base,
|
||||
machine: MachineType,
|
||||
@@ -257,12 +259,6 @@ impl AnimationBlendingStateMachine {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for AnimationBlendingStateMachine {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("4b08c753-2a10-41e3-8fb2-4fd0517e86bc")
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for AnimationBlendingStateMachine {
|
||||
type Target = Base;
|
||||
|
||||
@@ -309,7 +305,7 @@ impl NodeTrait for AnimationBlendingStateMachine {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn update(&mut self, context: &mut UpdateContext) {
|
||||
|
||||
@@ -28,7 +28,6 @@ use crate::{
|
||||
math::aabb::AxisAlignedBoundingBox,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -244,7 +243,10 @@ impl BoundValueCollectionExt for BoundValueCollection {
|
||||
/// (`animated_node`). Only then it creates an animation player node with an animation container with a single animation.
|
||||
/// To understand why this is so complicated, see the docs of [`Animation`].
|
||||
#[derive(Visit, Reflect, Clone, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "44d1c94e-354f-4f9a-b918-9d31c28aa16a"
|
||||
)]
|
||||
pub struct AnimationPlayer {
|
||||
base: Base,
|
||||
animations: InheritableVariable<AnimationContainer>,
|
||||
@@ -298,12 +300,6 @@ impl AnimationPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for AnimationPlayer {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("44d1c94e-354f-4f9a-b918-9d31c28aa16a")
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for AnimationPlayer {
|
||||
type Target = Base;
|
||||
|
||||
@@ -340,7 +336,7 @@ impl NodeTrait for AnimationPlayer {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn update(&mut self, context: &mut UpdateContext) {
|
||||
|
||||
@@ -30,7 +30,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, Matrix4Ext},
|
||||
pool::{ErasedHandle, Handle},
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
variable::InheritableVariable,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
ImmutableString,
|
||||
@@ -57,8 +56,8 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
/// 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, Reflect, PartialEq, TypeUuidProvider)]
|
||||
#[type_uuid(id = "576b31a2-2b39-4c79-95dd-26aeaf381d8b")]
|
||||
#[derive(Debug, Default, Clone, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "576b31a2-2b39-4c79-95dd-26aeaf381d8b")]
|
||||
pub struct LevelOfDetail {
|
||||
/// Beginning of the range in which the level will be visible. It is expressed in normalized
|
||||
/// coordinates: where 0.0 - closest to camera, 1.0 - farthest from camera.
|
||||
@@ -125,18 +124,16 @@ 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, Reflect, PartialEq, TypeUuidProvider)]
|
||||
#[type_uuid(id = "8e7b18b1-c1e0-47d7-b952-4394c1d049e5")]
|
||||
#[derive(Debug, Default, Clone, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "8e7b18b1-c1e0-47d7-b952-4394c1d049e5")]
|
||||
pub struct LodGroup {
|
||||
/// Set of cascades.
|
||||
pub levels: Vec<LevelOfDetail>,
|
||||
}
|
||||
|
||||
/// A property value.
|
||||
#[derive(
|
||||
Debug, Visit, Reflect, PartialEq, Clone, AsRefStr, EnumString, VariantNames, TypeUuidProvider,
|
||||
)]
|
||||
#[type_uuid(id = "cce94b60-a57e-48ba-b6f4-e5e84788f7f8")]
|
||||
#[derive(Debug, Visit, Reflect, PartialEq, Clone, AsRefStr, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "cce94b60-a57e-48ba-b6f4-e5e84788f7f8")]
|
||||
pub enum PropertyValue {
|
||||
/// A node handle.
|
||||
///
|
||||
@@ -183,8 +180,8 @@ impl Default for PropertyValue {
|
||||
}
|
||||
|
||||
/// A custom property.
|
||||
#[derive(Debug, Visit, Reflect, Default, Clone, PartialEq, TypeUuidProvider)]
|
||||
#[type_uuid(id = "fc87fd21-a5e6-40d5-a79d-19f96b25d6c9")]
|
||||
#[derive(Debug, Visit, Reflect, Default, Clone, PartialEq)]
|
||||
#[reflect(type_uuid = "fc87fd21-a5e6-40d5-a79d-19f96b25d6c9")]
|
||||
pub struct Property {
|
||||
/// Name of the property.
|
||||
pub name: String,
|
||||
@@ -230,6 +227,7 @@ pub enum NodeScriptMessage {
|
||||
Deserialize,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
#[reflect(type_uuid = "6cebe796-6e14-479d-93a6-9fb04665740c")]
|
||||
pub struct SceneNodeId(pub Uuid);
|
||||
|
||||
impl Visit for SceneNodeId {
|
||||
@@ -239,8 +237,8 @@ impl Visit for SceneNodeId {
|
||||
}
|
||||
|
||||
/// A script container record.
|
||||
#[derive(Clone, Reflect, Debug, Default, TypeUuidProvider)]
|
||||
#[type_uuid(id = "51bc577b-5a50-4a97-9b31-eda2f3d46c9d")]
|
||||
#[derive(Clone, Reflect, Debug, Default)]
|
||||
#[reflect(type_uuid = "51bc577b-5a50-4a97-9b31-eda2f3d46c9d")]
|
||||
pub struct ScriptRecord {
|
||||
// Script is wrapped into `Option` to be able to do take-return trick to bypass borrow checker
|
||||
// issues.
|
||||
@@ -369,6 +367,7 @@ impl<T> DerefMut for TrackedProperty<T> {
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Debug, Reflect, Clone)]
|
||||
#[reflect(type_uuid = "5bf7fb77-fd50-4b92-83d7-27153b7da531")]
|
||||
pub struct Base {
|
||||
#[reflect(hidden)]
|
||||
self_handle: Handle<Node>,
|
||||
|
||||
@@ -28,9 +28,7 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, frustum::Frustum, ray::Ray, Rect},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
uuid_provider,
|
||||
variable::InheritableVariable,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
},
|
||||
@@ -58,6 +56,7 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
/// with increasing distance. This the projection type "used" by human eyes, photographic lens and
|
||||
/// it looks most realistic.
|
||||
#[derive(Reflect, Clone, Debug, PartialEq, Visit, Serialize, Deserialize)]
|
||||
#[reflect(type_uuid = "7a9662f3-28f1-4353-ba57-d610cc04834b")]
|
||||
pub struct PerspectiveProjection {
|
||||
/// Vertical angle at the top of viewing frustum, in radians. Larger values will increase field
|
||||
/// of view and create fish-eye effect, smaller values could be used to create "binocular" effect
|
||||
@@ -110,6 +109,7 @@ impl PerspectiveProjection {
|
||||
/// Parallel projection. Object's size won't be affected by distance from the viewer, it can be
|
||||
/// used for 2D games.
|
||||
#[derive(Reflect, Clone, Debug, PartialEq, Visit, Serialize, Deserialize)]
|
||||
#[reflect(type_uuid = "dcfe9e8b-f6a7-42ce-a2be-5d389175d555")]
|
||||
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.
|
||||
@@ -192,6 +192,7 @@ impl OrthographicProjection {
|
||||
Serialize,
|
||||
Deserialize,
|
||||
)]
|
||||
#[reflect(type_uuid = "0eb5bec0-fc4e-4945-99b6-e6c5392ad971")]
|
||||
pub enum Projection {
|
||||
/// See [`PerspectiveProjection`] docs.
|
||||
Perspective(PerspectiveProjection),
|
||||
@@ -199,8 +200,6 @@ pub enum Projection {
|
||||
Orthographic(OrthographicProjection),
|
||||
}
|
||||
|
||||
uuid_provider!(Projection = "0eb5bec0-fc4e-4945-99b6-e6c5392ad971");
|
||||
|
||||
impl Projection {
|
||||
/// Sets the new value for the near clipping plane.
|
||||
#[inline]
|
||||
@@ -303,6 +302,7 @@ impl Default for Projection {
|
||||
Serialize,
|
||||
Deserialize,
|
||||
)]
|
||||
#[reflect(type_uuid = "0e35ee3d-8baa-4b0c-b3dd-6c31a08c121e")]
|
||||
pub enum Exposure {
|
||||
/// Automatic exposure based on the frame luminance. High luminance values will result
|
||||
/// in lower exposure levels and vice versa.
|
||||
@@ -322,8 +322,6 @@ pub enum Exposure {
|
||||
Manual(f32),
|
||||
}
|
||||
|
||||
uuid_provider!(Exposure = "0e35ee3d-8baa-4b0c-b3dd-6c31a08c121e");
|
||||
|
||||
impl Default for Exposure {
|
||||
fn default() -> Self {
|
||||
Self::Manual(1.0)
|
||||
@@ -354,7 +352,10 @@ impl Default for Exposure {
|
||||
/// Each camera forces engine to re-render same scene one more time, which may cause almost double load
|
||||
/// of your GPU.
|
||||
#[derive(Debug, Visit, Reflect, Clone)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "198d3aca-433c-4ce1-bb25-3190699b757f"
|
||||
)]
|
||||
pub struct Camera {
|
||||
base: Base,
|
||||
|
||||
@@ -415,12 +416,6 @@ impl Default for Camera {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Camera {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("198d3aca-433c-4ce1-bb25-3190699b757f")
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of camera fitting parameters for different projection modes. You should take these parameters
|
||||
/// and modify camera position and projection accordingly. In case of perspective projection all you need
|
||||
/// to do is to set new world-space position of the camera. In cae of orthographic projection, do previous
|
||||
@@ -812,7 +807,7 @@ impl NodeTrait for Camera {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn update(&mut self, context: &mut UpdateContext) {
|
||||
@@ -892,6 +887,7 @@ impl Display for ColorGradingLutCreationError {
|
||||
///
|
||||
/// See [more info in Unreal engine docs](https://docs.unrealengine.com/4.26/en-US/RenderingAndGraphics/PostProcessEffects/UsingLUTs/)
|
||||
#[derive(Visit, Clone, Default, PartialEq, Debug, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "bca9c90a-7cde-4960-8814-c132edfc9614")]
|
||||
pub struct ColorGradingLut {
|
||||
unwrapped_lut: Option<TextureResource>,
|
||||
|
||||
@@ -900,8 +896,6 @@ pub struct ColorGradingLut {
|
||||
lut: Option<TextureResource>,
|
||||
}
|
||||
|
||||
uuid_provider!(ColorGradingLut = "bca9c90a-7cde-4960-8814-c132edfc9614");
|
||||
|
||||
impl ColorGradingLut {
|
||||
/// Creates 3D look-up texture from 2D strip.
|
||||
///
|
||||
|
||||
@@ -30,7 +30,6 @@ use crate::{
|
||||
num_traits::{NumCast, One, ToPrimitive, Zero},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -47,7 +46,6 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use fyrox_core::algebra::{Isometry3, Translation3};
|
||||
use fyrox_core::uuid_provider;
|
||||
|
||||
use fyrox_graph::constructor::ConstructorProvider;
|
||||
use fyrox_graph::SceneGraph;
|
||||
@@ -61,6 +59,7 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
|
||||
/// Ball is an idea sphere shape defined by a single parameters - its radius.
|
||||
#[derive(Clone, Debug, PartialEq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "6b94901a-2f8f-45f6-851d-89342e8455b1")]
|
||||
pub struct BallShape {
|
||||
/// Radius of the sphere.
|
||||
#[reflect(min_value = 0.001, step = 0.05)]
|
||||
@@ -75,6 +74,7 @@ impl Default for BallShape {
|
||||
|
||||
/// Cylinder shape aligned in Y axis.
|
||||
#[derive(Clone, Debug, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "cfcb8dfb-4ca9-41f1-8547-6d24c03399ed")]
|
||||
pub struct CylinderShape {
|
||||
/// Half height of the cylinder, actual height will be 2 times bigger.
|
||||
#[reflect(min_value = 0.001, step = 0.05)]
|
||||
@@ -95,6 +95,7 @@ impl Default for CylinderShape {
|
||||
|
||||
/// Cone shape aligned in Y axis.
|
||||
#[derive(Clone, Debug, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "afacc379-4cc6-4dd2-8d95-4663a582b680")]
|
||||
pub struct ConeShape {
|
||||
/// Half height of the cone, actual height will be 2 times bigger.
|
||||
#[reflect(min_value = 0.001, step = 0.05)]
|
||||
@@ -115,6 +116,7 @@ impl Default for ConeShape {
|
||||
|
||||
/// Cuboid shape (box).
|
||||
#[derive(Clone, Debug, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "9618ec4f-88c4-40f1-aa4a-20a15efd5355")]
|
||||
pub struct CuboidShape {
|
||||
/// Half extents of the box. X - half width, Y - half height, Z - half depth.
|
||||
/// Actual _size_ will be 2 times bigger.
|
||||
@@ -132,6 +134,7 @@ impl Default for CuboidShape {
|
||||
|
||||
/// Arbitrary capsule shape defined by 2 points (which forms axis) and a radius.
|
||||
#[derive(Clone, Debug, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "595c7250-7a88-4c18-b961-e61ed81aa8f2")]
|
||||
pub struct CapsuleShape {
|
||||
/// Begin point of the capsule.
|
||||
pub begin: Vector3<f32>,
|
||||
@@ -155,6 +158,7 @@ impl Default for CapsuleShape {
|
||||
|
||||
/// Arbitrary segment shape defined by two points.
|
||||
#[derive(Clone, Debug, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "4fda8c19-597f-4caa-a006-2eaedef312a1")]
|
||||
pub struct SegmentShape {
|
||||
/// Begin point of the capsule.
|
||||
pub begin: Vector3<f32>,
|
||||
@@ -173,6 +177,7 @@ impl Default for SegmentShape {
|
||||
|
||||
/// Arbitrary triangle shape.
|
||||
#[derive(Clone, Debug, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "b27adb3c-bec6-4cd4-9e9f-68a19d69312e")]
|
||||
pub struct TriangleShape {
|
||||
/// First point of the triangle shape.
|
||||
pub a: Vector3<f32>,
|
||||
@@ -198,12 +203,12 @@ impl Default for TriangleShape {
|
||||
///
|
||||
/// 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, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "6fea7c72-c488-48a1-935f-2752a8a10e9a")]
|
||||
pub struct GeometrySource(pub Handle<Node>);
|
||||
|
||||
uuid_provider!(GeometrySource = "6fea7c72-c488-48a1-935f-2752a8a10e9a");
|
||||
|
||||
/// Arbitrary triangle mesh shape.
|
||||
#[derive(Default, Clone, Debug, Visit, Reflect, PartialEq, Eq)]
|
||||
#[reflect(type_uuid = "664c4ed4-26d1-437e-b198-c25aa3b7b790")]
|
||||
pub struct TrimeshShape {
|
||||
/// Geometry sources for the shape.
|
||||
pub sources: Vec<GeometrySource>,
|
||||
@@ -211,6 +216,7 @@ pub struct TrimeshShape {
|
||||
|
||||
/// Arbitrary height field shape.
|
||||
#[derive(Default, Clone, Debug, Visit, Reflect, PartialEq, Eq)]
|
||||
#[reflect(type_uuid = "a5c12eb6-d4af-49ee-8bf1-6766c753a3d5")]
|
||||
pub struct HeightfieldShape {
|
||||
/// A handle to terrain scene node.
|
||||
pub geometry_source: GeometrySource,
|
||||
@@ -218,6 +224,7 @@ pub struct HeightfieldShape {
|
||||
|
||||
/// Arbitrary convex polyhedron shape.
|
||||
#[derive(Default, Clone, Debug, Visit, Reflect, PartialEq, Eq)]
|
||||
#[reflect(type_uuid = "fbf2e9b1-56ad-4450-8806-582151dc1868")]
|
||||
pub struct ConvexPolyhedronShape {
|
||||
/// A handle to a mesh node.
|
||||
pub geometry_source: GeometrySource,
|
||||
@@ -225,10 +232,9 @@ pub struct ConvexPolyhedronShape {
|
||||
|
||||
/// A set of bits used for pairwise collision filtering.
|
||||
#[derive(Clone, Copy, Default, PartialEq, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "f2db0c2a-921b-4728-9ce4-2506d95c60fa")]
|
||||
pub struct BitMask(pub u32);
|
||||
|
||||
uuid_provider!(BitMask = "f2db0c2a-921b-4728-9ce4-2506d95c60fa");
|
||||
|
||||
impl BitMask {
|
||||
/// BitMask with all bits set. BitMask(u32::MAX)
|
||||
pub const fn all() -> Self {
|
||||
@@ -386,6 +392,7 @@ impl NumCast for BitMask {
|
||||
/// (self.memberships & rhs.filter) != 0 && (rhs.memberships & self.filter) != 0
|
||||
/// ```
|
||||
#[derive(Visit, Debug, Clone, Copy, PartialEq, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "423f1fde-d1f8-461a-8fa9-1fa09db915d4")]
|
||||
pub struct InteractionGroups {
|
||||
/// Groups memberships.
|
||||
pub memberships: BitMask,
|
||||
@@ -500,6 +507,7 @@ impl From<rapier2d::parry::query::ShapeCastStatus> for TOIStatus {
|
||||
|
||||
/// Possible collider shapes.
|
||||
#[derive(Clone, Debug, PartialEq, Visit, Reflect, AsRefStr, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "2e627337-71ea-4b33-a5f1-be697f705a86")]
|
||||
pub enum ColliderShape {
|
||||
/// See [`BallShape`] docs.
|
||||
Ball(BallShape),
|
||||
@@ -523,8 +531,6 @@ pub enum ColliderShape {
|
||||
Polyhedron(ConvexPolyhedronShape),
|
||||
}
|
||||
|
||||
uuid_provider!(ColliderShape = "2e627337-71ea-4b33-a5f1-be697f705a86");
|
||||
|
||||
impl Default for ColliderShape {
|
||||
fn default() -> Self {
|
||||
Self::Ball(Default::default())
|
||||
@@ -612,7 +618,10 @@ 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(Reflect, Visit, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "bfaa2e82-9c19-4b99-983b-3bc115744a1d"
|
||||
)]
|
||||
pub struct Collider {
|
||||
base: Base,
|
||||
|
||||
@@ -699,12 +708,6 @@ impl Clone for Collider {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Collider {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("bfaa2e82-9c19-4b99-983b-3bc115744a1d")
|
||||
}
|
||||
}
|
||||
|
||||
impl Collider {
|
||||
/// Sets the new shape to the collider.
|
||||
///
|
||||
@@ -1000,7 +1003,7 @@ impl NodeTrait for Collider {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn on_removed_from_graph(&mut self, graph: &mut Graph) {
|
||||
|
||||
@@ -28,7 +28,6 @@ use crate::{
|
||||
math::aabb::AxisAlignedBoundingBox,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -109,7 +108,10 @@ use std::ops::{Deref, DerefMut};
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Debug, Visit, Default, Clone, Reflect)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "c4d24e48-edd1-4fb2-ad82-4b3d3ea985d8"
|
||||
)]
|
||||
pub struct Decal {
|
||||
base: Base,
|
||||
|
||||
@@ -141,12 +143,6 @@ impl DerefMut for Decal {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Decal {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("c4d24e48-edd1-4fb2-ad82-4b3d3ea985d8")
|
||||
}
|
||||
}
|
||||
|
||||
impl Decal {
|
||||
/// Sets new diffuse texture.
|
||||
pub fn set_diffuse_texture(
|
||||
@@ -239,7 +235,7 @@ impl NodeTrait for Decal {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,9 @@ use crate::{
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
uuid_provider,
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
ImmutableString, TypeUuidProvider,
|
||||
ImmutableString,
|
||||
},
|
||||
graph::SceneGraph,
|
||||
scene::{
|
||||
@@ -59,6 +58,7 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
|
||||
/// Ball is an idea sphere shape defined by a single parameters - its radius.
|
||||
#[derive(Clone, Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "8847dfd3-2d41-4e77-ab68-5d16503eafe0")]
|
||||
pub struct BallShape {
|
||||
/// Radius of the sphere.
|
||||
#[reflect(min_value = 0.001, step = 0.05)]
|
||||
@@ -73,6 +73,7 @@ impl Default for BallShape {
|
||||
|
||||
/// Cuboid shape (rectangle).
|
||||
#[derive(Clone, Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "47b69ea8-d203-4c4a-9451-fec2d77233b3")]
|
||||
pub struct CuboidShape {
|
||||
/// Half extents of the box. X - half width, Y - half height.
|
||||
/// Actual _size_ will be 2 times bigger.
|
||||
@@ -90,6 +91,7 @@ impl Default for CuboidShape {
|
||||
|
||||
/// Arbitrary capsule shape defined by 2 points (which forms axis) and a radius.
|
||||
#[derive(Clone, Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "d5c3444c-38eb-4a72-bb70-939fccc7a044")]
|
||||
pub struct CapsuleShape {
|
||||
/// Begin point of the capsule.
|
||||
pub begin: Vector2<f32>,
|
||||
@@ -113,6 +115,7 @@ impl Default for CapsuleShape {
|
||||
|
||||
/// Arbitrary segment shape defined by two points.
|
||||
#[derive(Clone, Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "53725358-ae6e-4928-b7e2-89b99703a66c")]
|
||||
pub struct SegmentShape {
|
||||
/// Begin point of the capsule.
|
||||
pub begin: Vector2<f32>,
|
||||
@@ -131,6 +134,7 @@ impl Default for SegmentShape {
|
||||
|
||||
/// Arbitrary triangle shape.
|
||||
#[derive(Clone, Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "7b5c0314-10c7-4593-96f4-ace606ccda8d")]
|
||||
pub struct TriangleShape {
|
||||
/// First point of the triangle shape.
|
||||
pub a: Vector2<f32>,
|
||||
@@ -155,12 +159,13 @@ 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, Reflect, Eq, TypeUuidProvider)]
|
||||
#[type_uuid(id = "1d451699-d76e-4774-87ea-dd3e2751cb39")]
|
||||
#[derive(Default, Clone, Copy, PartialEq, Hash, Debug, Visit, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "1d451699-d76e-4774-87ea-dd3e2751cb39")]
|
||||
pub struct GeometrySource(pub Handle<Node>);
|
||||
|
||||
/// Arbitrary triangle mesh shape.
|
||||
#[derive(Default, Clone, Debug, PartialEq, Visit, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "bdf7cb5f-7a68-4ac1-b261-b6d1b537d8e1")]
|
||||
pub struct TrimeshShape {
|
||||
/// Geometry sources for the shape.
|
||||
pub sources: Vec<GeometrySource>,
|
||||
@@ -168,6 +173,7 @@ pub struct TrimeshShape {
|
||||
|
||||
/// Arbitrary height field shape.
|
||||
#[derive(Default, Clone, Debug, PartialEq, Visit, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "ff6e1e20-4b32-4607-b4c7-d2398b607232")]
|
||||
pub struct HeightfieldShape {
|
||||
/// A handle to terrain scene node.
|
||||
pub geometry_source: GeometrySource,
|
||||
@@ -175,6 +181,7 @@ pub struct HeightfieldShape {
|
||||
|
||||
/// Arbitrary tile map shape.
|
||||
#[derive(Default, Clone, Debug, PartialEq, Visit, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "57502a1f-a3df-4c48-ad91-69e321a237dc")]
|
||||
pub struct TileMapShape {
|
||||
/// A handle to tile map scene node.
|
||||
pub tile_map: GeometrySource,
|
||||
@@ -184,6 +191,7 @@ pub struct TileMapShape {
|
||||
|
||||
/// Possible collider shapes.
|
||||
#[derive(Clone, Debug, Visit, Reflect, AsRefStr, PartialEq, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "4615485f-f8db-4405-b4a5-437e74b3f5b8")]
|
||||
pub enum ColliderShape {
|
||||
/// See [`BallShape`] docs.
|
||||
Ball(BallShape),
|
||||
@@ -203,8 +211,6 @@ pub enum ColliderShape {
|
||||
TileMap(TileMapShape),
|
||||
}
|
||||
|
||||
uuid_provider!(ColliderShape = "4615485f-f8db-4405-b4a5-437e74b3f5b8");
|
||||
|
||||
impl Default for ColliderShape {
|
||||
fn default() -> Self {
|
||||
Self::Ball(Default::default())
|
||||
@@ -268,7 +274,10 @@ impl ColliderShape {
|
||||
/// Collider is a geometric entity that can be attached to a rigid body to allow to participate in
|
||||
/// contact generation, collision response and proximity queries.
|
||||
#[derive(Reflect, Visit, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "2b1659ea-a116-4224-bcd4-7931e3ae3b40"
|
||||
)]
|
||||
pub struct Collider {
|
||||
base: Base,
|
||||
|
||||
@@ -355,12 +364,6 @@ impl Clone for Collider {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Collider {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("2b1659ea-a116-4224-bcd4-7931e3ae3b40")
|
||||
}
|
||||
}
|
||||
|
||||
impl Collider {
|
||||
/// Sets the new shape to the collider.
|
||||
///
|
||||
@@ -656,7 +659,7 @@ impl NodeTrait for Collider {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn on_removed_from_graph(&mut self, graph: &mut Graph) {
|
||||
|
||||
@@ -28,7 +28,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, m4x4_approx_eq},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -41,7 +40,6 @@ use crate::{
|
||||
Scene,
|
||||
},
|
||||
};
|
||||
use fyrox_core::uuid_provider;
|
||||
|
||||
use fyrox_graph::constructor::ConstructorProvider;
|
||||
use fyrox_graph::SceneGraph;
|
||||
@@ -56,6 +54,7 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
/// allows rigid bodies to perform relative rotations. The real world example is a human shoulder,
|
||||
/// pendulum, etc.
|
||||
#[derive(Clone, Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "b35f39a3-7b93-4ea9-8f9a-01faeee658ae")]
|
||||
pub struct BallJoint {
|
||||
/// Whether angular limits are enabled or not. Default is `false`
|
||||
pub limits_enabled: bool,
|
||||
@@ -76,11 +75,13 @@ 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, Reflect, Eq)]
|
||||
#[reflect(type_uuid = "cf69b42d-0d7d-41a0-9354-af7659aaf5e6")]
|
||||
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, Reflect)]
|
||||
#[reflect(type_uuid = "4b02e35a-a1b1-4617-a08a-c06139223969")]
|
||||
pub struct PrismaticJoint {
|
||||
/// Whether linear limits along local X axis of the joint are enabled or not. Default is `false`
|
||||
pub limits_enabled: bool,
|
||||
@@ -100,6 +101,7 @@ impl Default for PrismaticJoint {
|
||||
|
||||
/// Parameters that define how the joint motor will behave.
|
||||
#[derive(Default, Clone, Debug, PartialEq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "b4dab2d7-8cba-4b6a-85c9-ac7c6dd48ed5")]
|
||||
pub struct JointMotorParams {
|
||||
/// The target velocity of the motor.
|
||||
pub target_vel: f32,
|
||||
@@ -115,6 +117,7 @@ pub struct JointMotorParams {
|
||||
|
||||
/// The exact kind of the joint.
|
||||
#[derive(Clone, Debug, PartialEq, Visit, Reflect, AsRefStr, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "e1fa2015-3ea3-47bb-8ad3-d408559c9643")]
|
||||
pub enum JointParams {
|
||||
/// See [`BallJoint`] for more info.
|
||||
BallJoint(BallJoint),
|
||||
@@ -124,8 +127,6 @@ pub enum JointParams {
|
||||
PrismaticJoint(PrismaticJoint),
|
||||
}
|
||||
|
||||
uuid_provider!(JointParams = "e1fa2015-3ea3-47bb-8ad3-d408559c9643");
|
||||
|
||||
impl Default for JointParams {
|
||||
fn default() -> Self {
|
||||
Self::BallJoint(Default::default())
|
||||
@@ -133,6 +134,7 @@ impl Default for JointParams {
|
||||
}
|
||||
|
||||
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
||||
#[reflect(type_uuid = "d22556ef-f011-4b85-ac67-c1ff4d43d59e")]
|
||||
pub(crate) struct LocalFrame {
|
||||
pub position: Vector2<f32>,
|
||||
pub rotation: UnitComplex<f32>,
|
||||
@@ -148,6 +150,7 @@ impl LocalFrame {
|
||||
}
|
||||
|
||||
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
||||
#[reflect(type_uuid = "448ce88b-1c89-4a66-b909-6835aff07d12")]
|
||||
pub(crate) struct JointLocalFrames {
|
||||
pub body1: LocalFrame,
|
||||
pub body2: LocalFrame,
|
||||
@@ -165,7 +168,10 @@ impl JointLocalFrames {
|
||||
/// 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, Reflect, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "b8d66eda-b69f-4c57-80ba-d76665573565"
|
||||
)]
|
||||
pub struct Joint {
|
||||
base: Base,
|
||||
|
||||
@@ -238,12 +244,6 @@ impl Clone for Joint {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Joint {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("b8d66eda-b69f-4c57-80ba-d76665573565")
|
||||
}
|
||||
}
|
||||
|
||||
impl Joint {
|
||||
/// Sets new parameters of the joint.
|
||||
pub fn set_params(&mut self, params: JointParams) -> JointParams {
|
||||
@@ -558,7 +558,7 @@ impl NodeTrait for Joint {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn on_removed_from_graph(&mut self, graph: &mut Graph) {
|
||||
|
||||
@@ -458,6 +458,7 @@ fn isometry2_to_mat4(isometry: &Isometry2<f32>) -> Matrix4<f32> {
|
||||
/// methods, mostly for ray casting. You should add physical entities using scene graph nodes, such
|
||||
/// as RigidBody, Collider, Joint.
|
||||
#[derive(Visit, Reflect)]
|
||||
#[reflect(type_uuid = "035cccc1-a098-4b25-bbd6-cac507d6649d")]
|
||||
pub struct PhysicsWorld {
|
||||
/// A flag that defines whether physics simulation is enabled or not.
|
||||
pub enabled: InheritableVariable<bool>,
|
||||
|
||||
@@ -31,7 +31,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, Rect, TriangleDefinition},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
value_as_u8_slice,
|
||||
variable::InheritableVariable,
|
||||
@@ -172,7 +171,10 @@ impl Hash for RectangleVertex {
|
||||
/// which means `[0; 0]` corresponds to top-left corner of the texture and `[1; 1]` corresponds to
|
||||
/// right-bottom corner.
|
||||
#[derive(Reflect, Debug, Clone, Visit)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "bb57b5e0-367a-4490-bf30-7f547407d5b5"
|
||||
)]
|
||||
pub struct Rectangle {
|
||||
base: Base,
|
||||
|
||||
@@ -222,12 +224,6 @@ impl DerefMut for Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Rectangle {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("bb57b5e0-367a-4490-bf30-7f547407d5b5")
|
||||
}
|
||||
}
|
||||
|
||||
impl Rectangle {
|
||||
/// Returns current color of the rectangle.
|
||||
pub fn color(&self) -> Color {
|
||||
@@ -321,7 +317,7 @@ impl NodeTrait for Rectangle {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn collect_render_data(&self, ctx: &mut RenderContext) -> RdcControlFlow {
|
||||
|
||||
@@ -37,7 +37,6 @@ use crate::{
|
||||
parking_lot::Mutex,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -91,7 +90,10 @@ 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, Reflect)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "0b242335-75a4-4c65-9685-3e82a8979047"
|
||||
)]
|
||||
pub struct RigidBody {
|
||||
base: Base,
|
||||
|
||||
@@ -218,12 +220,6 @@ impl Clone for RigidBody {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for RigidBody {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("0b242335-75a4-4c65-9685-3e82a8979047")
|
||||
}
|
||||
}
|
||||
|
||||
impl RigidBody {
|
||||
/// Sets new linear velocity of the rigid body. Changing this parameter will wake up the rigid
|
||||
/// body!
|
||||
@@ -488,7 +484,7 @@ impl NodeTrait for RigidBody {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn on_removed_from_graph(&mut self, graph: &mut Graph) {
|
||||
|
||||
@@ -126,6 +126,7 @@ pub type NodePool = Pool<Node, NodeContainer>;
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Reflect)]
|
||||
#[reflect(type_uuid = "92b8e89c-3934-4876-a60a-2970286a56f6")]
|
||||
pub struct Graph {
|
||||
#[reflect(hidden)]
|
||||
root: Handle<Node>,
|
||||
@@ -2216,7 +2217,6 @@ mod test {
|
||||
futures::executor::block_on,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
visitor::prelude::*,
|
||||
},
|
||||
engine::{self, SerializationContext},
|
||||
@@ -2240,8 +2240,8 @@ mod test {
|
||||
use fyrox_resource::untyped::ResourceKind;
|
||||
use std::{fs, path::Path, sync::Arc};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "722feb80-a10b-4ee0-8cef-5d1473df8457")]
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "722feb80-a10b-4ee0-8cef-5d1473df8457")]
|
||||
struct MyScript {
|
||||
foo: String,
|
||||
bar: f32,
|
||||
@@ -2249,8 +2249,8 @@ mod test {
|
||||
|
||||
impl ScriptTrait for MyScript {}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "722feb80-a10b-4ee0-8cef-5d1473df8458")]
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "722feb80-a10b-4ee0-8cef-5d1473df8458")]
|
||||
struct MyOtherScript {
|
||||
baz: u32,
|
||||
foobar: Vec<u32>,
|
||||
|
||||
@@ -33,7 +33,6 @@ use crate::{
|
||||
parking_lot::Mutex,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
uuid_provider,
|
||||
variable::{InheritableVariable, VariableFlags},
|
||||
visitor::prelude::*,
|
||||
BiDirHashMap, SafeLock,
|
||||
@@ -130,6 +129,7 @@ impl From<rapier2d::geometry::FeatureId> for FeatureId {
|
||||
Copy, Clone, Debug, PartialEq, Eq, Visit, Reflect, VariantNames, EnumString, AsRefStr, Default,
|
||||
)]
|
||||
#[repr(u32)]
|
||||
#[reflect(type_uuid = "775d5598-c283-4b44-9cc0-2e23dc8936f4")]
|
||||
pub enum CoefficientCombineRule {
|
||||
/// The two coefficients are averaged.
|
||||
#[default]
|
||||
@@ -144,8 +144,6 @@ pub enum CoefficientCombineRule {
|
||||
ClampedSum = 4,
|
||||
}
|
||||
|
||||
uuid_provider!(CoefficientCombineRule = "775d5598-c283-4b44-9cc0-2e23dc8936f4");
|
||||
|
||||
impl From<rapier3d::dynamics::CoefficientCombineRule> for CoefficientCombineRule {
|
||||
fn from(v: rapier3d::dynamics::CoefficientCombineRule) -> Self {
|
||||
match v {
|
||||
@@ -828,6 +826,7 @@ fn collider_shape_into_native_shape(
|
||||
/// each parameter.
|
||||
#[derive(Copy, Clone, Visit, Reflect, Debug, PartialEq)]
|
||||
#[visit(optional)]
|
||||
#[reflect(type_uuid = "bd4ca07f-34a5-4cf8-a70e-24919124545b")]
|
||||
pub struct IntegrationParameters {
|
||||
/// The time step length, default is None - this means that physics simulation will use engine's
|
||||
/// time step.
|
||||
@@ -913,6 +912,7 @@ impl Default for IntegrationParameters {
|
||||
/// methods, mostly for ray casting. You should add physical entities using scene graph nodes, such
|
||||
/// as RigidBody, Collider, Joint.
|
||||
#[derive(Visit, Reflect)]
|
||||
#[reflect(type_uuid = "17e663b8-98a4-46db-be71-a336246f571a")]
|
||||
pub struct PhysicsWorld {
|
||||
/// A flag that defines whether physics simulation is enabled or not.
|
||||
pub enabled: InheritableVariable<bool>,
|
||||
|
||||
@@ -28,7 +28,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, m4x4_approx_eq},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -42,7 +41,7 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use fyrox_core::algebra::{Isometry3, Vector3};
|
||||
use fyrox_core::uuid_provider;
|
||||
|
||||
use fyrox_graph::constructor::ConstructorProvider;
|
||||
use fyrox_graph::SceneGraph;
|
||||
use rapier2d::na::UnitQuaternion;
|
||||
@@ -58,6 +57,7 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
/// allows rigid bodies to perform relative rotations. The real world example is a human shoulder,
|
||||
/// pendulum, etc.
|
||||
#[derive(Clone, Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "bb63213b-5be2-4fc7-878e-c7389ab03685")]
|
||||
pub struct BallJoint {
|
||||
/// Whether X angular limits are enabled or not. Default is `false`
|
||||
pub x_limits_enabled: bool,
|
||||
@@ -94,11 +94,13 @@ 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, Reflect, Default, Eq)]
|
||||
#[reflect(type_uuid = "24ff690c-e797-47b4-8bd4-0e1fed4f7bb7")]
|
||||
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, Reflect)]
|
||||
#[reflect(type_uuid = "af31abc5-49e6-4ef8-8f23-f3aaa96d0634")]
|
||||
pub struct PrismaticJoint {
|
||||
/// Whether linear limits along local joint X axis are enabled or not. Default is `false`
|
||||
pub limits_enabled: bool,
|
||||
@@ -120,6 +122,7 @@ impl Default for PrismaticJoint {
|
||||
/// 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, Reflect)]
|
||||
#[reflect(type_uuid = "d7365d59-ef93-4558-8ce3-52b25be8161a")]
|
||||
pub struct RevoluteJoint {
|
||||
/// Whether angular limits around local X axis of the joint are enabled or not. Default is `false`
|
||||
pub limits_enabled: bool,
|
||||
@@ -139,6 +142,7 @@ impl Default for RevoluteJoint {
|
||||
|
||||
/// Parameters that define how the joint motor will behave.
|
||||
#[derive(Default, Clone, Debug, PartialEq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "4a0ff733-121b-49f7-943d-6aaa0c3540ec")]
|
||||
pub struct JointMotorParams {
|
||||
/// The target velocity of the motor.
|
||||
pub target_vel: f32,
|
||||
@@ -154,6 +158,7 @@ pub struct JointMotorParams {
|
||||
|
||||
/// The exact kind of the joint.
|
||||
#[derive(Clone, Debug, PartialEq, Visit, Reflect, AsRefStr, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "a3e09303-9de4-4123-9492-05e27f29aaa3")]
|
||||
pub enum JointParams {
|
||||
/// See [`BallJoint`] for more info.
|
||||
BallJoint(BallJoint),
|
||||
@@ -165,8 +170,6 @@ pub enum JointParams {
|
||||
RevoluteJoint(RevoluteJoint),
|
||||
}
|
||||
|
||||
uuid_provider!(JointParams = "a3e09303-9de4-4123-9492-05e27f29aaa3");
|
||||
|
||||
impl Default for JointParams {
|
||||
fn default() -> Self {
|
||||
Self::BallJoint(Default::default())
|
||||
@@ -174,6 +177,7 @@ impl Default for JointParams {
|
||||
}
|
||||
|
||||
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
||||
#[reflect(type_uuid = "1be0b82e-d05e-4b93-808a-41895c5a1627")]
|
||||
pub(crate) struct LocalFrame {
|
||||
pub position: Vector3<f32>,
|
||||
pub rotation: UnitQuaternion<f32>,
|
||||
@@ -189,6 +193,7 @@ impl LocalFrame {
|
||||
}
|
||||
|
||||
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
||||
#[reflect(type_uuid = "2a8e0d9c-4c14-454e-967b-920a032bbafb")]
|
||||
pub(crate) struct JointLocalFrames {
|
||||
pub body1: LocalFrame,
|
||||
pub body2: LocalFrame,
|
||||
@@ -206,7 +211,10 @@ impl JointLocalFrames {
|
||||
/// 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, Reflect, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "439d48f5-e3a3-4255-aa08-353c1ca42e3b"
|
||||
)]
|
||||
pub struct Joint {
|
||||
base: Base,
|
||||
|
||||
@@ -284,12 +292,6 @@ impl Clone for Joint {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Joint {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("439d48f5-e3a3-4255-aa08-353c1ca42e3b")
|
||||
}
|
||||
}
|
||||
|
||||
impl Joint {
|
||||
/// Returns a shared reference to the current joint parameters.
|
||||
pub fn params(&self) -> &JointParams {
|
||||
@@ -636,7 +638,7 @@ impl NodeTrait for Joint {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn on_removed_from_graph(&mut self, graph: &mut Graph) {
|
||||
|
||||
@@ -33,9 +33,7 @@ use crate::{
|
||||
math::aabb::AxisAlignedBoundingBox,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
uuid_provider,
|
||||
variable::InheritableVariable,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
},
|
||||
@@ -58,6 +56,7 @@ pub const CSM_NUM_CASCADES: usize = 3;
|
||||
|
||||
/// Frustum split options defines how to split camera's frustum to generate cascades.
|
||||
#[derive(Reflect, Clone, Visit, Debug, PartialEq, AsRefStr, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "b2ed128a-b7da-4d34-b027-a0af19c2f563")]
|
||||
pub enum FrustumSplitOptions {
|
||||
/// Camera frustum will be split into a [`CSM_NUM_CASCADES`] splits where each sub-frustum
|
||||
/// will have fixed far plane location.
|
||||
@@ -83,8 +82,6 @@ pub enum FrustumSplitOptions {
|
||||
},
|
||||
}
|
||||
|
||||
uuid_provider!(FrustumSplitOptions = "b2ed128a-b7da-4d34-b027-a0af19c2f563");
|
||||
|
||||
impl Default for FrustumSplitOptions {
|
||||
fn default() -> Self {
|
||||
Self::Absolute {
|
||||
@@ -95,6 +92,7 @@ impl Default for FrustumSplitOptions {
|
||||
|
||||
/// Cascade Shadow Mapping (CSM) options.
|
||||
#[derive(Reflect, Clone, Visit, PartialEq, Debug)]
|
||||
#[reflect(type_uuid = "a521b6d1-665f-42f8-af3b-0e628e1bf09d")]
|
||||
pub struct CsmOptions {
|
||||
/// See [`FrustumSplitOptions`].
|
||||
pub split_options: FrustumSplitOptions,
|
||||
@@ -128,7 +126,10 @@ impl CsmOptions {
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Default, Debug, Visit, Reflect, Clone)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "8b8248e1-1cdf-42a3-9abe-0691de82c519"
|
||||
)]
|
||||
pub struct DirectionalLight {
|
||||
base_light: BaseLight,
|
||||
/// See [`CsmOptions`].
|
||||
@@ -158,12 +159,6 @@ impl DerefMut for DirectionalLight {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for DirectionalLight {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("8b8248e1-1cdf-42a3-9abe-0691de82c519")
|
||||
}
|
||||
}
|
||||
|
||||
impl DirectionalLight {
|
||||
/// Returns a reference to base light.
|
||||
pub fn base_light_ref(&self) -> &BaseLight {
|
||||
@@ -201,7 +196,7 @@ impl NodeTrait for DirectionalLight {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn debug_draw(&self, ctx: &mut SceneDrawingContext) {
|
||||
|
||||
@@ -68,6 +68,7 @@ pub const DEFAULT_SCATTER_B: f32 = 0.03;
|
||||
/// scattering factor (per color channel) and other useful properties. Exact
|
||||
/// behavior defined by specific light kind.
|
||||
#[derive(Debug, Reflect, Clone, Visit)]
|
||||
#[reflect(type_uuid = "5c9486ed-5f3b-4225-bed5-95f9bde6360e")]
|
||||
pub struct BaseLight {
|
||||
base: Base,
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ use crate::{
|
||||
math::aabb::AxisAlignedBoundingBox,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
@@ -64,7 +63,10 @@ use std::ops::{Deref, DerefMut};
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Debug, Reflect, Clone, Visit)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "c81dcc31-7cb9-465f-abd9-b385ac6f4d37"
|
||||
)]
|
||||
pub struct PointLight {
|
||||
base_light: BaseLight,
|
||||
|
||||
@@ -91,12 +93,6 @@ impl DerefMut for PointLight {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for PointLight {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("c81dcc31-7cb9-465f-abd9-b385ac6f4d37")
|
||||
}
|
||||
}
|
||||
|
||||
impl PointLight {
|
||||
/// Returns a reference to base light.
|
||||
pub fn base_light_ref(&self) -> &BaseLight {
|
||||
@@ -160,7 +156,7 @@ impl NodeTrait for PointLight {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn debug_draw(&self, ctx: &mut SceneDrawingContext) {
|
||||
|
||||
@@ -51,7 +51,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, Matrix4Ext},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
@@ -71,7 +70,10 @@ use std::ops::{Deref, DerefMut};
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Debug, Reflect, Clone, Visit)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "9856a3c1-ced7-47ec-b682-4dc4dea89d8f"
|
||||
)]
|
||||
pub struct SpotLight {
|
||||
base_light: BaseLight,
|
||||
|
||||
@@ -122,12 +124,6 @@ impl Default for SpotLight {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for SpotLight {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("9856a3c1-ced7-47ec-b682-4dc4dea89d8f")
|
||||
}
|
||||
}
|
||||
|
||||
impl SpotLight {
|
||||
/// Returns a reference to base light.
|
||||
pub fn base_light_ref(&self) -> &BaseLight {
|
||||
@@ -248,7 +244,7 @@ impl NodeTrait for SpotLight {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn debug_draw(&self, ctx: &mut SceneDrawingContext) {
|
||||
|
||||
@@ -59,6 +59,7 @@ pub trait VertexTrait: Copy + 'static {
|
||||
#[derive(Reflect, Copy, Clone, PartialOrd, PartialEq, Eq, Ord, Hash, Visit, Debug)]
|
||||
#[repr(u8)]
|
||||
#[derive(Default)]
|
||||
#[reflect(type_uuid = "c131e587-c400-4185-93fb-fbfbd11c1d8b")]
|
||||
pub enum VertexAttributeDataType {
|
||||
/// 32-bit floating-point.
|
||||
#[default]
|
||||
@@ -87,6 +88,7 @@ impl VertexAttributeDataType {
|
||||
#[derive(Reflect, Copy, Clone, PartialOrd, PartialEq, Eq, Ord, Hash, Visit, Debug)]
|
||||
#[repr(u32)]
|
||||
#[derive(Default)]
|
||||
#[reflect(type_uuid = "17839987-f47f-4dd4-9a66-4c39b301681f")]
|
||||
pub enum VertexAttributeUsage {
|
||||
/// Vertex position. Usually `Vector2<f32>` or `Vector3<f32>`.
|
||||
#[default]
|
||||
@@ -169,6 +171,7 @@ pub struct VertexAttributeDescriptor {
|
||||
/// Vertex attribute is a simple "bridge" between raw data and its interpretation. In
|
||||
/// other words it defines how to treat raw data in vertex shader.
|
||||
#[derive(Reflect, Visit, Copy, Clone, Default, Debug, Hash)]
|
||||
#[reflect(type_uuid = "705f8ad3-69b4-4b39-99aa-a3f97e319202")]
|
||||
pub struct VertexAttribute {
|
||||
/// Claimed usage of the attribute. It could be Position, Normal, etc.
|
||||
pub usage: VertexAttributeUsage,
|
||||
@@ -217,6 +220,7 @@ impl Display for VertexAttribute {
|
||||
|
||||
/// Bytes storage of a vertex buffer.
|
||||
#[derive(Reflect, Clone, Debug)]
|
||||
#[reflect(type_uuid = "493045ee-fba2-4c5f-a5cd-c27034d1ec71")]
|
||||
pub struct BytesStorage {
|
||||
bytes: Vec<u8>,
|
||||
#[reflect(hidden)]
|
||||
@@ -396,6 +400,7 @@ impl Deref for BytesStorage {
|
||||
/// Vertex size cannot be more than 256 bytes, this limitation shouldn't be a problem because almost every GPU supports up to
|
||||
/// 16 vertex attributes with 16 bytes of size each, which gives exactly 256 bytes.
|
||||
#[derive(Reflect, Clone, Visit, Default, Debug)]
|
||||
#[reflect(type_uuid = "edab7161-6695-4e2a-b947-13305709d451")]
|
||||
pub struct VertexBuffer {
|
||||
dense_layout: Vec<VertexAttribute>,
|
||||
sparse_layout: [Option<VertexAttribute>; VertexAttributeUsage::Count as usize],
|
||||
@@ -1464,6 +1469,7 @@ impl VertexWriteTrait for VertexViewMut<'_> {
|
||||
|
||||
/// A buffer for data that defines connections between vertices.
|
||||
#[derive(Reflect, Default, Clone, Debug)]
|
||||
#[reflect(type_uuid = "ed9f9aa9-e1fb-4f58-b1cb-162d51dbc9e7")]
|
||||
pub struct TriangleBuffer {
|
||||
triangles: Vec<TriangleDefinition>,
|
||||
modifications_counter: u64,
|
||||
|
||||
@@ -29,7 +29,6 @@ use crate::{
|
||||
parking_lot::Mutex,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
SafeLock,
|
||||
@@ -93,9 +92,8 @@ pub mod vertex;
|
||||
AsRefStr,
|
||||
EnumString,
|
||||
VariantNames,
|
||||
TypeUuidProvider,
|
||||
)]
|
||||
#[type_uuid(id = "009bccb6-42e4-4dc6-bb26-6a8a70b3fab9")]
|
||||
#[reflect(type_uuid = "009bccb6-42e4-4dc6-bb26-6a8a70b3fab9")]
|
||||
#[repr(u32)]
|
||||
pub enum RenderPath {
|
||||
/// Deferred rendering has much better performance than Forward, but it does not support transparent
|
||||
@@ -143,9 +141,8 @@ fn transform_vertex(mut vertex: VertexViewMut, world: &Matrix4<f32>) {
|
||||
AsRefStr,
|
||||
EnumString,
|
||||
VariantNames,
|
||||
TypeUuidProvider,
|
||||
)]
|
||||
#[type_uuid(id = "745e6f32-63f5-46fe-8edb-9708699ae328")]
|
||||
#[reflect(type_uuid = "745e6f32-63f5-46fe-8edb-9708699ae328")]
|
||||
#[repr(u32)]
|
||||
pub enum BatchingMode {
|
||||
/// No batching. The mesh will be drawn in a separate draw call.
|
||||
@@ -318,7 +315,10 @@ impl RenderDataBundleStorageTrait for BatchContainer {
|
||||
/// This example creates a unit cube surface with default material and then creates a mesh with this surface. If you need to create
|
||||
/// custom surface, see [`crate::scene::mesh::surface::SurfaceData`] docs for more info.
|
||||
#[derive(Debug, Reflect, Clone, Visit)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "caaf9d7b-bd74-48ce-b7cc-57e9dc65c2e6"
|
||||
)]
|
||||
pub struct Mesh {
|
||||
#[visit(rename = "Common")]
|
||||
base: Base,
|
||||
@@ -401,12 +401,6 @@ impl DerefMut for Mesh {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Mesh {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("caaf9d7b-bd74-48ce-b7cc-57e9dc65c2e6")
|
||||
}
|
||||
}
|
||||
|
||||
impl Mesh {
|
||||
/// Default name of the blend shapes storage property in a shader.
|
||||
pub const DEFAULT_BLEND_SHAPES_PROPERTY_NAME: &'static str = "blendShapesStorage";
|
||||
@@ -661,7 +655,7 @@ impl NodeTrait for Mesh {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn on_global_transform_changed(
|
||||
|
||||
@@ -37,11 +37,8 @@ use crate::{
|
||||
pool::{ErasedHandle, Handle},
|
||||
reflect::prelude::*,
|
||||
sparse::AtomicIndex,
|
||||
type_traits::prelude::*,
|
||||
uuid_provider,
|
||||
variable::InheritableVariable,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
Uuid,
|
||||
},
|
||||
material::{Material, MaterialResource, MaterialResourceExtension},
|
||||
resource::texture::{TextureKind, TexturePixelKind, TextureResource, TextureResourceExtension},
|
||||
@@ -70,6 +67,7 @@ use std::{
|
||||
|
||||
/// A target shape for blending.
|
||||
#[derive(Debug, Clone, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "fea08418-58fe-4fde-991b-36be235432bd")]
|
||||
pub struct BlendShape {
|
||||
/// Weight of the shape.
|
||||
#[reflect(min_value = 0.0, max_value = 100.0, step = 1.0)]
|
||||
@@ -79,8 +77,6 @@ pub struct BlendShape {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
uuid_provider!(BlendShape = "fea08418-58fe-4fde-991b-36be235432bd");
|
||||
|
||||
impl Default for BlendShape {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -92,6 +88,7 @@ impl Default for BlendShape {
|
||||
|
||||
/// A container for multiple blend shapes/
|
||||
#[derive(Reflect, Debug, Clone, Default)]
|
||||
#[reflect(type_uuid = "bd60343b-4a27-42aa-959e-b0d1bc8682db")]
|
||||
pub struct BlendShapesContainer {
|
||||
/// A list of blend shapes.
|
||||
pub blend_shapes: Vec<BlendShape>,
|
||||
@@ -223,8 +220,8 @@ impl BlendShapesContainer {
|
||||
/// Data source of a surface. Each surface can share same data source, this is used
|
||||
/// in instancing technique to render multiple instances of same model at different
|
||||
/// places.
|
||||
#[derive(Debug, Clone, Default, Reflect, TypeUuidProvider)]
|
||||
#[type_uuid(id = "8a23a414-e66d-4e12-9628-92c6ab49c2f0")]
|
||||
#[derive(Debug, Clone, Default, Reflect)]
|
||||
#[reflect(type_uuid = "8a23a414-e66d-4e12-9628-92c6ab49c2f0")]
|
||||
pub struct SurfaceData {
|
||||
/// Current vertex buffer.
|
||||
pub vertex_buffer: VertexBuffer,
|
||||
@@ -237,10 +234,6 @@ pub struct SurfaceData {
|
||||
}
|
||||
|
||||
impl ResourceData for SurfaceData {
|
||||
fn type_uuid(&self) -> Uuid {
|
||||
<SurfaceData as fyrox_core::TypeUuidProvider>::type_uuid()
|
||||
}
|
||||
|
||||
fn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
let mut visitor = Visitor::new();
|
||||
self.visit("SurfaceData", &mut visitor)?;
|
||||
@@ -1252,6 +1245,7 @@ impl SurfaceResourceExtension for SurfaceResource {
|
||||
/// This code snippet creates a cone surface instance, check the docs for [`SurfaceData`] for more info about built-in
|
||||
/// methods.
|
||||
#[derive(Debug, Reflect, Visit, PartialEq)]
|
||||
#[reflect(type_uuid = "485caf12-4e7d-4b1a-b6bd-0681fd92f789")]
|
||||
pub struct Surface {
|
||||
pub(crate) data: InheritableVariable<SurfaceResource>,
|
||||
|
||||
@@ -1276,8 +1270,6 @@ pub struct Surface {
|
||||
pub(crate) vertex_weights: Vec<VertexWeightSet>,
|
||||
}
|
||||
|
||||
uuid_provider!(Surface = "485caf12-4e7d-4b1a-b6bd-0681fd92f789");
|
||||
|
||||
impl Clone for Surface {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@@ -1451,7 +1443,7 @@ impl ResourceLoader for SurfaceDataLoader {
|
||||
}
|
||||
|
||||
fn data_type_uuid(&self) -> Uuid {
|
||||
<SurfaceData as TypeUuidProvider>::type_uuid()
|
||||
<SurfaceData as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn load(&self, path: PathBuf, io: Arc<dyn ResourceIo>) -> BoxedLoaderFuture {
|
||||
|
||||
@@ -59,7 +59,6 @@ use crate::{
|
||||
log::{Log, MessageKind},
|
||||
pool::{Handle, Pool, Ticket},
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
variable::InheritableVariable,
|
||||
visitor::{error::VisitError, Visit, VisitResult, Visitor},
|
||||
SafeLock,
|
||||
@@ -170,19 +169,9 @@ impl IndexMut<Handle<Navmesh>> for NavMeshContainer {
|
||||
/// A set of options, that allows selecting the source of environment lighting for a scene. By
|
||||
/// default, it is set to [`EnvironmentLightingSource::SkyBox`].
|
||||
#[derive(
|
||||
Reflect,
|
||||
Visit,
|
||||
Debug,
|
||||
Default,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
AsRefStr,
|
||||
EnumString,
|
||||
VariantNames,
|
||||
TypeUuidProvider,
|
||||
Reflect, Visit, Debug, Default, Clone, Copy, PartialEq, AsRefStr, EnumString, VariantNames,
|
||||
)]
|
||||
#[type_uuid(id = "28f22fe7-22ed-47e1-ae43-779866a46cdf")]
|
||||
#[reflect(type_uuid = "28f22fe7-22ed-47e1-ae43-779866a46cdf")]
|
||||
pub enum EnvironmentLightingSource {
|
||||
/// Sky box of a scene will be the source of lighting.
|
||||
#[default]
|
||||
@@ -193,6 +182,7 @@ pub enum EnvironmentLightingSource {
|
||||
|
||||
/// Rendering options of a scene. It allows you to specify a render target to render the scene to, change its clear color, etc.
|
||||
#[derive(Debug, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "74a58c1d-4f70-4a04-9cac-bfdaec63b321")]
|
||||
pub struct SceneRenderingOptions {
|
||||
/// A texture to draw the scene to. If empty, then the scene will be drawn on screen directly. It is useful to "embed" some scene into other
|
||||
/// by drawing a quad with this texture. This can be used to make in-game video conference - you can make separate scene with
|
||||
@@ -251,6 +241,7 @@ impl Clone for SceneRenderingOptions {
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Debug, Reflect)]
|
||||
#[reflect(type_uuid = "03b3f812-3518-429b-befe-3f7a160503fa")]
|
||||
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
|
||||
@@ -282,7 +273,7 @@ pub struct Scene {
|
||||
}
|
||||
|
||||
impl Reflect for &'static mut Scene {
|
||||
blank_reflect_ref!();
|
||||
blank_reflect_ref!("1258e495-5789-4aa4-a2c5-3f9f79bef5f4");
|
||||
}
|
||||
|
||||
impl Clone for Scene {
|
||||
|
||||
@@ -29,7 +29,6 @@ use crate::{
|
||||
parking_lot::RwLock,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -53,6 +52,7 @@ use std::{
|
||||
};
|
||||
|
||||
#[derive(Clone, Default, Reflect, Debug)]
|
||||
#[reflect(type_uuid = "7e5978ab-788b-4f41-a125-299ad89b81c7")]
|
||||
pub(crate) struct Container(Arc<RwLock<Navmesh>>);
|
||||
|
||||
impl PartialEq for Container {
|
||||
@@ -157,19 +157,16 @@ impl Visit for Container {
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Debug, Clone, Visit, Reflect, Default)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "d0ce963c-b50a-4707-bd21-af6dc0d1c668"
|
||||
)]
|
||||
pub struct NavigationalMesh {
|
||||
base: Base,
|
||||
#[reflect(read_only)]
|
||||
navmesh: InheritableVariable<Container>,
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for NavigationalMesh {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("d0ce963c-b50a-4707-bd21-af6dc0d1c668")
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for NavigationalMesh {
|
||||
type Target = Base;
|
||||
|
||||
@@ -215,7 +212,7 @@ impl NodeTrait for NavigationalMesh {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn debug_draw(&self, ctx: &mut SceneDrawingContext) {
|
||||
|
||||
@@ -36,6 +36,7 @@ use fyrox_core::visitor::error::VisitError;
|
||||
/// A wrapper for node pool record that allows to define custom visit method to have full
|
||||
/// control over instantiation process at deserialization.
|
||||
#[derive(Debug, Clone, Default, Reflect)]
|
||||
#[reflect(type_uuid = "be27db20-c0b0-491e-9421-8b1ebc357b9a")]
|
||||
pub struct NodeContainer(Option<Node>);
|
||||
|
||||
fn read_node(name: &str, visitor: &mut Visitor) -> Result<Node, VisitError> {
|
||||
|
||||
@@ -33,7 +33,7 @@ use crate::{
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
uuid::Uuid,
|
||||
uuid_provider, variable,
|
||||
variable,
|
||||
variable::mark_inheritable_properties_non_modified,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
NameProvider,
|
||||
@@ -359,6 +359,7 @@ impl<T: NodeTrait> ObjectOrVariantHelper<Node, T> for PhantomData<T> {
|
||||
/// of every field, even those inheritable variables which are non-modified. Which means that there's no benefits of RAM
|
||||
/// consumption, only disk space usage is reduced.
|
||||
#[derive(Debug, Reflect)]
|
||||
#[reflect(type_uuid = "a9bc5231-155c-4564-b0ca-f23972673925")]
|
||||
pub struct Node(#[reflect(deref, display_name = "Node")] pub(crate) Box<dyn NodeTrait>);
|
||||
|
||||
impl<T: NodeTrait> From<T> for Node {
|
||||
@@ -437,8 +438,6 @@ impl NameProvider for Node {
|
||||
}
|
||||
}
|
||||
|
||||
uuid_provider!(Node = "a9bc5231-155c-4564-b0ca-f23972673925");
|
||||
|
||||
impl Deref for Node {
|
||||
type Target = dyn NodeTrait;
|
||||
|
||||
@@ -588,7 +587,7 @@ mod test {
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::{prelude::*, Visitor},
|
||||
SafeLock, TypeUuidProvider,
|
||||
SafeLock,
|
||||
},
|
||||
engine::{self, SerializationContext},
|
||||
resource::model::{Model, ModelResourceExtension},
|
||||
@@ -610,17 +609,12 @@ mod test {
|
||||
use std::{fs, path::Path, sync::Arc};
|
||||
|
||||
#[derive(Debug, Clone, Reflect, Visit, Default)]
|
||||
#[reflect(type_uuid = "d3f66902-803f-4ace-8170-0aa485d98b40")]
|
||||
struct MyScript {
|
||||
some_field: InheritableVariable<String>,
|
||||
some_collection: InheritableVariable<Vec<u32>>,
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for MyScript {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("d3f66902-803f-4ace-8170-0aa485d98b40")
|
||||
}
|
||||
}
|
||||
|
||||
impl ScriptTrait for MyScript {}
|
||||
|
||||
fn create_scene() -> Scene {
|
||||
|
||||
@@ -31,6 +31,7 @@ use std::ops::Range;
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "61dcd2a8-58e5-4b53-92ed-7e0b531e1ed2")]
|
||||
pub struct BaseEmitter {
|
||||
/// Offset from center of particle system.
|
||||
position: Vector3<f32>,
|
||||
|
||||
@@ -37,6 +37,7 @@ use std::ops::{Deref, DerefMut};
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Debug, Clone, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "3afa3670-fa3f-4da2-b971-b0223b1309ec")]
|
||||
pub struct CuboidEmitter {
|
||||
emitter: BaseEmitter,
|
||||
#[reflect(min_value = 0.0, step = 0.1)]
|
||||
|
||||
@@ -35,6 +35,7 @@ use std::ops::{Deref, DerefMut};
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Clone, Debug, Visit, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "6cff3e6e-bc27-4f36-8b79-cdfbc46550b7")]
|
||||
pub struct CylinderEmitter {
|
||||
emitter: BaseEmitter,
|
||||
#[reflect(min_value = 0.0, step = 0.1)]
|
||||
|
||||
@@ -31,7 +31,7 @@ use crate::{
|
||||
Particle, ParticleSystemRng,
|
||||
},
|
||||
};
|
||||
use fyrox_core::uuid_provider;
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
|
||||
@@ -48,6 +48,7 @@ pub trait Emit {
|
||||
|
||||
/// See module docs.
|
||||
#[derive(PartialEq, Debug, Reflect, AsRefStr, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "4cad87ed-6b2c-411d-8c05-86dc26e463b2")]
|
||||
pub enum Emitter {
|
||||
/// See BoxEmitter docs.
|
||||
Cuboid(CuboidEmitter),
|
||||
@@ -57,8 +58,6 @@ pub enum Emitter {
|
||||
Cylinder(CylinderEmitter),
|
||||
}
|
||||
|
||||
uuid_provider!(Emitter = "4cad87ed-6b2c-411d-8c05-86dc26e463b2");
|
||||
|
||||
impl Emitter {
|
||||
/// Creates new emitter from given id.
|
||||
pub fn new(id: i32) -> Result<Self, String> {
|
||||
|
||||
@@ -36,6 +36,7 @@ use std::ops::{Deref, DerefMut};
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Debug, Clone, Reflect, PartialEq, Visit)]
|
||||
#[reflect(type_uuid = "5482aeb8-6a7c-4346-bb17-063b561f0e26")]
|
||||
pub struct SphereEmitter {
|
||||
emitter: BaseEmitter,
|
||||
#[reflect(min_value = 0.0, step = 0.1)]
|
||||
|
||||
@@ -30,7 +30,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, TriangleDefinition},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
value_as_u8_slice,
|
||||
variable::InheritableVariable,
|
||||
@@ -65,6 +64,7 @@ pub mod particle;
|
||||
|
||||
/// Pseudo-random numbers generator for particle systems.
|
||||
#[derive(Debug, Clone, Reflect)]
|
||||
#[reflect(type_uuid = "13d58184-e65c-41a3-9986-fc8d31231636")]
|
||||
pub struct ParticleSystemRng {
|
||||
rng_seed: u64,
|
||||
|
||||
@@ -219,7 +219,10 @@ impl Visit for ParticleSystemRng {
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Debug, Clone, Reflect)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "8b210eff-97a4-494f-ba7a-a581d3f4a442"
|
||||
)]
|
||||
pub struct ParticleSystem {
|
||||
base: Base,
|
||||
|
||||
@@ -278,9 +281,8 @@ pub struct ParticleSystem {
|
||||
AsRefStr,
|
||||
EnumString,
|
||||
VariantNames,
|
||||
TypeUuidProvider,
|
||||
)]
|
||||
#[type_uuid(id = "d19e13ec-03d5-4c88-b0b2-d161d1912632")]
|
||||
#[reflect(type_uuid = "d19e13ec-03d5-4c88-b0b2-d161d1912632")]
|
||||
pub enum CoordinateSystem {
|
||||
/// Local coordinate system moves particles together with the particle system itself. For example
|
||||
/// if a particle system is moved, rotated, scaled, etc. then the particle will be moved, rotated,
|
||||
@@ -335,12 +337,6 @@ impl DerefMut for ParticleSystem {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for ParticleSystem {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("8b210eff-97a4-494f-ba7a-a581d3f4a442")
|
||||
}
|
||||
}
|
||||
|
||||
impl ParticleSystem {
|
||||
/// Returns current acceleration for particles in particle system.
|
||||
pub fn acceleration(&self) -> Vector3<f32> {
|
||||
@@ -547,7 +543,7 @@ impl NodeTrait for ParticleSystem {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn update(&mut self, context: &mut UpdateContext) {
|
||||
|
||||
@@ -25,7 +25,6 @@ use crate::{
|
||||
math::aabb::AxisAlignedBoundingBox,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
visitor::prelude::*,
|
||||
},
|
||||
@@ -41,7 +40,10 @@ use std::ops::{Deref, DerefMut};
|
||||
|
||||
/// A simplest possible node which represents point in space.
|
||||
#[derive(Clone, Reflect, Default, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "dd2ecb96-b1f4-4ee0-943b-2a4d1844e3bb"
|
||||
)]
|
||||
pub struct Pivot {
|
||||
base: Base,
|
||||
}
|
||||
@@ -60,12 +62,6 @@ impl Deref for Pivot {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Pivot {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("dd2ecb96-b1f4-4ee0-943b-2a4d1844e3bb")
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Pivot {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.base
|
||||
@@ -92,7 +88,7 @@ impl NodeTrait for Pivot {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ use crate::{
|
||||
math::aabb::AxisAlignedBoundingBox,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -52,19 +51,8 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
const DEFAULT_RESOLUTION: usize = 512;
|
||||
|
||||
/// Update mode of reflection probes.
|
||||
#[derive(
|
||||
Clone,
|
||||
Reflect,
|
||||
PartialEq,
|
||||
Default,
|
||||
Debug,
|
||||
Visit,
|
||||
TypeUuidProvider,
|
||||
AsRefStr,
|
||||
EnumString,
|
||||
VariantNames,
|
||||
)]
|
||||
#[type_uuid(id = "66450303-4f6c-4456-bde5-a7309f25b7ce")]
|
||||
#[derive(Clone, Reflect, PartialEq, Default, Debug, Visit, AsRefStr, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "66450303-4f6c-4456-bde5-a7309f25b7ce")]
|
||||
pub enum UpdateMode {
|
||||
/// The probe will be updated once it is created and its content won't change until the
|
||||
/// [`ReflectionProbe::force_update`] call.
|
||||
@@ -140,8 +128,8 @@ pub enum UpdateMode {
|
||||
/// .build(graph)
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Clone, Reflect, Debug, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "7e0c138f-e371-4045-bd2c-ff5b165c7ee6")]
|
||||
#[derive(Clone, Reflect, Debug, Visit)]
|
||||
#[reflect(type_uuid = "7e0c138f-e371-4045-bd2c-ff5b165c7ee6")]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[visit(optional, post_visit_method = "on_visited")]
|
||||
pub struct ReflectionProbe {
|
||||
@@ -282,7 +270,7 @@ impl NodeTrait for ReflectionProbe {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn update(&mut self, _context: &mut UpdateContext) {
|
||||
|
||||
@@ -29,9 +29,7 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, Matrix4Ext},
|
||||
pool::{Handle, PoolError},
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
uuid_provider,
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
},
|
||||
@@ -50,6 +48,7 @@ use std::ops::{Deref, DerefMut};
|
||||
/// A part of ragdoll, that has a physical rigid body, a bone and zero or more children limbs.
|
||||
/// Multiple limbs together forms a ragdoll.
|
||||
#[derive(Clone, Debug, PartialEq, Default, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "6d5bc2f7-8acc-4b64-8e4b-65d4551150bf")]
|
||||
pub struct Limb {
|
||||
/// A handle of a scene node, that is used as a bone in some other scene node (mesh).
|
||||
pub bone: Handle<Node>,
|
||||
@@ -59,8 +58,6 @@ pub struct Limb {
|
||||
pub children: Vec<Limb>,
|
||||
}
|
||||
|
||||
uuid_provider!(Limb = "6d5bc2f7-8acc-4b64-8e4b-65d4551150bf");
|
||||
|
||||
impl Limb {
|
||||
/// Iterates recursively across the entire tree of descendant limbs and does the specified action
|
||||
/// with every limb along the way.
|
||||
@@ -89,7 +86,10 @@ impl Limb {
|
||||
/// you're brave enough you can read this code <https://github.com/FyroxEngine/Fyrox/blob/master/editor/src/utils/ragdoll.rs> -
|
||||
/// it creates a ragdoll using a humanoid skeleton.
|
||||
#[derive(Clone, Reflect, Visit, Debug, Default)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "f4441683-dcef-472d-9d7d-4adca4579107"
|
||||
)]
|
||||
#[visit(optional)]
|
||||
pub struct Ragdoll {
|
||||
base: Base,
|
||||
@@ -123,12 +123,6 @@ impl DerefMut for Ragdoll {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Ragdoll {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("f4441683-dcef-472d-9d7d-4adca4579107")
|
||||
}
|
||||
}
|
||||
|
||||
impl ConstructorProvider<Node, Graph> for Ragdoll {
|
||||
fn constructor() -> NodeConstructor {
|
||||
NodeConstructor::new::<Self>()
|
||||
@@ -151,7 +145,7 @@ impl NodeTrait for Ragdoll {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn update(&mut self, ctx: &mut UpdateContext) {
|
||||
|
||||
@@ -38,7 +38,6 @@ use crate::{
|
||||
parking_lot::Mutex,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -51,7 +50,7 @@ use crate::{
|
||||
Scene,
|
||||
},
|
||||
};
|
||||
use fyrox_core::uuid_provider;
|
||||
|
||||
use fyrox_graph::constructor::ConstructorProvider;
|
||||
use fyrox_graph::SceneGraph;
|
||||
use rapier3d::{dynamics, prelude::RigidBodyHandle};
|
||||
@@ -69,6 +68,7 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
)]
|
||||
#[repr(u32)]
|
||||
#[derive(Default)]
|
||||
#[reflect(type_uuid = "562d2907-1b41-483a-8ca2-12eebaff7f5d")]
|
||||
pub enum RigidBodyType {
|
||||
/// Dynamic rigid bodies can be affected by external forces.
|
||||
#[default]
|
||||
@@ -83,8 +83,6 @@ pub enum RigidBodyType {
|
||||
KinematicVelocityBased = 3,
|
||||
}
|
||||
|
||||
uuid_provider!(RigidBodyType = "562d2907-1b41-483a-8ca2-12eebaff7f5d");
|
||||
|
||||
impl From<dynamics::RigidBodyType> for RigidBodyType {
|
||||
fn from(s: dynamics::RigidBodyType) -> Self {
|
||||
match s {
|
||||
@@ -146,8 +144,9 @@ pub(crate) enum ApplyAction {
|
||||
NextPosition(Isometry3<f32>),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Reflect, Visit, PartialEq, AsRefStr, EnumString, VariantNames)]
|
||||
/// Possible types of rigidbody mass properties
|
||||
#[derive(Copy, Clone, Debug, Reflect, Visit, PartialEq, AsRefStr, EnumString, VariantNames)]
|
||||
#[reflect(type_uuid = "663b6a92-9c0f-4f47-b66a-6b4293312a5d")]
|
||||
pub enum RigidBodyMassPropertiesType {
|
||||
/// Use default mass properties
|
||||
Default,
|
||||
@@ -159,7 +158,6 @@ pub enum RigidBodyMassPropertiesType {
|
||||
principal_inertia: Vector3<f32>,
|
||||
},
|
||||
}
|
||||
uuid_provider!(RigidBodyMassPropertiesType = "663b6a92-9c0f-4f47-b66a-6b4293312a5d");
|
||||
|
||||
/// Rigid body is a physics entity that responsible for the dynamics and kinematics of the solid.
|
||||
/// Use this node when you need to simulate real-world physics in your game.
|
||||
@@ -169,7 +167,10 @@ uuid_provider!(RigidBodyMassPropertiesType = "663b6a92-9c0f-4f47-b66a-6b4293312a
|
||||
/// 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, Reflect)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "4be15a7c-3566-49c4-bba8-2f4ccc57ffed"
|
||||
)]
|
||||
pub struct RigidBody {
|
||||
base: Base,
|
||||
|
||||
@@ -311,12 +312,6 @@ impl Clone for RigidBody {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for RigidBody {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("4be15a7c-3566-49c4-bba8-2f4ccc57ffed")
|
||||
}
|
||||
}
|
||||
|
||||
impl RigidBody {
|
||||
/// Sets new linear velocity of the rigid body. Changing this parameter will wake up the rigid
|
||||
/// body!
|
||||
@@ -630,7 +625,7 @@ impl NodeTrait for RigidBody {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn on_removed_from_graph(&mut self, graph: &mut Graph) {
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::{fmt::Display, sync::LazyLock};
|
||||
|
||||
use crate::{
|
||||
asset::{builtin::BuiltInResource, embedded_data_source, untyped::ResourceKind},
|
||||
core::{log::Log, reflect::prelude::*, uuid_provider, visitor::prelude::*},
|
||||
core::{log::Log, reflect::prelude::*, visitor::prelude::*},
|
||||
};
|
||||
use fyrox_core::color::Color;
|
||||
use fyrox_texture::{
|
||||
@@ -39,6 +39,7 @@ use uuid::{uuid, Uuid};
|
||||
/// 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, Reflect, Visit, Eq)]
|
||||
#[reflect(type_uuid = "45f359f1-e26f-4ace-81df-097f63474c72")]
|
||||
pub struct SkyBox {
|
||||
/// Texture for front face.
|
||||
#[reflect(setter = "set_front")]
|
||||
@@ -70,8 +71,6 @@ pub struct SkyBox {
|
||||
pub(crate) cubemap: Option<TextureResource>,
|
||||
}
|
||||
|
||||
uuid_provider!(SkyBox = "45f359f1-e26f-4ace-81df-097f63474c72");
|
||||
|
||||
impl SkyBox {
|
||||
/// Creates a new sky box from a single color.
|
||||
pub fn from_single_color(color: Color) -> Self {
|
||||
|
||||
@@ -29,7 +29,6 @@ use crate::{
|
||||
math::aabb::AxisAlignedBoundingBox,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
visitor::prelude::*,
|
||||
},
|
||||
@@ -58,7 +57,10 @@ use std::ops::{Deref, DerefMut};
|
||||
/// 2D sound sources (with spatial blend == 0.0) are not influenced by listener's position and
|
||||
/// orientation.
|
||||
#[derive(Visit, Reflect, Default, Clone, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "2c7dabc1-5666-4256-b020-01532701e4c6"
|
||||
)]
|
||||
pub struct Listener {
|
||||
base: Base,
|
||||
}
|
||||
@@ -77,12 +79,6 @@ impl DerefMut for Listener {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Listener {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("2c7dabc1-5666-4256-b020-01532701e4c6")
|
||||
}
|
||||
}
|
||||
|
||||
impl ConstructorProvider<Node, Graph> for Listener {
|
||||
fn constructor() -> NodeConstructor {
|
||||
NodeConstructor::new::<Self>()
|
||||
@@ -110,7 +106,7 @@ impl NodeTrait for Listener {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn sync_native(&self, _self_handle: Handle<Node>, context: &mut SyncContext) {
|
||||
|
||||
@@ -26,7 +26,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, m4x4_approx_eq},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -74,7 +73,10 @@ pub mod listener;
|
||||
|
||||
/// Sound source.
|
||||
#[derive(Visit, Reflect, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "28621735-8cd1-4fad-8faf-ecd24bf8aa99"
|
||||
)]
|
||||
pub struct Sound {
|
||||
base: Base,
|
||||
|
||||
@@ -189,12 +191,6 @@ impl Clone for Sound {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Sound {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("28621735-8cd1-4fad-8faf-ecd24bf8aa99")
|
||||
}
|
||||
}
|
||||
|
||||
impl Sound {
|
||||
/// Changes buffer of source. Source will continue playing from beginning, old
|
||||
/// position will be discarded.
|
||||
@@ -410,7 +406,7 @@ impl NodeTrait for Sound {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn on_removed_from_graph(&mut self, graph: &mut Graph) {
|
||||
|
||||
@@ -30,7 +30,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, Rect, TriangleDefinition},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
value_as_u8_slice,
|
||||
variable::InheritableVariable,
|
||||
@@ -155,7 +154,10 @@ impl VertexTrait for SpriteVertex {
|
||||
/// to get the best possible performance. Otherwise, each your sprite will be put in a separate batch
|
||||
/// which will force your GPU to render a single sprite in dedicated draw call which is quite slow.
|
||||
#[derive(Debug, Reflect, Clone, Visit)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "60fd7e34-46c1-4ae9-8803-1f5f4c341518"
|
||||
)]
|
||||
pub struct Sprite {
|
||||
base: Base,
|
||||
|
||||
@@ -201,12 +203,6 @@ impl Default for Sprite {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Sprite {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("60fd7e34-46c1-4ae9-8803-1f5f4c341518")
|
||||
}
|
||||
}
|
||||
|
||||
impl Sprite {
|
||||
/// Sets new size of sprite. Since sprite is always square, size defines half of width or height, so actual size
|
||||
/// will be doubled. Default value is 0.2.
|
||||
@@ -320,7 +316,7 @@ impl NodeTrait for Sprite {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn collect_render_data(&self, ctx: &mut RenderContext) -> RdcControlFlow {
|
||||
|
||||
@@ -50,7 +50,7 @@ use crate::core::{
|
||||
use crate::fxhash::FxHashMap;
|
||||
use crate::resource::texture::{Texture, TextureResource};
|
||||
use crate::scene::node::Node;
|
||||
use fyrox_core::uuid_provider;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::mpsc::{Receiver, SendError, Sender};
|
||||
|
||||
@@ -685,6 +685,7 @@ impl<V> StrokeData<V> {
|
||||
|
||||
/// Shape of a brush.
|
||||
#[derive(Copy, Clone, Reflect, Debug)]
|
||||
#[reflect(type_uuid = "a4dbfba0-077c-4658-9972-38384a8432f9")]
|
||||
pub enum BrushShape {
|
||||
/// Circle with given radius.
|
||||
Circle {
|
||||
@@ -700,8 +701,6 @@ pub enum BrushShape {
|
||||
},
|
||||
}
|
||||
|
||||
uuid_provider!(BrushShape = "a4dbfba0-077c-4658-9972-38384a8432f9");
|
||||
|
||||
impl Default for BrushShape {
|
||||
fn default() -> Self {
|
||||
BrushShape::Circle { radius: 1.0 }
|
||||
@@ -726,6 +725,7 @@ impl BrushShape {
|
||||
|
||||
/// Paint mode of a brush. It defines operation that will be performed on the terrain.
|
||||
#[derive(Clone, PartialEq, PartialOrd, Reflect, Debug)]
|
||||
#[reflect(type_uuid = "48ad4cac-05f3-485a-b2a3-66812713841f")]
|
||||
pub enum BrushMode {
|
||||
/// Raise or lower the value
|
||||
Raise {
|
||||
@@ -750,8 +750,6 @@ pub enum BrushMode {
|
||||
},
|
||||
}
|
||||
|
||||
uuid_provider!(BrushMode = "48ad4cac-05f3-485a-b2a3-66812713841f");
|
||||
|
||||
impl Default for BrushMode {
|
||||
fn default() -> Self {
|
||||
BrushMode::Raise { amount: 1.0 }
|
||||
@@ -760,6 +758,7 @@ impl Default for BrushMode {
|
||||
|
||||
/// Paint target of a brush. It defines the data that the brush will operate on.
|
||||
#[derive(Copy, Default, Clone, Reflect, Debug, PartialEq, Eq)]
|
||||
#[reflect(type_uuid = "461c1be7-189e-44ee-b8fd-00b8fdbc668f")]
|
||||
pub enum BrushTarget {
|
||||
#[default]
|
||||
/// Modifies the height map
|
||||
@@ -773,10 +772,9 @@ pub enum BrushTarget {
|
||||
HoleMask,
|
||||
}
|
||||
|
||||
uuid_provider!(BrushTarget = "461c1be7-189e-44ee-b8fd-00b8fdbc668f");
|
||||
|
||||
/// Brush is used to modify terrain. It supports multiple shapes and modes.
|
||||
#[derive(Clone, Reflect, Debug)]
|
||||
#[reflect(type_uuid = "dcc4c17b-dad6-42ba-accf-8b88aa2ad31b")]
|
||||
pub struct Brush {
|
||||
/// Shape of the brush.
|
||||
pub shape: BrushShape,
|
||||
|
||||
@@ -30,8 +30,8 @@ use crate::{
|
||||
vertex::StaticVertex,
|
||||
},
|
||||
};
|
||||
use fyrox_core::Uuid;
|
||||
use fyrox_resource::untyped::ResourceKind;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// The [SurfaceSharedData](crate::scene::mesh::surface::SurfaceResource) of a grid mesh for use
|
||||
/// in rendering a terrain.
|
||||
|
||||
@@ -30,7 +30,6 @@ use crate::{
|
||||
parking_lot::Mutex,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
uuid::{uuid, Uuid},
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
@@ -60,7 +59,7 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use fxhash::FxHashMap;
|
||||
use fyrox_core::{uuid_provider, warn};
|
||||
use fyrox_core::warn;
|
||||
use fyrox_graph::SceneGraph;
|
||||
use fyrox_resource::untyped::ResourceKind;
|
||||
use half::f16;
|
||||
@@ -243,6 +242,7 @@ impl std::ops::IndexMut<Vector2<i32>> for ChunkHeightMutData<'_> {
|
||||
/// performance, so keep amount of layers on reasonable level (1 - 5 should be enough for most
|
||||
/// cases).
|
||||
#[derive(Debug, Clone, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "7439d5fd-43a9-45f0-bd7c-76cf4d2ec22e")]
|
||||
pub struct Layer {
|
||||
/// Material of the layer.
|
||||
pub material: MaterialResource,
|
||||
@@ -263,8 +263,6 @@ pub struct Layer {
|
||||
pub node_uv_offsets_property_name: String,
|
||||
}
|
||||
|
||||
uuid_provider!(Layer = "7439d5fd-43a9-45f0-bd7c-76cf4d2ec22e");
|
||||
|
||||
impl Default for Layer {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -350,6 +348,7 @@ fn make_height_map_texture(height_map: Vec<f32>, size: Vector2<u32>) -> TextureR
|
||||
/// use its own set of materials for layers. This could be useful for different biomes, to prevent high amount of
|
||||
/// layers which could harm the performance.
|
||||
#[derive(Debug, Reflect)]
|
||||
#[reflect(type_uuid = "ae996754-69c1-49ba-9c17-a7bd4be072a9")]
|
||||
pub struct Chunk {
|
||||
#[reflect(hidden)]
|
||||
quad_tree: Mutex<QuadTree>,
|
||||
@@ -377,8 +376,6 @@ pub struct Chunk {
|
||||
height_map_modifications_count: u64,
|
||||
}
|
||||
|
||||
uuid_provider!(Chunk = "ae996754-69c1-49ba-9c17-a7bd4be072a9");
|
||||
|
||||
impl PartialEq for Chunk {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.heightmap == other.heightmap
|
||||
@@ -1033,7 +1030,10 @@ impl BrushContext {
|
||||
/// overlap with their neighbors just as chunks overlap. Two adjacent blocks share vertices along their edge,
|
||||
/// so they also share pixels in the height map data.
|
||||
#[derive(Debug, Reflect, Clone)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[reflect(
|
||||
derived_type = "Node",
|
||||
type_uuid = "4b0a7927-bcd8-41a3-949a-dd10fba8e16a"
|
||||
)]
|
||||
pub struct Terrain {
|
||||
base: Base,
|
||||
|
||||
@@ -1259,12 +1259,6 @@ fn create_zero_margin(mut data: Vec<f32>, data_size: Vector2<u32>) -> Vec<f32> {
|
||||
data
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Terrain {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("4b0a7927-bcd8-41a3-949a-dd10fba8e16a")
|
||||
}
|
||||
}
|
||||
|
||||
impl Terrain {
|
||||
/// The height map of a chunk must have one-pixel margins around the edges which do not correspond
|
||||
/// to vertices in the terrain of that chunk, but are still needed for calculating the normal of
|
||||
@@ -2432,7 +2426,7 @@ impl NodeTrait for Terrain {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn collect_render_data(&self, ctx: &mut RenderContext) -> RdcControlFlow {
|
||||
|
||||
@@ -43,7 +43,6 @@ use crate::{
|
||||
color::Color,
|
||||
io::FileError,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
visitor::prelude::*,
|
||||
},
|
||||
scene::debug::SceneDrawingContext,
|
||||
@@ -100,6 +99,7 @@ impl From<VisitError> for TileMapBrushResourceError {
|
||||
/// with the UUID of some macro or other user, and it is up to the user to determine
|
||||
/// the type of the resource.
|
||||
#[derive(Debug, Clone, Default, Reflect)]
|
||||
#[reflect(type_uuid = "a3427eef-8d8e-4573-a328-ab06e1d56e25")]
|
||||
pub struct BrushMacroInstanceList(Vec<BrushMacroData>);
|
||||
|
||||
impl BrushMacroInstanceList {
|
||||
@@ -160,6 +160,7 @@ impl Visit for BrushMacroInstanceList {
|
||||
/// A brush can have zero or more instances of a macro, and each instance
|
||||
/// has its own configuration data.
|
||||
#[derive(Debug, Default, Clone, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "3aa87ac2-c05f-4e9b-86eb-ee846a364585")]
|
||||
pub struct BrushMacroData {
|
||||
/// The UUID of the macro that owns this instance data.
|
||||
/// This is used to identify the macro that knows the type of this data.
|
||||
@@ -178,6 +179,7 @@ pub struct BrushMacroData {
|
||||
/// A page of tiles within a brush. Having multiple pages allows a brush to be optimized
|
||||
/// for use in multiple contexts.
|
||||
#[derive(Default, Debug, Clone, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "1e3de522-678b-4922-b959-76a6045de788")]
|
||||
pub struct TileMapBrushPage {
|
||||
/// The tile that represents this page in the editor
|
||||
pub icon: TileDefinitionHandle,
|
||||
@@ -240,8 +242,8 @@ fn draw_tile_outline(
|
||||
|
||||
/// Tile map brush is a set of tiles arranged in arbitrary shape, that can be used to draw on a tile
|
||||
/// map.
|
||||
#[derive(Default, Debug, Clone, Visit, Reflect, TypeUuidProvider)]
|
||||
#[type_uuid(id = "23ed39da-cb01-4181-a058-94dc77ecb4b2")]
|
||||
#[derive(Default, Debug, Clone, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "23ed39da-cb01-4181-a058-94dc77ecb4b2")]
|
||||
pub struct TileMapBrush {
|
||||
/// The tile set used by this brush. This must match the tile set of any tile map that this
|
||||
/// brush is used to edit.
|
||||
@@ -557,10 +559,6 @@ impl TileMapBrush {
|
||||
}
|
||||
|
||||
impl ResourceData for TileMapBrush {
|
||||
fn type_uuid(&self) -> Uuid {
|
||||
<Self as TypeUuidProvider>::type_uuid()
|
||||
}
|
||||
|
||||
fn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
self.save(path)
|
||||
}
|
||||
@@ -590,7 +588,7 @@ impl ResourceLoader for TileMapBrushLoader {
|
||||
}
|
||||
|
||||
fn data_type_uuid(&self) -> Uuid {
|
||||
<TileMapBrush as TypeUuidProvider>::type_uuid()
|
||||
<TileMapBrush as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn load(&self, path: PathBuf, io: Arc<dyn ResourceIo>) -> BoxedLoaderFuture {
|
||||
|
||||
@@ -24,9 +24,7 @@ use crate::asset::{Resource, ResourceData};
|
||||
use fxhash::FxHashMap;
|
||||
use fyrox_core::visitor::BinaryBlob;
|
||||
|
||||
use crate::core::{
|
||||
algebra::Vector2, reflect::prelude::*, type_traits::prelude::*, visitor::prelude::*,
|
||||
};
|
||||
use crate::core::{algebra::Vector2, reflect::prelude::*, visitor::prelude::*};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -53,6 +51,7 @@ fn tile_position_to_chunk_position(position: Vector2<i32>) -> (Vector2<i32>, Vec
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Reflect)]
|
||||
#[reflect(type_uuid = "dad649ae-eb5f-4328-832a-891edd79aff5")]
|
||||
struct Chunk([TileDefinitionHandle; CHUNK_WIDTH * CHUNK_HEIGHT]);
|
||||
|
||||
impl Visit for Chunk {
|
||||
@@ -177,8 +176,8 @@ impl<'a, P: FnMut(Vector2<i32>) -> bool> TileMapDataIterator<'a, P> {
|
||||
}
|
||||
|
||||
/// Asset containing the tile handles of a tile map.
|
||||
#[derive(Clone, Default, Debug, Reflect, TypeUuidProvider)]
|
||||
#[type_uuid(id = "a8e4b6b4-c1bd-4ed9-a753-0d5a3dfe1729")]
|
||||
#[derive(Clone, Default, Debug, Reflect)]
|
||||
#[reflect(type_uuid = "a8e4b6b4-c1bd-4ed9-a753-0d5a3dfe1729")]
|
||||
pub struct TileMapData {
|
||||
content: FxHashMap<Vector2<i32>, Chunk>,
|
||||
}
|
||||
@@ -193,10 +192,6 @@ impl Visit for TileMapData {
|
||||
}
|
||||
|
||||
impl ResourceData for TileMapData {
|
||||
fn type_uuid(&self) -> Uuid {
|
||||
<Self as TypeUuidProvider>::type_uuid()
|
||||
}
|
||||
|
||||
fn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
let mut visitor = Visitor::new();
|
||||
self.visit("TileMapData", &mut visitor)?;
|
||||
|
||||
@@ -59,7 +59,6 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, Matrix4Ext, TriangleDefinition},
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
variable::InheritableVariable,
|
||||
visitor::prelude::*,
|
||||
ImmutableString, SafeLock,
|
||||
@@ -365,6 +364,7 @@ impl VertexTrait for TileVertex {
|
||||
/// Giving a particular `TilePaletteStage` to a tile map palette will control which kind of
|
||||
/// tiles it will display.
|
||||
#[derive(Clone, Copy, Default, Debug, Visit, Reflect, PartialEq)]
|
||||
#[reflect(type_uuid = "05cec1a9-faa9-45a2-a4a4-245849cb2fb4")]
|
||||
pub enum TilePaletteStage {
|
||||
/// The page tile stage. These tiles allow the user to select which page they want to use.
|
||||
#[default]
|
||||
@@ -403,6 +403,7 @@ pub enum PageType {
|
||||
/// [`TileRenderData`]. For pages this is due to having an icon to allow the user to select the page.
|
||||
/// Both pages and tiles can be selected by the user, moved, and deleted.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "be84a122-3d0f-4a9f-8bba-d55cf8583aad")]
|
||||
pub enum ResourceTilePosition {
|
||||
/// This position refers to some page, and so it lacks tile coordinates.
|
||||
Page(Vector2<i32>),
|
||||
@@ -487,8 +488,8 @@ impl ResourceTilePosition {
|
||||
|
||||
/// Tile is a base block of a tile map. It has a position and a handle of tile definition, stored
|
||||
/// in the respective tile set.
|
||||
#[derive(Clone, Reflect, Default, Debug, PartialEq, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "e429ca1b-a311-46c3-b580-d5a2f49db7e2")]
|
||||
#[derive(Clone, Reflect, Default, Debug, PartialEq, Visit)]
|
||||
#[reflect(type_uuid = "e429ca1b-a311-46c3-b580-d5a2f49db7e2")]
|
||||
pub struct Tile {
|
||||
/// Position of the tile (in grid coordinates).
|
||||
pub position: Vector2<i32>,
|
||||
@@ -518,10 +519,11 @@ impl<I: Iterator<Item = Vector2<i32>>> Iterator for TileIter<I> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Visit, Reflect)]
|
||||
/// Abstract source of tiles, which can either be a tile set or a brush.
|
||||
/// It is called a "book" because each of these tile resources contains
|
||||
/// pages of tiles.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "76563800-35fa-46aa-bb58-5f358d769654")]
|
||||
pub enum TileBook {
|
||||
/// A tile resource containing no tiles.
|
||||
#[default]
|
||||
@@ -951,9 +953,9 @@ impl OrthoTransform for TileRenderData {
|
||||
/// which contains all the pages that may be referenced by the tile map's handles.
|
||||
///
|
||||
/// Optional [`TileMapEffect`] objects may be included in the `TileMap` to change how it renders.
|
||||
#[derive(Reflect, Debug, TypeUuidProvider)]
|
||||
#[derive(Reflect, Debug)]
|
||||
#[reflect(derived_type = "Node")]
|
||||
#[type_uuid(id = "aa9a3385-a4af-4faf-a69a-8d3af1a3aa67")]
|
||||
#[reflect(type_uuid = "aa9a3385-a4af-4faf-a69a-8d3af1a3aa67")]
|
||||
pub struct TileMap {
|
||||
base: Base,
|
||||
/// The source of rendering data for tiles in this tile map.
|
||||
@@ -1393,7 +1395,7 @@ impl NodeTrait for TileMap {
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
Self::type_uuid()
|
||||
<Self as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn collect_render_data(&self, ctx: &mut RenderContext) -> RdcControlFlow {
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
//! so the user can see each tile's shape and the shepe's layer at a glance.
|
||||
|
||||
use crate::core::{
|
||||
algebra::Vector2, color::Color, num_traits::Euclid, reflect::prelude::*,
|
||||
type_traits::prelude::*, visitor::prelude::*, ImmutableString,
|
||||
algebra::Vector2, color::Color, num_traits::Euclid, reflect::prelude::*, visitor::prelude::*,
|
||||
ImmutableString,
|
||||
};
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
|
||||
@@ -69,15 +69,19 @@ pub trait TileSetPropertyId {
|
||||
|
||||
/// UUID for a property with values of type i32.
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "013a1dfe-2f5c-4e55-91af-f234048ba2ea")]
|
||||
pub struct TileSetPropertyI32(pub Uuid);
|
||||
/// UUID for a property with values of type f32.
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "1b59e7b8-aa07-455e-a153-085e9603183b")]
|
||||
pub struct TileSetPropertyF32(pub Uuid);
|
||||
/// UUID for a property with values of type ImmutableString.
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "86af5ddd-037b-4687-8142-6e859f9f3145")]
|
||||
pub struct TileSetPropertyString(pub Uuid);
|
||||
/// UUID for a property with values of type [`NineI8`].
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "8546733a-3d3b-49b3-88c9-d2066f920c2f")]
|
||||
pub struct TileSetPropertyNine(pub Uuid);
|
||||
|
||||
impl TileSetPropertyId for TileSetPropertyI32 {
|
||||
@@ -112,6 +116,7 @@ impl TileSetPropertyId for TileSetPropertyNine {
|
||||
/// tile set data must allow each tile to include multiple values for its collider information.
|
||||
/// These multiple collider values are associated with their collider objects by a UUID and a name.
|
||||
#[derive(Clone, Default, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "f61cca93-6df4-44d6-a9da-902d82e0c401")]
|
||||
pub struct TileSetColliderLayer {
|
||||
/// The id number that identifies the collider
|
||||
pub uuid: Uuid,
|
||||
@@ -125,6 +130,7 @@ pub struct TileSetColliderLayer {
|
||||
/// across all tiles in a tile set. A tile property layer represents the association between a property name
|
||||
/// and its data type, along with other information.
|
||||
#[derive(Clone, Default, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "99967dc1-b358-4480-8cd6-e519d6deecb5")]
|
||||
pub struct TileSetPropertyLayer {
|
||||
/// The id number that identifies this property
|
||||
pub uuid: Uuid,
|
||||
@@ -140,6 +146,7 @@ pub struct TileSetPropertyLayer {
|
||||
/// for the game that is using the values, so it is useful to be able to label those values
|
||||
/// so their special meaning can be visible in the editor.
|
||||
#[derive(Clone, Default, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "43913556-aebd-45ae-8d2a-c9ecc8e98e70")]
|
||||
pub struct NamedValue {
|
||||
/// The label associated with the value.
|
||||
pub name: String,
|
||||
@@ -152,6 +159,7 @@ pub struct NamedValue {
|
||||
/// Named values can be either an integer or a float.
|
||||
/// It would make little sense to name a string or a nine slice.
|
||||
#[derive(Copy, Clone, Debug, Reflect, Visit, PartialEq)]
|
||||
#[reflect(type_uuid = "e0d453bc-a71a-476f-ad49-a9c5b0bfb6de")]
|
||||
pub enum NamableValue {
|
||||
/// A value for an element of a nine-slice
|
||||
I8(i8),
|
||||
@@ -301,6 +309,7 @@ impl TileSetPropertyLayer {
|
||||
/// be stored in that property, as the data type will affect how the editor
|
||||
/// allows users to edit the property on each tile.
|
||||
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "20a3d9d4-b3f0-41e2-bade-96eac6f34a01")]
|
||||
pub enum TileSetPropertyType {
|
||||
/// The type for integer properties.
|
||||
#[default]
|
||||
@@ -341,6 +350,7 @@ impl TileSetPropertyType {
|
||||
|
||||
/// The data stored in a tile property.
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "f8bc82fc-641c-4005-af2a-35e31ab91880")]
|
||||
pub enum TileSetPropertyValue {
|
||||
/// Integer property data.
|
||||
I32(i32),
|
||||
@@ -359,6 +369,7 @@ pub enum TileSetPropertyValue {
|
||||
/// is assigned a color and tiles are arranged so that whenever two tiles are adjacent the touching edges
|
||||
/// are the same color.
|
||||
#[derive(Default, Clone, Copy, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "385699f4-3d1d-4e79-9a13-6520abb53daa")]
|
||||
pub struct NineI8(pub [i8; 9]);
|
||||
|
||||
impl Visit for NineI8 {
|
||||
@@ -426,6 +437,7 @@ impl NineI8 {
|
||||
/// For most value types, the element is the whole of the value,
|
||||
/// but a nine-slice value contains nine elements.
|
||||
#[derive(Clone, Debug, PartialEq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "f116c004-8f0a-4f96-9967-e50eae542433")]
|
||||
pub enum TileSetPropertyValueElement {
|
||||
/// Integer property data.
|
||||
I32(i32),
|
||||
@@ -574,6 +586,7 @@ impl TileSetPropertyValue {
|
||||
/// A representation of data stored in a tile property, or the absence of that data
|
||||
/// when the data is unknown.
|
||||
#[derive(Clone, Debug, PartialEq, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "ad0584b2-fccb-4bd5-a3fb-6c15a74148ba")]
|
||||
pub enum TileSetPropertyOptionValue {
|
||||
/// Integer property data.
|
||||
I32(Option<i32>),
|
||||
|
||||
@@ -30,7 +30,6 @@ use crate::{
|
||||
core::{
|
||||
algebra::{Matrix4, Point3, Vector2},
|
||||
reflect::prelude::*,
|
||||
type_traits::prelude::*,
|
||||
visitor::prelude::*,
|
||||
},
|
||||
};
|
||||
@@ -46,19 +45,9 @@ use strum_macros::{AsRefStr, EnumString, VariantNames};
|
||||
|
||||
/// Supported collider types for tiles.
|
||||
#[derive(
|
||||
Clone,
|
||||
Hash,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Default,
|
||||
Visit,
|
||||
Reflect,
|
||||
AsRefStr,
|
||||
EnumString,
|
||||
VariantNames,
|
||||
TypeUuidProvider,
|
||||
Clone, Hash, PartialEq, Eq, Default, Visit, Reflect, AsRefStr, EnumString, VariantNames,
|
||||
)]
|
||||
#[type_uuid(id = "04a44fec-394f-4497-97d5-fe9e6f915831")]
|
||||
#[reflect(type_uuid = "04a44fec-394f-4497-97d5-fe9e6f915831")]
|
||||
pub enum TileCollider {
|
||||
/// No collider.
|
||||
#[default]
|
||||
@@ -178,8 +167,8 @@ pub type CustomTileColliderResource = Resource<CustomTileCollider>;
|
||||
/// a valid string for a custom tile collider. The commas (,) are used to connect two numbers
|
||||
/// as being part of the same group. Any other characters are ignored, so this would also be
|
||||
/// accepted: "(0,0) (1,1) (1,0) \[0,1,2\]".
|
||||
#[derive(Clone, PartialEq, Debug, Default, Visit, Reflect, TypeUuidProvider)]
|
||||
#[type_uuid(id = "118da556-a444-4bd9-bd88-12d78d26107f")]
|
||||
#[derive(Clone, PartialEq, Debug, Default, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "118da556-a444-4bd9-bd88-12d78d26107f")]
|
||||
pub struct CustomTileCollider {
|
||||
/// The vertices of the triangles, with the boundaries of the tile being between (0,0) and (1,1).
|
||||
pub vertices: Vec<Vector2<f32>>,
|
||||
@@ -188,10 +177,6 @@ pub struct CustomTileCollider {
|
||||
}
|
||||
|
||||
impl ResourceData for CustomTileCollider {
|
||||
fn type_uuid(&self) -> Uuid {
|
||||
<Self as TypeUuidProvider>::type_uuid()
|
||||
}
|
||||
|
||||
fn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
let mut visitor = Visitor::new();
|
||||
self.visit("CustomTileCollider", &mut visitor)?;
|
||||
|
||||
@@ -58,6 +58,7 @@ fn position_to_vector(source: PalettePosition) -> Vector2<i32> {
|
||||
|
||||
/// A 2D grid that contains tile data.
|
||||
#[derive(Default, Debug, Clone, PartialEq, Reflect)]
|
||||
#[reflect(type_uuid = "161e38e6-197c-41ed-aa87-de293662cd3d")]
|
||||
pub struct TileGridMap<V: Debug + Clone + Reflect>(FxHashMap<Vector2<i32>, V>);
|
||||
|
||||
impl<V: Visit + Default + Debug + Clone + Reflect> Visit for TileGridMap<V> {
|
||||
@@ -80,8 +81,8 @@ impl<V: Debug + Clone + Reflect> DerefMut for TileGridMap<V> {
|
||||
}
|
||||
|
||||
/// Position of a tile definition within some tile set
|
||||
#[derive(Eq, PartialEq, Clone, Copy, Default, Hash, Reflect, Visit, TypeUuidProvider)]
|
||||
#[type_uuid(id = "3eb69303-d361-482d-8094-44b9f9c323ca")]
|
||||
#[derive(Eq, PartialEq, Clone, Copy, Default, Hash, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "3eb69303-d361-482d-8094-44b9f9c323ca")]
|
||||
#[repr(C)]
|
||||
pub struct TileDefinitionHandle {
|
||||
/// Position of the tile's page
|
||||
@@ -383,6 +384,7 @@ pub struct Stamp {
|
||||
/// Each cell of a stamp must have a tile handle and it may optionally have
|
||||
/// the handle of a brush cell where the tile was taken from.
|
||||
#[derive(Clone, Debug, Reflect, Visit, Default)]
|
||||
#[reflect(type_uuid = "40f40b03-0061-4221-909f-d8590f15efd9")]
|
||||
pub struct StampElement {
|
||||
/// The stamp cell's tile handle
|
||||
pub handle: TileDefinitionHandle,
|
||||
|
||||
@@ -38,7 +38,7 @@ use crate::{
|
||||
},
|
||||
core::{
|
||||
algebra::Vector2, color::Color, io::FileError, log::Log, reflect::prelude::*,
|
||||
type_traits::prelude::*, visitor::prelude::*, ImmutableString,
|
||||
visitor::prelude::*, ImmutableString,
|
||||
},
|
||||
fxhash::{FxHashMap, FxHashSet},
|
||||
material::{MaterialResource, MaterialResourceExtension},
|
||||
@@ -104,6 +104,7 @@ impl From<VisitError> for TileSetResourceError {
|
||||
|
||||
/// Definition of a tile.
|
||||
#[derive(Clone, Default, PartialEq, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "5decdb65-5489-47ad-9f16-9ab952cdac59")]
|
||||
#[visit(optional)]
|
||||
pub struct TileDefinition {
|
||||
/// The tile's material resource and the rect within that material that should be rendered as the tile.
|
||||
@@ -137,6 +138,7 @@ impl OrthoTransform for TileDefinition {
|
||||
|
||||
/// A tile's material resource and the rect within that material that should be rendered as the tile.
|
||||
#[derive(Clone, PartialEq, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "8e9d5152-bfec-43c1-bf2e-2b47a554dbbd")]
|
||||
pub struct TileMaterialBounds {
|
||||
/// Material of the tile.
|
||||
pub material: MaterialResource,
|
||||
@@ -171,6 +173,7 @@ impl OrthoTransform for TileMaterialBounds {
|
||||
|
||||
/// Miscellaneous data that is stored with the tile definition.
|
||||
#[derive(Clone, Default, PartialEq, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "44053a39-2d64-4f85-9b26-9ffed230da31")]
|
||||
#[visit(optional)]
|
||||
pub struct TileData {
|
||||
/// Colliders of the tile.
|
||||
@@ -210,6 +213,7 @@ impl OrthoTransform for TileData {
|
||||
/// and otherwise transformed with respect the their source material, so for example the
|
||||
/// left-top corner of the tile may be to the right of the right-top corner in the material.
|
||||
#[derive(Clone, Default, PartialEq, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "3eaf24a1-74c9-4f48-8292-2ba50c4d4eae")]
|
||||
pub struct TileBounds {
|
||||
/// The position of the tile's left-top corner within its source material.
|
||||
pub left_top_corner: Vector2<u32>,
|
||||
@@ -289,6 +293,7 @@ impl OrthoTransform for TileBounds {
|
||||
/// A tile set can contain multiple pages of tiles, and each page may have its own
|
||||
/// independent source of tile data.
|
||||
#[derive(Clone, Default, Debug, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "d781e98c-802a-4e0a-b228-77b13368c24d")]
|
||||
pub struct TileSetPage {
|
||||
/// The tile that represents this page in the editor
|
||||
pub icon: TileDefinitionHandle,
|
||||
@@ -542,6 +547,7 @@ pub enum AbstractTile {
|
||||
|
||||
/// This is where tile set pages store their tile data.
|
||||
#[derive(Clone, PartialEq, Debug, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "cbff9460-53ce-4427-b265-d3866e32a641")]
|
||||
pub enum TileSetPageSource {
|
||||
/// A page that gets its data from a material resource and arranges its tiles according to their positions in the material.
|
||||
/// All tiles in an atlas page share the same material and their UV data is automatically calculated based on the position
|
||||
@@ -617,6 +623,7 @@ impl TileSetPageSource {
|
||||
/// for any combination of 90-degree rotations, horizontal flips, and vertical flips by
|
||||
/// moving around the 2x4 grid.
|
||||
#[derive(Default, Clone, PartialEq, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "520d903b-cbf6-4dde-8f93-397ecaa333e7")]
|
||||
pub struct TransformSetTiles(
|
||||
#[reflect(hidden)]
|
||||
#[visit(optional)]
|
||||
@@ -643,6 +650,7 @@ impl DerefMut for TransformSetTiles {
|
||||
/// along continuous rows of tiles, until an empty cell is found, and then
|
||||
/// the animation returns to the start of the sequence and repeats.
|
||||
#[derive(Clone, PartialEq, Debug, Reflect, Visit)]
|
||||
#[reflect(type_uuid = "638f7a76-7d03-4ade-89af-6748a36f4767")]
|
||||
pub struct AnimationTiles {
|
||||
/// The speed of the animation in frames per second.
|
||||
pub frame_rate: f32,
|
||||
@@ -678,6 +686,7 @@ impl DerefMut for AnimationTiles {
|
||||
/// A material resource plus the size of each tile, so that the tile set can
|
||||
/// carve up the material into tiles.
|
||||
#[derive(Clone, PartialEq, Debug, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "d1a299ca-930d-462d-9455-e4c8ca7ab5f6")]
|
||||
pub struct TileMaterial {
|
||||
/// The source material.
|
||||
pub material: MaterialResource,
|
||||
@@ -1323,8 +1332,8 @@ impl AnimationCache {
|
||||
/// Each layer has a name and a color. The color is used to allow the user to quickly
|
||||
/// identify which shapes correspond to which layers while in the tile set editor.
|
||||
/// See [`TileSetColliderLayer`] for more information.
|
||||
#[derive(Clone, Default, Debug, Visit, Reflect, TypeUuidProvider)]
|
||||
#[type_uuid(id = "7b7e057b-a41e-4150-ab3b-0ae99f4024f0")]
|
||||
#[derive(Clone, Default, Debug, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "7b7e057b-a41e-4150-ab3b-0ae99f4024f0")]
|
||||
pub struct TileSet {
|
||||
/// A mapping from animated tiles to the corresponding cells on animation pages.
|
||||
#[reflect(hidden)]
|
||||
@@ -2104,10 +2113,6 @@ impl TileSet {
|
||||
}
|
||||
|
||||
impl ResourceData for TileSet {
|
||||
fn type_uuid(&self) -> Uuid {
|
||||
<Self as TypeUuidProvider>::type_uuid()
|
||||
}
|
||||
|
||||
fn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
let mut visitor = Visitor::new();
|
||||
self.visit("TileSet", &mut visitor)?;
|
||||
@@ -2143,7 +2148,7 @@ impl ResourceLoader for TileSetLoader {
|
||||
}
|
||||
|
||||
fn data_type_uuid(&self) -> Uuid {
|
||||
<TileSet as TypeUuidProvider>::type_uuid()
|
||||
<TileSet as Reflect>::type_info().type_uuid
|
||||
}
|
||||
|
||||
fn load(&self, path: PathBuf, io: Arc<dyn ResourceIo>) -> BoxedLoaderFuture {
|
||||
|
||||
@@ -50,6 +50,7 @@ use super::OptionTileRect;
|
||||
/// These transformations are useful in situations where positions are
|
||||
/// restricted to an orthogonal grid, as in a tile map.
|
||||
#[derive(Copy, Clone, Hash, Eq, PartialEq, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "fc588f6b-0f07-467c-af6c-c6b62ffc6063")]
|
||||
pub struct OrthoTransformation(i8);
|
||||
|
||||
/// A map from `Vector2<i32>` to values. It can be transformed to flip and rotate the positions of the values.
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
//! update is the final step before finally applying the modification to a tile map.
|
||||
|
||||
use super::*;
|
||||
use crate::core::{algebra::Vector2, color::Color, log::Log, type_traits::prelude::*};
|
||||
use crate::core::{algebra::Vector2, color::Color, log::Log};
|
||||
use fxhash::FxHashMap;
|
||||
use fyrox_core::swap_hash_map_entry;
|
||||
use std::{
|
||||
@@ -586,6 +586,7 @@ impl TileSetUpdate {
|
||||
/// allowing the stamp element itself to be later transformed before it is applied to a tile map,
|
||||
/// tile set, or brush.
|
||||
#[derive(Debug, Clone, Reflect)]
|
||||
#[reflect(type_uuid = "276857c4-1104-496e-8878-f3fd4368afe9")]
|
||||
pub struct RotTileHandle {
|
||||
/// The transformation of the element.
|
||||
pub transform: OrthoTransformation,
|
||||
|
||||
@@ -75,6 +75,7 @@ use std::cell::Cell;
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Clone, Debug, Reflect)]
|
||||
#[reflect(type_uuid = "16c75838-4a4f-4880-acf5-7e612fc54f01")]
|
||||
pub struct Transform {
|
||||
// Indicates that some property has changed and matrix must be
|
||||
// recalculated before use. This is some sort of lazy evaluation.
|
||||
|
||||
@@ -24,10 +24,11 @@ use crate::{
|
||||
core::{
|
||||
parking_lot::{Mutex, MutexGuard},
|
||||
uuid::Uuid,
|
||||
SafeLock, TypeUuidProvider,
|
||||
SafeLock,
|
||||
},
|
||||
script::{Script, ScriptTrait},
|
||||
};
|
||||
use fyrox_core::reflect::Reflect;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// Script constructor contains all required data and methods to create script instances
|
||||
@@ -66,12 +67,12 @@ impl ScriptConstructorContainer {
|
||||
/// The method will panic if there is already a constructor for given type uuid.
|
||||
pub fn add<T>(&self, name: &str) -> &Self
|
||||
where
|
||||
T: TypeUuidProvider + ScriptTrait + Default,
|
||||
T: ScriptTrait + Default,
|
||||
{
|
||||
let type_info = T::type_info();
|
||||
|
||||
let old = self.map.safe_lock().insert(
|
||||
T::type_uuid(),
|
||||
<T as Reflect>::type_info().type_uuid,
|
||||
ScriptConstructor {
|
||||
constructor: Box::new(|| Script::new(T::default())),
|
||||
name: name.to_owned(),
|
||||
|
||||
@@ -28,10 +28,9 @@ use crate::{
|
||||
core::{
|
||||
log::Log,
|
||||
pool::{Handle, PoolError},
|
||||
reflect::{FieldMut, FieldRef, Reflect},
|
||||
reflect::prelude::*,
|
||||
uuid::Uuid,
|
||||
visitor::{Visit, VisitResult, Visitor},
|
||||
TypeUuidProvider,
|
||||
},
|
||||
engine::{input::InputState, task::TaskPoolHandler, GraphicsContext, ScriptMessageDispatcher},
|
||||
event::Event,
|
||||
@@ -47,7 +46,6 @@ use std::{
|
||||
any::Any,
|
||||
fmt::{Debug, Formatter},
|
||||
ops::{Deref, DerefMut},
|
||||
str::FromStr,
|
||||
sync::mpsc::Sender,
|
||||
};
|
||||
|
||||
@@ -227,23 +225,14 @@ pub trait BaseScript: Visit + Reflect + Send + Debug + 'static {
|
||||
/// core::reflect::prelude::*,
|
||||
/// core::uuid::Uuid,
|
||||
/// script::ScriptTrait,
|
||||
/// core::TypeUuidProvider,
|
||||
/// core::uuid::uuid, core::type_traits::prelude::*
|
||||
/// core::uuid::uuid,
|
||||
/// };
|
||||
///
|
||||
/// #[derive(Reflect, Visit, Debug, Clone)]
|
||||
/// // Use https://www.uuidgenerator.net/ to generate new UUID or an extension for your IDE.
|
||||
/// #[reflect(type_uuid = "4cfbe65e-a2c1-474f-b123-57516d80b1f8")]
|
||||
/// struct MyScript { }
|
||||
///
|
||||
/// // Implement TypeUuidProvider trait that will return type uuid of the type.
|
||||
/// // Every script must implement the trait so the script can be registered in
|
||||
/// // serialization context of the engine.
|
||||
/// impl TypeUuidProvider for MyScript {
|
||||
/// fn type_uuid() -> Uuid {
|
||||
/// // Use https://www.uuidgenerator.net/ to generate new UUID.
|
||||
/// uuid!("4cfbe65e-a2c1-474f-b123-57516d80b1f8")
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl ScriptTrait for MyScript { }
|
||||
/// ```
|
||||
fn id(&self) -> Uuid;
|
||||
@@ -251,7 +240,7 @@ pub trait BaseScript: Visit + Reflect + Send + Debug + 'static {
|
||||
|
||||
impl<T> BaseScript for T
|
||||
where
|
||||
T: Clone + ScriptTrait + Any + TypeUuidProvider,
|
||||
T: Clone + ScriptTrait + Any,
|
||||
{
|
||||
fn clone_box(&self) -> Box<dyn ScriptTrait> {
|
||||
Box::new(self.clone())
|
||||
@@ -266,7 +255,7 @@ where
|
||||
}
|
||||
|
||||
fn id(&self) -> Uuid {
|
||||
T::type_uuid()
|
||||
<T as Reflect>::type_info().type_uuid
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,21 +330,21 @@ pub struct ScriptContext<'a, 'b, 'c> {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use fyrox_impl::{
|
||||
/// # core::{reflect::prelude::*, type_traits::prelude::*, visitor::prelude::*},
|
||||
/// # core::{reflect::prelude::*, visitor::prelude::*},
|
||||
/// # plugin::{Plugin, error::GameResult},
|
||||
/// # script::{ScriptContext, ScriptTrait},
|
||||
/// # };
|
||||
/// #
|
||||
/// #[derive(Visit, Reflect, Default, Debug)]
|
||||
/// #[reflect(non_cloneable)]
|
||||
/// #[reflect(non_cloneable, type_uuid = "bf06a1f4-5e76-4560-a260-e64187a9484b")]
|
||||
/// struct Game {
|
||||
/// player_name: String,
|
||||
/// }
|
||||
///
|
||||
/// impl Plugin for Game {}
|
||||
///
|
||||
/// #[derive(Visit, Reflect, Clone, Default, Debug, TypeUuidProvider)]
|
||||
/// #[type_uuid(id = "f732654e-5e3c-4b52-9a3d-44c0cfb14e18")]
|
||||
/// #[derive(Visit, Reflect, Clone, Default, Debug)]
|
||||
/// #[reflect(type_uuid = "f732654e-5e3c-4b52-9a3d-44c0cfb14e18")]
|
||||
/// struct MyScript {}
|
||||
///
|
||||
/// impl ScriptTrait for MyScript {
|
||||
@@ -663,8 +652,7 @@ pub trait ScriptTrait: BaseScript {
|
||||
///
|
||||
/// ```rust
|
||||
/// use fyrox_impl::{
|
||||
/// core::{reflect::prelude::*, uuid::Uuid, visitor::prelude::*, type_traits::prelude::*},
|
||||
/// core::TypeUuidProvider,
|
||||
/// core::{reflect::prelude::*, uuid::Uuid, visitor::prelude::*},
|
||||
/// script::ScriptTrait,
|
||||
/// plugin::error::GameResult,
|
||||
/// script::{ScriptContext, ScriptMessageContext, ScriptMessagePayload},
|
||||
@@ -673,14 +661,9 @@ pub trait ScriptTrait: BaseScript {
|
||||
/// struct Message;
|
||||
///
|
||||
/// #[derive(Reflect, Visit, Debug, Clone)]
|
||||
/// #[reflect(type_uuid = "2649187c-46c2-485f-bf62-c9d3aef0c432")]
|
||||
/// struct MyScript {}
|
||||
///
|
||||
/// # impl TypeUuidProvider for MyScript {
|
||||
/// # fn type_uuid() -> Uuid {
|
||||
/// # todo!();
|
||||
/// # }
|
||||
/// # }
|
||||
///
|
||||
/// impl ScriptTrait for MyScript {
|
||||
/// fn on_start(&mut self, ctx: &mut ScriptContext) -> GameResult {
|
||||
/// // Subscription is mandatory to receive any message of the type!
|
||||
@@ -711,6 +694,7 @@ pub trait ScriptTrait: BaseScript {
|
||||
|
||||
/// A wrapper for actual script instance internals, it used by the engine.
|
||||
#[derive(Debug, Reflect)]
|
||||
#[reflect(type_uuid = "24ecd17d-9b46-4cc8-9d07-a1273e50a20e")]
|
||||
pub struct Script {
|
||||
#[reflect(deref, display_name = "Script")]
|
||||
instance: Box<dyn ScriptTrait>,
|
||||
@@ -720,12 +704,6 @@ pub struct Script {
|
||||
pub(crate) started: bool,
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Script {
|
||||
fn type_uuid() -> Uuid {
|
||||
Uuid::from_str("24ecd17d-9b46-4cc8-9d07-a1273e50a20e").unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Script {
|
||||
type Target = dyn ScriptTrait;
|
||||
|
||||
@@ -844,15 +822,13 @@ mod test {
|
||||
scene::base::Base,
|
||||
script::{Script, ScriptTrait},
|
||||
};
|
||||
use fyrox_core::uuid_provider;
|
||||
|
||||
#[derive(Reflect, Visit, Debug, Clone, Default)]
|
||||
#[reflect(type_uuid = "eed9bf56-7d71-44a0-ba8e-0f3163c59669")]
|
||||
struct MyScript {
|
||||
field: InheritableVariable<f32>,
|
||||
}
|
||||
|
||||
uuid_provider!(MyScript = "eed9bf56-7d71-44a0-ba8e-0f3163c59669");
|
||||
|
||||
impl ScriptTrait for MyScript {}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -53,7 +53,7 @@ use crate::{
|
||||
utils::{uvgen, uvgen::SurfaceDataPatch},
|
||||
};
|
||||
use fxhash::FxHashMap;
|
||||
use fyrox_core::{ok_or_continue, warn, Uuid};
|
||||
use fyrox_core::{ok_or_continue, warn};
|
||||
use fyrox_graph::SceneGraphNode;
|
||||
use fyrox_material::Material;
|
||||
use fyrox_resource::ResourceData;
|
||||
@@ -125,6 +125,7 @@ pub fn apply_surface_data_patch(
|
||||
|
||||
/// Lightmap entry.
|
||||
#[derive(Default, Clone, Debug, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "17c570ce-0e98-42c0-b93f-ddc97012380d")]
|
||||
pub struct LightmapEntry {
|
||||
/// Lightmap texture.
|
||||
///
|
||||
@@ -166,6 +167,7 @@ impl Visit for SurfaceDataPatchWrapper {
|
||||
|
||||
/// Lightmap is a texture with precomputed lighting.
|
||||
#[derive(Clone, Debug, Visit, Reflect)]
|
||||
#[reflect(type_uuid = "931d2ee2-f8f0-42e7-9d9b-3c429ca75128")]
|
||||
pub struct Lightmap {
|
||||
/// Name of the property this light map is bound to in all materials across all
|
||||
/// surfaces for which the light map was generated.
|
||||
|
||||
@@ -76,6 +76,7 @@ impl VertexDataProvider for Vertex {}
|
||||
|
||||
/// See module docs.
|
||||
#[derive(Clone, Debug, Default, Reflect)]
|
||||
#[reflect(type_uuid = "5bc7c49c-2dc4-4f67-916c-1d9affd755ef")]
|
||||
#[reflect(hide_all)]
|
||||
pub struct Navmesh {
|
||||
octree: Octree,
|
||||
|
||||
Reference in New Issue
Block a user