From 6499937553642b55dc0430f40f84d9e9112cdfa7 Mon Sep 17 00:00:00 2001 From: Dmitry Stepanov Date: Sun, 11 Feb 2024 15:24:33 +0300 Subject: [PATCH] split `SceneGraph` trait into object-safe and object-non-safe parts - `BaseSceneGraph` is object safe, which allows to pass it using `&dyn BaseSceneGraph<..>` references --- editor/src/absm/blendspace.rs | 2 +- editor/src/absm/canvas.rs | 2 +- editor/src/absm/mod.rs | 2 +- editor/src/absm/node.rs | 2 +- editor/src/absm/parameter.rs | 2 +- editor/src/absm/state_graph/context.rs | 2 +- editor/src/absm/state_graph/mod.rs | 2 +- editor/src/absm/state_viewer/context.rs | 2 +- editor/src/absm/state_viewer/mod.rs | 2 +- editor/src/absm/toolbar.rs | 2 +- editor/src/animation/mod.rs | 2 +- editor/src/animation/ruler.rs | 2 +- editor/src/animation/toolbar.rs | 2 +- editor/src/animation/track.rs | 2 +- editor/src/asset/inspector/mod.rs | 2 +- editor/src/asset/mod.rs | 2 +- editor/src/audio/mod.rs | 2 +- editor/src/camera/mod.rs | 2 +- editor/src/highlight.rs | 2 +- editor/src/inspector/editors/font.rs | 2 +- editor/src/inspector/editors/handle.rs | 2 +- editor/src/inspector/editors/material.rs | 2 +- editor/src/inspector/editors/resource.rs | 2 +- editor/src/inspector/editors/script.rs | 2 +- .../inspector/editors/spritesheet/window.rs | 2 +- editor/src/inspector/editors/texture.rs | 2 +- editor/src/inspector/mod.rs | 2 +- editor/src/interaction/gizmo/move_gizmo.rs | 2 +- editor/src/interaction/gizmo/rotate_gizmo.rs | 2 +- editor/src/interaction/gizmo/scale_gizmo.rs | 2 +- editor/src/interaction/move_mode.rs | 2 +- editor/src/interaction/select_mode.rs | 2 +- editor/src/interaction/terrain.rs | 2 +- editor/src/lib.rs | 2 +- editor/src/log.rs | 2 +- editor/src/material.rs | 2 +- editor/src/menu/view.rs | 2 +- editor/src/physics/mod.rs | 2 +- editor/src/preview.rs | 2 +- editor/src/scene/commands/graph.rs | 2 +- editor/src/scene/commands/mod.rs | 2 +- editor/src/scene/dialog.rs | 2 +- editor/src/scene/mod.rs | 1 + editor/src/scene/property.rs | 2 +- editor/src/scene/selector.rs | 2 +- editor/src/scene_viewer/mod.rs | 2 +- editor/src/ui_scene/clipboard.rs | 2 +- editor/src/ui_scene/commands/graph.rs | 2 +- editor/src/ui_scene/interaction/mod.rs | 2 +- editor/src/ui_scene/interaction/move_mode.rs | 2 +- editor/src/ui_scene/menu.rs | 2 +- editor/src/ui_scene/mod.rs | 2 +- editor/src/ui_scene/selection.rs | 2 +- editor/src/ui_scene/utils.rs | 3 +- editor/src/utils/mod.rs | 2 +- editor/src/utils/path_fixer.rs | 2 +- editor/src/utils/ragdoll.rs | 2 +- editor/src/world/graph/item.rs | 2 +- editor/src/world/graph/menu.rs | 2 +- editor/src/world/graph/mod.rs | 2 +- editor/src/world/mod.rs | 1 + fyrox-graph/src/lib.rs | 255 +++++++++--------- fyrox-ui/src/animation.rs | 2 +- fyrox-ui/src/bit.rs | 2 +- fyrox-ui/src/build.rs | 2 +- fyrox-ui/src/color/gradient.rs | 2 +- fyrox-ui/src/color/mod.rs | 2 +- fyrox-ui/src/control.rs | 2 +- fyrox-ui/src/curve/mod.rs | 2 +- fyrox-ui/src/dock/config.rs | 2 +- fyrox-ui/src/dock/mod.rs | 2 +- fyrox-ui/src/dock/tile.rs | 2 +- fyrox-ui/src/dropdown_list.rs | 2 +- fyrox-ui/src/file_browser/menu.rs | 2 +- fyrox-ui/src/file_browser/mod.rs | 2 +- fyrox-ui/src/file_browser/selector.rs | 2 +- fyrox-ui/src/grid.rs | 2 +- fyrox-ui/src/inspector/editors/array.rs | 2 +- fyrox-ui/src/inspector/editors/collection.rs | 2 +- fyrox-ui/src/inspector/editors/enumeration.rs | 2 +- fyrox-ui/src/inspector/editors/inherit.rs | 2 +- fyrox-ui/src/inspector/editors/inspectable.rs | 2 +- fyrox-ui/src/inspector/mod.rs | 2 +- fyrox-ui/src/lib.rs | 26 +- fyrox-ui/src/list_view.rs | 2 +- fyrox-ui/src/menu.rs | 2 +- fyrox-ui/src/nine_patch.rs | 2 +- fyrox-ui/src/numeric.rs | 2 +- fyrox-ui/src/popup.rs | 2 +- fyrox-ui/src/scroll_bar.rs | 2 +- fyrox-ui/src/scroll_panel.rs | 2 +- fyrox-ui/src/scroll_viewer.rs | 2 +- fyrox-ui/src/stack_panel.rs | 2 +- fyrox-ui/src/tree.rs | 2 +- fyrox-ui/src/widget.rs | 2 +- fyrox-ui/src/window.rs | 2 +- fyrox-ui/src/wrap_panel.rs | 2 +- src/engine/mod.rs | 4 +- src/renderer/batch.rs | 1 + src/resource/fbx/mod.rs | 2 +- src/scene/animation/absm.rs | 2 +- src/scene/animation/mod.rs | 2 +- src/scene/base.rs | 2 +- src/scene/camera.rs | 2 +- src/scene/collider.rs | 2 +- src/scene/decal.rs | 2 +- src/scene/dim2/collider.rs | 2 +- src/scene/dim2/joint.rs | 2 +- src/scene/dim2/rectangle.rs | 2 +- src/scene/dim2/rigidbody.rs | 2 +- src/scene/graph/event.rs | 2 +- src/scene/graph/mod.rs | 30 ++- src/scene/joint.rs | 2 +- src/scene/light/directional.rs | 2 +- src/scene/light/point.rs | 2 +- src/scene/light/spot.rs | 2 +- src/scene/mesh/mod.rs | 2 +- src/scene/navmesh.rs | 2 +- src/scene/particle_system/mod.rs | 2 +- src/scene/pivot.rs | 2 +- src/scene/ragdoll.rs | 2 +- src/scene/rigidbody.rs | 2 +- src/scene/sound/listener.rs | 2 +- src/scene/sound/mod.rs | 2 +- src/scene/sprite.rs | 2 +- src/scene/terrain/mod.rs | 2 +- 126 files changed, 288 insertions(+), 269 deletions(-) diff --git a/editor/src/absm/blendspace.rs b/editor/src/absm/blendspace.rs index 3ff4001ac..406c96c33 100644 --- a/editor/src/absm/blendspace.rs +++ b/editor/src/absm/blendspace.rs @@ -10,7 +10,7 @@ use crate::{ message::MessageSender, send_sync_message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::Vector2, diff --git a/editor/src/absm/canvas.rs b/editor/src/absm/canvas.rs index f5f4d806c..fa2958f03 100644 --- a/editor/src/absm/canvas.rs +++ b/editor/src/absm/canvas.rs @@ -9,7 +9,7 @@ use crate::{ }, utils::fetch_node_screen_center_ui, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{Matrix3, Point2, Vector2}, diff --git a/editor/src/absm/mod.rs b/editor/src/absm/mod.rs index 0c495fb47..78e2036cf 100644 --- a/editor/src/absm/mod.rs +++ b/editor/src/absm/mod.rs @@ -13,7 +13,7 @@ use crate::{ scene::{GameScene, Selection}, Message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{color::Color, pool::Handle}, engine::Engine, diff --git a/editor/src/absm/node.rs b/editor/src/absm/node.rs index 51ea144c9..29742b8b5 100644 --- a/editor/src/absm/node.rs +++ b/editor/src/absm/node.rs @@ -2,7 +2,7 @@ use crate::absm::{ selectable::{Selectable, SelectableMessage}, BORDER_COLOR, NORMAL_BACKGROUND, SELECTED_BACKGROUND, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ color::Color, diff --git a/editor/src/absm/parameter.rs b/editor/src/absm/parameter.rs index 139f4a6ee..bd8bcdc60 100644 --- a/editor/src/absm/parameter.rs +++ b/editor/src/absm/parameter.rs @@ -4,7 +4,7 @@ use crate::message::MessageSender; use crate::{ inspector::editors::make_property_editors_container, Message, MessageDirection, MSG_SYNC_FLAG, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{log::Log, pool::Handle}, gui::{ diff --git a/editor/src/absm/state_graph/context.rs b/editor/src/absm/state_graph/context.rs index 44f8950a1..612e80488 100644 --- a/editor/src/absm/state_graph/context.rs +++ b/editor/src/absm/state_graph/context.rs @@ -14,7 +14,7 @@ use crate::{ message::MessageSender, scene::{commands::ChangeSelectionCommand, Selection}, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::pool::Handle, gui::{ diff --git a/editor/src/absm/state_graph/mod.rs b/editor/src/absm/state_graph/mod.rs index f54d1d580..fa9adef15 100644 --- a/editor/src/absm/state_graph/mod.rs +++ b/editor/src/absm/state_graph/mod.rs @@ -14,7 +14,7 @@ use crate::{ scene::{commands::ChangeSelectionCommand, Selection}, send_sync_message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::pool::Handle, gui::{ diff --git a/editor/src/absm/state_viewer/context.rs b/editor/src/absm/state_viewer/context.rs index 51ada1da8..05aadcb70 100644 --- a/editor/src/absm/state_viewer/context.rs +++ b/editor/src/absm/state_viewer/context.rs @@ -16,7 +16,7 @@ use crate::{ message::MessageSender, scene::{commands::ChangeSelectionCommand, Selection}, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{algebra::Vector2, pool::Handle}, gui::{ diff --git a/editor/src/absm/state_viewer/mod.rs b/editor/src/absm/state_viewer/mod.rs index 3a405e9c5..394f0dd98 100644 --- a/editor/src/absm/state_viewer/mod.rs +++ b/editor/src/absm/state_viewer/mod.rs @@ -21,7 +21,7 @@ use crate::{ scene::{commands::ChangeSelectionCommand, Selection}, send_sync_message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::{BaseSceneGraph, SceneGraph}; use fyrox::{ core::pool::Handle, gui::{ diff --git a/editor/src/absm/toolbar.rs b/editor/src/absm/toolbar.rs index 1d1e7faca..9b9aad174 100644 --- a/editor/src/absm/toolbar.rs +++ b/editor/src/absm/toolbar.rs @@ -15,7 +15,7 @@ use crate::{ }, send_sync_message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::{BaseSceneGraph, SceneGraph}; use fyrox::{ core::{pool::ErasedHandle, pool::Handle}, fxhash::FxHashSet, diff --git a/editor/src/animation/mod.rs b/editor/src/animation/mod.rs index 04509932c..1e6ed5a5f 100644 --- a/editor/src/animation/mod.rs +++ b/editor/src/animation/mod.rs @@ -14,7 +14,7 @@ use crate::{ scene::{commands::ChangeSelectionCommand, GameScene, Selection}, send_sync_message, Message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::{BaseSceneGraph, SceneGraph}; use fyrox::{ core::{algebra::Vector2, math::Rect, pool::Handle, uuid::Uuid}, engine::Engine, diff --git a/editor/src/animation/ruler.rs b/editor/src/animation/ruler.rs index a5165b7b7..56bda198b 100644 --- a/editor/src/animation/ruler.rs +++ b/editor/src/animation/ruler.rs @@ -1,5 +1,5 @@ use crate::menu::create_menu_item; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{Matrix3, Point2, Vector2}, diff --git a/editor/src/animation/toolbar.rs b/editor/src/animation/toolbar.rs index 8250f824e..ba6dc360c 100644 --- a/editor/src/animation/toolbar.rs +++ b/editor/src/animation/toolbar.rs @@ -19,7 +19,7 @@ use crate::{ }, send_sync_message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::manager::ResourceManager, core::{algebra::Vector2, futures::executor::block_on, log::Log, math::Rect, pool::Handle}, diff --git a/editor/src/animation/track.rs b/editor/src/animation/track.rs index f9dce00f8..54d6e5000 100644 --- a/editor/src/animation/track.rs +++ b/editor/src/animation/track.rs @@ -24,7 +24,7 @@ use crate::{ }, send_sync_message, utils, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{UnitQuaternion, Vector2, Vector3, Vector4}, diff --git a/editor/src/asset/inspector/mod.rs b/editor/src/asset/inspector/mod.rs index 1089b2605..2ce88e964 100644 --- a/editor/src/asset/inspector/mod.rs +++ b/editor/src/asset/inspector/mod.rs @@ -2,7 +2,7 @@ use crate::{ inspector::editors::make_property_editors_container, message::MessageSender, MSG_SYNC_FLAG, }; use fyrox::core::reflect::Reflect; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::{manager::ResourceManager, options::BaseImportOptions}, core::{append_extension, futures::executor::block_on, log::Log, pool::Handle}, diff --git a/editor/src/asset/mod.rs b/editor/src/asset/mod.rs index 56021704f..1ddceecea 100644 --- a/editor/src/asset/mod.rs +++ b/editor/src/asset/mod.rs @@ -9,7 +9,7 @@ use crate::{ utils::window_content, AssetItem, Message, Mode, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::{ manager::ResourceManager, diff --git a/editor/src/audio/mod.rs b/editor/src/audio/mod.rs index 3ad63c9c0..5bd15bc41 100644 --- a/editor/src/audio/mod.rs +++ b/editor/src/audio/mod.rs @@ -17,7 +17,7 @@ use crate::{ }; use fyrox::asset::manager::ResourceManager; use fyrox::core::parking_lot::Mutex; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{futures::executor::block_on, pool::Handle}, engine::Engine, diff --git a/editor/src/camera/mod.rs b/editor/src/camera/mod.rs index 462b46e18..14a62516c 100644 --- a/editor/src/camera/mod.rs +++ b/editor/src/camera/mod.rs @@ -4,7 +4,7 @@ use crate::settings::{ scene::{SceneCameraSettings, SceneSettings}, Settings, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{Matrix4, Point3, UnitQuaternion, Vector2, Vector3}, diff --git a/editor/src/highlight.rs b/editor/src/highlight.rs index 999c39731..cf5dad2a8 100644 --- a/editor/src/highlight.rs +++ b/editor/src/highlight.rs @@ -1,4 +1,4 @@ -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{Matrix4, Vector3}, diff --git a/editor/src/inspector/editors/font.rs b/editor/src/inspector/editors/font.rs index 8c7d7983b..fab8a3ce6 100644 --- a/editor/src/inspector/editors/font.rs +++ b/editor/src/inspector/editors/font.rs @@ -1,5 +1,5 @@ use crate::{asset::item::AssetItem, inspector::EditorEnvironment}; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::{manager::ResourceManager, untyped::ResourceKind}, core::{ diff --git a/editor/src/inspector/editors/handle.rs b/editor/src/inspector/editors/handle.rs index fbc8c6f4b..90d850c94 100644 --- a/editor/src/inspector/editors/handle.rs +++ b/editor/src/inspector/editors/handle.rs @@ -5,7 +5,7 @@ use crate::{ world::graph::item::SceneItem, Message, UiMessage, UiNode, UserInterface, VerticalAlignment, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ color::Color, pool::ErasedHandle, pool::Handle, reflect::prelude::*, diff --git a/editor/src/inspector/editors/material.rs b/editor/src/inspector/editors/material.rs index 7790732e6..9bdd2b70c 100644 --- a/editor/src/inspector/editors/material.rs +++ b/editor/src/inspector/editors/material.rs @@ -2,7 +2,7 @@ use crate::{ asset::item::AssetItem, inspector::EditorEnvironment, message::MessageSender, Message, MessageDirection, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::{core::pool::Handle, manager::ResourceManager, state::ResourceState}, core::{ diff --git a/editor/src/inspector/editors/resource.rs b/editor/src/inspector/editors/resource.rs index 4fb164d05..bfe9ee752 100644 --- a/editor/src/inspector/editors/resource.rs +++ b/editor/src/inspector/editors/resource.rs @@ -2,7 +2,7 @@ use crate::{ asset::item::AssetItem, inspector::EditorEnvironment, load_image, message::MessageSender, Message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::{manager::ResourceManager, state::LoadError, Resource, TypedResourceData}, core::{ diff --git a/editor/src/inspector/editors/script.rs b/editor/src/inspector/editors/script.rs index dbd79f4f7..90624c4ce 100644 --- a/editor/src/inspector/editors/script.rs +++ b/editor/src/inspector/editors/script.rs @@ -11,7 +11,7 @@ use fyrox::{ uuid::Uuid, uuid_provider, visitor::prelude::*, }, engine::SerializationContext, - graph::SceneGraph, + graph::BaseSceneGraph, gui::{ button::{ButtonBuilder, ButtonMessage}, define_constructor, diff --git a/editor/src/inspector/editors/spritesheet/window.rs b/editor/src/inspector/editors/spritesheet/window.rs index aa6d4d23a..03227418f 100644 --- a/editor/src/inspector/editors/spritesheet/window.rs +++ b/editor/src/inspector/editors/spritesheet/window.rs @@ -1,5 +1,5 @@ use crate::inspector::editors::spritesheet::SpriteSheetFramesPropertyEditorMessage; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::Vector2, color::Color, parking_lot::Mutex, pool::Handle, reflect::prelude::*, diff --git a/editor/src/inspector/editors/texture.rs b/editor/src/inspector/editors/texture.rs index fb77bc93a..547522e2b 100644 --- a/editor/src/inspector/editors/texture.rs +++ b/editor/src/inspector/editors/texture.rs @@ -1,5 +1,5 @@ use crate::{asset::item::AssetItem, inspector::EditorEnvironment}; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::manager::ResourceManager, asset::untyped::UntypedResource, diff --git a/editor/src/inspector/mod.rs b/editor/src/inspector/mod.rs index 0cf6ebfda..ea544fc7a 100644 --- a/editor/src/inspector/mod.rs +++ b/editor/src/inspector/mod.rs @@ -9,7 +9,7 @@ use crate::{ Brush, Engine, Message, Mode, WidgetMessage, WrapMode, MSG_SYNC_FLAG, }; use fyrox::core::pool::ErasedHandle; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::manager::ResourceManager, core::{ diff --git a/editor/src/interaction/gizmo/move_gizmo.rs b/editor/src/interaction/gizmo/move_gizmo.rs index e8c195d2b..29428da95 100644 --- a/editor/src/interaction/gizmo/move_gizmo.rs +++ b/editor/src/interaction/gizmo/move_gizmo.rs @@ -4,7 +4,7 @@ use crate::{ scene::{GameScene, Selection}, set_mesh_diffuse_color, Engine, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{Matrix4, UnitQuaternion, Vector2, Vector3}, diff --git a/editor/src/interaction/gizmo/rotate_gizmo.rs b/editor/src/interaction/gizmo/rotate_gizmo.rs index 0831a144f..8ed40ff7a 100644 --- a/editor/src/interaction/gizmo/rotate_gizmo.rs +++ b/editor/src/interaction/gizmo/rotate_gizmo.rs @@ -2,7 +2,7 @@ use crate::{ make_color_material, scene::GameScene, set_mesh_diffuse_color, world::graph::selection::GraphSelection, Engine, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{Matrix4, UnitQuaternion, Vector2, Vector3}, diff --git a/editor/src/interaction/gizmo/scale_gizmo.rs b/editor/src/interaction/gizmo/scale_gizmo.rs index 126def282..ee3d21030 100644 --- a/editor/src/interaction/gizmo/scale_gizmo.rs +++ b/editor/src/interaction/gizmo/scale_gizmo.rs @@ -2,7 +2,7 @@ use crate::{ make_color_material, scene::GameScene, set_mesh_diffuse_color, world::graph::selection::GraphSelection, Engine, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{Matrix4, UnitQuaternion, Vector2, Vector3}, diff --git a/editor/src/interaction/move_mode.rs b/editor/src/interaction/move_mode.rs index 6db0ba103..5b124954c 100644 --- a/editor/src/interaction/move_mode.rs +++ b/editor/src/interaction/move_mode.rs @@ -18,7 +18,7 @@ use crate::{ }; use fyrox::core::uuid::{uuid, Uuid}; use fyrox::core::TypeUuidProvider; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::gui::{BuildContext, UiNode}; use fyrox::{ core::{ diff --git a/editor/src/interaction/select_mode.rs b/editor/src/interaction/select_mode.rs index 493087ba9..49dc74254 100644 --- a/editor/src/interaction/select_mode.rs +++ b/editor/src/interaction/select_mode.rs @@ -10,7 +10,7 @@ use crate::{ }; use fyrox::core::uuid::{uuid, Uuid}; use fyrox::core::TypeUuidProvider; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::gui::BuildContext; use fyrox::{ core::{algebra::Vector2, pool::Handle}, diff --git a/editor/src/interaction/terrain.rs b/editor/src/interaction/terrain.rs index edb30a1e3..733409349 100644 --- a/editor/src/interaction/terrain.rs +++ b/editor/src/interaction/terrain.rs @@ -14,7 +14,7 @@ use crate::{ }; use fyrox::core::uuid::{uuid, Uuid}; use fyrox::core::TypeUuidProvider; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::gui::{HorizontalAlignment, Thickness, VerticalAlignment}; use fyrox::{ core::{ diff --git a/editor/src/lib.rs b/editor/src/lib.rs index 815684a8d..abf402281 100644 --- a/editor/src/lib.rs +++ b/editor/src/lib.rs @@ -87,7 +87,7 @@ use crate::{ world::{graph::menu::SceneNodeContextMenu, graph::EditorSceneWrapper, WorldViewer}, }; use fyrox::dpi::LogicalSize; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::{io::FsResourceIo, manager::ResourceManager, untyped::UntypedResource}, core::{ diff --git a/editor/src/log.rs b/editor/src/log.rs index fa6ec5977..56590ae42 100644 --- a/editor/src/log.rs +++ b/editor/src/log.rs @@ -2,7 +2,7 @@ use crate::{ gui::{make_dropdown_list_option, make_image_button_with_tooltip}, load_image, Brush, Color, DropdownListBuilder, Engine, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ log::{LogMessage, MessageKind}, diff --git a/editor/src/material.rs b/editor/src/material.rs index 9c8ce105b..340b2a828 100644 --- a/editor/src/material.rs +++ b/editor/src/material.rs @@ -8,7 +8,7 @@ use crate::{ }; use fyrox::asset::manager::ResourceManager; use fyrox::core::parking_lot::Mutex; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::{Matrix4, Vector2, Vector3, Vector4}, diff --git a/editor/src/menu/view.rs b/editor/src/menu/view.rs index 7aada441a..bc9eaa8bc 100644 --- a/editor/src/menu/view.rs +++ b/editor/src/menu/view.rs @@ -3,7 +3,7 @@ use crate::{ message::MessageSender, Message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::pool::Handle, gui::{ diff --git a/editor/src/physics/mod.rs b/editor/src/physics/mod.rs index 22cd5263a..3d4b2399a 100644 --- a/editor/src/physics/mod.rs +++ b/editor/src/physics/mod.rs @@ -5,7 +5,7 @@ use crate::{ scene::{GameScene, Selection}, Message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::{BaseSceneGraph, SceneGraph}; use fyrox::{ core::{algebra::Vector3, pool::Handle, reflect::Reflect}, engine::Engine, diff --git a/editor/src/preview.rs b/editor/src/preview.rs index bcbe78545..1c4039516 100644 --- a/editor/src/preview.rs +++ b/editor/src/preview.rs @@ -1,5 +1,5 @@ use crate::{load_image, Engine}; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::scene::SceneRenderingOptions; use fyrox::{ core::{ diff --git a/editor/src/scene/commands/graph.rs b/editor/src/scene/commands/graph.rs index 1935d0697..8f725db97 100644 --- a/editor/src/scene/commands/graph.rs +++ b/editor/src/scene/commands/graph.rs @@ -3,7 +3,7 @@ use crate::{ command::CommandTrait, scene::commands::GameSceneContext, scene::Selection, world::graph::selection::GraphSelection, Message, }; -use fyrox::graph::{LinkScheme, SceneGraph, SceneGraphNode}; +use fyrox::graph::{BaseSceneGraph, LinkScheme, SceneGraphNode}; use fyrox::{ core::{ algebra::{UnitQuaternion, Vector3}, diff --git a/editor/src/scene/commands/mod.rs b/editor/src/scene/commands/mod.rs index fd65b5382..5f8cb1760 100644 --- a/editor/src/scene/commands/mod.rs +++ b/editor/src/scene/commands/mod.rs @@ -12,7 +12,7 @@ use fyrox::{ asset::manager::ResourceManager, core::{log::Log, pool::Handle, reflect::prelude::*, type_traits::prelude::*}, engine::SerializationContext, - graph::{SceneGraph, SceneGraphNode}, + graph::{BaseSceneGraph, SceneGraphNode}, scene::{graph::SubGraph, node::Node, Scene}, }; use std::sync::Arc; diff --git a/editor/src/scene/dialog.rs b/editor/src/scene/dialog.rs index 0a3758994..03574ad92 100644 --- a/editor/src/scene/dialog.rs +++ b/editor/src/scene/dialog.rs @@ -7,7 +7,7 @@ use crate::{ }, Message, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::pool::Handle, engine::Engine, diff --git a/editor/src/scene/mod.rs b/editor/src/scene/mod.rs index 2f8908d5f..b36260ae8 100644 --- a/editor/src/scene/mod.rs +++ b/editor/src/scene/mod.rs @@ -29,6 +29,7 @@ use crate::{ world::graph::selection::GraphSelection, Message, Settings, }; +use fyrox::graph::BaseSceneGraph; use fyrox::scene::sound::AudioBus; use fyrox::{ core::{ diff --git a/editor/src/scene/property.rs b/editor/src/scene/property.rs index 220d4a307..5530e3c9a 100644 --- a/editor/src/scene/property.rs +++ b/editor/src/scene/property.rs @@ -1,4 +1,4 @@ -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::Vector2, make_pretty_type_name, parking_lot::Mutex, pool::Handle, diff --git a/editor/src/scene/selector.rs b/editor/src/scene/selector.rs index 11bfcb939..f95359337 100644 --- a/editor/src/scene/selector.rs +++ b/editor/src/scene/selector.rs @@ -1,5 +1,5 @@ use crate::utils::make_node_name; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::Vector2, parking_lot::Mutex, pool::ErasedHandle, pool::Handle, diff --git a/editor/src/scene_viewer/mod.rs b/editor/src/scene_viewer/mod.rs index 3ceb5c916..de98f58b6 100644 --- a/editor/src/scene_viewer/mod.rs +++ b/editor/src/scene_viewer/mod.rs @@ -9,7 +9,7 @@ use crate::{ BuildProfile, DropdownListBuilder, GameScene, Message, Mode, SaveSceneConfirmationDialogAction, SceneContainer, Settings, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{color::Color, math::Rect, pool::Handle, uuid::Uuid}, engine::Engine, diff --git a/editor/src/ui_scene/clipboard.rs b/editor/src/ui_scene/clipboard.rs index aa111d1dc..7b9d978ab 100644 --- a/editor/src/ui_scene/clipboard.rs +++ b/editor/src/ui_scene/clipboard.rs @@ -1,6 +1,6 @@ use crate::ui_scene::selection::UiSelection; use fyrox::core::pool::Handle; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::gui::{UiNode, UserInterface}; use std::collections::HashMap; diff --git a/editor/src/ui_scene/commands/graph.rs b/editor/src/ui_scene/commands/graph.rs index 97285cdc7..4d3a7d2ce 100644 --- a/editor/src/ui_scene/commands/graph.rs +++ b/editor/src/ui_scene/commands/graph.rs @@ -7,7 +7,7 @@ use crate::{ ui_scene::{commands::UiSceneContext, UiSelection}, Message, }; -use fyrox::graph::{LinkScheme, SceneGraph, SceneGraphNode}; +use fyrox::graph::{BaseSceneGraph, LinkScheme, SceneGraphNode}; use fyrox::{ core::pool::Handle, gui::{SubGraph, UiNode, UserInterface}, diff --git a/editor/src/ui_scene/interaction/mod.rs b/editor/src/ui_scene/interaction/mod.rs index 7c124989b..67520f31f 100644 --- a/editor/src/ui_scene/interaction/mod.rs +++ b/editor/src/ui_scene/interaction/mod.rs @@ -6,7 +6,7 @@ use crate::{ settings::Settings, ui_scene::{UiScene, UiSelection}, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{ algebra::Vector2, diff --git a/editor/src/ui_scene/interaction/move_mode.rs b/editor/src/ui_scene/interaction/move_mode.rs index dd8255f9c..4ae91b6a0 100644 --- a/editor/src/ui_scene/interaction/move_mode.rs +++ b/editor/src/ui_scene/interaction/move_mode.rs @@ -12,7 +12,7 @@ use fyrox::{ TypeUuidProvider, }, engine::Engine, - graph::SceneGraph, + graph::BaseSceneGraph, gui::{BuildContext, UiNode}, }; diff --git a/editor/src/ui_scene/menu.rs b/editor/src/ui_scene/menu.rs index d786fef46..312f2489d 100644 --- a/editor/src/ui_scene/menu.rs +++ b/editor/src/ui_scene/menu.rs @@ -10,7 +10,7 @@ use crate::{ world::WorldViewerItemContextMenu, Engine, Message, MessageDirection, }; -use fyrox::graph::{SceneGraph, SceneGraphNode}; +use fyrox::graph::{BaseSceneGraph, SceneGraphNode}; use fyrox::{ core::pool::Handle, gui::{ diff --git a/editor/src/ui_scene/mod.rs b/editor/src/ui_scene/mod.rs index 9fe263cb4..2265f7f33 100644 --- a/editor/src/ui_scene/mod.rs +++ b/editor/src/ui_scene/mod.rs @@ -37,7 +37,7 @@ use fyrox::{ }, engine::Engine, fxhash::FxHashSet, - graph::{SceneGraph, SceneGraphNode}, + graph::{BaseSceneGraph, SceneGraphNode}, gui::{ brush::Brush, draw::{CommandTexture, Draw}, diff --git a/editor/src/ui_scene/selection.rs b/editor/src/ui_scene/selection.rs index 8825fe796..41fe56803 100644 --- a/editor/src/ui_scene/selection.rs +++ b/editor/src/ui_scene/selection.rs @@ -5,7 +5,7 @@ use crate::{ }; use fyrox::{ core::pool::Handle, - graph::SceneGraph, + graph::BaseSceneGraph, gui::{UiNode, UserInterface}, }; diff --git a/editor/src/ui_scene/utils.rs b/editor/src/ui_scene/utils.rs index 5943791e4..e31265568 100644 --- a/editor/src/ui_scene/utils.rs +++ b/editor/src/ui_scene/utils.rs @@ -9,13 +9,14 @@ use crate::{ }, world::{graph::item::DropAnchor, WorldViewerDataProvider}, }; +use fyrox::graph::SceneGraphNode; use fyrox::{ asset::{manager::ResourceManager, untyped::UntypedResource}, core::{ futures::executor::block_on, make_pretty_type_name, make_relative_path, pool::ErasedHandle, pool::Handle, reflect::Reflect, }, - graph::{SceneGraph, SceneGraphNode}, + graph::{BaseSceneGraph, SceneGraph}, gui::{ button::Button, canvas::Canvas, grid::Grid, screen::Screen, text::Text, UiNode, UserInterface, UserInterfaceResourceExtension, diff --git a/editor/src/utils/mod.rs b/editor/src/utils/mod.rs index b968f2cc7..8c0c32cc6 100644 --- a/editor/src/utils/mod.rs +++ b/editor/src/utils/mod.rs @@ -1,4 +1,4 @@ -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ core::{algebra::Vector2, pool::ErasedHandle, pool::Handle, visitor::Visitor}, gui::{ diff --git a/editor/src/utils/path_fixer.rs b/editor/src/utils/path_fixer.rs index cdcf534ff..efebbd927 100644 --- a/editor/src/utils/path_fixer.rs +++ b/editor/src/utils/path_fixer.rs @@ -3,7 +3,7 @@ use crate::{make_scene_file_filter, Message}; use fyrox::asset::untyped::ResourceKind; -use fyrox::graph::SceneGraph; +use fyrox::graph::{BaseSceneGraph, SceneGraph}; use fyrox::{ asset::{manager::ResourceManager, untyped::UntypedResource}, core::{ diff --git a/editor/src/utils/ragdoll.rs b/editor/src/utils/ragdoll.rs index 8eb2dcf99..32dbd99e2 100644 --- a/editor/src/utils/ragdoll.rs +++ b/editor/src/utils/ragdoll.rs @@ -9,7 +9,7 @@ use crate::{ world::graph::selection::GraphSelection, MSG_SYNC_FLAG, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::{BaseSceneGraph, SceneGraph}; use fyrox::{ core::{ algebra::{UnitQuaternion, Vector3}, diff --git a/editor/src/world/graph/item.rs b/editor/src/world/graph/item.rs index 62bc4a7a1..7634f8c5b 100644 --- a/editor/src/world/graph/item.rs +++ b/editor/src/world/graph/item.rs @@ -1,6 +1,6 @@ use crate::{load_image, message::MessageSender, utils::make_node_name, Message}; use fyrox::core::color::Color; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::gui::draw::{CommandTexture, Draw}; use fyrox::{ asset::untyped::UntypedResource, diff --git a/editor/src/world/graph/menu.rs b/editor/src/world/graph/menu.rs index 8fcdec9db..735a19758 100644 --- a/editor/src/world/graph/menu.rs +++ b/editor/src/world/graph/menu.rs @@ -16,7 +16,7 @@ use crate::{ world::WorldViewerItemContextMenu, Engine, Message, MessageDirection, PasteCommand, }; -use fyrox::graph::SceneGraph; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::untyped::UntypedResource, core::{algebra::Vector2, pool::Handle, reflect::Reflect, scope_profile}, diff --git a/editor/src/world/graph/mod.rs b/editor/src/world/graph/mod.rs index 9c198038a..387b657cf 100644 --- a/editor/src/world/graph/mod.rs +++ b/editor/src/world/graph/mod.rs @@ -15,7 +15,7 @@ use crate::{ WorldViewerDataProvider, }, }; -use fyrox::graph::SceneGraphNode; +use fyrox::graph::{BaseSceneGraph, SceneGraphNode}; use fyrox::{ asset::{manager::ResourceManager, untyped::UntypedResource}, core::{ diff --git a/editor/src/world/mod.rs b/editor/src/world/mod.rs index 497b8bb31..ee2593866 100644 --- a/editor/src/world/mod.rs +++ b/editor/src/world/mod.rs @@ -8,6 +8,7 @@ use crate::{ world::graph::item::{DropAnchor, SceneItem, SceneItemBuilder, SceneItemMessage}, Mode, Settings, }; +use fyrox::graph::BaseSceneGraph; use fyrox::{ asset::untyped::UntypedResource, core::{ diff --git a/fyrox-graph/src/lib.rs b/fyrox-graph/src/lib.rs index 2335fb336..2913e3fa0 100644 --- a/fyrox-graph/src/lib.rs +++ b/fyrox-graph/src/lib.rs @@ -558,7 +558,7 @@ impl Default for LinkScheme { } } -pub trait SceneGraph: Sized + 'static { +pub trait BaseSceneGraph: 'static { type Prefab: PrefabData; type Node: SceneGraphNode; @@ -568,12 +568,11 @@ pub trait SceneGraph: Sized + 'static { /// Sets the new root of the graph. If used incorrectly, it may create isolated sub-graphs. fn set_root(&mut self, root: Handle); - /// Creates new iterator that iterates over internal collection giving (handle; node) pairs. - fn pair_iter(&self) -> impl Iterator, &Self::Node)>; + /// Tries to borrow a node, returns Some(node) if the handle is valid, None - otherwise. + fn try_get(&self, handle: Handle) -> Option<&Self::Node>; - /// Creates an iterator that has linear iteration order over internal collection - /// of nodes. It does *not* perform any tree traversal! - fn linear_iter_mut(&mut self) -> impl Iterator; + /// Tries to borrow a node, returns Some(node) if the handle is valid, None - otherwise. + fn try_get_mut(&mut self, handle: Handle) -> Option<&mut Self::Node>; /// Checks whether the given node handle is valid or not. fn is_valid_handle(&self, handle: Handle) -> bool; @@ -594,12 +593,6 @@ pub trait SceneGraph: Sized + 'static { /// graph. fn isolate_node(&mut self, node_handle: Handle); - /// Tries to borrow a node, returns Some(node) if the handle is valid, None - otherwise. - fn try_get(&self, handle: Handle) -> Option<&Self::Node>; - - /// Tries to borrow a node, returns Some(node) if the handle is valid, None - otherwise. - fn try_get_mut(&mut self, handle: Handle) -> Option<&mut Self::Node>; - /// Borrows a node by its handle. fn node(&self, handle: Handle) -> &Self::Node { self.try_get(handle).expect("The handle must be valid!") @@ -610,6 +603,117 @@ pub trait SceneGraph: Sized + 'static { self.try_get_mut(handle).expect("The handle must be valid!") } + /// Reorders the node hierarchy so the `new_root` becomes the root node for the entire hierarchy + /// under the `prev_root` node. For example, if we have this hierarchy and want to set `C` as + /// the new root: + /// + /// ```text + /// Root_ + /// |_A_ + /// |_B + /// |_C_ + /// |_D + /// ``` + /// + /// The new hierarchy will become: + /// + /// ```text + /// C_ + /// |_D + /// |_A_ + /// | |_B + /// |_Root + /// ``` + /// + /// This method returns an instance of [`LinkScheme`], that could be used to revert the hierarchy + /// back to its original. See [`Self::apply_link_scheme`] for more info. + #[inline] + #[allow(clippy::unnecessary_to_owned)] // False-positive + fn change_hierarchy_root( + &mut self, + prev_root: Handle, + new_root: Handle, + ) -> LinkScheme { + let mut scheme = LinkScheme::default(); + + if prev_root == new_root { + return scheme; + } + + scheme + .links + .push((prev_root, self.node(prev_root).parent())); + + scheme.links.push((new_root, self.node(new_root).parent())); + + self.isolate_node(new_root); + + for prev_root_child in self.node(prev_root).children().to_vec() { + self.link_nodes(prev_root_child, new_root); + scheme.links.push((prev_root_child, prev_root)); + } + + self.link_nodes(prev_root, new_root); + + if prev_root == self.root() { + self.set_root(new_root); + scheme.root = prev_root; + } else { + scheme.root = self.root(); + } + + scheme + } + + /// Applies the given link scheme to the graph, basically reverting graph structure to the one + /// that was before the call of [`Self::change_hierarchy_root`]. + #[inline] + fn apply_link_scheme(&mut self, mut scheme: LinkScheme) { + for (child, parent) in scheme.links.drain(..) { + if parent.is_some() { + self.link_nodes(child, parent); + } else { + self.isolate_node(child); + } + } + if scheme.root.is_some() { + self.set_root(scheme.root); + } + } + + /// Create a graph depth traversal iterator. + #[inline] + fn traverse_iter( + &self, + from: Handle, + ) -> GraphTraverseIterator<'_, Self, Self::Node> { + GraphTraverseIterator { + graph: self, + stack: vec![from], + } + } + + /// Create a graph depth traversal iterator. + #[inline] + fn traverse_handle_iter( + &self, + from: Handle, + ) -> GraphHandleTraverseIterator<'_, Self, Self::Node> { + GraphHandleTraverseIterator { + graph: self, + stack: vec![from], + } + } +} + +pub trait SceneGraph: BaseSceneGraph { + /// Creates new iterator that iterates over internal collection giving (handle; node) pairs. + fn pair_iter(&self) -> impl Iterator, &Self::Node)>; + + /// Creates an iterator that has linear iteration order over internal collection + /// of nodes. It does *not* perform any tree traversal! + fn linear_iter_mut(&mut self) -> impl Iterator; + /// Tries to borrow a node and fetch its component of specified type. #[inline] fn try_get_of_type(&self, handle: Handle) -> Option<&T> @@ -800,84 +904,6 @@ pub trait SceneGraph: Sized + 'static { }) } - /// Reorders the node hierarchy so the `new_root` becomes the root node for the entire hierarchy - /// under the `prev_root` node. For example, if we have this hierarchy and want to set `C` as - /// the new root: - /// - /// ```text - /// Root_ - /// |_A_ - /// |_B - /// |_C_ - /// |_D - /// ``` - /// - /// The new hierarchy will become: - /// - /// ```text - /// C_ - /// |_D - /// |_A_ - /// | |_B - /// |_Root - /// ``` - /// - /// This method returns an instance of [`LinkScheme`], that could be used to revert the hierarchy - /// back to its original. See [`Self::apply_link_scheme`] for more info. - #[inline] - #[allow(clippy::unnecessary_to_owned)] // False-positive - fn change_hierarchy_root( - &mut self, - prev_root: Handle, - new_root: Handle, - ) -> LinkScheme { - let mut scheme = LinkScheme::default(); - - if prev_root == new_root { - return scheme; - } - - scheme - .links - .push((prev_root, self.node(prev_root).parent())); - - scheme.links.push((new_root, self.node(new_root).parent())); - - self.isolate_node(new_root); - - for prev_root_child in self.node(prev_root).children().to_vec() { - self.link_nodes(prev_root_child, new_root); - scheme.links.push((prev_root_child, prev_root)); - } - - self.link_nodes(prev_root, new_root); - - if prev_root == self.root() { - self.set_root(new_root); - scheme.root = prev_root; - } else { - scheme.root = self.root(); - } - - scheme - } - - /// Applies the given link scheme to the graph, basically reverting graph structure to the one - /// that was before the call of [`Self::change_hierarchy_root`]. - #[inline] - fn apply_link_scheme(&mut self, mut scheme: LinkScheme) { - for (child, parent) in scheme.links.drain(..) { - if parent.is_some() { - self.link_nodes(child, parent); - } else { - self.isolate_node(child); - } - } - if scheme.root.is_some() { - self.set_root(scheme.root); - } - } - /// The same as [`Self::find`], but only returns node handle which will be [`Handle::NONE`] /// if nothing is found. #[inline] @@ -890,27 +916,6 @@ pub trait SceneGraph: Sized + 'static { .unwrap_or_default() } - /// Create a graph depth traversal iterator. - #[inline] - fn traverse_iter(&self, from: Handle) -> impl Iterator { - GraphTraverseIterator { - graph: self, - stack: vec![from], - } - } - - /// Create a graph depth traversal iterator. - #[inline] - fn traverse_handle_iter( - &self, - from: Handle, - ) -> impl Iterator> { - GraphHandleTraverseIterator { - graph: self, - stack: vec![from], - } - } - /// Returns position of the node in its parent children list and the handle to the parent. Adds /// given `offset` to the position. For example, if you have the following hierarchy: /// @@ -1247,12 +1252,12 @@ pub trait SceneGraph: Sized + 'static { } /// Iterator that traverses tree in depth and returns shared references to nodes. -pub struct GraphTraverseIterator<'a, G, N> { +pub struct GraphTraverseIterator<'a, G: ?Sized, N> { graph: &'a G, stack: Vec>, } -impl<'a, G, N> Iterator for GraphTraverseIterator<'a, G, N> +impl<'a, G: ?Sized, N> Iterator for GraphTraverseIterator<'a, G, N> where G: SceneGraph, N: SceneGraphNode, @@ -1276,7 +1281,7 @@ where } /// Iterator that traverses tree in depth and returns handles to nodes. -pub struct GraphHandleTraverseIterator<'a, G, N> { +pub struct GraphHandleTraverseIterator<'a, G: ?Sized, N> { graph: &'a G, stack: Vec>, } @@ -1303,7 +1308,7 @@ where #[cfg(test)] mod test { - use crate::{NodeMapping, PrefabData, SceneGraph, SceneGraphNode}; + use crate::{BaseSceneGraph, NodeMapping, PrefabData, SceneGraph, SceneGraphNode}; use fyrox_core::{ pool::{Handle, Pool}, reflect::prelude::*, @@ -1458,7 +1463,7 @@ mod test { } } - impl SceneGraph for Graph { + impl BaseSceneGraph for Graph { type Prefab = Graph; type Node = Node; @@ -1470,14 +1475,6 @@ mod test { self.root = root; } - fn pair_iter(&self) -> impl Iterator, &Self::Node)> { - self.nodes.pair_iter() - } - - fn linear_iter_mut(&mut self) -> impl Iterator { - self.nodes.iter_mut() - } - fn is_valid_handle(&self, handle: Handle) -> bool { self.nodes.is_valid_handle(handle) } @@ -1542,6 +1539,16 @@ mod test { } } + impl SceneGraph for Graph { + fn pair_iter(&self) -> impl Iterator, &Self::Node)> { + self.nodes.pair_iter() + } + + fn linear_iter_mut(&mut self) -> impl Iterator { + self.nodes.iter_mut() + } + } + #[test] fn test_set_child_position() { let mut graph = Graph::default(); diff --git a/fyrox-ui/src/animation.rs b/fyrox-ui/src/animation.rs index 3c25b1f05..0a8bb82fa 100644 --- a/fyrox-ui/src/animation.rs +++ b/fyrox-ui/src/animation.rs @@ -16,7 +16,7 @@ use crate::{ widget::{Widget, WidgetBuilder}, BuildContext, Control, UiNode, UserInterface, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// UI-specific animation. diff --git a/fyrox-ui/src/bit.rs b/fyrox-ui/src/bit.rs index bc7dd00d3..2142e80b8 100644 --- a/fyrox-ui/src/bit.rs +++ b/fyrox-ui/src/bit.rs @@ -19,7 +19,7 @@ use crate::{ BuildContext, Control, MessageDirection, MouseButton, Orientation, Thickness, UiNode, UserInterface, WidgetMessage, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ fmt::Debug, mem, diff --git a/fyrox-ui/src/build.rs b/fyrox-ui/src/build.rs index 6e8edc233..ddef27029 100644 --- a/fyrox-ui/src/build.rs +++ b/fyrox-ui/src/build.rs @@ -5,7 +5,7 @@ use crate::{ core::pool::Handle, font::FontResource, message::UiMessage, RestrictionEntry, UiNode, UserInterface, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ ops::{Index, IndexMut}, sync::mpsc::Sender, diff --git a/fyrox-ui/src/color/gradient.rs b/fyrox-ui/src/color/gradient.rs index af6fe5806..a8df503b2 100644 --- a/fyrox-ui/src/color/gradient.rs +++ b/fyrox-ui/src/color/gradient.rs @@ -21,7 +21,7 @@ use crate::{ widget::{Widget, WidgetBuilder, WidgetMessage}, BuildContext, Control, RcUiNodeHandle, UiNode, UserInterface, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ cell::Cell, ops::{Deref, DerefMut}, diff --git a/fyrox-ui/src/color/mod.rs b/fyrox-ui/src/color/mod.rs index 8706023cb..f7a38ad94 100644 --- a/fyrox-ui/src/color/mod.rs +++ b/fyrox-ui/src/color/mod.rs @@ -21,7 +21,7 @@ use crate::{ BuildContext, Control, Orientation, Thickness, UiNode, UserInterface, VerticalAlignment, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ ops::{Deref, DerefMut}, sync::mpsc::Sender, diff --git a/fyrox-ui/src/control.rs b/fyrox-ui/src/control.rs index 1da3d65a7..9c1b7b351 100644 --- a/fyrox-ui/src/control.rs +++ b/fyrox-ui/src/control.rs @@ -83,7 +83,7 @@ pub trait Control: /// # ops::{Deref, DerefMut}, /// # }; /// # use fyrox_core::uuid_provider; - /// # use fyrox_graph::SceneGraph; + /// # use fyrox_graph::BaseSceneGraph; /// # /// #[derive(Clone, Visit, Reflect, Debug, ComponentProvider)] /// struct MyWidget { diff --git a/fyrox-ui/src/curve/mod.rs b/fyrox-ui/src/curve/mod.rs index 1f98e5b6e..6e013a140 100644 --- a/fyrox-ui/src/curve/mod.rs +++ b/fyrox-ui/src/curve/mod.rs @@ -26,7 +26,7 @@ use crate::{ }; use fxhash::FxHashSet; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::sync::mpsc::Sender; use std::{ cell::{Cell, RefCell}, diff --git a/fyrox-ui/src/dock/config.rs b/fyrox-ui/src/dock/config.rs index 077a3ab97..bc3d73303 100644 --- a/fyrox-ui/src/dock/config.rs +++ b/fyrox-ui/src/dock/config.rs @@ -6,7 +6,7 @@ use crate::{ window::WindowMessage, Orientation, UiNode, UserInterface, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::{BaseSceneGraph, SceneGraph}; use serde::{Deserialize, Serialize}; #[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize)] diff --git a/fyrox-ui/src/dock/mod.rs b/fyrox-ui/src/dock/mod.rs index d71e580fc..8a086819e 100644 --- a/fyrox-ui/src/dock/mod.rs +++ b/fyrox-ui/src/dock/mod.rs @@ -7,7 +7,7 @@ use crate::core::{reflect::prelude::*, type_traits::prelude::*, visitor::prelude::*}; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::{BaseSceneGraph, SceneGraph}; use std::{ cell::RefCell, ops::{Deref, DerefMut}, diff --git a/fyrox-ui/src/dock/tile.rs b/fyrox-ui/src/dock/tile.rs index 5518f1e76..f5311a250 100644 --- a/fyrox-ui/src/dock/tile.rs +++ b/fyrox-ui/src/dock/tile.rs @@ -12,7 +12,7 @@ use crate::{ BuildContext, Control, Thickness, UiNode, UserInterface, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::{BaseSceneGraph, SceneGraph}; use std::{ cell::Cell, ops::{Deref, DerefMut}, diff --git a/fyrox-ui/src/dropdown_list.rs b/fyrox-ui/src/dropdown_list.rs index 57ac0304c..47eca86f6 100644 --- a/fyrox-ui/src/dropdown_list.rs +++ b/fyrox-ui/src/dropdown_list.rs @@ -16,7 +16,7 @@ use crate::{ }; use fyrox_core::uuid_provider; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ ops::{Deref, DerefMut}, sync::mpsc::Sender, diff --git a/fyrox-ui/src/file_browser/menu.rs b/fyrox-ui/src/file_browser/menu.rs index 3de632589..5548fb578 100644 --- a/fyrox-ui/src/file_browser/menu.rs +++ b/fyrox-ui/src/file_browser/menu.rs @@ -18,7 +18,7 @@ use crate::{ BuildContext, Control, HorizontalAlignment, Orientation, Thickness, UiNode, UserInterface, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ cell::{Cell, RefCell}, ops::{Deref, DerefMut}, diff --git a/fyrox-ui/src/file_browser/mod.rs b/fyrox-ui/src/file_browser/mod.rs index 2fed2bad9..253856d08 100644 --- a/fyrox-ui/src/file_browser/mod.rs +++ b/fyrox-ui/src/file_browser/mod.rs @@ -37,7 +37,7 @@ mod selector; use fyrox_core::parking_lot::Mutex; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use notify::Watcher; pub use selector::*; #[cfg(not(target_arch = "wasm32"))] diff --git a/fyrox-ui/src/file_browser/selector.rs b/fyrox-ui/src/file_browser/selector.rs index 627b805a7..7f498d17d 100644 --- a/fyrox-ui/src/file_browser/selector.rs +++ b/fyrox-ui/src/file_browser/selector.rs @@ -18,7 +18,7 @@ use crate::{ VerticalAlignment, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ ops::{Deref, DerefMut}, path::{Path, PathBuf}, diff --git a/fyrox-ui/src/grid.rs b/fyrox-ui/src/grid.rs index 8f935c59e..004593606 100644 --- a/fyrox-ui/src/grid.rs +++ b/fyrox-ui/src/grid.rs @@ -13,7 +13,7 @@ use crate::{ widget::{Widget, WidgetBuilder}, BuildContext, Control, UiNode, UserInterface, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ cell::RefCell, ops::{Deref, DerefMut}, diff --git a/fyrox-ui/src/inspector/editors/array.rs b/fyrox-ui/src/inspector/editors/array.rs index 9e9056e2a..12fdb778a 100644 --- a/fyrox-ui/src/inspector/editors/array.rs +++ b/fyrox-ui/src/inspector/editors/array.rs @@ -19,7 +19,7 @@ use crate::{ widget::{Widget, WidgetBuilder}, BuildContext, Control, Thickness, UiNode, UserInterface, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::sync::Arc; use std::{ any::TypeId, diff --git a/fyrox-ui/src/inspector/editors/collection.rs b/fyrox-ui/src/inspector/editors/collection.rs index 858c8be42..dce69489f 100644 --- a/fyrox-ui/src/inspector/editors/collection.rs +++ b/fyrox-ui/src/inspector/editors/collection.rs @@ -26,7 +26,7 @@ use crate::{ BuildContext, Control, HorizontalAlignment, Thickness, UiNode, UserInterface, VerticalAlignment, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ any::TypeId, fmt::Debug, diff --git a/fyrox-ui/src/inspector/editors/enumeration.rs b/fyrox-ui/src/inspector/editors/enumeration.rs index 3716f0670..c3ae9518e 100644 --- a/fyrox-ui/src/inspector/editors/enumeration.rs +++ b/fyrox-ui/src/inspector/editors/enumeration.rs @@ -28,7 +28,7 @@ use crate::{ VerticalAlignment, }; use fyrox_core::ComponentProvider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ any::TypeId, fmt::{Debug, Formatter}, diff --git a/fyrox-ui/src/inspector/editors/inherit.rs b/fyrox-ui/src/inspector/editors/inherit.rs index 058c03399..5bcb89736 100644 --- a/fyrox-ui/src/inspector/editors/inherit.rs +++ b/fyrox-ui/src/inspector/editors/inherit.rs @@ -23,7 +23,7 @@ use crate::{ BuildContext, Control, MessageDirection, Thickness, UiNode, UserInterface, VerticalAlignment, Widget, WidgetMessage, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ any::TypeId, fmt::{Debug, Formatter}, diff --git a/fyrox-ui/src/inspector/editors/inspectable.rs b/fyrox-ui/src/inspector/editors/inspectable.rs index 73c656bb1..c9e4b05df 100644 --- a/fyrox-ui/src/inspector/editors/inspectable.rs +++ b/fyrox-ui/src/inspector/editors/inspectable.rs @@ -13,7 +13,7 @@ use crate::{ }; use fyrox_core::pool::Handle; use fyrox_core::PhantomDataSendSync; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ any::TypeId, fmt::{Debug, Formatter}, diff --git a/fyrox-ui/src/inspector/mod.rs b/fyrox-ui/src/inspector/mod.rs index 0b6e0a26f..6918fb6f5 100644 --- a/fyrox-ui/src/inspector/mod.rs +++ b/fyrox-ui/src/inspector/mod.rs @@ -32,7 +32,7 @@ use crate::{ }; use copypasta::ClipboardProvider; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::sync::Arc; use std::{ any::{Any, TypeId}, diff --git a/fyrox-ui/src/lib.rs b/fyrox-ui/src/lib.rs index 0a83e7ae4..9ff3d566d 100644 --- a/fyrox-ui/src/lib.rs +++ b/fyrox-ui/src/lib.rs @@ -293,7 +293,9 @@ pub use build::*; pub use control::*; use fyrox_core::futures::future::join_all; use fyrox_core::log::Log; -use fyrox_graph::{NodeHandleMap, NodeMapping, PrefabData, SceneGraph, SceneGraphNode}; +use fyrox_graph::{ + BaseSceneGraph, NodeHandleMap, NodeMapping, PrefabData, SceneGraph, SceneGraphNode, +}; pub use node::*; pub use thickness::*; @@ -2800,7 +2802,7 @@ impl PrefabData for UserInterface { } } -impl SceneGraph for UserInterface { +impl BaseSceneGraph for UserInterface { type Prefab = Self; type Node = UiNode; @@ -2815,13 +2817,13 @@ impl SceneGraph for UserInterface { } #[inline] - fn pair_iter(&self) -> impl Iterator, &Self::Node)> { - self.nodes.pair_iter() + fn try_get(&self, handle: Handle) -> Option<&Self::Node> { + self.nodes.try_borrow(handle) } #[inline] - fn linear_iter_mut(&mut self) -> impl Iterator { - self.nodes.iter_mut() + fn try_get_mut(&mut self, handle: Handle) -> Option<&mut Self::Node> { + self.nodes.try_borrow_mut(handle) } #[inline] @@ -2906,15 +2908,17 @@ impl SceneGraph for UserInterface { self.nodes[parent_handle].remove_child(node_handle); } } +} +impl SceneGraph for UserInterface { #[inline] - fn try_get(&self, handle: Handle) -> Option<&Self::Node> { - self.nodes.try_borrow(handle) + fn pair_iter(&self) -> impl Iterator, &Self::Node)> { + self.nodes.pair_iter() } #[inline] - fn try_get_mut(&mut self, handle: Handle) -> Option<&mut Self::Node> { - self.nodes.try_borrow_mut(handle) + fn linear_iter_mut(&mut self) -> impl Iterator { + self.nodes.iter_mut() } } @@ -3163,7 +3167,7 @@ mod test { widget::{WidgetBuilder, WidgetMessage}, OsEvent, UserInterface, }; - use fyrox_graph::SceneGraph; + use fyrox_graph::BaseSceneGraph; #[test] fn test_transform_size() { diff --git a/fyrox-ui/src/list_view.rs b/fyrox-ui/src/list_view.rs index dbe630a0b..ebc9d32c8 100644 --- a/fyrox-ui/src/list_view.rs +++ b/fyrox-ui/src/list_view.rs @@ -21,7 +21,7 @@ use crate::{ }; use fyrox_core::uuid_provider; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// A set of messages that can be used to modify/fetch the state of a [`ListView`] widget at runtime. diff --git a/fyrox-ui/src/menu.rs b/fyrox-ui/src/menu.rs index 18db8542c..fd5373efa 100644 --- a/fyrox-ui/src/menu.rs +++ b/fyrox-ui/src/menu.rs @@ -24,7 +24,7 @@ use crate::{ UserInterface, VerticalAlignment, BRUSH_BRIGHT, BRUSH_BRIGHT_BLUE, BRUSH_PRIMARY, }; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::{BaseSceneGraph, SceneGraph}; use std::{ ops::{Deref, DerefMut}, sync::mpsc::Sender, diff --git a/fyrox-ui/src/nine_patch.rs b/fyrox-ui/src/nine_patch.rs index 1c0a02d97..58669e470 100644 --- a/fyrox-ui/src/nine_patch.rs +++ b/fyrox-ui/src/nine_patch.rs @@ -12,7 +12,7 @@ use crate::{ BuildContext, Control, UiNode, UserInterface, }; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use fyrox_resource::untyped::UntypedResource; use std::ops::{Deref, DerefMut}; diff --git a/fyrox-ui/src/numeric.rs b/fyrox-ui/src/numeric.rs index 7a039d237..520cdeb2c 100644 --- a/fyrox-ui/src/numeric.rs +++ b/fyrox-ui/src/numeric.rs @@ -30,7 +30,7 @@ use crate::{ VerticalAlignment, BRUSH_DARK, BRUSH_LIGHT, }; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ cmp::Ordering, fmt::{Debug, Display}, diff --git a/fyrox-ui/src/popup.rs b/fyrox-ui/src/popup.rs index 4174000b7..06ef7fa9f 100644 --- a/fyrox-ui/src/popup.rs +++ b/fyrox-ui/src/popup.rs @@ -17,7 +17,7 @@ use crate::{ }; use fyrox_core::uuid_provider; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// A set of messages for [`Popup`] widget. diff --git a/fyrox-ui/src/scroll_bar.rs b/fyrox-ui/src/scroll_bar.rs index 52341d5d8..0619b45ff 100644 --- a/fyrox-ui/src/scroll_bar.rs +++ b/fyrox-ui/src/scroll_bar.rs @@ -24,7 +24,7 @@ use crate::{ }; use fyrox_core::uuid_provider; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// A set of messages that can be accepted by [`ScrollBar`] widget. diff --git a/fyrox-ui/src/scroll_panel.rs b/fyrox-ui/src/scroll_panel.rs index 3406c0a88..f5995480b 100644 --- a/fyrox-ui/src/scroll_panel.rs +++ b/fyrox-ui/src/scroll_panel.rs @@ -17,7 +17,7 @@ use crate::{ BuildContext, Control, UiNode, UserInterface, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// A set of messages, that is used to modify the state of a scroll panel. diff --git a/fyrox-ui/src/scroll_viewer.rs b/fyrox-ui/src/scroll_viewer.rs index 7d8136b20..2ae133e0b 100644 --- a/fyrox-ui/src/scroll_viewer.rs +++ b/fyrox-ui/src/scroll_viewer.rs @@ -18,7 +18,7 @@ use crate::{ widget::{Widget, WidgetBuilder, WidgetMessage}, BuildContext, Control, Orientation, UiNode, UserInterface, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// A set of messages that could be used to alternate the state of a [`ScrollViewer`] widget. diff --git a/fyrox-ui/src/stack_panel.rs b/fyrox-ui/src/stack_panel.rs index 74ea0fa56..797713953 100644 --- a/fyrox-ui/src/stack_panel.rs +++ b/fyrox-ui/src/stack_panel.rs @@ -15,7 +15,7 @@ use crate::{ }; use fyrox_core::uuid_provider; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// A set of possible [`StackPanel`] widget messages. diff --git a/fyrox-ui/src/tree.rs b/fyrox-ui/src/tree.rs index f538cd60d..e336858cd 100644 --- a/fyrox-ui/src/tree.rs +++ b/fyrox-ui/src/tree.rs @@ -22,7 +22,7 @@ use crate::{ BRUSH_DARK, BRUSH_DARKEST, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::{BaseSceneGraph, SceneGraph}; use std::ops::{Deref, DerefMut}; /// Opaque selection state of a tree. diff --git a/fyrox-ui/src/widget.rs b/fyrox-ui/src/widget.rs index b8fbdee6a..cf84a8c7a 100644 --- a/fyrox-ui/src/widget.rs +++ b/fyrox-ui/src/widget.rs @@ -19,7 +19,7 @@ use crate::{ UserInterface, VerticalAlignment, BRUSH_FOREGROUND, BRUSH_PRIMARY, }; use fyrox_core::{parking_lot::Mutex, variable::InheritableVariable}; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use fyrox_resource::Resource; use std::{ any::Any, diff --git a/fyrox-ui/src/window.rs b/fyrox-ui/src/window.rs index ae9cd4329..6cf1f1240 100644 --- a/fyrox-ui/src/window.rs +++ b/fyrox-ui/src/window.rs @@ -20,7 +20,7 @@ use crate::{ VerticalAlignment, BRUSH_BRIGHT, BRUSH_LIGHT, BRUSH_LIGHTEST, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ cell::RefCell, ops::{Deref, DerefMut}, diff --git a/fyrox-ui/src/wrap_panel.rs b/fyrox-ui/src/wrap_panel.rs index 16ec1f99a..9b6c564dc 100644 --- a/fyrox-ui/src/wrap_panel.rs +++ b/fyrox-ui/src/wrap_panel.rs @@ -16,7 +16,7 @@ use crate::{ }; use fyrox_core::uuid_provider; use fyrox_core::variable::InheritableVariable; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ cell::RefCell, ops::{Deref, DerefMut, Range}, diff --git a/src/engine/mod.rs b/src/engine/mod.rs index cdd5c6e7e..d2e98250d 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -77,7 +77,7 @@ use crate::resource::texture; use crate::scene::navmesh; use crate::script::PluginsRefMut; use fyrox_core::task::TaskPool; -use fyrox_graph::NodeMapping; +use fyrox_graph::{BaseSceneGraph, NodeMapping}; use fyrox_resource::Resource; use fyrox_ui::font::BUILT_IN_FONT; use fyrox_ui::loader::UserInterfaceLoader; @@ -2278,7 +2278,7 @@ mod test { }; use std::sync::Arc; - use crate::graph::SceneGraph; + use crate::graph::BaseSceneGraph; use fyrox_ui::UserInterface; use std::sync::mpsc::{self, Sender, TryRecvError}; diff --git a/src/renderer/batch.rs b/src/renderer/batch.rs index 3d74ef225..506fe7bd7 100644 --- a/src/renderer/batch.rs +++ b/src/renderer/batch.rs @@ -22,6 +22,7 @@ use crate::{ }; use fxhash::{FxBuildHasher, FxHashMap, FxHasher}; +use fyrox_graph::BaseSceneGraph; use std::{ any::TypeId, collections::hash_map::DefaultHasher, diff --git a/src/resource/fbx/mod.rs b/src/resource/fbx/mod.rs index 01938dd11..84cb9f362 100644 --- a/src/resource/fbx/mod.rs +++ b/src/resource/fbx/mod.rs @@ -21,7 +21,7 @@ use crate::{ pool::Handle, sstorage::ImmutableString, }, - graph::SceneGraph, + graph::BaseSceneGraph, material::{shader::SamplerFallback, PropertyValue}, resource::{ fbx::{ diff --git a/src/scene/animation/absm.rs b/src/scene/animation/absm.rs index 5b07acd9d..8883f4605 100644 --- a/src/scene/animation/absm.rs +++ b/src/scene/animation/absm.rs @@ -19,7 +19,7 @@ use crate::{ Scene, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// Scene specific root motion settings. diff --git a/src/scene/animation/mod.rs b/src/scene/animation/mod.rs index ca07b4ffd..b26366ccb 100644 --- a/src/scene/animation/mod.rs +++ b/src/scene/animation/mod.rs @@ -19,7 +19,7 @@ use crate::{ node::{Node, NodeTrait, UpdateContext}, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; pub mod absm; diff --git a/src/scene/base.rs b/src/scene/base.rs index 999697d57..e799a11d0 100644 --- a/src/scene/base.rs +++ b/src/scene/base.rs @@ -19,7 +19,7 @@ use crate::{ script::{Script, ScriptTrait}, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use serde::{Deserialize, Serialize}; use std::{any::Any, cell::Cell, sync::mpsc::Sender}; use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; diff --git a/src/scene/camera.rs b/src/scene/camera.rs index 409e600a9..6d7e21960 100644 --- a/src/scene/camera.rs +++ b/src/scene/camera.rs @@ -27,7 +27,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use fyrox_resource::state::LoadError; use fyrox_resource::untyped::ResourceKind; use lazy_static::lazy_static; diff --git a/src/scene/collider.rs b/src/scene/collider.rs index a84e12bb6..7a766ca46 100644 --- a/src/scene/collider.rs +++ b/src/scene/collider.rs @@ -26,7 +26,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use rapier3d::geometry::{self, ColliderHandle}; use std::{ cell::Cell, diff --git a/src/scene/decal.rs b/src/scene/decal.rs index 920978f49..b14854b69 100644 --- a/src/scene/decal.rs +++ b/src/scene/decal.rs @@ -20,7 +20,7 @@ use crate::{ node::{Node, NodeTrait}, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// Decal is an image that gets projected to a geometry of a scene. Blood splatters, bullet holes, scratches diff --git a/src/scene/dim2/collider.rs b/src/scene/dim2/collider.rs index a41939dd6..69a895848 100644 --- a/src/scene/dim2/collider.rs +++ b/src/scene/dim2/collider.rs @@ -26,7 +26,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use rapier2d::geometry::ColliderHandle; use std::{ cell::Cell, diff --git a/src/scene/dim2/joint.rs b/src/scene/dim2/joint.rs index 84b619dfa..51c3046bb 100644 --- a/src/scene/dim2/joint.rs +++ b/src/scene/dim2/joint.rs @@ -21,7 +21,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use rapier2d::dynamics::ImpulseJointHandle; use std::{ cell::{Cell, RefCell}, diff --git a/src/scene/dim2/rectangle.rs b/src/scene/dim2/rectangle.rs index 7c4f97679..21e69d214 100644 --- a/src/scene/dim2/rectangle.rs +++ b/src/scene/dim2/rectangle.rs @@ -27,7 +27,7 @@ use crate::{ node::{Node, NodeTrait}, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ hash::{Hash, Hasher}, ops::{Deref, DerefMut}, diff --git a/src/scene/dim2/rigidbody.rs b/src/scene/dim2/rigidbody.rs index cf6741045..fa2df78eb 100644 --- a/src/scene/dim2/rigidbody.rs +++ b/src/scene/dim2/rigidbody.rs @@ -30,7 +30,7 @@ use crate::{ Scene, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::{BaseSceneGraph, SceneGraph}; use rapier2d::prelude::RigidBodyHandle; use std::{ cell::Cell, diff --git a/src/scene/graph/event.rs b/src/scene/graph/event.rs index 23c2e623f..3a4040ee1 100644 --- a/src/scene/graph/event.rs +++ b/src/scene/graph/event.rs @@ -44,7 +44,7 @@ impl GraphEventBroadcaster { /// # use fyrox::scene::graph::event::GraphEvent; /// # use fyrox::scene::graph::Graph; /// # use fyrox::scene::pivot::PivotBuilder; - /// # use fyrox::graph::SceneGraph; + /// # use fyrox::graph::BaseSceneGraph; /// /// let mut graph = Graph::new(); /// diff --git a/src/scene/graph/mod.rs b/src/scene/graph/mod.rs index 51ec7f283..49b89fcb9 100644 --- a/src/scene/graph/mod.rs +++ b/src/scene/graph/mod.rs @@ -60,6 +60,7 @@ use crate::{ utils::lightmap::Lightmap, }; use fxhash::{FxHashMap, FxHashSet}; +use fyrox_graph::BaseSceneGraph; use std::{ any::{Any, TypeId}, fmt::Debug, @@ -1053,7 +1054,7 @@ impl Graph { /// # use fyrox::scene::node::Node; /// # use fyrox::scene::graph::Graph; /// # use fyrox::scene::pivot::Pivot; - /// # use fyrox_graph::SceneGraph; + /// # use fyrox_graph::BaseSceneGraph; /// let mut graph = Graph::new(); /// graph.add_node(Node::new(Pivot::default())); /// graph.add_node(Node::new(Pivot::default())); @@ -1077,7 +1078,7 @@ impl Graph { /// # use fyrox::scene::node::Node; /// # use fyrox::scene::graph::Graph; /// # use fyrox::scene::pivot::Pivot; - /// # use fyrox_graph::SceneGraph; + /// # use fyrox_graph::BaseSceneGraph; /// let mut graph = Graph::new(); /// graph.add_node(Node::new(Pivot::default())); /// graph.add_node(Node::new(Pivot::default())); @@ -1492,7 +1493,7 @@ impl Visit for Graph { } } -impl SceneGraph for Graph { +impl BaseSceneGraph for Graph { type Prefab = Model; type Node = Node; @@ -1506,16 +1507,6 @@ impl SceneGraph for Graph { self.root = root; } - #[inline] - fn pair_iter(&self) -> impl Iterator, &Self::Node)> { - self.pool.pair_iter() - } - - #[inline] - fn linear_iter_mut(&mut self) -> impl Iterator { - self.pool.iter_mut() - } - #[inline] fn is_valid_handle(&self, handle: Handle) -> bool { self.pool.is_valid_handle(handle) @@ -1620,6 +1611,18 @@ impl SceneGraph for Graph { } } +impl SceneGraph for Graph { + #[inline] + fn pair_iter(&self) -> impl Iterator, &Self::Node)> { + self.pool.pair_iter() + } + + #[inline] + fn linear_iter_mut(&mut self) -> impl Iterator { + self.pool.iter_mut() + } +} + #[cfg(test)] mod test { use crate::graph::SceneGraph; @@ -1646,6 +1649,7 @@ mod test { Scene, SceneLoader, }, }; + use fyrox_graph::BaseSceneGraph; use std::{fs, path::Path, sync::Arc}; #[test] diff --git a/src/scene/joint.rs b/src/scene/joint.rs index 5fc3b17c6..f933abde3 100644 --- a/src/scene/joint.rs +++ b/src/scene/joint.rs @@ -22,7 +22,7 @@ use crate::{ }; use fyrox_core::algebra::{Isometry3, Vector3}; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use rapier2d::na::UnitQuaternion; use rapier3d::dynamics::ImpulseJointHandle; use std::cell::RefCell; diff --git a/src/scene/light/directional.rs b/src/scene/light/directional.rs index bc0498c90..873bf0f55 100644 --- a/src/scene/light/directional.rs +++ b/src/scene/light/directional.rs @@ -27,7 +27,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; use strum_macros::{AsRefStr, EnumString, EnumVariantNames}; diff --git a/src/scene/light/point.rs b/src/scene/light/point.rs index b2cf475e3..0fd1113a0 100644 --- a/src/scene/light/point.rs +++ b/src/scene/light/point.rs @@ -36,7 +36,7 @@ use crate::{ node::{Node, NodeTrait}, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// See module docs. diff --git a/src/scene/light/spot.rs b/src/scene/light/spot.rs index 65bd9d581..613f521a0 100644 --- a/src/scene/light/spot.rs +++ b/src/scene/light/spot.rs @@ -43,7 +43,7 @@ use crate::{ node::{Node, NodeTrait}, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// See module docs. diff --git a/src/scene/mesh/mod.rs b/src/scene/mesh/mod.rs index cd97b50fb..04786641a 100644 --- a/src/scene/mesh/mod.rs +++ b/src/scene/mesh/mod.rs @@ -30,7 +30,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ cell::Cell, ops::{Deref, DerefMut}, diff --git a/src/scene/navmesh.rs b/src/scene/navmesh.rs index 035b6e60b..395495b0e 100644 --- a/src/scene/navmesh.rs +++ b/src/scene/navmesh.rs @@ -22,7 +22,7 @@ use crate::{ utils::navmesh::Navmesh, }; use fyrox_core::parking_lot::{RwLockReadGuard, RwLockWriteGuard}; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ ops::{Deref, DerefMut}, sync::Arc, diff --git a/src/scene/particle_system/mod.rs b/src/scene/particle_system/mod.rs index 009a8401d..91bc961fd 100644 --- a/src/scene/particle_system/mod.rs +++ b/src/scene/particle_system/mod.rs @@ -30,7 +30,7 @@ use crate::{ }, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ cmp::Ordering, fmt::Debug, diff --git a/src/scene/pivot.rs b/src/scene/pivot.rs index 3a0a720ef..f182c7942 100644 --- a/src/scene/pivot.rs +++ b/src/scene/pivot.rs @@ -14,7 +14,7 @@ use crate::{ node::{Node, NodeTrait}, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// A simplest possible node which represents point in space. diff --git a/src/scene/ragdoll.rs b/src/scene/ragdoll.rs index bdd7cddef..ae6a7976d 100644 --- a/src/scene/ragdoll.rs +++ b/src/scene/ragdoll.rs @@ -20,7 +20,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::{ any::{type_name, Any, TypeId}, ops::{Deref, DerefMut}, diff --git a/src/scene/rigidbody.rs b/src/scene/rigidbody.rs index dabc6e8fc..fed3898f5 100644 --- a/src/scene/rigidbody.rs +++ b/src/scene/rigidbody.rs @@ -30,7 +30,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::{BaseSceneGraph, SceneGraph}; use rapier3d::{dynamics, prelude::RigidBodyHandle}; use std::{ cell::Cell, diff --git a/src/scene/sound/listener.rs b/src/scene/sound/listener.rs index 38aade867..a026fbf13 100644 --- a/src/scene/sound/listener.rs +++ b/src/scene/sound/listener.rs @@ -18,7 +18,7 @@ use crate::{ node::{Node, NodeTrait, SyncContext}, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// Listener represents directional microphone-like device. It receives sound from surroundings diff --git a/src/scene/sound/mod.rs b/src/scene/sound/mod.rs index 52bb471ab..6ce748bd6 100644 --- a/src/scene/sound/mod.rs +++ b/src/scene/sound/mod.rs @@ -37,7 +37,7 @@ pub use fyrox_sound::{ }; use crate::scene::Scene; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use fyrox_resource::state::ResourceState; use fyrox_sound::source::SoundSource; use std::{ diff --git a/src/scene/sprite.rs b/src/scene/sprite.rs index b0b0e3d6f..fb4ab62cc 100644 --- a/src/scene/sprite.rs +++ b/src/scene/sprite.rs @@ -30,7 +30,7 @@ use crate::{ node::{Node, NodeTrait}, }, }; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use std::ops::{Deref, DerefMut}; /// A vertex for sprites. diff --git a/src/scene/terrain/mod.rs b/src/scene/terrain/mod.rs index d61586006..0b44f057a 100644 --- a/src/scene/terrain/mod.rs +++ b/src/scene/terrain/mod.rs @@ -37,7 +37,7 @@ use crate::{ }, }; use fyrox_core::uuid_provider; -use fyrox_graph::SceneGraph; +use fyrox_graph::BaseSceneGraph; use fyrox_resource::untyped::ResourceKind; use half::f16; use image::{imageops::FilterType, ImageBuffer, Luma};