Fix Iter.field for non-owned components

main
copygirl 1 year ago
parent c8ec920290
commit ceb1f4cd80
  1. 4
      src/iter.zig

@ -43,7 +43,9 @@ pub fn Iter(comptime ctx: anytype) type {
pub fn field(self: Self, comptime T: type, index: usize) []T {
var raw_ptr = c.ecs_field_w_size(self.raw, @sizeOf(T), @intCast(index));
var typed_ptr: [*]T = @alignCast(@ptrCast(raw_ptr));
return typed_ptr[0..self.getCount()];
const is_self = c.ecs_field_is_self(self.raw, @intCast(index));
const count = if (is_self) self.getCount() else 1;
return typed_ptr[0..count];
}
pub fn fieldId(self: Self, index: usize) Id(ctx) {

Loading…
Cancel
Save