Rename Iter.count and .deltaTime

main
copygirl 9 months ago
parent 772908b3c1
commit 248f0af204
  1. 8
      src/iter.zig
  2. 4
      src/test/flecs/world.zig
  3. 4
      src/test/util.zig

@ -33,11 +33,11 @@ pub fn Iter(comptime ctx: anytype) type {
return (self.raw.flags & c.EcsIterIsValid) != 0; return (self.raw.flags & c.EcsIterIsValid) != 0;
} }
pub fn getCount(self: Self) usize { pub fn count(self: Self) usize {
return @intCast(self.raw.count); return @intCast(self.raw.count);
} }
pub fn getDeltaTime(self: Self) f32 { pub fn deltaTime(self: Self) f32 {
return self.raw.delta_time; return self.raw.delta_time;
} }
@ -45,8 +45,8 @@ pub fn Iter(comptime ctx: anytype) type {
const raw_ptr = c.ecs_field_w_size(self.raw, @sizeOf(T), @intCast(index)); const raw_ptr = c.ecs_field_w_size(self.raw, @sizeOf(T), @intCast(index));
var typed_ptr: [*]T = @alignCast(@ptrCast(raw_ptr)); var typed_ptr: [*]T = @alignCast(@ptrCast(raw_ptr));
const is_self = c.ecs_field_is_self(self.raw, @intCast(index)); const is_self = c.ecs_field_is_self(self.raw, @intCast(index));
const count = if (is_self) self.getCount() else 1; const count_ = if (is_self) self.count() else 1;
return typed_ptr[0..count]; return typed_ptr[0..count_];
} }
pub fn fieldId(self: Self, index: usize) Id { pub fn fieldId(self: Self, index: usize) Id {

@ -24,8 +24,8 @@ fn move(it: Iter) void {
util.Probe.probeIter(it) catch unreachable; util.Probe.probeIter(it) catch unreachable;
for (pos, vel) |*p, *v| { for (pos, vel) |*p, *v| {
p.x += v.x * it.getDeltaTime(); p.x += v.x * it.deltaTime();
p.y += v.y * it.getDeltaTime(); p.y += v.y * it.deltaTime();
} }
} }

@ -50,7 +50,7 @@ pub const Probe = struct {
try expect(e != 0); try expect(e != 0);
} }
for (0..it.getCount()) |i| { for (0..it.count()) |i| {
if (i + ctx.count < 256) { if (i + ctx.count < 256) {
ctx.e[i + ctx.count] = it.raw.entities[i]; ctx.e[i + ctx.count] = it.raw.entities[i];
} else { } else {
@ -59,7 +59,7 @@ pub const Probe = struct {
unreachable; unreachable;
} }
} }
ctx.count += it.getCount(); ctx.count += it.count();
ctx.invoked += 1; ctx.invoked += 1;
} }

Loading…
Cancel
Save