Owns the active hex map and the GPU meshes generated from it. 更多...
#include <HexMapModule.h>
Public 成员函数 | |
| Module_REG (HexMapModule) | |
| HexMapModule () | |
| Constructs an empty module with no map and no meshes. | |
| ~HexMapModule () override | |
| Destructor; GPU meshes must already have been released. | |
| Result< void > | newGrid (graphics::Graphics *gfx, std::int32_t cellCountX, std::int32_t cellCountZ, std::uint32_t seed) |
| Replaces the active grid and releases the meshes of the previous one. | |
| std::int32_t | rebuildDirtyChunks (graphics::Graphics *gfx) |
| Rebuilds every chunk surface currently marked dirty. | |
| std::int32_t | rebuildChunk (graphics::Graphics *gfx, std::int32_t chunkIndex) |
| Rebuilds all surfaces of one chunk. | |
| graphics::Mesh * | chunkMeshAt (std::int32_t chunkIndex, HexSurface surface) const |
| Borrowed GPU mesh of one chunk surface. | |
| void | releaseMeshes (graphics::Graphics *gfx) |
| Releases every mesh owned by the module. | |
| const HexMap & | map () const noexcept |
| The active map. | |
| HexMap & | map () noexcept |
| The active map (mutable, for internal build steps). | |
| bool | hasGrid () const noexcept |
| Whether a grid has been created. | |
| Result< void > | newSphere (graphics::Graphics *gfx, std::int32_t subdivision, float radius, std::uint32_t seed) |
| Replaces the spherical map and releases the meshes of the previous one. | |
| Result< void > | rebuildSphere (graphics::Graphics *gfx) |
| Rebuilds the whole-sphere terrain and ocean meshes from the current cells. | |
| void | releaseSphereMeshes (graphics::Graphics *gfx) noexcept |
| Releases every mesh owned by the spherical map. | |
| const HexSphereMap & | sphere () const noexcept |
| The active spherical map. | |
| HexSphereMap & | sphere () noexcept |
| The active spherical map (mutable, for internal build steps). | |
| graphics::Mesh * | sphereTerrainMesh () const noexcept |
Borrowed GPU terrain mesh of the sphere. @ownership Borrowed; the module retains ownership until releaseSphereMeshes. @nullable Yes; null before the first build or when the sphere has no cells. | |
| graphics::Mesh * | sphereWaterMesh () const noexcept |
Borrowed GPU ocean mesh of the sphere, or null when nothing is flooded. @ownership Borrowed; the module retains ownership until releaseSphereMeshes. @nullable Yes. | |
| HexVisibility & | visibility () noexcept |
| Fog-of-war counters of the active map. | |
| HexUnitRegistry & | units () noexcept |
| Units of the active map. | |
| HexSearchContext & | scratch () noexcept |
| Search scratch sized to the active map. | |
| Result< void > | adoptGrid (graphics::Graphics *gfx, HexMap &&restored, const std::vector< HexUnitState > &units) |
| Replaces the active grid with an already-decoded map. | |
| void | syncScratch () |
Re-sizes the search scratch to the active map. @cost Proportional to the cell count; called by newGrid and by load. | |
| Result< void > | applyTerrain (graphics::Graphics *gfx, const HexTerrainBake &bake) |
| Apply a procgen planar terrain bake and drop every unit. | |
| Result< void > | applySphereTerrain (graphics::Graphics *gfx, const HexTerrainBake &bake) |
| Apply a procgen sphere terrain bake and rebuild both meshes. | |
Public 成员函数 继承自 eve::Module | |
| virtual | ~Module () |
| Module. | |
| virtual std::string | getName () const =0 |
| Returns the name. | |
详细描述
Owns the active hex map and the GPU meshes generated from it.
The module exposes exactly one editable map to scripts (the reference hex-map editor also edits a single grid). newGrid replaces it and releases the meshes generated from the previous map.
Ownership and lifetime:
- The module owns
HexMapand everygraphics::Meshit created. chunkMeshAtreturns a borrowed mesh; aRenderable3Dmay reference it only while this module is alive and the grid has not been replaced.releaseMeshesmust be called with the sameGraphicsdevice that created the meshes, before that device is destroyed.
Thread affinity: main/render thread only; no callbacks are invoked and no lock is held across an external call.
在文件 HexMapModule.h 第 43 行定义.
构造及析构函数说明
◆ HexMapModule()
|
default |
Constructs an empty module with no map and no meshes.
◆ ~HexMapModule()
|
overridedefault |
Destructor; GPU meshes must already have been released.
成员函数说明
◆ adoptGrid()
| Result< void > eve::hexmap::HexMapModule::adoptGrid | ( | graphics::Graphics * | gfx, |
| HexMap && | restored, | ||
| const std::vector< HexUnitState > & | units | ||
| ) |
Replaces the active grid with an already-decoded map.
The load path: the payload was decoded into restored before this call, so the module only has to release the meshes of the previous grid, adopt the new one and rebuild its derived state (scratch, fog of war, mesh slots). The caller must follow it with a whole-map rebuild, because every chunk of the adopted grid starts dirty and no renderable points at the new meshes.
- 参数
-
gfx Device that owns the current meshes; required. restored Decoded grid, moved into the module. units Unit states to restore on the adopted grid.
- 返回
- Success, or InvalidArgument when the device or unit states are invalid. @cost Releases every owned mesh and allocates the derived state for the new grid.
在文件 HexMapModule.cpp 第 73 行定义.
引用了 eve::hexmap::HexMap::cellCount(), eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, releaseMeshes(), eve::hexmap::HexUnitRegistry::removeAll(), eve::hexmap::HexVisibility::reset(), eve::hexmap::HexUnitRegistry::restore(), syncScratch() , 以及 units().
◆ applySphereTerrain()
| Result< void > eve::hexmap::HexMapModule::applySphereTerrain | ( | graphics::Graphics * | gfx, |
| const HexTerrainBake & | bake | ||
| ) |
Apply a procgen sphere terrain bake and rebuild both meshes.
The live topology must already exist (newSphere) and match the bake. Units are not part of the spherical map. GPU meshes are rebuilt here because the sphere is a single pair of streams rather than dirty chunks.
- 参数
-
gfx Device that owns the sphere meshes; required. bake Sphere bake produced by procgen.generateHexSphere.
- 返回
- Success, InvalidArgument when there is no sphere or no device, or the apply/rebuild failure.
在文件 HexMapModule.cpp 第 215 行定义.
引用了 eve::hexmap::applyHexSphereTerrain(), eve::hexmap::HexSphereMap::empty(), eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::hexmap::HexTerrainBake::kind, rebuildSphere() , 以及 eve::hexmap::HexTerrainBake::Sphere.
◆ applyTerrain()
| Result< void > eve::hexmap::HexMapModule::applyTerrain | ( | graphics::Graphics * | gfx, |
| const HexTerrainBake & | bake | ||
| ) |
Apply a procgen planar terrain bake and drop every unit.
The grid is rebuilt from the bake's size and seed first, because terrain perturbation has to match the generation seed; that releases every mesh, unit and visibility counter of the previous grid. The caller must rebuild every chunk afterwards and place new units: a generated map has no explored cells, so nothing is visible until a unit grants vision.
- 参数
-
gfx Device that owns the current meshes; required. bake Planar bake produced by procgen.generateHexTerrain.
- 返回
- Success, or InvalidArgument when there is no device, or a failure forwarded from apply. @cost Releases every owned mesh and allocates the whole grid.
在文件 HexMapModule.cpp 第 56 行定义.
引用了 eve::hexmap::applyHexTerrain(), eve::hexmap::HexMap::cellCount(), eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::hexmap::HexTerrainBake::kind, eve::hexmap::HexTerrainBake::Planar, releaseMeshes(), eve::hexmap::HexUnitRegistry::removeAll(), eve::hexmap::HexVisibility::reset(), eve::Result< T >::success() , 以及 syncScratch().
◆ chunkMeshAt()
| graphics::Mesh * eve::hexmap::HexMapModule::chunkMeshAt | ( | std::int32_t | chunkIndex, |
| HexSurface | surface | ||
| ) | const |
Borrowed GPU mesh of one chunk surface.
- 参数
-
chunkIndex Chunk index in [0, chunkCount()).surface Surface stream to query.
- 返回
- The mesh, or null when that surface has no geometry or was never built. @ownership Borrowed; the module retains ownership until
releaseMeshes.
在文件 HexMapModule.cpp 第 120 行定义.
引用了 eve::hexmap::HexMap::chunkCount() , 以及 u.
◆ hasGrid()
|
inlinenoexcept |
Whether a grid has been created.
在文件 HexMapModule.h 第 108 行定义.
◆ map() [1/2]
|
inlinenoexcept |
The active map.
在文件 HexMapModule.h 第 104 行定义.
◆ map() [2/2]
|
inlinenoexcept |
The active map (mutable, for internal build steps).
在文件 HexMapModule.h 第 106 行定义.
◆ Module_REG()
| eve::hexmap::HexMapModule::Module_REG | ( | HexMapModule | ) |
◆ newGrid()
| Result< void > eve::hexmap::HexMapModule::newGrid | ( | graphics::Graphics * | gfx, |
| std::int32_t | cellCountX, | ||
| std::int32_t | cellCountZ, | ||
| std::uint32_t | seed | ||
| ) |
Replaces the active grid and releases the meshes of the previous one.
- 参数
-
gfx Graphics device used to release previously created meshes. cellCountX Columns; must be a positive multiple of the chunk size. cellCountZ Rows; must be a positive multiple of the chunk size. seed Deterministic seed for the cell noise field.
- 返回
- Success, or InvalidArgument for an unsupported size. @cost Releases every owned mesh and allocates
cellCountX * cellCountZcells; proportional to the map area, amortized over a whole-map rebuild.
在文件 HexMapModule.cpp 第 96 行定义.
引用了 eve::hexmap::HexMap::cellCount(), eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::hexmap::kMaxHexGridDimension, releaseMeshes(), eve::hexmap::HexUnitRegistry::removeAll(), eve::hexmap::HexVisibility::reset(), eve::hexmap::HexMap::reset(), seed, eve::Result< T >::success() , 以及 syncScratch().
◆ newSphere()
| Result< void > eve::hexmap::HexMapModule::newSphere | ( | graphics::Graphics * | gfx, |
| std::int32_t | subdivision, | ||
| float | radius, | ||
| std::uint32_t | seed | ||
| ) |
Replaces the spherical map and releases the meshes of the previous one.
The sphere is a second, independent world alongside the flat grid: it shares the module's device and its cell record types, but neither the flat map nor its meshes are touched, so a script may hold both without one invalidating the other.
- 参数
-
gfx Device used to release the previously created sphere meshes; required. subdivision Topology level in [0, kMaxHexSphereSubdivision].radius Sphere radius in world units; must be finite and positive. seed Deterministic seed for the sphere's noise field.
- 返回
- Success, or InvalidArgument for a missing device or a bad shape. @cost Releases the previous sphere meshes and rebuilds the whole topology.
在文件 HexMapModule.cpp 第 202 行定义.
引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, radius, releaseSphereMeshes(), eve::hexmap::HexSphereMap::reset(), seed , 以及 eve::Result< T >::success().
◆ rebuildChunk()
| std::int32_t eve::hexmap::HexMapModule::rebuildChunk | ( | graphics::Graphics * | gfx, |
| std::int32_t | chunkIndex | ||
| ) |
Rebuilds all surfaces of one chunk.
- 参数
-
gfx Graphics device that owns the chunk meshes. chunkIndex Chunk to regenerate.
- 返回
- Number of surfaces that produced geometry. @cost One CPU mesh build plus one vertex-buffer update per surface.
在文件 HexMapModule.cpp 第 130 行定义.
引用了 eve::hexmap::buildChunkSurfaceMesh(), eve::hexmap::buildFeatureMesh(), eve::hexmap::buildFogMesh(), eve::hexmap::buildWallMesh(), eve::hexmap::HexMap::chunkCount(), eve::hexmap::HexMap::empty(), eve::hexmap::HexMeshData::empty(), eve::hexmap::Feature, eve::hexmap::Fog, indexCount, eve::hexmap::HexMeshData::indices(), eve::hexmap::kHexSurfaceCount, mesh, eve::graphics::Graphics::newMeshFromArrays(), eve::hexmap::HexMeshData::normals(), eve::hexmap::HexMeshData::positions(), eve::graphics::Graphics::releaseMesh(), s, u, eve::graphics::Graphics::updateMeshVertices(), eve::hexmap::HexMeshData::uvs(), vertexCount, eve::hexmap::HexMeshData::vertexCount() , 以及 eve::hexmap::Wall.
被这些函数引用 rebuildDirtyChunks().
◆ rebuildDirtyChunks()
| std::int32_t eve::hexmap::HexMapModule::rebuildDirtyChunks | ( | graphics::Graphics * | gfx | ) |
Rebuilds every chunk surface currently marked dirty.
- 参数
-
gfx Graphics device that owns the chunk meshes.
- 返回
- Number of chunk surfaces that were (re)generated. @cost One CPU mesh build plus one vertex-buffer update per dirty surface.
在文件 HexMapModule.cpp 第 180 行定义.
引用了 eve::hexmap::HexMap::empty(), rebuildChunk() , 以及 eve::hexmap::HexMap::takeDirtyChunk().
◆ rebuildSphere()
| Result< void > eve::hexmap::HexMapModule::rebuildSphere | ( | graphics::Graphics * | gfx | ) |
Rebuilds the whole-sphere terrain and ocean meshes from the current cells.
- 参数
-
gfx Device that owns the sphere meshes; required.
- 返回
- Success, or InvalidArgument when there is no sphere or no device. @cost One CPU mesh build plus one GPU upload per stream; proportional to the cell count, so build it after a batch of edits rather than after each one.
在文件 HexMapModule.cpp 第 226 行定义.
引用了 eve::hexmap::buildSphereTerrainMesh(), eve::hexmap::buildSphereWaterMesh(), eve::hexmap::HexSphereMap::empty(), eve::Diagnostic::error(), eve::Result< T >::failure(), indexCount, eve::InvalidArgument, mesh, eve::graphics::Graphics::newMeshFromArrays(), eve::graphics::Graphics::releaseMesh(), eve::Result< T >::success(), terrain, eve::graphics::Graphics::updateMeshVertices(), vertexCount , 以及 water.
被这些函数引用 applySphereTerrain().
◆ releaseMeshes()
| void eve::hexmap::HexMapModule::releaseMeshes | ( | graphics::Graphics * | gfx | ) |
Releases every mesh owned by the module.
- 参数
-
gfx Device that created them; null releases nothing.
- 注解
- The script must call this before the grid is replaced by a different device or before shutdown;
newGridonly releases through itself.
在文件 HexMapModule.cpp 第 86 行定义.
引用了 mesh, eve::graphics::Graphics::releaseMesh() , 以及 u.
被这些函数引用 adoptGrid(), applyTerrain() , 以及 newGrid().
◆ releaseSphereMeshes()
|
noexcept |
Releases every mesh owned by the spherical map.
- 参数
-
gfx Device that created them; null releases nothing.
在文件 HexMapModule.cpp 第 193 行定义.
被这些函数引用 newSphere().
◆ scratch()
|
inlinenoexcept |
Search scratch sized to the active map.
在文件 HexMapModule.h 第 167 行定义.
◆ sphere() [1/2]
|
inlinenoexcept |
The active spherical map.
在文件 HexMapModule.h 第 146 行定义.
◆ sphere() [2/2]
|
inlinenoexcept |
The active spherical map (mutable, for internal build steps).
在文件 HexMapModule.h 第 148 行定义.
◆ sphereTerrainMesh()
|
inlinenoexcept |
Borrowed GPU terrain mesh of the sphere. @ownership Borrowed; the module retains ownership until releaseSphereMeshes. @nullable Yes; null before the first build or when the sphere has no cells.
在文件 HexMapModule.h 第 154 行定义.
◆ sphereWaterMesh()
|
inlinenoexcept |
Borrowed GPU ocean mesh of the sphere, or null when nothing is flooded. @ownership Borrowed; the module retains ownership until releaseSphereMeshes. @nullable Yes.
在文件 HexMapModule.h 第 160 行定义.
◆ syncScratch()
| void eve::hexmap::HexMapModule::syncScratch | ( | ) |
Re-sizes the search scratch to the active map. @cost Proportional to the cell count; called by newGrid and by load.
在文件 HexMapModule.cpp 第 52 行定义.
引用了 eve::hexmap::HexMap::cellCount() , 以及 eve::hexmap::HexSearchContext::resize().
被这些函数引用 adoptGrid(), applyTerrain() , 以及 newGrid().
◆ units()
|
inlinenoexcept |
◆ visibility()
|
inlinenoexcept |
Fog-of-war counters of the active map.
在文件 HexMapModule.h 第 163 行定义.
该类的文档由以下文件生成:
- src/modules/hexmap/HexMapModule.h
- src/modules/hexmap/HexMapModule.cpp
Public 成员函数 继承自