bevy/crates/bevy_picking/src
Eagster 064e5e48b4
Remove entity placeholder from observers (#19440)
# Objective

`Entity::PLACEHOLDER` acts as a magic number that will *probably* never
really exist, but it certainly could. And, `Entity` has a niche, so the
only reason to use `PLACEHOLDER` is as an alternative to `MaybeUninit`
that trades safety risks for logic risks.

As a result, bevy has generally advised against using `PLACEHOLDER`, but
we still use if for a lot internally. This pr starts removing internal
uses of it, starting from observers.

## Solution

Change all trigger target related types from `Entity` to
`Option<Entity>`

Small migration guide to come.

## Testing

CI

## Future Work

This turned a lot of code from 

```rust
trigger.target()
```

to 

```rust
trigger.target().unwrap()
```

The extra panic is no worse than before; it's just earlier than
panicking after passing the placeholder to something else.

But this is kinda annoying. 

I would like to add a `TriggerMode` or something to `Event` that would
restrict what kinds of targets can be used for that event. Many events
like `Removed` etc, are always triggered with a target. We can make
those have a way to assume Some, etc. But I wanted to save that for a
future pr.
2025-06-09 19:37:56 +00:00
..
mesh_picking Updating mesh_picking doc to include RenderAssetUsages (#19413) 2025-05-29 18:44:50 +00:00
backend.rs Add boilerplate docs for PointerHits::new and HitData::new (#19259) 2025-05-19 19:22:07 +00:00
events.rs Mention in the docs for pointer events that these are in screen-space. (#19518) 2025-06-06 22:20:14 +00:00
hover.rs Fix PickingInteraction change detection (#19488) 2025-06-08 16:29:13 +00:00
input.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
lib.rs Remove entity placeholder from observers (#19440) 2025-06-09 19:37:56 +00:00
pointer.rs fix(picking): Location is not a Component anymore. (#19306) 2025-05-22 01:33:01 +00:00
window.rs Renamed EventWriter::send methods to write. (#17977) 2025-02-23 21:18:52 +00:00