[Merged by Bors] - Add get_change_ticks method to EntityRef and EntityMut#2539
[Merged by Bors] - Add get_change_ticks method to EntityRef and EntityMut#2539TheRawMeatball wants to merge 7 commits intobevyengine:mainfrom
Conversation
|
As this is a little advanced, some doc comments would be nice 😃 |
| pub fn get_change_ticks<T: Component>(&self) -> Option<&'w ComponentTicks> { | ||
| // SAFE: entity location is valid and returned component is of type T | ||
| unsafe { | ||
| get_component_and_ticks_with_type( |
There was a problem hiding this comment.
I know you're trying to reuse code here, but we don't need to retrieve the component for this operation. This seems like the sort of small inefficiency that we'd merge and then forget about. A theoretical get_ticks and the existing get_component and get_component_with_ticks methods probably have some refactoring potential to share code. They all need to "get the entity's offset in each storage". This seems like a relatively trivial refactor for Table storage, but Sparse Set storage would probably need some new get_with_dense_index_unchecked() apis.
|
Closing as I no longer need this, might reopen if I do. |
|
Reopening because I need this |
| component_id: ComponentId, | ||
| entity: Entity, | ||
| location: EntityLocation, | ||
| ) -> Option<*mut ComponentTicks> { |
There was a problem hiding this comment.
This should use the new pointer types that you added in #3001 now.
|
|
||
| #[inline] | ||
| pub fn get_ticks(&self, entity: Entity) -> Option<&ComponentTicks> { | ||
| pub fn get_ticks_ptr(&self, entity: Entity) -> Option<*mut ComponentTicks> { |
There was a problem hiding this comment.
This should use the new pointer types that you added in #3001 now.
alice-i-cecile
left a comment
There was a problem hiding this comment.
I'm having a hard time seeing what users would do with this, but I'm open to being convinced.
In any case, now that #3001 is merged, we can use lifetimed pointers!
|
bors r+ |
Direct access to the change ticks is useful for integrating the reliable change detection with external stuff.
Direct access to the change ticks is useful for integrating the reliable change detection with external stuff.
Direct access to the change ticks is useful for integrating the reliable change detection with external stuff.
Direct access to the change ticks is useful for integrating the reliable change detection with external stuff.