Skip to content

Conversation

it-me-joda
Copy link
Contributor

@it-me-joda it-me-joda commented Sep 15, 2025

Objective

Solution

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.
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
486232152-9f8685f6-fbc3-4bc1-b9bd-7e28177cc901

After
486232412-bafd5e4a-69be-4249-894a-5f03dfe28b63

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave a quick note in the doc comments about this behavior and why it exists? Other than that, I like this solution much better!

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Sep 15, 2025
@dloukadakis
Copy link
Contributor

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.

The test I provided on the previous pull request is still relevant to test cloning does not introduce duplicates and cloning still adds a visibility class.

@it-me-joda
Copy link
Contributor Author

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.

The test I provided on the previous pull request is still relevant to test cloning does not introduce duplicates and cloning still adds a visibility class.

I'll see about adding it back in

@it-me-joda it-me-joda force-pushed the 20884_VisibilityClass_Transparency branch from f976d48 to b336acb Compare September 16, 2025 11:06
@it-me-joda
Copy link
Contributor Author

@dloukadakis I added your test back in and @alice-i-cecile I added some documentation. Let me know if there is anything else I can do to get this across the finish line. Thanks!

@it-me-joda it-me-joda force-pushed the 20884_VisibilityClass_Transparency branch from b336acb to 9f5345f Compare September 16, 2025 11:17
@alice-i-cecile
Copy link
Member

@dloukadakis @tychedelia @eugineerd, want to give this a look? This needs two approvals to be merged.

@tychedelia tychedelia added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Sep 16, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 16, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone Sep 16, 2025
Merged via the queue into bevyengine:main with commit 6f236bf Sep 16, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

VisibilityClass gets duplicated when cloning an entity, causing issues with transparency
4 participants