Skip to content

Changed<ComputedVisibility> always evaluates as true #8267

@ProfLander

Description

@ProfLander

Bevy version

v0.10.0

What you did

  • Implemented a system that relies on accurate change tracking via Changed<ComputedVisibility>
fn my_visibility_system(changed_visibility: Query<(Entity, &ComputedVisibility), Changed<ComputedVisibility>>) {
    for (entity, computed_visibility) in query_changed_visibility.iter() {
        info!("Entity {entity:?} visibility changed to {}", computed_visibility.is_visible());
    }
}

What went wrong

  • ComputedVisibility is mutated every frame regardless of whether its underlying flags have actually changed
  • In the above example, this causes Entity (foo) visibility changed to (bar) to log each frame, instead of when a self / ancestor Visibility component is modified, or when an entity's Aabb passes in / out of the view frustum.

Additional information

This prevents user code from reasoning about changes in ComputedVisibility, necessitating manual per-frame change tracking. This can be achieved by locally caching ComputedVisibility state on a per-entity basis, or checking the state fed into by ComputedVisibility before mutating it, but isn't DRY versus being able to use the built-in machinery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions