module: change state to avoid undefined, remove global allocator

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-04-05 17:05:48 -07:00 committed by Stephen Gutekanst
parent 5dbf9ece3b
commit cf883f5544
11 changed files with 271 additions and 222 deletions

View file

@ -83,17 +83,11 @@ test "example" {
try world.init(allocator);
defer world.deinit(allocator);
// TODO: better module initialization location
world.mod.physics.entities = &world.entities;
world.mod.physics.allocator = world.entities.allocator;
world.mod.renderer.entities = &world.entities;
world.mod.renderer.allocator = world.entities.allocator;
// Initialize module state.
var physics = &world.mod.physics;
var renderer = &world.mod.renderer;
physics.state = .{ .pointer = 123 };
_ = physics.state.pointer; // == 123
physics.init(.{ .pointer = 123 });
_ = physics.state().pointer; // == 123
const player1 = try physics.newEntity();
const player2 = try physics.newEntity();