include both!
This commit is contained in:
parent
c9d228bf19
commit
1d283cfddd
@ -179,8 +179,33 @@ pub const OwningGroup = struct {
|
||||
else => std.debug.assert("invalid func"),
|
||||
};
|
||||
|
||||
var iter = self.iterator(Components);
|
||||
while (iter.next()) |comps| {
|
||||
// optionally we could just use an Interator here
|
||||
// var iter = self.iterator(Components);
|
||||
// while (iter.next()) |comps| {
|
||||
// @call(.{ .modifier = .always_inline }, func, .{comps});
|
||||
// }
|
||||
|
||||
const component_info = @typeInfo(Components).Struct;
|
||||
|
||||
// get the data pointers for the chunks
|
||||
var component_ptrs: [component_info.fields.len][*]u8 = undefined;
|
||||
inline for (component_info.fields) |field, i| {
|
||||
const storage = self.registry.assure(field.field_type.Child);
|
||||
component_ptrs[i] = @ptrCast([*]u8, storage.instances.items.ptr);
|
||||
}
|
||||
|
||||
var storage = self.firstOwnedStorage();
|
||||
var index: usize = 0;
|
||||
while (index < self.group_data.current) : (index += 1) {
|
||||
const ent = storage.set.dense.items[index];
|
||||
const entity_index = storage.set.index(ent);
|
||||
|
||||
var comps: Components = undefined;
|
||||
inline for (component_info.fields) |field, i| {
|
||||
const typed_ptr = @ptrCast([*]field.field_type.Child, @alignCast(@alignOf(field.field_type.Child), component_ptrs[i]));
|
||||
@field(comps, field.name) = &typed_ptr[entity_index];
|
||||
}
|
||||
|
||||
@call(.{ .modifier = .always_inline }, func, .{comps});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user