From 5db383ca9cd3f8e1f3e419693eecd093e6e10b49 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Thu, 10 Apr 2025 13:46:34 -0700 Subject: [PATCH] Ignore RenderEntity during entity clones (#18798) # Objective Fixes #18795 ## Solution Ignore RenderEntity during entity clones --- crates/bevy_render/src/sync_world.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/sync_world.rs b/crates/bevy_render/src/sync_world.rs index 7bb74c5cab..6db9f78394 100644 --- a/crates/bevy_render/src/sync_world.rs +++ b/crates/bevy_render/src/sync_world.rs @@ -1,5 +1,6 @@ use bevy_app::Plugin; use bevy_derive::{Deref, DerefMut}; +use bevy_ecs::component::{ComponentCloneBehavior, Mutable, StorageType}; use bevy_ecs::entity::EntityHash; use bevy_ecs::{ component::Component, @@ -126,7 +127,7 @@ pub struct SyncToRenderWorld; /// Component added on the main world entities that are synced to the Render World in order to keep track of the corresponding render world entity. /// /// Can also be used as a newtype wrapper for render world entities. -#[derive(Component, Deref, Copy, Clone, Debug, Eq, Hash, PartialEq)] +#[derive(Deref, Copy, Clone, Debug, Eq, Hash, PartialEq)] pub struct RenderEntity(Entity); impl RenderEntity { #[inline] @@ -135,6 +136,16 @@ impl RenderEntity { } } +impl Component for RenderEntity { + const STORAGE_TYPE: StorageType = StorageType::Table; + + type Mutability = Mutable; + + fn clone_behavior() -> ComponentCloneBehavior { + ComponentCloneBehavior::Ignore + } +} + impl From for RenderEntity { fn from(entity: Entity) -> Self { RenderEntity(entity)