From ccf0911ca665c3963807e7055aa9abf82b169ca2 Mon Sep 17 00:00:00 2001 From: Nicola Papale Date: Mon, 23 Oct 2023 16:46:32 +0200 Subject: [PATCH] Add some docs to MeshBindGroups --- crates/bevy_pbr/src/render/mesh_bindings.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/bevy_pbr/src/render/mesh_bindings.rs b/crates/bevy_pbr/src/render/mesh_bindings.rs index 99742cf455d6ac..dd62c20cb7cada 100644 --- a/crates/bevy_pbr/src/render/mesh_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_bindings.rs @@ -173,12 +173,17 @@ impl<'a> MeshBindGroupBuilder<'a> { /// The [`BindGroup`]s for individual existing mesh shader variants. /// -/// Morph targets allow several different bind groups, because individual mesh -/// may have a different [`TextureView`] that represents the morph target's pose -/// vertex attribute values. +/// To add bind groups to it, you would first create a `MeshBindGroupBuilder` +/// using `MeshBindGroups::bind_group_builder`. Then, call `add_variant` for +/// each `BindGroup` that will be needed for rendering. /// -/// Non-morph target bind groups are optional. We don't know at compile time -/// whether motion vectors or skinned meshes will be used. +/// `MeshBindGroups` has two `HashMap`, one `shared` that contains bind groups that +/// can be shared between different entities with the same set of `ActiveVariant`. +/// +/// The other `HashMap` is `distinct`, which contain bind groups that are unique per-mesh. +/// This is currently only relevant for meshes with morph targets. (Morph targets have +/// a texture binding, therefore need to bind to a different individual texture for each +/// individual mesh). #[derive(Default, Resource)] pub struct MeshBindGroups { shared: HashMap,