bevy/crates/bevy_core_pipeline/src
Zachary Harrold d0c0bad7b4
Split Component::register_component_hooks into individual methods (#17685)
# Objective

- Fixes #17411

## Solution

- Deprecated `Component::register_component_hooks`
- Added individual methods for each hook which return `None` if the hook
is unused.

## Testing

- CI

---

## Migration Guide

`Component::register_component_hooks` is now deprecated and will be
removed in a future release. When implementing `Component` manually,
also implement the respective hook methods on `Component`.

```rust
// Before
impl Component for Foo {
    // snip
    fn register_component_hooks(hooks: &mut ComponentHooks) {
            hooks.on_add(foo_on_add);
    }
}

// After
impl Component for Foo {
    // snip
    fn on_add() -> Option<ComponentHook> {
            Some(foo_on_add)
    }
}
```

## Notes

I've chosen to deprecate `Component::register_component_hooks` rather
than outright remove it to ease the migration guide. While it is in a
state of deprecation, it must be used by
`Components::register_component_internal` to ensure users who haven't
migrated to the new hook definition scheme aren't left behind. For users
of the new scheme, a default implementation of
`Component::register_component_hooks` is provided which forwards the new
individual hook implementations.

Personally, I think this is a cleaner API to work with, and would allow
the documentation for hooks to exist on the respective `Component`
methods (e.g., documentation for `OnAdd` can exist on
`Component::on_add`). Ideally, `Component::on_add` would be the hook
itself rather than a getter for the hook, but it is the only way to
early-out for a no-op hook, which is important for performance.

## Migration Guide

`Component::register_component_hooks` has been deprecated. If you are
manually implementing the `Component` trait and registering hooks there,
use the individual methods such as `on_add` instead for increased
clarity.
2025-02-05 19:33:05 +00:00
..
auto_exposure Move hashbrown and foldhash out of bevy_utils (#17460) 2025-01-23 16:46:08 +00:00
blit Expose Pipeline Compilation Zero Initialize Workgroup Memory Option (#16301) 2024-11-08 21:42:37 +00:00
bloom Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
contrast_adaptive_sharpening Remove all deprecated code (#16338) 2025-01-05 20:33:39 +00:00
core_2d Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. (#17413) 2025-01-27 05:02:46 +00:00
core_3d Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. (#17413) 2025-01-27 05:02:46 +00:00
deferred Key render phases off the main world view entity, not the render world view entity. (#16942) 2025-01-12 20:24:17 +00:00
dof Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
experimental Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. (#17413) 2025-01-27 05:02:46 +00:00
fullscreen_vertex_shader
fxaa Don't reëxport bevy_image from bevy_render (#16163) 2024-11-10 06:54:38 +00:00
motion_blur Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
oit Split Component::register_component_hooks into individual methods (#17685) 2025-02-05 19:33:05 +00:00
post_process Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
prepass Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. (#17413) 2025-01-27 05:02:46 +00:00
skybox Fix calculation of skybox rotation (#17476) 2025-01-28 05:27:22 +00:00
smaa Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
taa Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
tonemapping bevy_core_pipeline: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17137) 2025-01-14 21:33:28 +00:00
upscaling Move hashbrown and foldhash out of bevy_utils (#17460) 2025-01-23 16:46:08 +00:00
lib.rs Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. (#17413) 2025-01-27 05:02:46 +00:00
msaa_writeback.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00