bevy/crates/bevy_render/src
James Liu e954b8573c Lock down access to Entities (#6740)
# Objective
The soundness of the ECS `World` partially relies on the correctness of the state of `Entities` stored within it. We're currently allowing users to (unsafely) mutate it, as well as readily construct it without using a `World`. While this is not strictly unsound so long as users (including `bevy_render`) safely use the APIs, it's a fairly easy path to unsoundness without much of a guard rail.

Addresses #3362 for `bevy_ecs::entity`. Incorporates the changes from #3985.

## Solution
Remove `Entities`'s  `Default` implementation and force access to the type to only be through a properly constructed `World`.

Additional cleanup for other parts of `bevy_ecs::entity`:

 - `Entity::index` and `Entity::generation` are no longer `pub(crate)`, opting to force the rest of bevy_ecs to use the public interface to access these values.
 - `EntityMeta` is no longer `pub` and also not `pub(crate)` to attempt to cut down on updating `generation` without going through an `Entities` API. It's currently inaccessible except via the `pub(crate)` Vec on `Entities`, there was no way for an outside user to use it.
 - Added `Entities::set`, an unsafe `pub(crate)` API for setting the location of an Entity (parallel to `Entities::get`) that replaces the internal case where we need to set the location of an entity when it's been spawned, moved, or despawned.
 - `Entities::alloc_at_without_replacement` is only used in `World::get_or_spawn` within the first party crates, and I cannot find a public use of this API in any ecosystem crate that I've checked (via GitHub search).
 - Attempted to document the few remaining undocumented public APIs in the module.

---

## Changelog
Removed: `Entities`'s `Default` implementation.
Removed: `EntityMeta`
Removed: `Entities::alloc_at_without_replacement` and `AllocAtWithoutReplacement`.

Co-authored-by: james7132 <contact@jamessliu.com>
Co-authored-by: James Liu <contact@jamessliu.com>
2022-11-28 20:39:02 +00:00
..
camera bevy_reflect: Register missing reflected types for bevy_render (#6725) 2022-11-23 00:41:21 +00:00
color Correctly use as_hsla_f32 in Add<Color> and AddAssign<Color>, fixes #5543 (#5546) 2022-08-17 14:00:10 +00:00
mesh bevy_reflect: Register missing reflected types for bevy_render (#6725) 2022-11-23 00:41:21 +00:00
primitives Very minor doc formatting changes (#5287) 2022-07-12 13:06:16 +00:00
render_graph Add try_* to add_slot_edge, add_node_edge (#6720) 2022-11-21 21:58:39 +00:00
render_phase Add DrawFunctionsInternals::id() (#6745) 2022-11-28 13:54:13 +00:00
render_resource set AVAILABLE_STORAGE_BUFFER_BINDINGS to the actual number of buffers available (#6787) 2022-11-28 19:27:04 +00:00
renderer Add try_* to add_slot_edge, add_node_edge (#6720) 2022-11-21 21:58:39 +00:00
texture Add support for Rgb9e5Ufloat textures (#6781) 2022-11-28 14:14:08 +00:00
view bevy_reflect: Register missing reflected types for bevy_render (#6725) 2022-11-23 00:41:21 +00:00
extract_component.rs ExtractComponent output optional associated type (#6699) 2022-11-21 13:19:44 +00:00
extract_param.rs Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
extract_resource.rs Prepare for upcoming rustlang by fixing upcoming clippy warnings (#6376) 2022-10-26 19:15:15 +00:00
globals.rs bevy_reflect: Register missing reflected types for bevy_render (#6725) 2022-11-23 00:41:21 +00:00
lib.rs Lock down access to Entities (#6740) 2022-11-28 20:39:02 +00:00
rangefinder.rs Very minor doc formatting changes (#5287) 2022-07-12 13:06:16 +00:00
render_asset.rs Fix clippy::iter_with_drain (#6485) 2022-11-06 01:42:15 +00:00
settings.rs Make Resource trait opt-in, requiring #[derive(Resource)] V2 (#5577) 2022-08-08 21:36:35 +00:00
spatial_bundle.rs Add associated constant IDENTITY to Transform and friends. (#5340) 2022-08-30 22:10:24 +00:00