18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 07:24:57 +01:00

Fields: one noise for the edges of the fields and the natural slopes, one filling of the geometry of the water

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ
This commit is contained in:
Claude
2026-11-10 12:30:41 +01:00
parent 60941f2d92
commit 907de021e5
4 changed files with 36 additions and 69 deletions

View File

@@ -187,7 +187,17 @@ int floor_div(int const Value, int const Divisor)
return (Value >= 0 ? Value / Divisor : -((-Value + Divisor - 1) / Divisor));
}
// smooth noise of -1..1 in waves of about Scale metres, the same at the same place every time; Channel gives another one
// the larger of two values, the corner between them rounded off over K
double soft_max(double const A, double const B, double const K)
{
if (K <= 1e-6)
return std::max(A, B);
auto const h{std::max(K - std::abs(A - B), 0.0) / K};
return std::max(A, B) + h * h * K * 0.25;
}
} // namespace
double natural_noise(double const X, double const Z, double const Scale, int const Channel)
{
auto const hash = [](std::int64_t const Ix, std::int64_t const Iz) {
@@ -216,17 +226,6 @@ double natural_noise(double const X, double const Z, double const Scale, int con
return std::clamp(0.7 * octave(u, v) + 0.3 * octave(u * 2.7 + 17.3, v * 2.7 - 9.1), -1.0, 1.0);
}
// the larger of two values, the corner between them rounded off over K
double soft_max(double const A, double const B, double const K)
{
if (K <= 1e-6)
return std::max(A, B);
auto const h{std::max(K - std::abs(A - B), 0.0) / K};
return std::max(A, B) + h * h * K * 0.25;
}
} // namespace
int cells_for(float const Spacing)
{
return static_cast<int>(std::lround(chunk_size / valid_spacing(Spacing)));