mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
feat: add BlockType
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
|
||||
namespace Cubed {
|
||||
|
||||
using BlockType = uint8_t;
|
||||
|
||||
struct BlockTexture {
|
||||
std::string name;
|
||||
unsigned id;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "Cubed/primitive_data.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Cubed {
|
||||
|
||||
@@ -32,7 +31,7 @@ private:
|
||||
World& m_world;
|
||||
HeightMapArray m_heightmap;
|
||||
// the index is a array of block id
|
||||
std::vector<uint8_t> m_blocks;
|
||||
std::vector<BlockType> m_blocks;
|
||||
GLuint m_vbo = 0;
|
||||
std::vector<Vertex> m_vertexs_data;
|
||||
|
||||
@@ -51,7 +50,7 @@ public:
|
||||
|
||||
BiomeType get_biome() const;
|
||||
ChunkPos get_chunk_pos() const;
|
||||
const std::vector<uint8_t>& get_chunk_blocks() const;
|
||||
const std::vector<BlockType>& get_chunk_blocks() const;
|
||||
HeightMapArray get_heightmap() const;
|
||||
static int get_index(int x, int y, int z);
|
||||
static int get_index(const glm::vec3& pos);
|
||||
@@ -69,8 +68,8 @@ public:
|
||||
// Generate terrain blocks from heightmap and biome
|
||||
void gen_phase_five();
|
||||
// Blend surface blocks at chunk borders with neighbors
|
||||
void gen_phase_six(const std::array<std::optional<std::vector<uint8_t>>, 4>&
|
||||
neighbor_block);
|
||||
void gen_phase_six(const std::array<std::optional<std::vector<BlockType>>,
|
||||
4>& neighbor_block);
|
||||
// Generate biome-specific vegetation/structures
|
||||
void gen_phase_seven();
|
||||
// void gen_vertex_data();
|
||||
@@ -79,7 +78,7 @@ public:
|
||||
// 2 : (0, 1)
|
||||
// 3 : (0, -1)
|
||||
void gen_vertex_data(
|
||||
const std::array<const std::vector<uint8_t>*, 4>& neighbor_block);
|
||||
const std::array<const std::vector<BlockType>*, 4>& neighbor_block);
|
||||
void upload_to_gpu();
|
||||
|
||||
GLuint get_vbo() const;
|
||||
@@ -97,7 +96,7 @@ public:
|
||||
BiomeType biome() const;
|
||||
void biome(BiomeType b);
|
||||
HeightMapArray& heightmap();
|
||||
std::vector<uint8_t>& blocks();
|
||||
std::vector<BlockType>& blocks();
|
||||
World& world();
|
||||
unsigned seed() const;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Cubed/constants.hpp"
|
||||
#include "Cubed/gameplay/biome.hpp"
|
||||
#include "Cubed/gameplay/block.hpp"
|
||||
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||
#include "Cubed/tools/cubed_random.hpp"
|
||||
|
||||
@@ -36,7 +37,7 @@ public:
|
||||
void generate_terrain_blocks();
|
||||
// Adjust Block;
|
||||
void blend_surface_blocks_borders(
|
||||
const std::array<std::optional<std::vector<uint8_t>>, 4>&
|
||||
const std::array<std::optional<std::vector<BlockType>>, 4>&
|
||||
neighbor_block);
|
||||
// Generate Structure
|
||||
void generate_vegetation();
|
||||
|
||||
Reference in New Issue
Block a user