载入中...
搜索中...
未找到
HexMapMesh.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
7#include "hexmap/HexMap.h"
10
11#include <cstdint>
12
13namespace eve::hexmap {
14
31 [[nodiscard]] static float encodeIndices(std::int32_t a, std::int32_t b, std::int32_t c) noexcept {
32 return static_cast<float>(a) + static_cast<float>(b) * 8.f + static_cast<float>(c) * 64.f;
33 }
35 [[nodiscard]] static float encodeWeights(float weightB, float weightC) noexcept { return weightB + weightC * 16.f; }
36};
37
40 float a = 1.f;
41 float b = 0.f;
42 float c = 0.f;
43
45 [[nodiscard]] static HexTerrainWeights primary() noexcept { return HexTerrainWeights{1.f, 0.f, 0.f}; }
47 [[nodiscard]] static HexTerrainWeights blend(float t) noexcept { return HexTerrainWeights{1.f - t, t, 0.f}; }
49 [[nodiscard]] static HexTerrainWeights blend3(float t2, float t3) noexcept {
50 return HexTerrainWeights{1.f - t2 - t3, t2, t3};
51 }
53 [[nodiscard]] static HexTerrainWeights lerp(const HexTerrainWeights& a, const HexTerrainWeights& b,
54 float t) noexcept {
55 return HexTerrainWeights{a.a + (b.a - a.a) * t, a.b + (b.b - a.b) * t, a.c + (b.c - a.c) * t};
56 }
57};
58
70EVENGINE_API_WORLD void buildTerrainMesh(const HexMap& map, std::int32_t chunkIndex, HexMeshData& out);
71
78EVENGINE_API_WORLD void buildWaterMesh(const HexMap& map, std::int32_t chunkIndex, HexMeshData& out);
79
85void buildRiverMesh(const HexMap& map, std::int32_t chunkIndex, HexMeshData& out);
86
92void buildRoadMesh(const HexMap& map, std::int32_t chunkIndex, HexMeshData& out);
93
103EVENGINE_API_WORLD void buildChunkSurfaceMesh(const HexMap& map, std::int32_t chunkIndex, HexSurface surface,
104 HexMeshData& out);
105
122EVENGINE_API_WORLD void buildFogMesh(const HexMap& map, const HexVisibility& visibility, std::int32_t chunkIndex,
123 HexMeshData& out);
124
125} // namespace eve::hexmap
#define EVENGINE_API_WORLD
Definition Export.h:109
Editable hex cell grid: topology, queries, picking and authoring.
CPU vertex/index container shared by the hex surface builders.
std::int32_t c
Reference-counted cell visibility and explored state.
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float t
void buildRoadMesh(const HexMap &map, std::int32_t chunkIndex, HexMeshData &out)
Builds the road surface of one chunk.
HexSurface
Surface streams a chunk mesh is generated for.
Definition HexMap.h:19
void buildChunkSurfaceMesh(const HexMap &map, std::int32_t chunkIndex, HexSurface surface, HexMeshData &out)
Builds one chunk surface by dispatching on surface.
Definition HexMapMesh.cpp:5
EVENGINE_API_WORLD void buildTerrainMesh(const HexMap &map, std::int32_t chunkIndex, HexMeshData &out)
Builds the ground, terrace and cliff surface of one chunk.
void buildRiverMesh(const HexMap &map, std::int32_t chunkIndex, HexMeshData &out)
Builds the river channel surface of one chunk.
EVENGINE_API_WORLD void buildWaterMesh(const HexMap &map, std::int32_t chunkIndex, HexMeshData &out)
Builds the water surface and shore band of one chunk.
void buildFogMesh(const HexMap &map, const HexVisibility &visibility, std::int32_t chunkIndex, HexMeshData &out)
Builds the fog-of-war overlay of one chunk.
Encodes the three contributing cells of a terrain vertex.
Definition HexMapMesh.h:29
static float encodeIndices(std::int32_t a, std::int32_t b, std::int32_t c) noexcept
First texture coordinate, carrying the three terrain indices.
Definition HexMapMesh.h:31
static float encodeWeights(float weightB, float weightC) noexcept
Second texture coordinate, carrying the secondary/tertiary weights.
Definition HexMapMesh.h:35
Terrain-layer weights of a vertex; the three entries sum to 1.
Definition HexMapMesh.h:39
static HexTerrainWeights blend(float t) noexcept
Weights of two cells, t towards the second.
Definition HexMapMesh.h:47
static HexTerrainWeights lerp(const HexTerrainWeights &a, const HexTerrainWeights &b, float t) noexcept
Interpolates two weight sets.
Definition HexMapMesh.h:53
static HexTerrainWeights blend3(float t2, float t3) noexcept
Weights of three cells, t2/t3 towards the second and third.
Definition HexMapMesh.h:49
static HexTerrainWeights primary() noexcept
Weights of the first cell alone.
Definition HexMapMesh.h:45