Separate out Chunks-related code, "fix" collisions to be less broken
This commit is contained in:
13
src/Game.zig
13
src/Game.zig
@@ -10,6 +10,7 @@ const worldgen = @import("worldgen.zig");
|
||||
|
||||
const Blocks = @import("assets/Blocks.zig");
|
||||
const Chunk = @import("assets/Chunk.zig");
|
||||
const Chunks = @import("Chunks.zig");
|
||||
const CommandBuffer = @import("engine/CommandBuffer.zig");
|
||||
const Engine = @import("engine/Engine.zig");
|
||||
const Iterator2 = math.Iterator2;
|
||||
@@ -50,7 +51,7 @@ deferred_command_buffers: std.ArrayList(CommandBuffer),
|
||||
blocks: Blocks,
|
||||
materials: Materials,
|
||||
textures: Textures,
|
||||
chunks: std.AutoHashMapUnmanaged([3]i16, Chunk),
|
||||
chunks: Chunks,
|
||||
skybox: Skybox,
|
||||
|
||||
player: Player,
|
||||
@@ -659,7 +660,7 @@ pub fn init(allocator: std.mem.Allocator, engine: *Engine, swapchain: *Swapchain
|
||||
.blocks = blocks,
|
||||
.materials = materials,
|
||||
.textures = textures,
|
||||
.chunks = chunks,
|
||||
.chunks = .{ .chunks = chunks },
|
||||
.skybox = skybox,
|
||||
|
||||
.player = .init(player_position_sv, 0, 0),
|
||||
@@ -677,11 +678,7 @@ pub fn deinit(self: *Game) void {
|
||||
self.vertex_buffer.deinit(self.engine);
|
||||
self.index_buffer.deinit(self.engine);
|
||||
|
||||
var it = self.chunks.valueIterator();
|
||||
while (it.next()) |chunk| {
|
||||
chunk.deinit(self.engine, self.descriptor_pool);
|
||||
}
|
||||
self.chunks.deinit(self.allocator);
|
||||
self.chunks.deinit(self.engine, self.descriptor_pool, self.allocator);
|
||||
self.skybox.deinit(self.engine);
|
||||
|
||||
self.global_uniforms.deinit(self.engine);
|
||||
@@ -889,7 +886,7 @@ fn render(self: *Game) !void {
|
||||
command_buffer.bindIndexBuffer(self.index_buffer.buffer, 0, .uint16);
|
||||
command_buffer.bindDescriptorSet(.graphics, self.pipeline_layout, 0, self.global_descriptor_set, null);
|
||||
|
||||
var it = self.chunks.valueIterator();
|
||||
var it = self.chunks.chunks.valueIterator();
|
||||
while (it.next()) |chunk| {
|
||||
chunk.draw(self.pipeline_layout, command_buffer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user