Don't access the internals of the ChannelChunk.

This makes it easier to swap the implementation for future compression attempts.
This commit is contained in:
IntegratedQuantum 2024-02-26 14:59:00 +01:00
parent d4f9270fa9
commit 69920c343d
2 changed files with 11 additions and 7 deletions

View File

@ -240,14 +240,13 @@ const PrimitiveMesh = struct {
const x = (wx >> mesh.chunk.voxelSizeShift) & chunk.chunkMask; const x = (wx >> mesh.chunk.voxelSizeShift) & chunk.chunkMask;
const y = (wy >> mesh.chunk.voxelSizeShift) & chunk.chunkMask; const y = (wy >> mesh.chunk.voxelSizeShift) & chunk.chunkMask;
const z = (wz >> mesh.chunk.voxelSizeShift) & chunk.chunkMask; const z = (wz >> mesh.chunk.voxelSizeShift) & chunk.chunkMask;
const index = chunk.getIndex(x, y, z);
return .{ return .{
mesh.lightingData[0].data[index].load(.Unordered), mesh.lightingData[0].getValue(x, y, z),
mesh.lightingData[1].data[index].load(.Unordered), mesh.lightingData[1].getValue(x, y, z),
mesh.lightingData[2].data[index].load(.Unordered), mesh.lightingData[2].getValue(x, y, z),
mesh.lightingData[3].data[index].load(.Unordered), mesh.lightingData[3].getValue(x, y, z),
mesh.lightingData[4].data[index].load(.Unordered), mesh.lightingData[4].getValue(x, y, z),
mesh.lightingData[5].data[index].load(.Unordered), mesh.lightingData[5].getValue(x, y, z),
}; };
} }

View File

@ -84,6 +84,11 @@ pub const ChannelChunk = struct {
entries: main.ListUnmanaged(PositionEntry), entries: main.ListUnmanaged(PositionEntry),
}; };
pub fn getValue(self: *const ChannelChunk, x: i32, y: i32, z: i32) u8 {
const index = chunk.getIndex(x, y, z);
return self.data[index].load(.Unordered);
}
fn propagateDirect(self: *ChannelChunk, lightQueue: *main.utils.CircularBufferQueue(Entry)) void { fn propagateDirect(self: *ChannelChunk, lightQueue: *main.utils.CircularBufferQueue(Entry)) void {
var neighborLists: [6]main.ListUnmanaged(Entry) = .{.{}} ** 6; var neighborLists: [6]main.ListUnmanaged(Entry) = .{.{}} ** 6;
defer { defer {