bevy/crates/bevy_render/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
..
batching clippy: expect large variants and other small fixes (#19222) 2025-05-15 22:29:59 +00:00
camera Add CameraMainTextureUsages helper method (#19549) 2025-06-09 04:54:14 +00:00
diagnostic refactor(render): move WgpuWrapper into bevy_utils (#19303) 2025-05-27 03:43:49 +00:00
experimental Remove Shader weak_handles from bevy_render. (#19362) 2025-05-26 20:20:25 +00:00
mesh clippy: expect large variants and other small fixes (#19222) 2025-05-15 22:29:59 +00:00
primitives reexport entity set collections in entity module (#18413) 2025-03-30 03:51:14 +00:00
render_graph Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
render_phase Remove ArchetypeComponentId and archetype_component_access (#19143) 2025-05-27 19:04:32 +00:00
render_resource Add more wgpu helpers/types (#19548) 2025-06-09 04:54:02 +00:00
renderer bevyengine.org -> bevy.org (#19503) 2025-06-05 23:09:28 +00:00
texture Optional explicit compressed image format support (#19190) 2025-05-26 18:00:33 +00:00
view Unrequire VisibilityClass from Node (#17918) 2025-05-31 08:18:01 +00:00
alpha.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
bindless.wgsl Use global binding arrays for bindless resources. (#17898) 2025-02-21 05:55:36 +00:00
color_operations.wgsl move wgsl color operations from bevy_pbr to bevy_render (#13209) 2024-05-04 10:30:23 +00:00
extract_component.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
extract_instances.rs Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
extract_param.rs Remove ArchetypeComponentId and archetype_component_access (#19143) 2025-05-27 19:04:32 +00:00
extract_resource.rs Fix "Unrecognized Option" error when using Criterion-specific arguments in benchmarks (#17222) 2025-01-08 00:09:31 +00:00
globals.rs Remove Shader weak_handles from bevy_render. (#19362) 2025-05-26 20:20:25 +00:00
globals.wgsl Refactor Globals and View structs into separate shaders (#7512) 2023-02-11 17:55:18 +00:00
gpu_component_array_buffer.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
gpu_readback.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
lib.rs bevyengine.org -> bevy.org (#19503) 2025-06-05 23:09:28 +00:00
maths.wgsl Atmosphere LUT parameterization improvements (#17555) 2025-02-03 21:52:11 +00:00
pipelined_rendering.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
render_asset.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
settings.rs clippy: expect large variants and other small fixes (#19222) 2025-05-15 22:29:59 +00:00
storage.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
sync_component.rs Refactored ComponentHook Parameters into HookContext (#17503) 2025-01-23 02:45:24 +00:00
sync_world.rs Remove entity placeholder from observers (#19440) 2025-06-09 19:37:56 +00:00