bevy/crates
IceSentry 613b5a69ae
Add ViewNode to simplify render node management (#8118)
# Objective

- When writing render nodes that need a view, you always need to define
a `Query` on the associated view and make sure to update it manually and
query it manually. This is verbose and error prone.

## Solution

- Introduce a new `ViewNode` trait and `ViewNodeRunner` `Node` that will
take care of managing the associated view query automatically.
- The trait is currently a passthrough of the `Node` trait. So it still
has the update/run with all the same data passed in.
- The `ViewNodeRunner` is the actual node that is added to the render
graph and it contains the custom node. This is necessary because it's
the one that takes care of updating the node.

---

## Changelog

- Add `ViewNode`
- Add `ViewNodeRunner`

## Notes

Currently, this only handles the view query, but it could probably have
a ReadOnlySystemState that would also simplify querying all the readonly
resources that most render nodes currently query manually. The issue is
that I don't know how to do that without a `&mut self`.

At first, I tried making this a default feature of all `Node`, but I
kept hitting errors related to traits and generics and stuff I'm not
super comfortable with. This implementations is much simpler and keeps
the default Node behaviour so isn't a breaking change

## Reviewer Notes

The PR looks quite big, but the core of the PR is the changes in
`render_graph/node.rs`. Every other change is simply updating existing
nodes to use this new feature.

## Open questions

~~- Naming is not final, I'm opened to anything. I named it
ViewQueryNode because it's a node with a managed Query on a View.~~
~~- What to do when the query fails? All nodes using this pattern
currently just `return Ok(())` when it fails, so I chose that, but
should it be more flexible?~~
~~- Is the ViewQueryFilter actually necessary? All view queries run on
the entity that is already guaranteed to be a view. Filtering won't do
much, but maybe someone wants to control an effect with the presence of
a component instead of a flag.~~
~~- What to do with Nodes that are empty struct? Implementing
`FromWorld` is pretty verbose but not implementing it means there's 2
ways to create a `ViewNodeRunner` which seems less ideal. This is an
issue now because most node simply existed to hold the query, but now
that they don't hold the query state we are left with a bunch of empty
structs.~~
- Should we have a `RenderGraphApp::add_render_graph_view_node()`, this
isn't necessary, but it could make the code a bit shorter.

---------

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2023-05-08 19:42:23 +00:00
..
bevy_a11y Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_animation Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
bevy_app Webgpu support (#8336) 2023-05-04 22:07:57 +00:00
bevy_asset Add Reflect and FromReflect for AssetPath (#8531) 2023-05-08 19:19:19 +00:00
bevy_audio Ability to set a Global Volume (#7706) 2023-04-10 14:08:43 +00:00
bevy_core Add Reflect and FromReflect for AssetPath (#8531) 2023-05-08 19:19:19 +00:00
bevy_core_pipeline Add ViewNode to simplify render node management (#8118) 2023-05-08 19:42:23 +00:00
bevy_derive Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_diagnostic Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_dylib Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_dynamic_plugin Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_ecs Fix wording on DetectChanges::is_changed (#8550) 2023-05-05 20:33:02 +00:00
bevy_ecs_compile_fail_tests Fix 1.69 CI clippy lints (#8450) 2023-04-20 16:51:21 +00:00
bevy_encase_derive Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_gilrs Add gamepad rumble support to bevy_input (#8398) 2023-04-24 15:28:53 +00:00
bevy_gizmos Webgpu support (#8336) 2023-05-04 22:07:57 +00:00
bevy_gltf Add support for custom glTF vertex attributes. (#5370) 2023-04-24 14:20:13 +00:00
bevy_hierarchy Expose sorting methods in Children (#8522) 2023-05-01 15:57:25 +00:00
bevy_input Fix typos in gamepad AxisSettings (#8542) 2023-05-04 23:23:45 +00:00
bevy_internal Take example screenshots in CI (#8488) 2023-05-01 18:00:01 +00:00
bevy_log add a feature for memory tracing with tracy (#8272) 2023-04-17 16:04:46 +00:00
bevy_macro_utils Simplify world schedule methods (#8403) 2023-04-19 19:48:35 +00:00
bevy_math Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_mikktspace Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_pbr Webgpu support (#8336) 2023-05-04 22:07:57 +00:00
bevy_ptr Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
bevy_reflect Add Reflect and FromReflect for AssetPath (#8531) 2023-05-08 19:19:19 +00:00
bevy_reflect_compile_fail_tests Fix 1.69 CI clippy lints (#8450) 2023-04-20 16:51:21 +00:00
bevy_render Add ViewNode to simplify render node management (#8118) 2023-05-08 19:42:23 +00:00
bevy_scene Rename map_entities and map_specific_entities (#7570) 2023-05-01 21:40:19 +00:00
bevy_sprite Webgpu support (#8336) 2023-05-04 22:07:57 +00:00
bevy_tasks Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
bevy_text Fix panic when using debug_asset_server (#8485) 2023-04-25 10:11:11 +00:00
bevy_time Take example screenshots in CI (#8488) 2023-05-01 18:00:01 +00:00
bevy_transform Add a bounding box gizmo (#8468) 2023-04-24 15:23:06 +00:00
bevy_ui Replace the local text queues in the text systems with flags stored in a component (#8549) 2023-05-08 13:57:52 +00:00
bevy_utils Simplify world schedule methods (#8403) 2023-04-19 19:48:35 +00:00
bevy_window Make scene handling of entity references robust (#7335) 2023-05-01 15:49:27 +00:00
bevy_winit Webgpu support (#8336) 2023-05-04 22:07:57 +00:00