-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug when joining cleared optional components #3726
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -343,7 +343,9 @@ impl<A: Archetype> ArchetypeView<A> { | |
|
||
let component = self.components.get(&C::name()); | ||
|
||
if let Some(component) = component { | ||
let is_empty = component.map_or(true, |c| c.is_empty()); | ||
|
||
if let (Some(component), false) = (component, is_empty) { | ||
// NOTE(1): Autogenerated instance keys are interned behind datacells. | ||
// If two or more rows in the store share the same keys, then they will share | ||
// also the same cells. | ||
|
@@ -357,6 +359,15 @@ impl<A: Archetype> ArchetypeView<A> { | |
// - If the data isn't the same, the cost of the comparison will be dwarfed by the cost | ||
// of the join anyway. | ||
if self.required_comp().instance_keys == component.instance_keys { | ||
// This fast iterator is assumed to match the length of the primary component | ||
// We shouldn't hit this if since the store should enforce matched lengths for | ||
// non-empty components, and the outer if-guard should keep us from reaching this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, I don't think this is true for splats, e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Splats are currently split into their own rows. See: #1893 -- adding a TODO linking to that issue though. |
||
// in the case of an empty component. | ||
debug_assert!( | ||
self.required_comp().instance_keys.num_instances() | ||
== component.values.num_instances() | ||
); | ||
|
||
// NOTE: A component instance cannot be optional in itself, and if we're on this | ||
// path then we know for a fact that both batches can be intersected 1-to-1. | ||
// Therefore there cannot be any null values, therefore we can go through the fast | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please motivate this with a comment, i.e. why only non-empty components?
And does the code handle splat components (length=1) correctly?