载入中...
搜索中...
未找到
CaveGenerationState.h
浏览该文件的文档.
1#pragma once
2
5
42
43#include <algorithm>
44#include <cmath>
45#include <cstdint>
46#include <random>
47#include <string>
48#include <unordered_map>
49#include <vector>
50
52
55
56struct Chamber {
59 float irregularity = 0.f;
60 float phase = 0.f;
61};
62
66 float radius = 0.05f;
67};
68
69struct Dripstone {
72 float startRadius = 0.05f;
73 float endRadius = 0.01f;
74 float profileAmplitude = 0.f;
75 float profileFrequency = 2.f;
76 float profilePhase = 0.f;
77};
78
79struct Flowstone {
83 float halfWidth = 0.08f;
84 float halfHeight = 0.12f;
85 float thickness = 0.02f;
86 float rippleAmplitude = 0.01f;
87 float rippleFrequency = 5.f;
88 float phase = 0.f;
89};
90
91struct Curtain {
95 float halfWidth = 0.08f;
96 float length = 0.18f;
97 float thickness = 0.018f;
98 float waveAmplitude = 0.018f;
99 float waveFrequency = 3.f;
100 float phase = 0.f;
101};
102
104 int x = 0;
105 int y = 0;
106 int z = 0;
107 int group = 0;
108
109 bool operator==(const QuantizedPoint& other) const {
110 return x == other.x && y == other.y && z == other.z && group == other.group;
111 }
112};
113
114struct EdgeKey {
115 int ax = 0, ay = 0, az = 0;
116 int bx = 0, by = 0, bz = 0;
117
118 bool operator==(const EdgeKey& other) const {
119 return ax == other.ax && ay == other.ay && az == other.az && bx == other.bx && by == other.by && bz == other.bz;
120 }
121};
122
125 bool split = false;
126};
127
128uint32_t hash(uint32_t value);
129
131 size_t operator()(const EdgeKey& key) const {
132 size_t value = size_t(hash(uint32_t(key.ax)));
133 value ^= size_t(hash(uint32_t(key.ay))) << 1u;
134 value ^= size_t(hash(uint32_t(key.az))) << 2u;
135 value ^= size_t(hash(uint32_t(key.bx))) << 3u;
136 value ^= size_t(hash(uint32_t(key.by))) << 4u;
137 value ^= size_t(hash(uint32_t(key.bz))) << 5u;
138 return value;
139 }
140};
141
142float dot(Vec3 a, Vec3 b);
143Vec3 sub(Vec3 a, Vec3 b);
144Vec3 add(Vec3 a, Vec3 b);
145Vec3 mul(Vec3 a, float scale);
146EdgeKey makeEdgeKey(Vec3 a, Vec3 b);
147float smoothstep(float edge0, float edge1, float value);
148float smoothMaximum(float a, float b, float blendRadius);
150float ellipsoidDistance(Vec3 point, const Chamber& shape);
151float taperedSegmentDistance(Vec3 point, const Dripstone& shape, float horizontalX = 1.f, float horizontalZ = 1.f);
152float flowstoneDistance(Vec3 point, const Flowstone& shape);
153float curtainDistance(Vec3 point, const Curtain& shape);
154uint32_t hash(uint32_t value);
155float latticeNoise(float x, float y, float z, uint32_t seed);
156Vec3 projectToDensitySurface(Vec3 meshPoint, const std::vector<float>& density, int nx, int ny, int nz);
157void addFacetedTriangle(MeshBuild& mesh, Vec3 a, Vec3 b, Vec3 c, Vec3 referenceNormal);
158bool validStyle(const std::string& style);
159bool validGenesis(const std::string& genesis);
160
161struct State {
162 std::vector<CaveSurfaceOperation> surfaceSchedule;
163 bool depositsApplied = false;
164 bool fieldEdited = false;
165 bool skeletonEdited = false;
167 std::string style{};
168 std::string genesis{};
170 int nx{};
171 int ny{};
172 int nz{};
180 float roughness{};
183 float erosion{};
184 float bedding{};
222 float recharge{};
224 float damkohler{};
225 float transportG{};
234 std::string stalagmiteShape{};
236 std::string surfaceNormalMode{};
244 float breakdown{};
247 float paragenesis{};
255 float width{};
256 float height{};
257 float depth{};
258 std::vector<PassagePoint> spine{};
260 std::vector<CaveHydrologyBranch> branches{};
262 std::vector<CaveMixingSite> mixingSites{};
263 std::vector<CaveConstrictionScourSite> constrictionScourSites{};
264 std::vector<CaveKnickpointSite> knickpointSites{};
265 std::vector<Chamber> chambers{};
268 std::vector<CaveBreakdownChamber> breakdownChambers{};
270 std::vector<CaveObstacleScourSite> obstacleScourSites{};
271 std::vector<CaveSedimentPathPoint> sedimentPath{};
273 std::vector<CaveFracture> fractures{};
274 std::vector<CavePotholeSite> potholeSites{};
275 std::vector<Chamber> cupolas{};
276 std::vector<RisingConduit> feeders{};
277 std::vector<RisingConduit> ceilingChannels{};
278 std::vector<Dripstone> dripstones{};
280 std::vector<Flowstone> flowstones{};
281 std::vector<Curtain> curtains{};
282 std::vector<float> density{};
283 std::vector<float> reactiveRate{};
284 std::vector<float> hydraulicExposure{};
285 std::vector<CaveHydrologyVec3> flowDirection{};
358 float voxelSize{};
359 float embedDepth{};
363 std::vector<Dripstone> anchoredDripstones{};
365 std::vector<Flowstone> anchoredFlowstones{};
367 std::vector<Curtain> anchoredCurtains{};
368 std::vector<float> depositDelta{};
372 std::vector<int> caveWallGroups{};
377 float sx{};
378 float sy{};
379 float sz{};
390 void metadata(MeshBuild& out);
391};
392
393} // namespace eve::procgen::cave_detail
double z
double y
double x
ActionParameterOperation operation
SQObjectPtr key
Definition ECS.cpp:155
float density
ShaderImageInput shape
std::int32_t c
std::array< float, 3 > scale
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
OceanMeshSettings mesh
Object::Ptr value
std::string hash
ScriptStructure out
uint32_t seed
Definition TreeMesh.cpp:276
glm::vec3 point
Move-only operation result carrying either a value or Status.
Definition Result.h:176
CPU triangle mesh from procedural mesh recipes (e.g. marching cubes). Positions/normals are xyz-packe...
Definition MeshBuild.h:20
Owning, typed generation parameters.
Definition Params.h:27
Vec3 sub(Vec3 a, Vec3 b)
Vec3 projectToDensitySurface(Vec3 meshPoint, const std::vector< float > &density, int nx, int ny, int nz)
void addFacetedTriangle(MeshBuild &mesh, Vec3 a, Vec3 b, Vec3 c, Vec3 referenceNormal)
bool validStyle(const std::string &style)
float latticeNoise(float x, float y, float z, uint32_t seed)
Vec3 add(Vec3 a, Vec3 b)
float curtainDistance(Vec3 point, const Curtain &shape)
float ellipsoidDistance(Vec3 point, const Chamber &shape)
float smoothMaximum(float a, float b, float blendRadius)
float taperedSegmentDistance(Vec3 point, const Dripstone &shape, float horizontalX=1.f, float horizontalZ=1.f)
bool validGenesis(const std::string &genesis)
float distanceToSegment(Vec3 point, Vec3 a, Vec3 b)
EdgeKey makeEdgeKey(Vec3 a, Vec3 b)
float flowstoneDistance(Vec3 point, const Flowstone &shape)
Vec3 mul(Vec3 a, float scale)
float smoothstep(float edge0, float edge1, float value)
float dot(Vec3 a, Vec3 b)
CaveSurfaceOperation
Independently composable surface operators; order is chosen by the caller.
CaveBoundaryClosure public API.
CaveBreakdownSet public API.
CaveCondensationResult public API.
CaveDetachmentResult public API.
Definition CaveSupport.h:10
CaveHydrologyPoint public API.
CaveHydrologyVec3 public API.
CaveHydrologyWeights public API.
Diagnostics from spatially correlated heterogeneous cave-wall dissolution.
CaveResampledField public API.
CaveSedimentSet public API.
CaveSurfaceEvolutionResult public API.
Diagnostics from geometry-controlled cave-surface dissolution.
CaveWetnessRefinement public API.
Definition CaveWetness.h:13
size_t operator()(const EdgeKey &key) const
bool operator==(const EdgeKey &other) const
bool operator==(const QuantizedPoint &other) const
Result< void > evolve(CaveSurfaceOperation operation)
std::vector< CaveConstrictionScourSite > constrictionScourSites
std::vector< RisingConduit > ceilingChannels
std::vector< CaveFracture > fractures
std::vector< Flowstone > anchoredFlowstones
std::vector< CaveHydrologyBranch > branches
CaveSurfaceEvolutionResult surfaceEvolution
std::vector< CaveHydrologyVec3 > flowDirection
std::vector< CaveKnickpointSite > knickpointSites
std::vector< CaveBreakdownChamber > breakdownChambers
std::vector< CaveObstacleScourSite > obstacleScourSites
std::vector< CaveSedimentPathPoint > sedimentPath
std::vector< Curtain > anchoredCurtains
std::vector< Flowstone > flowstones
std::vector< CavePotholeSite > potholeSites
CaveSurfaceReactivityResult surfaceReactivity
std::vector< CaveSurfaceOperation > surfaceSchedule
CaveReactivePatchinessResult reactivePatchEvolution
std::vector< RisingConduit > feeders
std::vector< CaveMixingSite > mixingSites
std::vector< PassagePoint > spine
std::vector< Dripstone > anchoredDripstones
std::vector< Dripstone > dripstones