This commit is contained in:
Ara
2023-12-09 18:43:58 +06:00
19 changed files with 383 additions and 141 deletions
+8
View File
@@ -1,5 +1,6 @@
#include "Chunk.h"
#include "voxel.h"
#include "../content/ContentLUT.h"
#include "../lighting/Lightmap.h"
Chunk::Chunk(int xpos, int zpos) : x(xpos), z(zpos){
@@ -80,3 +81,10 @@ bool Chunk::decode(ubyte* data) {
}
return true;
}
void Chunk::convert(ubyte* data, const ContentLUT* lut) {
for (size_t i = 0; i < CHUNK_VOL; i++) {
blockid_t id = data[i];
data[i] = lut->getBlockId(id);
}
}
+3
View File
@@ -16,6 +16,7 @@ struct ChunkFlag{
struct voxel;
class Lightmap;
class ContentLUT;
struct RenderData {
float* vertices;
@@ -76,6 +77,8 @@ public:
ubyte* encode() const;
bool decode(ubyte* data);
static void convert(ubyte* data, const ContentLUT* lut);
};
#endif /* VOXELS_CHUNK_H_ */
+1 -1
View File
@@ -175,7 +175,7 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cz, int seed){
float hum = fnlGetNoise3D(&noise, real_x * 0.3 + 633, 0.0, real_z * 0.3);
if (height >= SEA_LEVEL) {
height = ((height - SEA_LEVEL) * 0.1) - 0.0;
height = powf(height, (1.0+hum - fmax(0.0, height) * 0.2));
height = powf(height, (1.0+hum - fmax(0.0, height) * 0.1));
height = height * 10 + SEA_LEVEL;
} else {
height *= 1.0f + (height-SEA_LEVEL) * 0.05f * hum;