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

Sprite z-order is wrong when parent entity has no Transform. #1976

Closed
StarArawn opened this issue Apr 21, 2021 · 6 comments
Closed

Sprite z-order is wrong when parent entity has no Transform. #1976

StarArawn opened this issue Apr 21, 2021 · 6 comments
Labels
A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior

Comments

@StarArawn
Copy link
Contributor

StarArawn commented Apr 21, 2021

Bevy version

0.5

Operating system & version

Windows 10

What you did

Create a sprite like:

commands
        .spawn()
        .insert(Enemy::default())
        .with_children(|child_builder| {
            let texture_handle: Handle<Texture> = asset_server.load("textures/spider_sprite.png");
            let enemy_sprite_material = materials.add(texture_handle.into());
            child_builder    
                .spawn_bundle(SpriteBundle {
                    material: enemy_sprite_material,
                    transform: Transform::from_xyz(position.x, position.y, 10.0),
                    ..Default::default()
                })
                .insert(RenderLayers::layer(0));
        })

Have another sprite that is suppose to render behind and you can see how the sprites z values on the GPU are completely wrong.

With a sprite that has no parent the calculated z values are:
.9980
and with a sprite that has a parent without a transform:
-0.001

What you expected to happen

If a parent entity has no transform its children's transforms should not change.

@StarArawn StarArawn added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 21, 2021
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets and removed S-Needs-Triage This issue needs to be labelled labels Apr 21, 2021
@tim-blackbird
Copy link
Contributor

The given example code will now produce a warning since #5590 was merged

@superdump
Copy link
Contributor

@StarArawn - is this still a problem?

@nicopap
Copy link
Contributor

nicopap commented Jan 31, 2023

It is "fixed" by #5590 in the sense that it now displays a warning that tells the user why the transform is not applied, and allow them to fix it themselves.

@nicopap
Copy link
Contributor

nicopap commented Apr 18, 2023

should this be kept open or can we consider it resolved?

@TimJentzsch
Copy link
Contributor

Triage

Behavior is unchanged with Bevy 0.12.

Reproduction code: https://github.com/TimJentzsch/bevy_triage/tree/main/issues/issue_1976

In this example we spawn a yellow rectangle at the bottom, a red rectangle in the middle, but with a parent element which doesn't have a transform, and a blue rectangle at the top.
Instead, the red rectangle is at the bottom:
Red rectangle at the bottom, then yellow, then blue at the top

However, we get the following warnings in the console:

2024-01-25T19:44:31.856051Z  WARN bevy_hierarchy::valid_parent_check_plugin: warning[B0004]: An entity with the InheritedVisibility component has a parent without InheritedVisibility.
This will cause inconsistent behaviors! See https://bevyengine.org/learn/errors/#b0004
2024-01-25T19:44:31.856091Z  WARN bevy_hierarchy::valid_parent_check_plugin: warning[B0004]: An entity with the GlobalTransform component has a parent without GlobalTransform.
This will cause inconsistent behaviors! See https://bevyengine.org/learn/errors/#b0004

Considering that there is even an error code with a more detailed explanation, I think we could consider this resolved for now.
I will defer for other maintainers to make this decision though.

@mnmaita
Copy link
Member

mnmaita commented Jun 3, 2024

Since we can always reopen this in the future, I'm closing this as completed based on the fact that we have these warnings now.

@mnmaita mnmaita closed this as completed Jun 3, 2024
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 A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

7 participants