Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Children are invisible unless parent has Visibility and ComputedInvisibility #5334

Closed
rparrett opened this issue Jul 16, 2022 · 2 comments
Closed
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled

Comments

@rparrett
Copy link
Contributor

Bevy version

main, also
c8aa047 (commit prior to #5310)

What you did

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn_bundle(Camera2dBundle::default());
    commands
        .spawn_bundle(TransformBundle::default())
        // .insert(ComputedVisibility::default())
        // .insert(Visibility::default())
        .with_children(|parent| {
            parent.spawn_bundle(SpriteBundle {
                texture: asset_server.load("branding/icon.png"),
                ..default()
            });
        });
}

What went wrong

Prior to #5310, the above code worked as-is and displayed the bevy logo.

After #5310, the logo is not displayed unless the two commented-out lines are uncommented.

Additional information

If this is expected behavior, we should mention that in the migration guide and close this.

This may have implications for other bits of documentation / examples.

@rparrett rparrett added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 16, 2022
@rparrett
Copy link
Contributor Author

Indeed, it seems that many_foxes and perhaps other examples are broken due to this.

@cart
Copy link
Member

cart commented Jul 16, 2022

I think for now this is expected behavior. We only propagate visibility down hierarchies that have visibility/computedvisibility chains. The Transform system has the same behavior. The naive solution to the problem (walk the whole unfiltered entity tree and check each entity for visibility component existence) doesn't feel particularly good to me, as checking each entity in World would be pretty expensive for very large worlds.

Maybe we add a convenience VisibilityBundle to help make it easy to build these chains.

We could also consider adding some sort of VisibilityRoot / TransformRoot marker to cheaply identify arbitrarily nested things with inheritance behaviors. But that also requires manual action and increases complexity of the system.

Short term, I think we should fix the examples, update the migration guide to call out this case, and add a VisibilityBundle.

bors bot pushed a commit that referenced this issue Jul 16, 2022
…5335)

# Objective

Gltfs, and a few examples were broken by #5310. Fix em.

Closes #5334

## Solution

Add `VisibilityBundle` as described here: #5334 (comment) and sprinkle it around where needed.
@bors bors bot closed this as completed in a63d761 Jul 16, 2022
inodentry pushed a commit to IyesGames/bevy that referenced this issue Aug 8, 2022
…evyengine#5335)

# Objective

Gltfs, and a few examples were broken by bevyengine#5310. Fix em.

Closes bevyengine#5334

## Solution

Add `VisibilityBundle` as described here: bevyengine#5334 (comment) and sprinkle it around where needed.
james7132 pushed a commit to james7132/bevy that referenced this issue Oct 28, 2022
…evyengine#5335)

# Objective

Gltfs, and a few examples were broken by bevyengine#5310. Fix em.

Closes bevyengine#5334

## Solution

Add `VisibilityBundle` as described here: bevyengine#5334 (comment) and sprinkle it around where needed.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
…evyengine#5335)

# Objective

Gltfs, and a few examples were broken by bevyengine#5310. Fix em.

Closes bevyengine#5334

## Solution

Add `VisibilityBundle` as described here: bevyengine#5334 (comment) and sprinkle it around where needed.
dekirisu pushed a commit to dekirisu/bevy_gltf_trait that referenced this issue Jul 7, 2024
…5335)

# Objective

Gltfs, and a few examples were broken by #5310. Fix em.

Closes #5334

## Solution

Add `VisibilityBundle` as described here: bevyengine/bevy#5334 (comment) and sprinkle it around where needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants