voxels renderer rebuilt, WorldFiles fix

This commit is contained in:
MihailRis
2023-11-02 13:23:52 +03:00
committed by GitHub
parent 0576316282
commit 754c5b80d0
44 changed files with 1141 additions and 524 deletions
+4 -1
View File
@@ -6,8 +6,11 @@
#include "../voxels/voxel.h"
#include "../voxels/Block.h"
#include <memory>
#include <iostream>
using std::shared_ptr;
Lighting::Lighting(Chunks* chunks){
this->chunks = chunks;
solverR = new LightSolver(chunks, 0);
@@ -25,7 +28,7 @@ Lighting::~Lighting(){
void Lighting::clear(){
for (unsigned int index = 0; index < chunks->volume; index++){
Chunk* chunk = chunks->chunks[index];
shared_ptr<Chunk> chunk = chunks->chunks[index];
if (chunk == nullptr)
continue;
Lightmap* lightmap = chunk->lightmap;
+15 -1
View File
@@ -1,11 +1,13 @@
#ifndef LIGHTING_LIGHTMAP_H_
#define LIGHTING_LIGHTMAP_H_
#include "../constants.h"
#include "../voxels/Chunk.h"
// Lichtkarte
class Lightmap {
public:
unsigned short* map;
light_t* map;
int highestPoint = 0;
Lightmap();
~Lightmap();
@@ -60,6 +62,18 @@ public:
const int index = y*CHUNK_D*CHUNK_W+z*CHUNK_W+x;
map[index] = (map[index] & (0xFFFF & (~(0xF << (channel*4))))) | (value << (channel << 2));
}
inline const light_t* getLights() const {
return map;
}
inline light_t* getLightsWriteable() {
return map;
}
static inline light_t extract(light_t light, ubyte channel) {
return (light >> (channel << 2)) & 0xF;
}
};
#endif /* LIGHTING_LIGHTMAP_H_ */