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<AlphaMode>()` 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.
This commit is contained in:
Matty 2024-02-21 14:34:10 -05:00 committed by GitHub
parent 8531033b31
commit 328008f904
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 7 deletions

View File

@ -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::{

View File

@ -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::<StandardMaterial>()
.register_type::<AlphaMode>()
.register_type::<AmbientLight>()
.register_type::<Cascade>()
.register_type::<CascadeShadowConfig>()

View File

@ -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::<color::Color>()
app.register_type::<alpha::AlphaMode>()
.register_type::<color::Color>()
.register_type::<primitives::Aabb>()
.register_type::<primitives::CascadesFrusta>()
.register_type::<primitives::CubemapFrusta>()