载入中...
搜索中...
未找到
CaveWaterTable.cpp
浏览该文件的文档.
2
3#include <algorithm>
4#include <cmath>
5
6namespace eve::procgen {
7namespace {
8
9float smoothstep(float lo, float hi, float value) {
10 const float t = std::clamp((value - lo) / std::max(hi - lo, 1e-6f), 0.f, 1.f);
11 return t * t * (3.f - 2.f * t);
12}
13
14} // namespace
15
18 // passageAngle is zero at the crown and +/- pi/2 at the walls. Restricting
19 // retreat to sidewalls prevents a horizontal density slice from cutting floors.
20 result.sidewallMask = std::pow(std::fabs(std::sin(input.passageAngle)), 1.45f);
21 const float seedPhase = float(input.seed % 1009u) * 0.006227141f;
22 const float halfThickness = 0.022f + input.fluctuation * 0.035f;
23 for (int stage = 0; stage < input.stages; ++stage) {
24 const float nominalLevel = input.level - float(stage) * input.stageDrop;
25 // Long-wavelength variation retains a recognizably level belt without making
26 // it an artificial perfectly planar cut through every chamber.
27 const float localLevel =
28 nominalLevel + std::sin(input.along * 1.7f + seedPhase + float(stage) * 1.91f) * halfThickness * 0.22f;
29 const float verticalDistance = std::fabs(input.y - localLevel);
30 const float band = 1.f - smoothstep(halfThickness, halfThickness * 2.6f, verticalDistance);
31 const float preservation = std::pow(0.78f, float(stage));
32 const float erosion = band * preservation * result.sidewallMask;
33 if (erosion > result.erosion) {
34 result.erosion = erosion;
35 result.dominantStage = stage;
36 result.dominantLevel = nominalLevel;
37 }
38 }
39 return result;
40}
41
42} // namespace eve::procgen
double value
EvpackChunkInput input
Definition Evpack.cpp:170
float t
CaveWaterTableSample sampleCaveWaterTableCorrosion(const CaveWaterTableInput &input)
Sample laterally continuous corrosion belts left by one or more water-table stages.
Inputs for a staged epiphreatic water-table corrosion belt.
Local staged water-table corrosion and the dominant historical level.