Skip to content

Commit bfbcb36

Browse files
committed
Guard against VisibilityClass duplicates
1 parent 1dfcde6 commit bfbcb36

File tree

1 file changed

+8
-2
lines changed
  • crates/bevy_camera/src/visibility

1 file changed

+8
-2
lines changed

crates/bevy_camera/src/visibility/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,14 @@ pub fn add_visibility_class<C>(
679679
) where
680680
C: 'static,
681681
{
682-
if let Some(mut visibility_class) = world.get_mut::<VisibilityClass>(entity) {
683-
visibility_class.push(TypeId::of::<C>());
682+
let Some(mut visibility_class) = world.get_mut::<VisibilityClass>(entity) else {
683+
// potentially warn in this case?
684+
return;
685+
};
686+
687+
let type_id = TypeId::of::<C>();
688+
if !visibility_class.contains(&type_id) {
689+
visibility_class.push(type_id);
684690
}
685691
}
686692

0 commit comments

Comments
 (0)