mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 22:18:33 +00:00
# Objective - ~~This PR adds more flexible versions of `set_if_neq` and `replace_if_neq` to only compare and update certain fields of a components which is not just a newtype~~ - https://github.com/bevyengine/bevy/pull/12919#issuecomment-2048049786 gave a good solution to the original problem, so let's update the docs so that this is easier to find ## Solution - ~~Add `set_if_neq_with` and `replace_if_neq_with` which take an accessor closure to access the relevant field~~ --- In a recent project, a scenario emerged that required careful consideration regarding change detection without compromising performance. The context involves a component that maintains a collection of `Vec<Vec2>` representing a horizontal surface, alongside a height field. When the height is updated, there are a few approaches to consider: 1. Clone the collection of points to utilize the existing `set_if_neq` method. 2. Inline and adjust the `set_if_neq` code specifically for this scenario. 3. (Consider splitting the component into more granular components.) It's worth noting that the third option might be the most suitable in most cases. A similar situation arises with the Bevy internal Transform component, which includes fields for translation, rotation, and scale. These fields are relatively small (`Vec3` or `Quat` with 3 or 4 `f32` values), but the creation of a single pointer (`usize`) might be more efficient than copying the data of the other fields. This is speculative, and insights from others could be valuable. Questions remain: - Is it feasible to develop a more flexible API, and what might that entail? - Is there general interest in this change? There's no hard feelings if this idea or the PR is ultimately rejected. I just wanted to put this idea out there and hope that this might be beneficial to others and that feedback could be valuable before abandoning the idea. |
||
---|---|---|
.. | ||
bevy_a11y | ||
bevy_animation | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_color | ||
bevy_core | ||
bevy_core_pipeline | ||
bevy_derive | ||
bevy_dev_tools | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_dynamic_plugin | ||
bevy_ecs | ||
bevy_ecs_compile_fail_tests | ||
bevy_encase_derive | ||
bevy_gilrs | ||
bevy_gizmos | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_macros_compile_fail_tests | ||
bevy_math | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_reflect_compile_fail_tests | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |