Interator2
This commit is contained in:
33
src/Game.zig
33
src/Game.zig
@@ -15,7 +15,7 @@ const Engine = @import("engine/Engine.zig");
|
||||
const GenericBuffer = @import("engine/GenericBuffer.zig").GenericBuffer;
|
||||
const StagingBuffer = @import("engine/StagingBuffer.zig");
|
||||
const Swapchain = @import("engine/Swapchain.zig");
|
||||
const Interator3 = math.Interator3;
|
||||
const Interator2 = math.Interator2;
|
||||
const Matrix4x4 = math.Matrix4x4;
|
||||
const Quaternion = math.Quaternion;
|
||||
const Vector2 = math.Vector2;
|
||||
@@ -612,31 +612,36 @@ pub fn init(allocator: std.mem.Allocator, engine: *Engine, swapchain: *Swapchain
|
||||
chunks.deinit(allocator);
|
||||
}
|
||||
|
||||
var it = Interator3(i16).init(-10, -10, 0, 9, 9, 0);
|
||||
var it = Interator2(i16).init(-10, -10, 9, 9);
|
||||
|
||||
const block_grass = blocks.getFilename("Grass.json").?;
|
||||
const block_dirt = blocks.getFilename("Dirt.json").?;
|
||||
const block_stone = blocks.getFilename("Stone.json").?;
|
||||
const block_bedrock = blocks.getFilename("Bedrock.json").?;
|
||||
|
||||
while (it.next()) |chunk_coords| {
|
||||
while (it.next()) |chunk_coords2| {
|
||||
const chunk_coords3 = chunk_coords2 ++ [_]i16{0};
|
||||
|
||||
const origin = Vector3.init(
|
||||
@floatFromInt(chunk_coords[0]),
|
||||
@floatFromInt(chunk_coords[1]),
|
||||
@floatFromInt(chunk_coords[2]),
|
||||
@floatFromInt(chunk_coords3[0]),
|
||||
@floatFromInt(chunk_coords3[1]),
|
||||
@floatFromInt(chunk_coords3[2]),
|
||||
).mulScalar(16);
|
||||
|
||||
try chunks.ensureUnusedCapacity(allocator, 1);
|
||||
chunks.putAssumeCapacityNoClobber(chunk_coords, try Chunk.init(engine, .{
|
||||
.origin = origin,
|
||||
.descriptor_pool = descriptor_pool,
|
||||
.per_batch_descriptor_set_layout = per_batch_descriptor_set_layout,
|
||||
}));
|
||||
const chunk = chunks.getPtr(chunk_coords).?;
|
||||
chunks.putAssumeCapacityNoClobber(
|
||||
chunk_coords3,
|
||||
try Chunk.init(engine, .{
|
||||
.origin = origin,
|
||||
.descriptor_pool = descriptor_pool,
|
||||
.per_batch_descriptor_set_layout = per_batch_descriptor_set_layout,
|
||||
}),
|
||||
);
|
||||
const chunk = chunks.getPtr(chunk_coords3).?;
|
||||
|
||||
var it2 = Interator3(usize).init(0, 0, 0, 15, 15, 0);
|
||||
var it2 = Interator2(usize).init(0, 0, 15, 15);
|
||||
while (it2.next()) |pos| {
|
||||
const x, const y, _ = pos;
|
||||
const x, const y = pos;
|
||||
const fpos = Vector2.init(
|
||||
@floatFromInt(pos[0]),
|
||||
@floatFromInt(pos[1]),
|
||||
|
||||
Reference in New Issue
Block a user