From 328008f904ccacc647294180e95c7c665da3f7e7 Mon Sep 17 00:00:00 2001 From: Matty Date: Wed, 21 Feb 2024 14:34:10 -0500 Subject: [PATCH] Move AlphaMode into bevy_render (#12012) # Objective - Closes #11985 ## Solution - alpha.rs has been moved from bevy_pbr into bevy_render; bevy_pbr and bevy_gltf now access `AlphaMode` through bevy_render. --- ## Migration Guide In the present implementation, external consumers of `AlphaMode` will have to access it through bevy_render rather than through bevy_pbr, changing their import from `bevy_pbr::AlphaMode` to `bevy_render::alpha::AlphaMode` (or the corresponding glob import from `bevy_pbr::prelude::*` to `bevy_render::prelude::*`). ## Uncertainties Some remaining things from this that I am uncertain about: - Here, the `app.register_type()` call has been moved from `PbrPlugin` to `RenderPlugin`; I'm not sure if this is quite right, and I was unable to find any direct relationship between `PbrPlugin` and `RenderPlugin`. - `AlphaMode` was placed in the prelude of bevy_render. I'm not certain that this is actually appropriate. - bevy_pbr does not re-export `AlphaMode`, which makes this a breaking change for external consumers. Any of these things could be easily changed; I'm just not confident that I necessarily adopted the right approach in these (known) ways since this codebase and ecosystem is quite new to me. --- crates/bevy_gltf/src/loader.rs | 5 +++-- crates/bevy_pbr/src/lib.rs | 5 +---- crates/{bevy_pbr => bevy_render}/src/alpha.rs | 0 crates/bevy_render/src/lib.rs | 5 ++++- 4 files changed, 8 insertions(+), 7 deletions(-) rename crates/{bevy_pbr => bevy_render}/src/alpha.rs (100%) diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 1bc4c8328a..b3306ef3d0 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -11,10 +11,11 @@ use bevy_hierarchy::{BuildWorldChildren, WorldChildBuilder}; use bevy_log::{error, info_span, warn}; use bevy_math::{Affine2, Mat4, Vec3}; use bevy_pbr::{ - AlphaMode, DirectionalLight, DirectionalLightBundle, PbrBundle, PointLight, PointLightBundle, - SpotLight, SpotLightBundle, StandardMaterial, MAX_JOINTS, + DirectionalLight, DirectionalLightBundle, PbrBundle, PointLight, PointLightBundle, SpotLight, + SpotLightBundle, StandardMaterial, MAX_JOINTS, }; use bevy_render::{ + alpha::AlphaMode, camera::{Camera, OrthographicProjection, PerspectiveProjection, Projection, ScalingMode}, color::Color, mesh::{ diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index 5d11e67196..091348c938 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -3,7 +3,6 @@ pub mod wireframe; -mod alpha; mod bundle; pub mod deferred; mod extended_material; @@ -18,7 +17,6 @@ mod prepass; mod render; mod ssao; -pub use alpha::*; pub use bundle::*; pub use extended_material::*; pub use fog::*; @@ -35,7 +33,6 @@ pub use ssao::*; pub mod prelude { #[doc(hidden)] pub use crate::{ - alpha::AlphaMode, bundle::{ DirectionalLightBundle, MaterialMeshBundle, PbrBundle, PointLightBundle, SpotLightBundle, @@ -72,6 +69,7 @@ use bevy_asset::{load_internal_asset, AssetApp, Assets, Handle}; use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d}; use bevy_ecs::prelude::*; use bevy_render::{ + alpha::AlphaMode, camera::{CameraUpdateSystem, Projection}, extract_component::ExtractComponentPlugin, extract_resource::ExtractResourcePlugin, @@ -235,7 +233,6 @@ impl Plugin for PbrPlugin { ); app.register_asset_reflect::() - .register_type::() .register_type::() .register_type::() .register_type::() diff --git a/crates/bevy_pbr/src/alpha.rs b/crates/bevy_render/src/alpha.rs similarity index 100% rename from crates/bevy_pbr/src/alpha.rs rename to crates/bevy_render/src/alpha.rs diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index c95a4168d4..28a29405db 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -6,6 +6,7 @@ compile_error!("bevy_render cannot compile for a 16-bit platform."); extern crate core; +pub mod alpha; pub mod batching; pub mod camera; pub mod color; @@ -32,6 +33,7 @@ pub mod view; pub mod prelude { #[doc(hidden)] pub use crate::{ + alpha::AlphaMode, camera::{ Camera, ClearColor, ClearColorConfig, OrthographicProjection, PerspectiveProjection, Projection, @@ -327,7 +329,8 @@ impl Plugin for RenderPlugin { MorphPlugin, )); - app.register_type::() + app.register_type::() + .register_type::() .register_type::() .register_type::() .register_type::()