From c9d228bf19310bf1df0641eadce7664d76f515c1 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 9 Jun 2020 16:34:07 -0700 Subject: [PATCH] cleaner --- zig-ecs/src/ecs/groups.zig | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/zig-ecs/src/ecs/groups.zig b/zig-ecs/src/ecs/groups.zig index 0529570..a630db4 100644 --- a/zig-ecs/src/ecs/groups.zig +++ b/zig-ecs/src/ecs/groups.zig @@ -179,27 +179,8 @@ pub const OwningGroup = struct { else => std.debug.assert("invalid func"), }; - 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]; - } - + var iter = self.iterator(Components); + while (iter.next()) |comps| { @call(.{ .modifier = .always_inline }, func, .{comps}); } }