From d9adea1b5ea2ed53021847022872f84b204ade55 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Thu, 16 Jul 2020 16:32:39 -0700 Subject: [PATCH] transform: TransformPlugin --- crates/bevy_app/src/app_builder.rs | 32 ++++++++++++++ crates/bevy_core/Cargo.toml | 1 - crates/bevy_core/src/lib.rs | 25 +---------- .../src/{transform => math}/face_toward.rs | 0 .../bevy_core/src/{transform => math}/mod.rs | 2 - crates/bevy_transform/Cargo.toml | 2 + .../src/{ => hierarchy}/child_builder.rs | 0 .../src/hierarchy}/hierarchy.rs | 2 +- .../hierarchy_maintenance_system.rs | 4 +- crates/bevy_transform/src/hierarchy/mod.rs | 9 ++++ .../{ => hierarchy}/world_child_builder.rs | 0 crates/bevy_transform/src/lib.rs | 42 +++++++++++++------ .../src/transform_propagate_system.rs | 4 +- crates/bevy_ui/Cargo.toml | 1 - crates/bevy_ui/src/ui_update_system.rs | 8 ++-- src/prelude.rs | 2 +- 16 files changed, 86 insertions(+), 48 deletions(-) rename crates/bevy_core/src/{transform => math}/face_toward.rs (100%) rename crates/bevy_core/src/{transform => math}/mod.rs (53%) rename crates/bevy_transform/src/{ => hierarchy}/child_builder.rs (100%) rename crates/{bevy_core/src/transform => bevy_transform/src/hierarchy}/hierarchy.rs (97%) rename crates/bevy_transform/src/{ => hierarchy}/hierarchy_maintenance_system.rs (98%) create mode 100644 crates/bevy_transform/src/hierarchy/mod.rs rename crates/bevy_transform/src/{ => hierarchy}/world_child_builder.rs (100%) diff --git a/crates/bevy_app/src/app_builder.rs b/crates/bevy_app/src/app_builder.rs index cbff09b407..fd01e10b89 100644 --- a/crates/bevy_app/src/app_builder.rs +++ b/crates/bevy_app/src/app_builder.rs @@ -74,6 +74,10 @@ impl AppBuilder { self.add_system_to_stage(stage::UPDATE, system) } + pub fn add_systems(&mut self, systems: Vec>) -> &mut Self { + self.add_systems_to_stage(stage::UPDATE, systems) + } + pub fn init_system( &mut self, build: impl FnMut(&mut Resources) -> Box, @@ -101,6 +105,19 @@ impl AppBuilder { self } + pub fn add_startup_systems_to_stage( + &mut self, + stage_name: &'static str, + systems: Vec>, + ) -> &mut Self { + for system in systems { + self.app + .startup_schedule + .add_system_to_stage(stage_name, system); + } + self + } + pub fn add_startup_system(&mut self, system: Box) -> &mut Self { self.app .startup_schedule @@ -108,6 +125,10 @@ impl AppBuilder { self } + pub fn add_startup_systems(&mut self, systems: Vec>) -> &mut Self { + self.add_startup_systems_to_stage(startup_stage::STARTUP, systems) + } + pub fn init_startup_system( &mut self, build: impl FnMut(&mut Resources) -> Box, @@ -144,6 +165,17 @@ impl AppBuilder { self } + pub fn add_systems_to_stage( + &mut self, + stage_name: &'static str, + systems: Vec>, + ) -> &mut Self { + for system in systems { + self.app.schedule.add_system_to_stage(stage_name, system); + } + self + } + pub fn add_event(&mut self) -> &mut Self where T: Send + Sync + 'static, diff --git a/crates/bevy_core/Cargo.toml b/crates/bevy_core/Cargo.toml index 9c40bd25c0..4ef406d7dd 100644 --- a/crates/bevy_core/Cargo.toml +++ b/crates/bevy_core/Cargo.toml @@ -10,5 +10,4 @@ bevy_derive = { path = "../bevy_derive" } bevy_ecs = { path = "../bevy_ecs" } bevy_property = { path = "../bevy_property" } bevy_type_registry = { path = "../bevy_type_registry" } -bevy_transform = { path = "../bevy_transform" } glam = "0.8.7" \ No newline at end of file diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs index 79d3763365..ed59473291 100644 --- a/crates/bevy_core/src/lib.rs +++ b/crates/bevy_core/src/lib.rs @@ -1,16 +1,10 @@ pub mod bytes; pub mod float_ord; pub mod time; -pub mod transform; +pub mod math; -use bevy_app::{stage, startup_stage, AppBuilder, AppPlugin}; +use bevy_app::{stage, AppBuilder, AppPlugin}; use bevy_ecs::IntoQuerySystem; -use bevy_transform::{ - build_systems, - components::{ - Children, LocalTransform, NonUniformScale, Rotation, Scale, Transform, Translation, - }, -}; use bevy_type_registry::RegisterType; use glam::{Mat3, Mat4, Quat, Vec2, Vec3}; use time::{time_system, timer_system, Time, Timer}; @@ -20,22 +14,7 @@ pub struct CorePlugin; impl AppPlugin for CorePlugin { fn build(&self, app: &mut AppBuilder) { - // we also add a copy of transform systems to startup to ensure we begin with correct transform/parent state - for transform_system in build_systems() { - app.add_startup_system_to_stage(startup_stage::POST_STARTUP, transform_system); - } - for transform_system in build_systems() { - app.add_system_to_stage(stage::POST_UPDATE, transform_system); - } - app.init_resource::