载入中...
搜索中...
未找到
eve::hexmap::HexMapModule类 参考

Owns the active hex map and the GPU meshes generated from it. 更多...

#include <HexMapModule.h>

类 eve::hexmap::HexMapModule 继承关系图:
eve::Module

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 HexMap and every graphics::Mesh it created.
  • chunkMeshAt returns a borrowed mesh; a Renderable3D may reference it only while this module is alive and the grid has not been replaced.
  • releaseMeshes must be called with the same Graphics device 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()

eve::hexmap::HexMapModule::HexMapModule ( )
default

Constructs an empty module with no map and no meshes.

◆ ~HexMapModule()

eve::hexmap::HexMapModule::~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.

参数
gfxDevice that owns the current meshes; required.
restoredDecoded grid, moved into the module.
unitsUnit 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.

参数
gfxDevice that owns the sphere meshes; required.
bakeSphere 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.

参数
gfxDevice that owns the current meshes; required.
bakePlanar 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.

参数
chunkIndexChunk index in [0, chunkCount()).
surfaceSurface 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()

bool eve::hexmap::HexMapModule::hasGrid ( ) const
inlinenoexcept

Whether a grid has been created.

在文件 HexMapModule.h 第 108 行定义.

◆ map() [1/2]

const HexMap & eve::hexmap::HexMapModule::map ( ) const
inlinenoexcept

The active map.

在文件 HexMapModule.h 第 104 行定义.

◆ map() [2/2]

HexMap & eve::hexmap::HexMapModule::map ( )
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.

参数
gfxGraphics device used to release previously created meshes.
cellCountXColumns; must be a positive multiple of the chunk size.
cellCountZRows; must be a positive multiple of the chunk size.
seedDeterministic seed for the cell noise field.
返回
Success, or InvalidArgument for an unsupported size. @cost Releases every owned mesh and allocates cellCountX * cellCountZ cells; 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.

参数
gfxDevice used to release the previously created sphere meshes; required.
subdivisionTopology level in [0, kMaxHexSphereSubdivision].
radiusSphere radius in world units; must be finite and positive.
seedDeterministic 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()

◆ rebuildDirtyChunks()

std::int32_t eve::hexmap::HexMapModule::rebuildDirtyChunks ( graphics::Graphics *  gfx)

Rebuilds every chunk surface currently marked dirty.

参数
gfxGraphics 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.

参数
gfxDevice 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.

参数
gfxDevice that created them; null releases nothing.
注解
The script must call this before the grid is replaced by a different device or before shutdown; newGrid only releases through itself.

在文件 HexMapModule.cpp 第 86 行定义.

引用了 mesh, eve::graphics::Graphics::releaseMesh() , 以及 u.

被这些函数引用 adoptGrid(), applyTerrain() , 以及 newGrid().

◆ releaseSphereMeshes()

void eve::hexmap::HexMapModule::releaseSphereMeshes ( graphics::Graphics *  gfx)
noexcept

Releases every mesh owned by the spherical map.

参数
gfxDevice that created them; null releases nothing.

在文件 HexMapModule.cpp 第 193 行定义.

被这些函数引用 newSphere().

◆ scratch()

HexSearchContext & eve::hexmap::HexMapModule::scratch ( )
inlinenoexcept

Search scratch sized to the active map.

在文件 HexMapModule.h 第 167 行定义.

◆ sphere() [1/2]

const HexSphereMap & eve::hexmap::HexMapModule::sphere ( ) const
inlinenoexcept

The active spherical map.

在文件 HexMapModule.h 第 146 行定义.

◆ sphere() [2/2]

HexSphereMap & eve::hexmap::HexMapModule::sphere ( )
inlinenoexcept

The active spherical map (mutable, for internal build steps).

在文件 HexMapModule.h 第 148 行定义.

◆ sphereTerrainMesh()

graphics::Mesh * eve::hexmap::HexMapModule::sphereTerrainMesh ( ) const
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()

graphics::Mesh * eve::hexmap::HexMapModule::sphereWaterMesh ( ) const
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()

HexUnitRegistry & eve::hexmap::HexMapModule::units ( )
inlinenoexcept

Units of the active map.

在文件 HexMapModule.h 第 165 行定义.

被这些函数引用 adoptGrid().

◆ visibility()

HexVisibility & eve::hexmap::HexMapModule::visibility ( )
inlinenoexcept

Fog-of-war counters of the active map.

在文件 HexMapModule.h 第 163 行定义.


该类的文档由以下文件生成: