mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-12 14:01:59 -04:00
Fix fog when the world isn't fully loaded.
This commit is contained in:
parent
4a84b862b5
commit
31e5526b14
@ -876,7 +876,7 @@ pub const meshing = struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn uploadDataAndFinishNeighbors(self: *ChunkMesh) !void { // TODO: The way neighboring chunks are handled doesn't work well with transparency.
|
||||
pub fn uploadDataAndFinishNeighbors(self: *ChunkMesh) !void {
|
||||
std.debug.assert(!self.mutex.tryLock()); // The mutex should be locked when calling this function.
|
||||
const chunk = self.chunk.load(.Monotonic) orelse return; // In the mean-time the mesh was discarded and recreated and all the data was lost.
|
||||
self.opaqueMesh.resetToCore();
|
||||
|
@ -215,7 +215,7 @@ pub fn renderWorld(world: *World, ambientLight: Vec3f, skyColor: Vec3f, playerPo
|
||||
// Meshes.emissionTextureArray.bind();
|
||||
// }
|
||||
|
||||
const playerBlock = RenderStructure.getBlock(@intFromFloat(@floor(playerPos[0])), @intFromFloat(@floor(playerPos[1])), @intFromFloat(@floor(playerPos[2]))) orelse blocks.Block{.typ = 0, .data = 0};
|
||||
const playerBlock = RenderStructure.getBlockFromAnyLod(@intFromFloat(@floor(playerPos[0])), @intFromFloat(@floor(playerPos[1])), @intFromFloat(@floor(playerPos[2])));
|
||||
|
||||
if(settings.bloom) {
|
||||
Bloom.render(lastWidth, lastHeight, playerBlock);
|
||||
@ -915,6 +915,16 @@ pub const RenderStructure = struct {
|
||||
return block;
|
||||
}
|
||||
|
||||
pub fn getBlockFromAnyLod(x: i32, y: i32, z: i32) blocks.Block {
|
||||
var lod: u5 = 0;
|
||||
while(lod < settings.highestLOD) : (lod += 1) {
|
||||
const node = RenderStructure._getNode(.{.wx = x, .wy = y, .wz = z, .voxelSize=@as(u31, 1) << lod}) orelse continue;
|
||||
const block = (node.mesh.chunk.load(.Monotonic) orelse continue).getBlock(x & chunk.chunkMask<<lod, y & chunk.chunkMask<<lod, z & chunk.chunkMask<<lod);
|
||||
return block;
|
||||
}
|
||||
return blocks.Block{.typ = 0, .data = 0};
|
||||
}
|
||||
|
||||
pub fn getNeighbor(_pos: chunk.ChunkPosition, resolution: u31, neighbor: u3) ?*chunk.meshing.ChunkMesh {
|
||||
var pos = _pos;
|
||||
pos.wx += pos.voxelSize*chunk.chunkSize*chunk.Neighbors.relX[neighbor];
|
||||
|
Loading…
x
Reference in New Issue
Block a user