mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
218f78157d
# Objective The method `World::increment_change_tick` currently takes `&self` as the method receiver, which is semantically strange. Even though the interior mutability is sound, the existence of this method is strange since we tend to think of `&World` as being a read-only snapshot of a world, not an aliasable reference to a world with mutability. For those purposes, we have `UnsafeWorldCell`. ## Solution Change the method signature to take `&mut self`. Use exclusive access to remove the need for atomic adds, which makes the method slightly more efficient. Redirect users to [`UnsafeWorldCell::increment_change_tick`] if they need to increment the world's change tick from an aliased context. In practice I don't think there will be many breakages, if any. In cases where you need to call `increment_change_tick`, you usually already have either `&mut World` or `UnsafeWorldCell`. --- ## Migration Guide The method `World::increment_change_tick` now requires `&mut self` instead of `&self`. If you need to call this method but do not have mutable access to the world, consider using `world.as_unsafe_world_cell_readonly().increment_change_tick()`, which does the same thing, but is less efficient than the method on `World` due to requiring atomic synchronization. ```rust fn my_system(world: &World) { // Before world.increment_change_tick(); // After world.as_unsafe_world_cell_readonly().increment_change_tick(); } ``` |
||
---|---|---|
.. | ||
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_encase_derive | ||
bevy_gilrs | ||
bevy_gizmos | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_math | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_picking | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_state | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |