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