Added 3 unicode pages for font, fixed UI, added Block.breakable

Added 1, 2, 3 and 4 unicode pages from Minecraft.
Font now uses std::wstring instead of std::string
Added Block.breakable field (the only unbreakable block is bedrock)
Bedrock is now selectable
This commit is contained in:
MihailRis
2022-07-14 19:23:31 +03:00
committed by GitHub
parent b2872650d6
commit bdd3fbf7d4
17 changed files with 94 additions and 47 deletions
+1
View File
@@ -14,6 +14,7 @@ public:
bool skyLightPassing = false;
bool obstacle = true;
bool selectable = true;
bool breakable = true;
Block(unsigned int id, int texture);
};
+8
View File
@@ -3,6 +3,8 @@
#include "Chunk.h"
#include "Chunks.h"
#include "Block.h"
#include "voxel.h"
#include "../world/World.h"
#include "WorldGenerator.h"
#include "../lighting/Lighting.h"
@@ -36,6 +38,12 @@ void ChunksLoader::_thread(){
WorldGenerator::generate(chunk->voxels, chunk->x, chunk->y, chunk->z, world->seed);
}
for (size_t i = 0; i < CHUNK_VOL; i++){
if (Block::blocks[chunk->voxels[i].id] == nullptr){
std::cout << "corruped block detected at " << i << " of chunk " << chunk->x << "x" << chunk->z << std::endl;
chunk->voxels[i].id = 11;
}
}
lighting.onChunkLoaded(chunk->x, chunk->y, chunk->z, true);
}
else if (state == RENDER){
+11 -3
View File
@@ -28,12 +28,16 @@ public:
};
float calc_height(fnl_state *noise, int real_x, int real_z){
const float s = 0.2f;
const float s = 0.18f;
float height = fnlGetNoise3D(noise, real_x*0.0125f*s*32,real_z*0.0125f*s*32, 0.0f);
height += fnlGetNoise3D(noise, real_x*0.025f*s*32,real_z*0.025f*s*32, 0.0f)*0.5f;
height += fnlGetNoise3D(noise, real_x*0.05f*s*32,real_z*0.05f*s*32, 0.0f)*0.25f;
height += fnlGetNoise3D(noise, real_x*0.1f*s*32,real_z*0.1f*s*32, 0.0f)*0.225f;
height += fnlGetNoise3D(noise, real_x*0.2f*s*32,real_z*0.2f*s*32, 0.0f)*0.125f;
height += fnlGetNoise3D(noise,
real_x*0.2f*s*32 + fnlGetNoise3D(noise, real_x*0.1f*s*32,real_z*0.1f*s*32, 0.0f)*50,
real_z*0.2f*s*32 + fnlGetNoise3D(noise, real_x*0.1f*s*32+4363,real_z*0.1f*s*32, 0.0f)*50,
0.0f)*0.1f;
height += fnlGetNoise3D(noise, real_x*0.4f*s*32,real_z*0.4f*s*32, 0.0f)*0.0625f;
// height += fnlGetNoise3D(noise, real_x*s*32,real_z*s*32, 0.0f)*0.03f;
height = height * 0.5f + 0.5f;
@@ -44,13 +48,17 @@ float calc_height(fnl_state *noise, int real_x, int real_z){
}
float calc_height_faster(fnl_state *noise, int real_x, int real_z){
const float s = 0.2f;
const float s = 0.18f;
float height = fnlGetNoise3D(noise, real_x*0.0125f*s*32,real_z*0.0125f*s*32, 0.0f);
height += fnlGetNoise3D(noise, real_x*0.025f*s*32,real_z*0.025f*s*32, 0.0f)*0.5f;
height += fnlGetNoise3D(noise, real_x*0.05f*s*32,real_z*0.05f*s*32, 0.0f)*0.25f;
height += fnlGetNoise3D(noise, real_x*0.1f*s*32,real_z*0.1f*s*32, 0.0f)*0.225f;
height += fnlGetNoise3D(noise, real_x*0.2f*s*32,real_z*0.2f*s*32, 0.0f)*0.125f;
//height += fnlGetNoise3D(noise, real_x*0.4f*s*32,real_z*0.4f*s*32, 0.0f)*0.125f*0.5F;
height += fnlGetNoise3D(noise,
real_x*0.2f*s*32 + fnlGetNoise3D(noise, real_x*0.1f*s*32,real_z*0.1f*s*32, 0.0f)*50,
real_z*0.2f*s*32 + fnlGetNoise3D(noise, real_x*0.1f*s*32+4363,real_z*0.1f*s*32, 0.0f)*50,
0.0f)*0.1f;
// height += fnlGetNoise3D(noise, real_x*0.4f*s*32,real_z*0.4f*s*32, 0.0f)*0.125f*0.5F;
height = height * 0.5f + 0.5f;
height *= height;
height *= (140.0f)*0.12f/s;