Deprecate insert_or_spawn function family#18147
Deprecate insert_or_spawn function family#18147alice-i-cecile merged 6 commits intobevyengine:mainfrom
insert_or_spawn function family#18147Conversation
Mark this as deprecated so it's easier to find and remove later please :) |
alice-i-cecile
left a comment
There was a problem hiding this comment.
Can you link the issue number in the deprecation notice please? I'd like to funnel affected users to it, and it's a much more compelling explanation than a bare assertion that this is slow.
Great idea! I've added the issue number. If you like, I'd be happy to change it to a full link too. |
|
Merging the prerequisite PR, then this. |
# Objective Based on and closes #18054, this PR builds on #18035 and #18147 to remove: - `Commands::insert_or_spawn_batch` - `Entities::alloc_at_without_replacement` - `Entities::alloc_at` - `entity::AllocAtWithoutReplacement` - `World::insert_or_spawn_batch` - `World::insert_or_spawn_batch_with_caller` ## Testing Just removing unused, deprecated code, so no new tests. Note that as of writing, #18035 is still under testing and review. ## Future Work Per [this](#18054 (comment)) comment on #18054, there may be additional performance improvements possible to the entity allocator now that `alloc_at` no longer is supported. At a glance, I don't see anything obvious to improve, but it may be worth further investigation in the future. --------- Co-authored-by: JaySpruce <jsprucebruce@gmail.com>
# Objective Based on and closes bevyengine#18054, this PR builds on bevyengine#18035 and bevyengine#18147 to remove: - `Commands::insert_or_spawn_batch` - `Entities::alloc_at_without_replacement` - `Entities::alloc_at` - `entity::AllocAtWithoutReplacement` - `World::insert_or_spawn_batch` - `World::insert_or_spawn_batch_with_caller` ## Testing Just removing unused, deprecated code, so no new tests. Note that as of writing, bevyengine#18035 is still under testing and review. ## Future Work Per [this](bevyengine#18054 (comment)) comment on bevyengine#18054, there may be additional performance improvements possible to the entity allocator now that `alloc_at` no longer is supported. At a glance, I don't see anything obvious to improve, but it may be worth further investigation in the future. --------- Co-authored-by: JaySpruce <jsprucebruce@gmail.com>
Objective
Based on #18054, this PR builds on #18035 to deprecate:
Commands::insert_or_spawn_batchEntities::alloc_at_without_replacementEntities::alloc_atWorld::insert_or_spawn_batchWorld::insert_or_spawn_batch_with_callerTesting
Just deprecation, so no new tests. Note that as of writing #18035 is still under testing and review.
Open Questions
entity::AllocAtWithoutReplacementbe deprecated? It is internal and only used inEntities::alloc_at_without_replacement. EDIT: Now deprecated.Migration Guide
The following functions have been deprecated:
Commands::insert_or_spawn_batchWorld::insert_or_spawn_batchWorld::insert_or_spawn_batch_with_callerThese functions, when used incorrectly, can cause major performance problems and are generally viewed as anti-patterns and foot guns. These are planned to be removed altogether in 0.17.
Instead of these functions consider doing one of the following:
Option A) Instead of despawing entities and re-spawning them at a particular id, insert the new
Disabledcomponent without despawning the entity, and usetry_insert_batchorinsert_batchand removeDisabledinstead of re-spawning it.Option B) Instead of giving special meaning to an entity id, simply use
spawn_batchand ensure entity references are valid when despawning.