mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +00:00
minor refactor
This commit is contained in:
parent
1750599165
commit
693f50eb87
2 changed files with 4 additions and 5 deletions
|
|
@ -125,8 +125,8 @@ void WorldRenderer::drawChunks(Chunks* chunks, Camera* camera, Shader* shader) {
|
||||||
float px = camera->position.x / (float)CHUNK_W - 0.5f;
|
float px = camera->position.x / (float)CHUNK_W - 0.5f;
|
||||||
float pz = camera->position.z / (float)CHUNK_D - 0.5f;
|
float pz = camera->position.z / (float)CHUNK_D - 0.5f;
|
||||||
std::sort(indices.begin(), indices.end(), [chunks, px, pz](auto i, auto j) {
|
std::sort(indices.begin(), indices.end(), [chunks, px, pz](auto i, auto j) {
|
||||||
const auto& a = chunks->chunks[i];
|
const auto a = chunks->chunks[i].get();
|
||||||
const auto& b = chunks->chunks[j];
|
const auto b = chunks->chunks[j].get();
|
||||||
auto adx = (a->x - px);
|
auto adx = (a->x - px);
|
||||||
auto adz = (a->z - pz);
|
auto adz = (a->z - pz);
|
||||||
auto bdx = (b->x - px);
|
auto bdx = (b->x - px);
|
||||||
|
|
|
||||||
|
|
@ -65,14 +65,13 @@ void Lighting::buildSkyLight(int cx, int cz){
|
||||||
Chunk* chunk = chunks->getChunk(cx, cz);
|
Chunk* chunk = chunks->getChunk(cx, cz);
|
||||||
for (int z = 0; z < CHUNK_D; z++){
|
for (int z = 0; z < CHUNK_D; z++){
|
||||||
for (int x = 0; x < CHUNK_W; x++){
|
for (int x = 0; x < CHUNK_W; x++){
|
||||||
|
int gx = x + cx * CHUNK_W;
|
||||||
|
int gz = z + cz * CHUNK_D;
|
||||||
for (int y = chunk->lightmap.highestPoint; y >= 0; y--){
|
for (int y = chunk->lightmap.highestPoint; y >= 0; y--){
|
||||||
int gx = x + cx * CHUNK_W;
|
|
||||||
int gz = z + cz * CHUNK_D;
|
|
||||||
while (y > 0 && !blockDefs[chunk->voxels[vox_index(x, y, z)].id]->lightPassing) {
|
while (y > 0 && !blockDefs[chunk->voxels[vox_index(x, y, z)].id]->lightPassing) {
|
||||||
y--;
|
y--;
|
||||||
}
|
}
|
||||||
if (chunk->lightmap.getS(x, y, z) != 15) {
|
if (chunk->lightmap.getS(x, y, z) != 15) {
|
||||||
solverS->add(gx,y+1,gz);
|
|
||||||
for (; y >= 0; y--){
|
for (; y >= 0; y--){
|
||||||
solverS->add(gx+1,y,gz);
|
solverS->add(gx+1,y,gz);
|
||||||
solverS->add(gx-1,y,gz);
|
solverS->add(gx-1,y,gz);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue