refactor: warp everything in Cubed namespace

This commit is contained in:
2026-04-20 22:18:02 +08:00
parent 6c74f4582c
commit c2321a0a6e
49 changed files with 288 additions and 66 deletions

View File

@@ -2,6 +2,8 @@
#include <array>
#include <string>
namespace Cubed {
constexpr float BIOME_NOISE_FREQUENCY = 0.003f;
constexpr float PLAIN_FREQ = 0.4f;
@@ -28,3 +30,4 @@ BiomeHeightRange get_biome_height_range(Biome biome);
Biome safe_int_to_biome(int x);
int get_interpolated_height(float world_x, float world_z, float temp, float humid);
}

View File

@@ -7,6 +7,10 @@
#include <Cubed/config.hpp>
#include <Cubed/tools/cubed_assert.hpp>
namespace Cubed {
struct BlockTexture {
std::string name;
unsigned id;
@@ -62,6 +66,9 @@ const std::array<bool, MAX_BLOCK_NUM> TRANSPARENT_MAP {
};
inline bool is_in_transparent_map(unsigned id) {
CUBED_ASSERT_MSG(id < MAX_BLOCK_NUM, "ID is invaild");
ASSERT_MSG(id < MAX_BLOCK_NUM, "ID is invaild");
return TRANSPARENT_MAP[id];
};
};
}

View File

@@ -8,6 +8,9 @@
#include <Cubed/gameplay/chunk_pos.hpp>
#include <Cubed/gameplay/block.hpp>
namespace Cubed {
class World;
// if want to use, do init_chunk(), gen_vertex_data() and
class Chunk {
@@ -71,4 +74,7 @@ public:
void set_chunk_block(int index, unsigned id);
};
};
}

View File

@@ -4,6 +4,10 @@
#include <Cubed/tools/log.hpp>
#include <Cubed/tools/cubed_assert.hpp>
namespace Cubed {
struct ChunkPos {
int x;
int z;
@@ -28,3 +32,5 @@ struct ChunkPos {
};
};
}

View File

@@ -2,6 +2,10 @@
#include <stdexcept>
#include <string>
namespace Cubed {
enum class GameMode {
CREATIVE,
SPECTATOR
@@ -16,4 +20,7 @@ inline std::string to_str(GameMode mode) {
return {"Spective"};
}
throw std::invalid_argument{"GameMode is invaild"};
}
}

View File

@@ -11,6 +11,8 @@
#include <optional>
#include <string>
namespace Cubed {
enum class Gait{
WALK,
RUN
@@ -88,4 +90,7 @@ public:
void update_player_move_state(int key, int action);
void update_scroll(double yoffset);
};
};
}

View File

@@ -2,6 +2,8 @@
#include <glm/glm.hpp>
namespace Cubed {
class Chunk;
struct TreeStructNode {
@@ -9,4 +11,6 @@ struct TreeStructNode {
unsigned id = 0;
};
bool build_tree(Chunk& chunk, const glm::ivec3& pos);
bool build_tree(Chunk& chunk, const glm::ivec3& pos);
}

View File

@@ -9,6 +9,8 @@
#include <Cubed/AABB.hpp>
#include <Cubed/gameplay/chunk.hpp>
namespace Cubed {
struct ChunkRenderSnapshot {
GLuint vbo;
size_t vertex_count;
@@ -83,4 +85,6 @@ public:
void push_delete_vbo(GLuint vbo);
};
};
}