mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
feat: ocean (#16)
* feat(gameplay): add Ocean biome with water generation and heightmap adjustments - Introduce Ocean biome enum, builder, and detection logic. - Add ocean water building to all existing biomes and modify heightmap thresholds for low mountainous areas. - Skip cave and river generation in Ocean (and River) biomes; avoid carving water blocks. - Comment out border blending call and update block fill logic. * fix(gameplay): re-enable border blending and protect water in cave gen * refactor(generation): move ocean water build to later phase * feat(block): add is_transitional property and refine border blending * fix(block): set stone block as transitional * fix(world): generate temporary chunks for surface blend neighbor data * fix(gameplay): simplify block fill logic in blend_surface_blocks_borders * refactor(tree): remove debug logging and unused include
This commit is contained in:
@@ -15,6 +15,7 @@ enum class BiomeType {
|
||||
MOUNTAIN,
|
||||
RIVER,
|
||||
SNOWY_PLAIN,
|
||||
OCEAN,
|
||||
NONE
|
||||
};
|
||||
|
||||
|
||||
@@ -50,13 +50,14 @@ struct BlockData {
|
||||
|
||||
bool is_discard = false;
|
||||
bool is_blend = false;
|
||||
|
||||
bool is_transitional = false;
|
||||
BlockData(BlockType b_id, std::string_view b_name, bool liquid,
|
||||
bool passable, bool cross_plane, bool transparent, bool gas,
|
||||
bool discard, bool blend)
|
||||
bool discard, bool blend, bool transitional)
|
||||
: name(b_name), id(b_id), is_liquid(liquid), is_gas(gas),
|
||||
is_passable(passable), is_cross_plane(cross_plane),
|
||||
is_transparent(transparent), is_discard(discard), is_blend(blend) {}
|
||||
is_transparent(transparent), is_discard(discard), is_blend(blend),
|
||||
is_transitional(transitional) {}
|
||||
};
|
||||
|
||||
class BlockManager {
|
||||
@@ -77,7 +78,7 @@ public:
|
||||
|
||||
static bool is_discard(BlockType id);
|
||||
static bool is_blend(BlockType id);
|
||||
|
||||
static bool is_transitional(BlockType id);
|
||||
static BlockType cross_plane_index(BlockType id);
|
||||
|
||||
private:
|
||||
|
||||
@@ -9,6 +9,7 @@ public:
|
||||
virtual ChunkGenerator& get_chunk_generator() = 0;
|
||||
virtual void build_biome() = 0;
|
||||
virtual void build_vegetation() = 0;
|
||||
void ocean_water_build();
|
||||
|
||||
protected:
|
||||
void build_bottom();
|
||||
|
||||
23
include/Cubed/gameplay/builders/ocean_builder.hpp
Normal file
23
include/Cubed/gameplay/builders/ocean_builder.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||
namespace Cubed {
|
||||
|
||||
class ChunkGenerator;
|
||||
|
||||
class OceanBuilder : public BiomeBuilder {
|
||||
public:
|
||||
OceanBuilder(ChunkGenerator& chunk_generator);
|
||||
void build_biome() override;
|
||||
ChunkGenerator& get_chunk_generator() override;
|
||||
void build_vegetation() override;
|
||||
|
||||
private:
|
||||
ChunkGenerator& m_chunk_generator;
|
||||
|
||||
void build_blocks();
|
||||
};
|
||||
|
||||
} // namespace Cubed
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
Chunk& chunk();
|
||||
Random& random();
|
||||
const std::array<BiomeType, 8>& neighbor_biome() const;
|
||||
void ocean_build();
|
||||
void generate_cave();
|
||||
void generate_river();
|
||||
|
||||
|
||||
@@ -70,8 +70,10 @@ private:
|
||||
|
||||
void gen_chunks_internal();
|
||||
void sync_player_pos(glm::vec3& player_pos);
|
||||
void compute_required_chunks(ChunkPosSet& required_chunks,
|
||||
ChunkHashMap& temp_neighbor);
|
||||
void
|
||||
compute_required_chunks(ChunkPosSet& required_chunks,
|
||||
ChunkHashMap& temp_neighbor,
|
||||
std::vector<ChunkPos>& need_gen_temp_chunks_pos);
|
||||
void sync_and_collect_missing_chunks(std::vector<ChunkPos>&,
|
||||
const ChunkPosSet&);
|
||||
void
|
||||
|
||||
@@ -11,7 +11,7 @@ void extract_frustum_planes(const glm::mat4& mvp_matrix,
|
||||
float smootherstep(float edge0, float edge1, float x);
|
||||
bool is_aabb_in_frustum(const glm::vec3& center, const glm::vec3& half_extents,
|
||||
const std::vector<glm::vec4>& planes);
|
||||
|
||||
float deterministic_random(int x, int z, uint64_t seed);
|
||||
} // namespace Math
|
||||
|
||||
} // namespace Cubed
|
||||
Reference in New Issue
Block a user