try_insert NoAutomaticBatching (#12396)
# 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.
This commit is contained in:
		
							parent
							
								
									8a08825348
								
							
						
					
					
						commit
						cca4ab3663
					
				@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user