Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Remove focuspolicy#230

Merged
aevyrie merged 15 commits into
mainfrom
remove-focuspolicy
Aug 20, 2023
Merged

Remove focuspolicy#230
aevyrie merged 15 commits into
mainfrom
remove-focuspolicy

Conversation

@aevyrie

@aevyrie aevyrie commented Jul 10, 2023

Copy link
Copy Markdown
Owner
  • Changed: The plugin no longer respects bevy_ui's FocusPolicy. This was proving to cause problems
    as mod_picking and bevy_ui have some fundamental differences that cannot be reconciled. This has
    been replaced by added fields on the Pickable component. You can use this to override the
    behavior of any entity in picking. This allows you to decide if that entity will block lower
    entities (on by default), and if that entity should emit events and be hover-able (on by default).
    • To make objects non-pickable, instead of removing the Pickable entity, use the new const
      value Pickable::IGNORE.
  • Changed: The Pickable component is now optional. Backends can choose to use it for optimization,
    but should not filter out entities that do not have this component. An example of an optimization
    would be to early exit and stop raycasting once an entity is hit that blocks the entities below
    it.
  • Changed: To fully remove bevy_ui as a dependency and avoid issues similar to the FocusPolicy
    change, bevy_mod_picking no longer updates the bevy_ui Interaction state. This has been replaced
    with a PickInteraction component that serves a similar purpose. This component aggregates the
    picking state of an entity (press, hover, none) across all pointers.
  • Changed: PickLayer, used to order data from backends that targets the same render target, such
    as multiple render passes on the same window, has been changed from an isize to an f32. This
    change was made to support bevy_ui, which is "special" and can be rendered on any camera via a
    flag, instead of being rendered with its own camera. The bevy_ui backend now sets the order of any
    events emitted to be the camera order plus 0.5, which was not possible with an integer.
  • Changed: The PointerInteraction component, which is added to pointers and tracks all entities
    being interacted with has changed internally from a hashmap of entities and their Interaction to
    a sorted list of entities and HitData, sorted by depth. This better reflects how pointer data
    would be expected to work, and makes it easier to find the topmost entity under each pointer.
  • Added: get_nearest_hit method added to PointerInteraction
  • Changed: Moved PointerInteraction from the focus module to pointer.

Comment thread backends/bevy_picking_ui/src/lib.rs
Comment thread crates/bevy_picking_core/src/focus.rs Outdated
Comment thread crates/bevy_picking_core/src/focus.rs Outdated
Comment thread crates/bevy_picking_core/src/lib.rs Outdated
Comment thread crates/bevy_picking_core/src/focus.rs Outdated
Comment thread crates/bevy_picking_core/src/lib.rs Outdated
Comment thread backends/bevy_picking_ui/src/lib.rs Outdated
Comment thread backends/bevy_picking_sprite/src/lib.rs
Comment thread crates/bevy_picking_core/src/focus.rs Outdated
@aevyrie

aevyrie commented Jul 12, 2023

Copy link
Copy Markdown
Owner Author

Had a discussion about this offline.

  • Picking should work automatically, the Pickable component should only act as an override
  • Add two booleans in the override:
    • block_lower: should this entity block interacting with lower entities
    • emit_events: should this entity emit events
    • By default, entities without the component should block and emit events.
  • Backends can ignore this component, but may want to use it as a form of optimization. For example, during raycasting it might be desirable to early-exit if an entity is hit that blocks the entities below it.

@aevyrie aevyrie merged commit 7ed321e into main Aug 20, 2023
@aevyrie aevyrie deleted the remove-focuspolicy branch August 20, 2023 08:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants