bump for new zig version

master
Mike Desaro 4 years ago
parent d6cfdbe671
commit a18a627f98

@ -5,8 +5,8 @@ pub fn build(b: *Builder) void {
const buildMode = b.standardReleaseOptions(); const buildMode = b.standardReleaseOptions();
const examples = [_][2][]const u8{ const examples = [_][2][]const u8{
[_][]const u8{ "group_sort", "examples/group_sort.zig" },
[_][]const u8{ "view_vs_group", "examples/view_vs_group.zig" }, [_][]const u8{ "view_vs_group", "examples/view_vs_group.zig" },
[_][]const u8{ "group_sort", "examples/group_sort.zig" },
[_][]const u8{ "simple", "examples/simple.zig" }, [_][]const u8{ "simple", "examples/simple.zig" },
}; };

@ -32,7 +32,7 @@ fn createEntities(reg: *ecs.Registry) void {
} }
var end = timer.lap(); var end = timer.lap();
std.debug.warn("create {d} entities: {d}\n", .{total_entities, @intToFloat(f64, end) / 1000000000}); std.debug.warn("create {d} entities: {d}\n", .{ total_entities, @intToFloat(f64, end) / 1000000000 });
} }
fn owningGroup(reg: *ecs.Registry) void { fn owningGroup(reg: *ecs.Registry) void {
@ -59,7 +59,6 @@ fn owningGroup(reg: *ecs.Registry) void {
end = timer.lap(); end = timer.lap();
std.debug.warn("group (sort 2): {d}\n", .{@intToFloat(f64, end) / 1000000000}); std.debug.warn("group (sort 2): {d}\n", .{@intToFloat(f64, end) / 1000000000});
// var group_iter2 = group.iterator(struct { vel: *Velocity, pos: *Position }); // var group_iter2 = group.iterator(struct { vel: *Velocity, pos: *Position });
// while (group_iter2.next()) |e| { // while (group_iter2.next()) |e| {
// std.debug.warn("pos.y {d:.3}, ent: {}\n", .{e.pos.y, group_iter2.entity()}); // std.debug.warn("pos.y {d:.3}, ent: {}\n", .{e.pos.y, group_iter2.entity()});

@ -67,7 +67,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type {
entities: *const []Entity, entities: *const []Entity,
pub fn init(view: *Self) Iterator { pub fn init(view: *Self) Iterator {
const ptr = view.registry.components.getValue(view.type_ids[0]).?; const ptr = view.registry.components.get(view.type_ids[0]).?;
const entities = @intToPtr(*Storage(u8), ptr).dataPtr(); const entities = @intToPtr(*Storage(u8), ptr).dataPtr();
return .{ return .{
.view = view, .view = view,
@ -85,7 +85,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type {
// entity must be in all other Storages // entity must be in all other Storages
for (it.view.type_ids) |tid| { for (it.view.type_ids) |tid| {
const ptr = it.view.registry.components.getValue(tid).?; const ptr = it.view.registry.components.get(tid).?;
if (!@intToPtr(*Storage(u1), ptr).contains(entity)) { if (!@intToPtr(*Storage(u1), ptr).contains(entity)) {
break :blk; break :blk;
} }
@ -93,7 +93,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type {
// entity must not be in all other excluded Storages // entity must not be in all other excluded Storages
for (it.view.exclude_type_ids) |tid| { for (it.view.exclude_type_ids) |tid| {
const ptr = it.view.registry.components.getValue(tid).?; const ptr = it.view.registry.components.get(tid).?;
if (@intToPtr(*Storage(u1), ptr).contains(entity)) { if (@intToPtr(*Storage(u1), ptr).contains(entity)) {
break :blk; break :blk;
} }
@ -129,7 +129,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type {
// get our component counts in an array so we can sort the type_ids based on how many entities are in each // get our component counts in an array so we can sort the type_ids based on how many entities are in each
var sub_items: [n_includes]usize = undefined; var sub_items: [n_includes]usize = undefined;
for (self.type_ids) |tid, i| { for (self.type_ids) |tid, i| {
const ptr = self.registry.components.getValue(tid).?; const ptr = self.registry.components.get(tid).?;
const store = @intToPtr(*Storage(u8), ptr); const store = @intToPtr(*Storage(u8), ptr);
sub_items[i] = store.len(); sub_items[i] = store.len();
} }

@ -21,7 +21,6 @@ const Thing = struct {
} }
}; };
test "Dispatcher" { test "Dispatcher" {
var thing = Thing{}; var thing = Thing{};
@ -37,4 +36,4 @@ test "Dispatcher" {
sink2.connect(tester2); sink2.connect(tester2);
sink2.connectBound(&thing, "testI32"); sink2.connectBound(&thing, "testI32");
d.trigger(i32, -543); d.trigger(i32, -543);
} }

@ -13,7 +13,7 @@ const Transform = struct { x: f32 = 0 };
const Renderable = struct { x: f32 = 0 }; const Renderable = struct { x: f32 = 0 };
const Rotation = struct { x: f32 = 0 }; const Rotation = struct { x: f32 = 0 };
fn printStore(store: var, name: []const u8) void { fn printStore(store: anytype, name: []const u8) void {
warn("--- {} ---\n", .{name}); warn("--- {} ---\n", .{name});
for (store.set.dense.items) |e, i| { for (store.set.dense.items) |e, i| {
warn("e[{}] s[{}]{}", .{ e, store.set.page(store.set.dense.items[i]), store.set.sparse.items[store.set.page(store.set.dense.items[i])] }); warn("e[{}] s[{}]{}", .{ e, store.set.page(store.set.dense.items[i]), store.set.sparse.items[store.set.page(store.set.dense.items[i])] });
@ -106,11 +106,11 @@ test "sort OwningGroup by Entity" {
return sprite_a.x > sprite_b.x; return sprite_a.x > sprite_b.x;
} }
}; };
const context = SortContext{.group = group}; const context = SortContext{ .group = group };
group.sort(ecs.Entity, context, SortContext.sort); group.sort(ecs.Entity, context, SortContext.sort);
var val: f32 = 0; var val: f32 = 0;
var iter = group.iterator(struct {s: *Sprite, r: *Renderable}); var iter = group.iterator(struct { s: *Sprite, r: *Renderable });
while (iter.next()) |entity| { while (iter.next()) |entity| {
std.testing.expectEqual(val, entity.s.*.x); std.testing.expectEqual(val, entity.s.*.x);
val += 1; val += 1;
@ -138,7 +138,7 @@ test "sort OwningGroup by Component" {
group.sort(Sprite, {}, SortContext.sort); group.sort(Sprite, {}, SortContext.sort);
var val: f32 = 0; var val: f32 = 0;
var iter = group.iterator(struct {s: *Sprite, r: *Renderable}); var iter = group.iterator(struct { s: *Sprite, r: *Renderable });
while (iter.next()) |entity| { while (iter.next()) |entity| {
std.testing.expectEqual(val, entity.s.*.x); std.testing.expectEqual(val, entity.s.*.x);
val += 1; val += 1;

@ -17,7 +17,7 @@ test "Registry" {
var e1 = reg.create(); var e1 = reg.create();
reg.addTypes(e1, .{Empty, Position}); reg.addTypes(e1, .{ Empty, Position });
reg.add(e1, BigOne{ .pos = Position{ .x = 5, .y = 5 }, .vel = Velocity{ .x = 5, .y = 5 }, .accel = Velocity{ .x = 5, .y = 5 } }); reg.add(e1, BigOne{ .pos = Position{ .x = 5, .y = 5 }, .vel = Velocity{ .x = 5, .y = 5 }, .accel = Velocity{ .x = 5, .y = 5 } });
std.testing.expect(reg.has(Empty, e1)); std.testing.expect(reg.has(Empty, e1));

Loading…
Cancel
Save