Rename SortedRenderPhase add to add_retained#24404
Conversation
eswartz
left a comment
There was a problem hiding this comment.
The rationale for the renaming and forcing users to accommodate the change makes sense to me. I think it warrants an explanatory note in the docs, though.
| @@ -1809,7 +1809,7 @@ where | |||
| { | |||
| /// Adds a [`PhaseItem`] to this render phase. | |||
There was a problem hiding this comment.
Perhaps add a comment here to explain what "retained" means, vs. add_transient?
There was a problem hiding this comment.
For this data structure specifically it doesn't mean much except that the item is not automatically removed. I don't know enough about the change list machinery to give a succinct explanation here, and in principle you could use it in other ways as well.
I guess I could add a "Unlike add_transient, the item is not removed by the end of the frame and needs to be updated by an external system"?
There was a problem hiding this comment.
I guess I could add a "Unlike
add_transient, the item is not removed by the end of the frame and needs to be updated by an external system"?
Right, though I just meant the bare minimum to explain what "retained" means :). Wording it positively, it could be Adds a [PhaseItem] to this render phase, which will persist between frames until removed.
Then the add_transient doc -- which I see is a bit odd to read, could also be reworded to Adds a [PhaseItem] to this render phase, which will be removed automatically after this frame.
Objective
In #22966 the semantics of the
addmethod onSortedRenderPhasewas changed from the items being cleared at the end of the frame, to items being retained until they are removed. A newadd_transientmethod was added with the old functionality, but this is a big migration hazard because it's a major semantic change that doesn't give any compiler errors or warnings.I discovered this after updating
bevy_vector_shapesto the RC and seeing drawings not being cleared properly.Solution
Rename
addtoadd_retainedboth for clarity and to make old uses not compile, so the affected users will know to look in the migration guide.A sentence about this should be added to the migration guide if/when this is backported to the 0.19 release branch.
Testing
It compiles (hopefully).