mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
fix normals computation for gltf (#13396)
# Objective - some gltf files are broken since #13333 ``` thread 'IO Task Pool (2)' panicked at crates/bevy_render/src/mesh/mesh/mod.rs:581:9: `compute_flat_normals` can't work on indexed geometry. Consider calling either `Mesh::compute_smooth_normals` or `Mesh::duplicate_vertices` followed by `Mesh::compute_flat_normals`. ``` - test with example `custom_gltf_vertex_attribute` or `gltf_skinned_mesh` ## Solution - Call the wrapper function for normals that will either call `compute_flat_normals` or `compute_smooth_normals` as appropriate ## Testing - Ran the two examples mentioned above
This commit is contained in:
parent
450a9202d0
commit
a55e0e31e8
1 changed files with 10 additions and 0 deletions
|
@ -502,7 +502,17 @@ async fn load_gltf<'a, 'b, 'c>(
|
|||
bevy_utils::tracing::debug!(
|
||||
"Automatically calculating missing vertex normals for geometry."
|
||||
);
|
||||
let vertex_count_before = mesh.count_vertices();
|
||||
mesh.duplicate_vertices();
|
||||
mesh.compute_flat_normals();
|
||||
let vertex_count_after = mesh.count_vertices();
|
||||
if vertex_count_before != vertex_count_after {
|
||||
bevy_utils::tracing::debug!("Missing vertex normals in indexed geometry, computing them as flat. Vertex count increased from {} to {}", vertex_count_before, vertex_count_after);
|
||||
} else {
|
||||
bevy_utils::tracing::debug!(
|
||||
"Missing vertex normals in indexed geometry, computing them as flat."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(vertex_attribute) = reader
|
||||
|
|
Loading…
Add table
Reference in a new issue