diff --git a/src/main.zig b/src/main.zig index bf01614..09ad344 100644 --- a/src/main.zig +++ b/src/main.zig @@ -78,13 +78,29 @@ pub fn main() !void { //} raylib.SetShaderValue(shader, raylib.GetShaderLocation(shader, "textureTiling"), &.{ @as(f32, @floatFromInt(tile_columns)), @as(f32, @floatFromInt(tile_rows)) }, raylib.SHADER_UNIFORM_VEC2); - // genegate chunk - var chunk = try generation.generate_world(a7r, 413445, 3445, 0.1); - defer chunk.deinit(); - // generate chunk model for just created chunk - const model = try render.chunk_to_model(chunk, texture, shader, tile_rows, tile_columns); - defer raylib.UnloadChunkModel(model); + + + + + + var list_models = std.ArrayList(raylib.ChunkModel).init(a7r); + defer list_models.deinit(); + + var i: usize = 0; + while (i < 1000) : (i += 1) { + // generate chunk + const randInt: i32 = @intCast(i * 145343 % 4539); + const chunk = try generation.generate_world(a7r, randInt, @divTrunc(randInt, 2), 0.1); + defer chunk.deinit(); + + // generate model + const model = try render.chunk_to_model(chunk, texture, shader, tile_rows, tile_columns); + + // store model + try list_models.append(model); + } + // if (benchmark_chunk_meshing) { @@ -136,7 +152,7 @@ pub fn main() !void { const chunk_pos_x: u64 = @intCast(x); const chunk_pos_y: u64 = @intCast(y); const chunk_pos_z: u64 = @intCast(z); - try render.draw_model(model, camera, shader, chunk_pos_x, chunk_pos_y, chunk_pos_z); + try render.draw_model(list_models.items[chunk_pos_x * 100 + chunk_pos_y * 10 + chunk_pos_z], camera, shader, chunk_pos_x * 2, chunk_pos_y * 2, chunk_pos_z * 2); }; raylib.DrawFPS(10, 10);