mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
refactor BlocksRenderer a bit
This commit is contained in:
parent
cc524088e0
commit
dc10dc60c0
2 changed files with 144 additions and 144 deletions
|
|
@ -7,6 +7,10 @@
|
|||
#include "voxels/voxel.hpp"
|
||||
#include "typedefs.hpp"
|
||||
|
||||
#include "voxels/Block.hpp"
|
||||
#include "voxels/Chunk.hpp"
|
||||
#include "voxels/VoxelsVolume.hpp"
|
||||
|
||||
class Content;
|
||||
class Mesh;
|
||||
class Block;
|
||||
|
|
@ -84,9 +88,9 @@ class BlocksRenderer {
|
|||
bool lights
|
||||
);
|
||||
void blockCube(
|
||||
int x, int y, int z,
|
||||
const glm::ivec3& coord,
|
||||
const UVRegion(&faces)[6],
|
||||
const Block* block,
|
||||
const Block& block,
|
||||
blockstate states,
|
||||
bool lights,
|
||||
bool ao
|
||||
|
|
@ -115,7 +119,22 @@ class BlocksRenderer {
|
|||
);
|
||||
|
||||
bool isOpenForLight(int x, int y, int z) const;
|
||||
bool isOpen(int x, int y, int z, ubyte group) const;
|
||||
|
||||
|
||||
// Does block allow to see other blocks sides (is it transparent)
|
||||
inline constexpr bool isOpen(const glm::ivec3& pos, ubyte group) const {
|
||||
auto id = voxelsBuffer->pickBlockId(
|
||||
chunk->x * CHUNK_W + pos.x, pos.y, chunk->z * CHUNK_D + pos.z
|
||||
);
|
||||
if (id == BLOCK_VOID) {
|
||||
return false;
|
||||
}
|
||||
const auto& block = *blockDefsCache[id];
|
||||
if ((block.drawGroup != group && block.lightPassing) || !block.rt.solid) {
|
||||
return true;
|
||||
}
|
||||
return !id;
|
||||
}
|
||||
|
||||
glm::vec4 pickLight(int x, int y, int z) const;
|
||||
glm::vec4 pickLight(const glm::ivec3& coord) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue