mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +00:00
fixes
This commit is contained in:
parent
32a26ebbcc
commit
c323b1ad15
4 changed files with 23 additions and 17 deletions
|
|
@ -144,7 +144,7 @@ private:
|
||||||
|
|
||||||
// Does block allow to see other blocks sides (is it transparent)
|
// Does block allow to see other blocks sides (is it transparent)
|
||||||
inline bool isOpen(const glm::ivec3& pos, const Block& def, const Variant& variant) const {
|
inline bool isOpen(const glm::ivec3& pos, const Block& def, const Variant& variant) const {
|
||||||
auto vox = voxelsBuffer->pickBlock(
|
const auto& vox = voxelsBuffer->pickBlock(
|
||||||
chunk->x * CHUNK_W + pos.x, pos.y, chunk->z * CHUNK_D + pos.z
|
chunk->x * CHUNK_W + pos.x, pos.y, chunk->z * CHUNK_D + pos.z
|
||||||
);
|
);
|
||||||
if (vox.id == BLOCK_VOID) {
|
if (vox.id == BLOCK_VOID) {
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,6 @@ std::shared_ptr<VoxelsRenderVolume> ChunksRenderer::prepareVoxelsVolume(
|
||||||
const Mesh<ChunkVertex>* ChunksRenderer::render(
|
const Mesh<ChunkVertex>* ChunksRenderer::render(
|
||||||
const std::shared_ptr<Chunk>& chunk, bool important, bool lowPriority
|
const std::shared_ptr<Chunk>& chunk, bool important, bool lowPriority
|
||||||
) {
|
) {
|
||||||
important = true;
|
|
||||||
glm::ivec2 key(chunk->x, chunk->z);
|
glm::ivec2 key(chunk->x, chunk->z);
|
||||||
chunk->flags.modified = false;
|
chunk->flags.modified = false;
|
||||||
if (important) {
|
if (important) {
|
||||||
|
|
@ -135,7 +134,7 @@ const Mesh<ChunkVertex>* ChunksRenderer::render(
|
||||||
return meshes[key].mesh.get();
|
return meshes[key].mesh.get();
|
||||||
}
|
}
|
||||||
if (inwork.find(key) != inwork.end() ||
|
if (inwork.find(key) != inwork.end() ||
|
||||||
((inwork.size() >= threadPool.getWorkTotal() ||
|
((inwork.size() >= threadPool.getWorkersCount() ||
|
||||||
enqueuedInFrame >= MAX_CHUNKS_ENQUEUED_IN_FRAME) &&
|
enqueuedInFrame >= MAX_CHUNKS_ENQUEUED_IN_FRAME) &&
|
||||||
lowPriority)) {
|
lowPriority)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ VC_ENUM_METADATA(BlockModelType)
|
||||||
{"custom", BlockModelType::CUSTOM},
|
{"custom", BlockModelType::CUSTOM},
|
||||||
VC_ENUM_END
|
VC_ENUM_END
|
||||||
|
|
||||||
enum class CullingMode {
|
enum class CullingMode : uint8_t {
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
OPTIONAL,
|
OPTIONAL,
|
||||||
DISABLED,
|
DISABLED,
|
||||||
|
|
|
||||||
|
|
@ -130,29 +130,36 @@ public:
|
||||||
return lights;
|
return lights;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline blockid_t pickBlockId(int bx, int by, int bz) const {
|
inline blockid_t pickBlockId(uint bx, uint by, uint bz) const {
|
||||||
if (bx < x || by < y || bz < z || bx >= x + w || by >= y + h ||
|
bx -= x;
|
||||||
bz >= z + d) {
|
by -= y;
|
||||||
|
bz -= z;
|
||||||
|
if (bx >= w || by >= h || bz >= d) {
|
||||||
return BLOCK_VOID;
|
return BLOCK_VOID;
|
||||||
}
|
}
|
||||||
return voxels[vox_index(bx - x, by - y, bz - z, w, d)].id;
|
return voxels[vox_index(bx, by, bz, w, d)].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline voxel pickBlock(int bx, int by, int bz) const {
|
inline const voxel& pickBlock(uint bx, uint by, uint bz) const {
|
||||||
if (bx < x || by < y || bz < z || bx >= x + w || by >= y + h ||
|
bx -= x;
|
||||||
bz >= z + d) {
|
by -= y;
|
||||||
return {BLOCK_VOID, {}};
|
bz -= z;
|
||||||
|
if (bx >= w || by >= h || bz >= d) {
|
||||||
|
static voxel voidVoxel {BLOCK_VOID, {}};
|
||||||
|
return voidVoxel;
|
||||||
}
|
}
|
||||||
return voxels[vox_index(bx - x, by - y, bz - z, w, d)];
|
return voxels[vox_index(bx, by, bz, w, d)];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline light_t pickLight(int bx, int by, int bz) const {
|
inline light_t pickLight(uint bx, uint by, uint bz) const {
|
||||||
if (bx < x || by < y || bz < z || bx >= x + w || by >= y + h ||
|
bx -= x;
|
||||||
bz >= z + d) {
|
by -= y;
|
||||||
|
bz -= z;
|
||||||
|
if (bx >= w || by >= h || bz >= d) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return lights[vox_index(bx - x, by - y, bz - z, w, d)];
|
return lights[vox_index(bx, by, bz, w, d)];
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue