You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Guard against VisibilityClass being duplicated while cloning (#21069)
# Objective
- This is the second attempt at "Fixes#20884" after conversation in
#20891
## Solution
- I followed the approach discussed in #20891 to add
`#[component(clone_behavior=Ignore)]` to avoid cloning this Component
## Testing
- I tested the change with a simple repro. I'm not sure if I can unit
test just the existence of this line but I'll see if I can and update
accordingly.
```rust
use bevy::{prelude::*, render::view::NoIndirectDrawing};
fn main() {
App::new()
.insert_resource(ClearColor(Color::BLACK))
.add_plugins(DefaultPlugins)
.add_systems(Startup, startup)
.run();
}
fn startup(
mut cmd: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut al: ResMut<AmbientLight>,
) {
al.brightness = 5000.;
cmd.spawn((
Mesh3d(meshes.add(Cuboid::from_size(Vec3::new(4., 0.5, 0.1)))),
MeshMaterial3d(materials.add(Color::srgb(1., 1., 0.))),
Transform::from_xyz(0., 0., -2.),
));
let mut id = cmd.spawn((
Mesh3d(meshes.add(Cuboid::from_length(1.))),
MeshMaterial3d(materials.add(Color::srgba(0., 0., 1., 0.5))),
Transform::from_xyz(-0.5, 0., 0.),
));
id.clone_and_spawn()
.insert(Transform::from_xyz(0.5, 0., 0.));
cmd.spawn((
Camera3d::default(),
Transform::from_xyz(0., 0., 10.).looking_at(Vec3::ZERO, Vec3::Y),
NoIndirectDrawing,
));
}
```
## Showcase
Before
<img width="178" height="202"
alt="486232152-9f8685f6-fbc3-4bc1-b9bd-7e28177cc901"
src="https://github.com/user-attachments/assets/2bca4f28-b956-49dc-83b4-edefef6ca595"
/>
After
<img width="120" height="173"
alt="486232412-bafd5e4a-69be-4249-894a-5f03dfe28b63"
src="https://github.com/user-attachments/assets/1b911bb6-01c4-451a-b010-20aab505217e"
/>
Co-authored-by: Dimitrios Loukadakis <[email protected]>
0 commit comments