chore: update clang-format
Signed-off-by: szdytom <szdytom@qq.com>
This commit is contained in:
parent
45836dc897
commit
6a3f23f989
@ -7,7 +7,7 @@ AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignOperands: DontAlign
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 2
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "biome.h"
|
||||
#include "chunk.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
namespace istd {
|
||||
|
||||
|
@ -23,24 +23,26 @@ void BiomeGenerationPass::operator()(TileMap &tilemap) {
|
||||
// Generate biomes for each sub-chunk
|
||||
for (std::uint8_t chunk_x = 0; chunk_x < map_size; ++chunk_x) {
|
||||
for (std::uint8_t chunk_y = 0; chunk_y < map_size; ++chunk_y) {
|
||||
Chunk &chunk = tilemap.get_chunk(chunk_x, chunk_y);
|
||||
auto &chunk = tilemap.get_chunk(chunk_x, chunk_y);
|
||||
|
||||
for (std::uint8_t sub_x = 0; sub_x < Chunk::subchunk_count;
|
||||
++sub_x) {
|
||||
for (std::uint8_t sub_y = 0; sub_y < Chunk::subchunk_count;
|
||||
++sub_y) {
|
||||
// Calculate global position for this sub-chunk's center
|
||||
auto [start_x, start_y]
|
||||
= subchunk_to_tile_start(SubChunkPos(sub_x, sub_y));
|
||||
double global_x = chunk_x * Chunk::size + start_x
|
||||
+ Chunk::subchunk_size / 2;
|
||||
auto [start_x, start_y] = subchunk_to_tile_start(
|
||||
{sub_x, sub_y}
|
||||
);
|
||||
|
||||
double global_x = chunk_x * Chunk::size + start_x
|
||||
+ (Chunk::subchunk_size >> 1);
|
||||
double global_y = chunk_y * Chunk::size + start_y
|
||||
+ Chunk::subchunk_size / 2;
|
||||
+ (Chunk::subchunk_size >> 1);
|
||||
|
||||
// Get climate values
|
||||
auto [temperature, humidity]
|
||||
= get_climate(global_x, global_y);
|
||||
auto [temperature, humidity] = get_climate(
|
||||
global_x, global_y
|
||||
);
|
||||
|
||||
// Determine biome and store directly in chunk
|
||||
BiomeType biome = determine_biome(temperature, humidity);
|
||||
|
@ -21,8 +21,9 @@ void DeepwaterGenerationPass::operator()(TileMap &tilemap) {
|
||||
++sub_y) {
|
||||
SubChunkPos sub_pos(sub_x, sub_y);
|
||||
BiomeType biome = chunk.get_biome(sub_pos);
|
||||
const BiomeProperties &properties
|
||||
= get_biome_properties(biome);
|
||||
const BiomeProperties &properties = get_biome_properties(
|
||||
biome
|
||||
);
|
||||
|
||||
// Only process ocean biomes
|
||||
if (!properties.is_ocean) {
|
||||
@ -83,10 +84,10 @@ bool DeepwaterGenerationPass::is_surrounded_by_water(
|
||||
dx <= static_cast<std::int32_t>(radius); ++dx) {
|
||||
for (std::int32_t dy = -static_cast<std::int32_t>(radius);
|
||||
dy <= static_cast<std::int32_t>(radius); ++dy) {
|
||||
std::int32_t check_x
|
||||
= static_cast<std::int32_t>(center_global_x) + dx;
|
||||
std::int32_t check_y
|
||||
= static_cast<std::int32_t>(center_global_y) + dy;
|
||||
std::int32_t check_x = static_cast<std::int32_t>(center_global_x)
|
||||
+ dx;
|
||||
std::int32_t check_y = static_cast<std::int32_t>(center_global_y)
|
||||
+ dy;
|
||||
|
||||
// Check bounds
|
||||
if (check_x < 0 || check_y < 0
|
||||
@ -117,4 +118,4 @@ void TerrainGenerator::deepwater_pass(TileMap &tilemap) {
|
||||
pass(tilemap);
|
||||
}
|
||||
|
||||
} // namespace istd
|
||||
} // namespace istd
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "generation.h"
|
||||
#include <algorithm>
|
||||
#include <queue>
|
||||
|
||||
namespace istd {
|
||||
@ -44,13 +45,13 @@ void MountainHoleFillPass::operator()(TileMap &tilemap) {
|
||||
);
|
||||
|
||||
// Check if this component touches the boundary
|
||||
bool touches_boundary = false;
|
||||
for (const auto component_pos : component_positions) {
|
||||
if (tilemap.is_at_boundary(component_pos)) {
|
||||
touches_boundary = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto boundary_checker =
|
||||
[&tilemap](const TilePos &component_pos) {
|
||||
return tilemap.is_at_boundary(component_pos);
|
||||
};
|
||||
bool touches_boundary = std::ranges::any_of(
|
||||
component_positions, boundary_checker
|
||||
);
|
||||
|
||||
// Fill small holes that don't touch the boundary
|
||||
if (!touches_boundary
|
||||
|
@ -57,14 +57,14 @@ void SmoothenIslandPass::remove_small_island(TileMap &tilemap) {
|
||||
tilemap, pos, visited, component_positions
|
||||
);
|
||||
|
||||
// If the component touches the boundary, skip it
|
||||
bool touches_boundary = false;
|
||||
for (auto component_pos : component_positions) {
|
||||
if (tilemap.is_at_boundary(component_pos)) {
|
||||
touches_boundary = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Check if this component touches the boundary
|
||||
auto boundary_checker =
|
||||
[&tilemap](const TilePos &component_pos) {
|
||||
return tilemap.is_at_boundary(component_pos);
|
||||
};
|
||||
bool touches_boundary = std::ranges::any_of(
|
||||
component_positions, boundary_checker
|
||||
);
|
||||
|
||||
// Skip if it touches the boundary
|
||||
if (touches_boundary) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user