add 'culling' property & optimize generated chunk meshes & fix faces culling when 'light-passing' is false
This commit is contained in:
@@ -342,41 +342,41 @@ void BlocksRenderer::blockCube(
|
||||
}
|
||||
|
||||
if (ao) {
|
||||
if (isOpen(coord + Z, group)) {
|
||||
if (isOpen(coord + Z, block)) {
|
||||
faceAO(coord, X, Y, Z, texfaces[5], lights);
|
||||
}
|
||||
if (isOpen(coord - Z, group)) {
|
||||
if (isOpen(coord - Z, block)) {
|
||||
faceAO(coord, -X, Y, -Z, texfaces[4], lights);
|
||||
}
|
||||
if (isOpen(coord + Y, group)) {
|
||||
if (isOpen(coord + Y, block)) {
|
||||
faceAO(coord, X, -Z, Y, texfaces[3], lights);
|
||||
}
|
||||
if (isOpen(coord - Y, group)) {
|
||||
if (isOpen(coord - Y, block)) {
|
||||
faceAO(coord, X, Z, -Y, texfaces[2], lights);
|
||||
}
|
||||
if (isOpen(coord + X, group)) {
|
||||
if (isOpen(coord + X, block)) {
|
||||
faceAO(coord, -Z, Y, X, texfaces[1], lights);
|
||||
}
|
||||
if (isOpen(coord - X, group)) {
|
||||
if (isOpen(coord - X, block)) {
|
||||
faceAO(coord, Z, Y, -X, texfaces[0], lights);
|
||||
}
|
||||
} else {
|
||||
if (isOpen(coord + Z, group)) {
|
||||
if (isOpen(coord + Z, block)) {
|
||||
face(coord, X, Y, Z, texfaces[5], pickLight(coord + Z), lights);
|
||||
}
|
||||
if (isOpen(coord - Z, group)) {
|
||||
if (isOpen(coord - Z, block)) {
|
||||
face(coord, -X, Y, -Z, texfaces[4], pickLight(coord - Z), lights);
|
||||
}
|
||||
if (isOpen(coord + Y, group)) {
|
||||
if (isOpen(coord + Y, block)) {
|
||||
face(coord, X, -Z, Y, texfaces[3], pickLight(coord + Y), lights);
|
||||
}
|
||||
if (isOpen(coord - Y, group)) {
|
||||
if (isOpen(coord - Y, block)) {
|
||||
face(coord, X, Z, -Y, texfaces[2], pickLight(coord - Y), lights);
|
||||
}
|
||||
if (isOpen(coord + X, group)) {
|
||||
if (isOpen(coord + X, block)) {
|
||||
face(coord, -Z, Y, X, texfaces[1], pickLight(coord + X), lights);
|
||||
}
|
||||
if (isOpen(coord - X, group)) {
|
||||
if (isOpen(coord - X, block)) {
|
||||
face(coord, Z, Y, -X, texfaces[0], pickLight(coord - X), lights);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class BlocksRenderer {
|
||||
bool isOpenForLight(int x, int y, int z) const;
|
||||
|
||||
// Does block allow to see other blocks sides (is it transparent)
|
||||
inline bool isOpen(const glm::ivec3& pos, ubyte group) const {
|
||||
inline bool isOpen(const glm::ivec3& pos, const Block& def) const {
|
||||
auto id = voxelsBuffer->pickBlockId(
|
||||
chunk->x * CHUNK_W + pos.x, pos.y, chunk->z * CHUNK_D + pos.z
|
||||
);
|
||||
@@ -126,7 +126,11 @@ class BlocksRenderer {
|
||||
return false;
|
||||
}
|
||||
const auto& block = *blockDefsCache[id];
|
||||
if ((block.drawGroup != group && block.lightPassing) || !block.rt.solid) {
|
||||
if (((block.drawGroup != def.drawGroup) && block.drawGroup) || !block.rt.solid) {
|
||||
return true;
|
||||
}
|
||||
if (def.culling == CullingMode::DISABLED ||
|
||||
(def.culling == CullingMode::OPTIONAL && id == def.rt.id)) {
|
||||
return true;
|
||||
}
|
||||
return !id;
|
||||
|
||||
Reference in New Issue
Block a user