Skip to content

Commit c78c41c

Browse files
authored
Fix footgunny MeshPlugin export (#21254)
# Objective - Fixes #21253, see that issue for details - The `MeshPlugin` that was *wrongly* used per that issue is now `MeshRenderAssetPlugin`, given that it deals with `RenderAsset`s. - Note that we cannot name it `MeshRenderPlugin`, as [that name is also already taken](https://dev-docs.bevy.org/bevy/pbr/struct.MeshRenderPlugin.html) - We now have `MeshPlugin`, `MeshRenderPlugin`, `MeshRenderAssetPlugin`, and `Mesh2dRenderPlugin`, ALL of which are in different crates :bavy: :bavy: :bavy: - Since this is an implementation detail, I think we could also make it `pub(crate)`. I verified that that compiles fine. But I'll leave that decision for someone who knows the rendering architecture better. - Also fixed a subtle mistake in asset initialization I spotted while on it, as the proper `MeshPlugin` forgets to initialize skinned mesh bind poses. - Funnily enough, the CI caught this, as before this change our own glTF tests accidentally used the *wrong* `MeshPlugin` lol - Fixes wrong documentation on the rendering plugin - No need for a migration guide, this is already documented in https://github.com/bevyengine/bevy/blob/release-0.17.0/release-content/migration-guides/bevy_render_reorganization.md
1 parent 2472010 commit c78c41c

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

crates/bevy_gltf/src/loader/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ mod test {
19091909
use bevy_ecs::{resource::Resource, world::World};
19101910
use bevy_log::LogPlugin;
19111911
use bevy_mesh::skinning::SkinnedMeshInverseBindposes;
1912-
use bevy_render::mesh::MeshPlugin;
1912+
use bevy_mesh::MeshPlugin;
19131913
use bevy_scene::ScenePlugin;
19141914

19151915
fn test_app(dir: Dir) -> App {

crates/bevy_mesh/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ bitflags! {
4545
}
4646
}
4747

48+
/// Adds [`Mesh`] as an asset.
4849
#[derive(Default)]
4950
pub struct MeshPlugin;
5051

5152
impl Plugin for MeshPlugin {
5253
fn build(&self, app: &mut App) {
5354
app.init_asset::<Mesh>()
55+
.init_asset::<skinning::SkinnedMeshInverseBindposes>()
5456
.register_asset_reflect::<Mesh>()
5557
.add_systems(
5658
PostUpdate,

crates/bevy_render/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub use extract_param::Extract;
7979
use crate::{
8080
camera::CameraPlugin,
8181
gpu_readback::GpuReadbackPlugin,
82-
mesh::{MeshPlugin, MorphPlugin, RenderMesh},
82+
mesh::{MeshRenderAssetPlugin, MorphPlugin, RenderMesh},
8383
render_asset::prepare_assets,
8484
render_resource::{init_empty_bind_group_layout, PipelineCache},
8585
renderer::{render_system, RenderAdapterInfo},
@@ -366,7 +366,7 @@ impl Plugin for RenderPlugin {
366366
WindowRenderPlugin,
367367
CameraPlugin,
368368
ViewPlugin,
369-
MeshPlugin,
369+
MeshRenderAssetPlugin,
370370
GlobalsPlugin,
371371
MorphPlugin,
372372
TexturePlugin,

crates/bevy_render/src/mesh/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
};
88
use allocator::MeshAllocatorPlugin;
99
use bevy_app::{App, Plugin, PostUpdate};
10-
use bevy_asset::{AssetApp, AssetId, RenderAssetUsages};
10+
use bevy_asset::{AssetId, RenderAssetUsages};
1111
use bevy_ecs::{
1212
prelude::*,
1313
system::{
@@ -19,12 +19,13 @@ use bevy_mesh::morph::{MeshMorphWeights, MorphWeights};
1919
use bevy_mesh::*;
2020
use wgpu::IndexFormat;
2121

22-
/// Adds the [`Mesh`] as an asset and makes sure that they are extracted and prepared for the GPU.
23-
pub struct MeshPlugin;
22+
/// Makes sure that [`Mesh`]es are extracted and prepared for the GPU.
23+
/// Does *not* add the [`Mesh`] as an asset. Use [`MeshPlugin`] for that.
24+
pub struct MeshRenderAssetPlugin;
2425

25-
impl Plugin for MeshPlugin {
26+
impl Plugin for MeshRenderAssetPlugin {
2627
fn build(&self, app: &mut App) {
27-
app.init_asset::<skinning::SkinnedMeshInverseBindposes>()
28+
app
2829
// 'Mesh' must be prepared after 'Image' as meshes rely on the morph target image being ready
2930
.add_plugins(RenderAssetPlugin::<RenderMesh, GpuImage>::default())
3031
.add_plugins(MeshAllocatorPlugin);

0 commit comments

Comments
 (0)