fix arraylist stuff

This commit is contained in:
catangent 2025-12-05 15:56:07 +00:00
parent 69a78e6c12
commit b999ff373c
2 changed files with 6 additions and 6 deletions

View file

@ -24,17 +24,17 @@ pub const GraphicsTaskManager = struct {
pub fn init(allocator: Allocator) GraphicsTaskManager {
var self: GraphicsTaskManager = undefined;
self.allocator = allocator;
self.tasks = ArrayList(Task).init(allocator);
self.tasks = ArrayList(Task).empty;
return self;
}
pub fn deinit(self: *GraphicsTaskManager) void{
self.tasks.deinit();
self.tasks.deinit(self.allocator);
self.* = undefined;
}
pub fn executeAll(self: *GraphicsTaskManager) !void {
self.mutex.lock();
const tasks = try self.tasks.toOwnedSlice();
const tasks = try self.tasks.toOwnedSlice(self.allocator);
defer self.allocator.free(tasks);
self.mutex.unlock();
@ -61,7 +61,7 @@ pub const GraphicsTaskManager = struct {
pub fn submit(self: *GraphicsTaskManager, task: Task) !void {
self.mutex.lock();
defer self.mutex.unlock();
try self.tasks.append(task);
try self.tasks.append(self.allocator, task);
}
pub fn wait(self: *GraphicsTaskManager) !void {

View file

@ -374,7 +374,7 @@ pub const Chunk = struct {
if(x != (if (sign == 1) 31 else 0) and y_end != 32 and z_start != 0)
y_plus_z_minus_obscured = chunk.getTileRawShifted(if (sign == 1) x+1 else x-1, @intCast(y_end), @intCast(z_start-1), dimension) != 0;
const raw_quad = packRawQuad(@floatFromInt(raw_x), y_start, y_end, z_start, z_end, sign, dimension, surface, y_minus_obscuring_pattern, y_plus_obscuring_pattern, z_minus_obscuring_pattern, z_plus_obscuring_pattern, y_minus_z_minus_obscured, y_minus_z_plus_obscured, y_plus_z_plus_obscured, y_plus_z_minus_obscured);
try raw_quads.append(raw_quad);
try raw_quads.append(chunk.allocator, raw_quad);
};
}
}
@ -385,7 +385,7 @@ pub const Chunk = struct {
// Create mesh of a chunk. tile_rows and tile_columns are the dimensions of the tiles.png file, in terms of individual tile textures.
pub fn createMesh(chunk: Chunk, tile_rows: u32, tile_columns: u32) !raylib.ChunkMesh {
var raw_quads = try scanForRawQuads(chunk);
defer raw_quads.deinit();
defer raw_quads.deinit(chunk.allocator);
const mesh = packMeshFromRawQuads(raw_quads, tile_columns, tile_rows);
return mesh;