载入中...
搜索中...
未找到
HexMetrics.h
浏览该文件的文档.
33[[nodiscard]] constexpr HexVec3 operator*(HexVec3 a, float s) noexcept { return HexVec3{a.x * s, a.y * s, a.z * s}; }
56[[nodiscard]] constexpr HexVec3 weightsLerp(HexVec3 a, HexVec3 b, float t) noexcept { return lerp(a, b, t); }
72 return d == HexDirection::NE ? HexDirection::NW : static_cast<HexDirection>(static_cast<int>(d) - 1);
77 return d == HexDirection::NW ? HexDirection::NE : static_cast<HexDirection>(static_cast<int>(d) + 1);
128 static constexpr float kVerticalTerraceStepSize = 1.f / static_cast<float>(kTerracesPerSlope + 1);
202 [[nodiscard]] static HexVec3 firstSolidCorner(HexDirection d) noexcept { return corner(d, kSolidFactor); }
204 [[nodiscard]] static HexVec3 secondSolidCorner(HexDirection d) noexcept { return corner(next(d), kSolidFactor); }
210 [[nodiscard]] static HexVec3 firstWaterCorner(HexDirection d) noexcept { return corner(d, kWaterFactor); }
212 [[nodiscard]] static HexVec3 secondWaterCorner(HexDirection d) noexcept { return corner(next(d), kWaterFactor); }
311 [[nodiscard]] static EdgeVertices terraceLerp(const EdgeVertices& a, const EdgeVertices& b, int step) noexcept {
Hexagon metrics shared by the map model and every mesh builder.
Definition HexMetrics.h:111
static constexpr float outerRadius() noexcept
Radius of a hex cell in world units.
Definition HexMetrics.h:174
static HexVec3 firstSolidCorner(HexDirection d) noexcept
First solid corner of direction.
Definition HexMetrics.h:202
static HexVec3 wallThicknessOffset(HexVec3 near, HexVec3 far) noexcept
Half-thickness offset applied to a wall segment.
Definition HexMetrics.h:255
static float solidRadius() noexcept
Distance from a cell centre to its nearest edge midpoint.
Definition HexMetrics.h:278
static HexVec3 secondSolidCorner(HexDirection d) noexcept
Second solid corner of direction.
Definition HexMetrics.h:204
static constexpr float kElevationPerturbStrength
Strength of the vertical elevation perturbation.
Definition HexMetrics.h:140
static HexVec3 secondWaterCorner(HexDirection d) noexcept
Second water corner of direction.
Definition HexMetrics.h:212
static HexVec3 terraceLerpWeights(HexVec3 a, HexVec3 b, int step) noexcept
Interpolates terrain weights along a terraced slope.
Definition HexMetrics.h:239
static constexpr int kTerraceSteps
Terrace interpolation steps per slope (terracesPerSlope * 2 + 1).
Definition HexMetrics.h:124
static constexpr float kDefaultOuterRadius
Default outer (corner) radius of one hex cell.
Definition HexMetrics.h:118
static HexVec3 secondCorner(HexDirection d) noexcept
Second (clockwise) outer corner of direction.
Definition HexMetrics.h:200
static float waterSurfaceY(int waterLevel) noexcept
Y coordinate of a water surface at waterLevel.
Definition HexMetrics.h:273
static constexpr float kWallElevationOffset
Wall elevation offset, matching the vertical terrace step size.
Definition HexMetrics.h:154
static HexVec3 wallLerp(HexVec3 near, HexVec3 far) noexcept
Position of the midpoint of a wall between two elevations.
Definition HexMetrics.h:246
static HexVec3 bridge(HexDirection d) noexcept
Bridge vector from the solid edge of direction to the neighbour.
Definition HexMetrics.h:214
static HexVec3 firstWaterCorner(HexDirection d) noexcept
First water corner of direction.
Definition HexMetrics.h:210
static HexVec3 solidEdgeMiddle(HexDirection d) noexcept
Midpoint of the solid edge of direction.
Definition HexMetrics.h:206
static constexpr float kInnerToOuter
Ratio of the inner radius to the outer radius.
Definition HexMetrics.h:116
static constexpr float kVerticalTerraceStepSize
Vertical fraction of one terrace interpolation step.
Definition HexMetrics.h:128
static constexpr float kElevationStep
Vertical distance between two elevation levels.
Definition HexMetrics.h:120
static constexpr float kHorizontalTerraceStepSize
Horizontal fraction of one terrace interpolation step.
Definition HexMetrics.h:126
static HexVec3 waterBridge(HexDirection d) noexcept
Bridge vector from the water edge of direction to the neighbour.
Definition HexMetrics.h:218
static constexpr float kInnerRadius
Inner (edge) radius of one hex cell in world units.
Definition HexMetrics.h:167
static constexpr float kWaterBlendFactor
Factor of the water blend region between two cells.
Definition HexMetrics.h:136
static constexpr float kOuterToInner
Ratio of the outer radius to the inner radius.
Definition HexMetrics.h:114
static constexpr float kWaterFactor
Factor of the solid water surface inscribed in a cell.
Definition HexMetrics.h:134
static constexpr float kWaterElevationOffset
Elevation offset of a water surface relative to the water level.
Definition HexMetrics.h:144
static constexpr float kCellPerturbStrength
Strength of the XZ position perturbation.
Definition HexMetrics.h:138
static constexpr float kOuterRadius
Outer (corner) radius of one hex cell in world units.
Definition HexMetrics.h:165
static constexpr float kWallYOffset
Vertical wall offset; negative so walls do not float above the surface.
Definition HexMetrics.h:150
static constexpr float kStreamBedElevationOffset
Elevation offset of a carved river bed relative to the cell.
Definition HexMetrics.h:142
static float elevationY(int elevation) noexcept
Y coordinate of a cell's elevation surface.
Definition HexMetrics.h:265
static float streamBedY(int elevation) noexcept
Y coordinate of a river bed inside a cell.
Definition HexMetrics.h:269
static HexVec3 corner(HexDirection direction, float scale=1.f) noexcept
Outer corner direction of a unit hex, scaled by scale.
Definition HexMetrics.h:183
static constexpr float kBlendFactor
Factor of the blend region between two neighbouring cells.
Definition HexMetrics.h:132
static constexpr float rowSpacing() noexcept
Row spacing between hex rows.
Definition HexMetrics.h:180
static HexVec3 terraceLerp(HexVec3 a, HexVec3 b, int step) noexcept
Interpolates a position along a terraced slope.
Definition HexMetrics.h:229
static constexpr float kSolidFactor
Factor of the solid, uniform-colour hex inscribed in a cell.
Definition HexMetrics.h:130
static HexVec3 firstCorner(HexDirection d) noexcept
First (counter-clockwise) outer corner of direction.
Definition HexMetrics.h:198
Definition HexCell.h:9
constexpr HexVec3 weightsLerp(HexVec3 a, HexVec3 b, float t) noexcept
Blends the three terrain-layer weights of a hex vertex.
Definition HexMetrics.h:56
constexpr HexDirection opposite(HexDirection d) noexcept
The direction opposite to d.
Definition HexMetrics.h:65
constexpr HexDirection previous2(HexDirection d) noexcept
Two steps counter-clockwise.
Definition HexMetrics.h:81
constexpr std::int32_t kHexDirectionCount
Number of hex edges / facing directions.
Definition HexMetrics.h:62
constexpr HexEdgeType edgeType(int elevation1, int elevation2) noexcept
The relationship between two elevations (single-step changes are slopes).
Definition HexMetrics.h:96
HexEdgeType
Relationship between two neighbouring cells of different elevation.
Definition HexMetrics.h:93
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
constexpr HexVec3 lerp(HexVec3 a, HexVec3 b, float t) noexcept
Linear interpolation between two positions.
Definition HexMetrics.h:51
constexpr HexVec3 & operator+=(HexVec3 &a, HexVec3 b) noexcept
Operator +=.
Definition HexMetrics.h:37
Five sample points along one hex edge, from v1 to v5.
Definition HexMetrics.h:282
EdgeVertices(HexVec3 c1, HexVec3 c2, float outerStep) noexcept
Samples the segment using an explicit outer step for v2/v4.
Definition HexMetrics.h:302
EdgeVertices(HexVec3 c1, HexVec3 c2) noexcept
Evenly samples the segment c1 -> c2 at 0, 0.25, 0.5, 0.75 and 1.
Definition HexMetrics.h:293
static EdgeVertices terraceLerp(const EdgeVertices &a, const EdgeVertices &b, int step) noexcept
Terrace-interpolates every sample between two edges.
Definition HexMetrics.h:311
Minimal 3-component float vector used by the hex mesh builders.
Definition HexMetrics.h:18
Four-component float vector, matching the reference four-channel noise sample.
Definition HexMetrics.h:43