Skip to content

Commit

Permalink
try_insert NoAutomaticBatching (#12396)
Browse files Browse the repository at this point in the history
# Objective

fix occasional crash from commands.insert when quickly spawning and
despawning skinned/morphed meshes
 
## Solution

use `try_insert` instead of `insert`. if the entity is deleted we don't
mind failing to add the `NoAutomaticBatching` marker.
  • Loading branch information
robtfm committed Mar 10, 2024
1 parent 8a08825 commit cca4ab3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/morph.rs
Expand Up @@ -109,6 +109,6 @@ pub fn no_automatic_morph_batching(
query: Query<Entity, (With<MeshMorphWeights>, Without<NoAutomaticBatching>)>,
) {
for entity in &query {
commands.entity(entity).insert(NoAutomaticBatching);
commands.entity(entity).try_insert(NoAutomaticBatching);
}
}
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/skin.rs
Expand Up @@ -146,6 +146,6 @@ pub fn no_automatic_skin_batching(
query: Query<Entity, (With<SkinnedMesh>, Without<NoAutomaticBatching>)>,
) {
for entity in &query {
commands.entity(entity).insert(NoAutomaticBatching);
commands.entity(entity).try_insert(NoAutomaticBatching);
}
}

0 comments on commit cca4ab3

Please sign in to comment.