Merge branch 'main' of https://github.com/MihailRis/VoxelEngine-Cpp
This commit is contained in:
+6
-2
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "../maths/aabb.h"
|
||||
#include "../typedefs.h"
|
||||
|
||||
#define FACE_MX 0
|
||||
#define FACE_PX 1
|
||||
@@ -15,13 +16,15 @@
|
||||
#define BLOCK_AABB_GRID 16
|
||||
|
||||
enum class BlockModel {
|
||||
none, block, xsprite
|
||||
none, // invisible
|
||||
block, // default shape
|
||||
xsprite, // X-shape (grass)
|
||||
aabb // box shaped as block hitbox
|
||||
};
|
||||
|
||||
class Block {
|
||||
public:
|
||||
std::string const name;
|
||||
unsigned int id;
|
||||
// 0 1 2 3 4 5
|
||||
std::string textureFaces[6]; // -x,x, -y,y, -z,z
|
||||
unsigned char emission[4];
|
||||
@@ -36,6 +39,7 @@ public:
|
||||
AABB hitbox;
|
||||
|
||||
struct {
|
||||
blockid_t id;
|
||||
bool solid = true;
|
||||
bool emissive = false;
|
||||
bool hitboxGrid[BLOCK_AABB_GRID][BLOCK_AABB_GRID][BLOCK_AABB_GRID];
|
||||
|
||||
@@ -230,6 +230,7 @@ voxel* Chunks::rayCast(vec3 start,
|
||||
end.y += dy / float(subs);
|
||||
end.z += dz / float(subs);
|
||||
if (box.inside(end)) {
|
||||
end += iend;
|
||||
norm.x = norm.y = norm.z = 0.0f;
|
||||
if (steppedIndex == 0) norm.x = -stepx;
|
||||
if (steppedIndex == 1) norm.y = -stepy;
|
||||
|
||||
@@ -97,16 +97,16 @@ float calc_height(fnl_state *noise, int real_x, int real_z){
|
||||
}
|
||||
|
||||
WorldGenerator::WorldGenerator(const Content* content)
|
||||
: idStone(content->require("base:stone")->id),
|
||||
idDirt(content->require("base:dirt")->id),
|
||||
idGrassBlock(content->require("base:grass_block")->id),
|
||||
idSand(content->require("base:sand")->id),
|
||||
idWater(content->require("base:water")->id),
|
||||
idWood(content->require("base:wood")->id),
|
||||
idLeaves(content->require("base:leaves")->id),
|
||||
idGrass(content->require("base:grass")->id),
|
||||
idFlower(content->require("base:flower")->id),
|
||||
idBedrock(content->require("base:bedrock")->id) {;
|
||||
: idStone(content->require("base:stone")->rt.id),
|
||||
idDirt(content->require("base:dirt")->rt.id),
|
||||
idGrassBlock(content->require("base:grass_block")->rt.id),
|
||||
idSand(content->require("base:sand")->rt.id),
|
||||
idWater(content->require("base:water")->rt.id),
|
||||
idWood(content->require("base:wood")->rt.id),
|
||||
idLeaves(content->require("base:leaves")->rt.id),
|
||||
idGrass(content->require("base:grass")->rt.id),
|
||||
idFlower(content->require("base:flower")->rt.id),
|
||||
idBedrock(content->require("base:bedrock")->rt.id) {;
|
||||
}
|
||||
|
||||
int generate_tree(fnl_state *noise,
|
||||
|
||||
Reference in New Issue
Block a user