fear: add r to gen new chunk

This commit is contained in:
2026-04-05 20:19:11 +08:00
parent 23affb78b5
commit ae914a944c
4 changed files with 103 additions and 16 deletions

View File

@@ -1,6 +1,4 @@
#pragma once
constexpr int WORLD_SIZE_X = 32;
constexpr int WORLD_SIZE_Z = 32;
constexpr int WORLD_SIZE_Y = 256;
constexpr int MAX_BLOCK_NUM = 2;
constexpr int MAX_UI_NUM = 1;

View File

@@ -9,10 +9,18 @@ class Player;
class World {
private:
bool need_gen_chunk = false;
BlockRenderData m_block_render_data;
std::unordered_map<ChunkPos , Chunk, ChunkPos::Hash> m_chunks;
std::unordered_map<std::size_t, Player> m_players;
std::vector<glm::vec4> m_planes;
std::pair<int, int> chunk_pos(int world_x, int world_z);
void gen_chunks();
public:
World();
@@ -24,8 +32,10 @@ public:
void init_world();
bool is_aabb_in_frustum(const glm::vec3& center, const glm::vec3& half_extents);
bool is_block(const glm::ivec3& block_pos) const;
void need_gen();
void render(const glm::mat4& mvp_matrix);
void set_block(const glm::ivec3& pos, unsigned id);
void update(float delta_time);