Skip to content

Commit

Permalink
Document why MAX_JOINTS and MAX_MORPH_WEIGHTS are set (#16324)
Browse files Browse the repository at this point in the history
# Objective

Fixes #15974

## Solution

Add the comment from @mockersf, adapted to fix in-context.
  • Loading branch information
BenjaminBrienen authored Dec 10, 2024
1 parent fcaa271 commit b744fb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/bevy_pbr/src/render/mesh_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ use bevy_render::{
use crate::render::skin::MAX_JOINTS;

const MORPH_WEIGHT_SIZE: usize = size_of::<f32>();

/// This is used to allocate buffers.
/// The correctness of the value depends on the GPU/platform.
/// The current value is chosen because it is guaranteed to work everywhere.
/// To allow for bigger values, a check must be made for the limits
/// of the GPU at runtime, which would mean not using consts anymore.
pub const MORPH_BUFFER_SIZE: usize = MAX_MORPH_WEIGHTS * MORPH_WEIGHT_SIZE;

const JOINT_SIZE: usize = size_of::<Mat4>();
Expand Down
6 changes: 6 additions & 0 deletions crates/bevy_pbr/src/render/skin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ use bevy_render::{
use bevy_transform::prelude::GlobalTransform;

/// Maximum number of joints supported for skinned meshes.
///
/// It is used to allocate buffers.
/// The correctness of the value depends on the GPU/platform.
/// The current value is chosen because it is guaranteed to work everywhere.
/// To allow for bigger values, a check must be made for the limits
/// of the GPU at runtime, which would mean not using consts anymore.
pub const MAX_JOINTS: usize = 256;

#[derive(Component)]
Expand Down

0 comments on commit b744fb4

Please sign in to comment.