world-wide commit to ruin everything
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "voxel.h"
|
||||
#include "Chunk.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/noise.hpp>
|
||||
@@ -9,6 +10,8 @@
|
||||
#include "../maths/FastNoiseLite.h"
|
||||
#include <time.h>
|
||||
|
||||
#include "../declarations.h"
|
||||
|
||||
class PseudoRandom {
|
||||
unsigned short seed;
|
||||
public:
|
||||
@@ -64,7 +67,7 @@ float calc_height_faster(fnl_state *noise, int real_x, int real_z){
|
||||
height *= 64.0f;
|
||||
return height;
|
||||
}
|
||||
#include <iostream>
|
||||
|
||||
int generate_tree(fnl_state *noise, PseudoRandom* random, const float* heights, int real_x, int real_y, int real_z, int tileSize){
|
||||
const int tileX = floor((double)real_x/(double)tileSize);
|
||||
const int tileY = floor((double)real_z/(double)tileSize);
|
||||
@@ -92,18 +95,14 @@ int generate_tree(fnl_state *noise, PseudoRandom* random, const float* heights,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WorldGenerator::generate(voxel* voxels, int cx, int cy, int cz, int seed){
|
||||
void WorldGenerator::generate(voxel* voxels, int cx, int cz, int seed){
|
||||
fnl_state noise = fnlCreateState();
|
||||
noise.noise_type = FNL_NOISE_OPENSIMPLEX2;
|
||||
noise.seed = seed * 60617077 % 25896307;
|
||||
|
||||
PseudoRandom randomtree;
|
||||
// PseudoRandom random;
|
||||
|
||||
float heights[CHUNK_VOL];
|
||||
|
||||
// std::cout << calc_height(&noise, cx, cy) << "\n";
|
||||
|
||||
for (int z = 0; z < CHUNK_D; z++){
|
||||
for (int x = 0; x < CHUNK_W; x++){
|
||||
int real_x = x + cx * CHUNK_W;
|
||||
@@ -120,14 +119,14 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cy, int cz, int seed){
|
||||
float height = heights[z*CHUNK_W+x];
|
||||
|
||||
for (int y = 0; y < CHUNK_H; y++){
|
||||
int real_y = y + cy * CHUNK_H;
|
||||
int id = real_y < 55 ? 9 : 0;
|
||||
if ((real_y == (int)height) && (54 < real_y))
|
||||
id = 2;
|
||||
else if (real_y < (height - 6)){
|
||||
id = 8;
|
||||
int real_y = y;
|
||||
int id = real_y < 55 ? BLOCK_WATER : BLOCK_AIR;
|
||||
if ((real_y == (int)height) && (54 < real_y)) {
|
||||
id = BLOCK_GRASS_BLOCK;
|
||||
} else if (real_y < (height - 6)){
|
||||
id = BLOCK_STONE;
|
||||
} else if (real_y < height){
|
||||
id = 1;
|
||||
id = BLOCK_DIRT;
|
||||
} else {
|
||||
int tree = generate_tree(&noise, &randomtree, heights, real_x, real_y, real_z, 16);
|
||||
if (tree) {
|
||||
@@ -139,15 +138,15 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cy, int cz, int seed){
|
||||
}
|
||||
}
|
||||
if ( ((height - (1.5 - 0.2 * pow(height - 54, 4))) < real_y) && (real_y < height)){
|
||||
id = 10;
|
||||
id = BLOCK_SAND;
|
||||
}
|
||||
if (real_y <= 2)
|
||||
id = 11;
|
||||
id = BLOCK_BEDROCK;
|
||||
if ((id == 0) && (real_y > 55) && ((int)height + 1 == real_y) && ((unsigned short)random() > 56000)){
|
||||
id = 12;
|
||||
id = BLOCK_GRASS;
|
||||
}
|
||||
if ((id == 0) && (real_y > 55) && ((int)height + 1 == real_y) && ((unsigned short)random() > 64000)){
|
||||
id = 13;
|
||||
id = BLOCK_FLOWER;
|
||||
}
|
||||
voxels[(y * CHUNK_D + z) * CHUNK_W + x].id = id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user