mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 15:01:49 +00:00
feat: blocks renderer optimization
This commit is contained in:
parent
14a61f7891
commit
9286d48365
3 changed files with 6 additions and 5 deletions
|
|
@ -692,8 +692,7 @@ void BlocksRenderer::build(const Chunk* chunk, const Chunks* chunks) {
|
||||||
voxelsBuffer->setPosition(
|
voxelsBuffer->setPosition(
|
||||||
chunk->x * CHUNK_W - voxelBufferPadding, 0,
|
chunk->x * CHUNK_W - voxelBufferPadding, 0,
|
||||||
chunk->z * CHUNK_D - voxelBufferPadding);
|
chunk->z * CHUNK_D - voxelBufferPadding);
|
||||||
chunks->getVoxels(*voxelsBuffer, settings.graphics.backlight.get());
|
chunks->getVoxels(*voxelsBuffer, settings.graphics.backlight.get(), chunk->top + 1);
|
||||||
|
|
||||||
if (voxelsBuffer->pickBlockId(
|
if (voxelsBuffer->pickBlockId(
|
||||||
chunk->x * CHUNK_W, 0, chunk->z * CHUNK_D
|
chunk->x * CHUNK_W, 0, chunk->z * CHUNK_D
|
||||||
) == BLOCK_VOID) {
|
) == BLOCK_VOID) {
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,8 @@ bool Chunks::putChunk(const std::shared_ptr<Chunk>& chunk) {
|
||||||
// reduce nesting on next modification
|
// reduce nesting on next modification
|
||||||
// 25.06.2024: not now
|
// 25.06.2024: not now
|
||||||
// 11.11.2024: not now
|
// 11.11.2024: not now
|
||||||
void Chunks::getVoxels(VoxelsVolume& volume, bool backlight) const {
|
// 12.12.2025: not now
|
||||||
|
void Chunks::getVoxels(VoxelsVolume& volume, bool backlight, int top) const {
|
||||||
voxel* voxels = volume.getVoxels();
|
voxel* voxels = volume.getVoxels();
|
||||||
light_t* lights = volume.getLights();
|
light_t* lights = volume.getLights();
|
||||||
int x = volume.getX();
|
int x = volume.getX();
|
||||||
|
|
@ -342,7 +343,7 @@ void Chunks::getVoxels(VoxelsVolume& volume, bool backlight) const {
|
||||||
int z = volume.getZ();
|
int z = volume.getZ();
|
||||||
|
|
||||||
int w = volume.getW();
|
int w = volume.getW();
|
||||||
int h = volume.getH();
|
int h = std::min<int>(volume.getH(), top);
|
||||||
int d = volume.getD();
|
int d = volume.getD();
|
||||||
|
|
||||||
int scx = floordiv<CHUNK_W>(x);
|
int scx = floordiv<CHUNK_W>(x);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "typedefs.hpp"
|
#include "typedefs.hpp"
|
||||||
#include "voxel.hpp"
|
#include "voxel.hpp"
|
||||||
|
#include "constants.hpp"
|
||||||
#include "util/AreaMap2D.hpp"
|
#include "util/AreaMap2D.hpp"
|
||||||
|
|
||||||
class VoxelRenderer;
|
class VoxelRenderer;
|
||||||
|
|
@ -126,7 +127,7 @@ public:
|
||||||
bool isReplaceableBlock(int32_t x, int32_t y, int32_t z);
|
bool isReplaceableBlock(int32_t x, int32_t y, int32_t z);
|
||||||
bool isObstacleBlock(int32_t x, int32_t y, int32_t z);
|
bool isObstacleBlock(int32_t x, int32_t y, int32_t z);
|
||||||
|
|
||||||
void getVoxels(VoxelsVolume& volume, bool backlight = false) const;
|
void getVoxels(VoxelsVolume& volume, bool backlight = false, int top = CHUNK_H) const;
|
||||||
|
|
||||||
void setCenter(int32_t x, int32_t z);
|
void setCenter(int32_t x, int32_t z);
|
||||||
void resize(uint32_t newW, uint32_t newD);
|
void resize(uint32_t newW, uint32_t newD);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue