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

Icosahedral (Goldberg) hex topology for a spherical hex map. 更多...

#include <HexSphereTopology.h>

Public 成员函数

 HexSphereTopology ()=default
 Hex sphere topology.
 
bool empty () const noexcept
 Whether the topology holds no cell.
 
std::int32_t subdivision () const noexcept
 The subdivision level this topology was built at.
 
std::int32_t frequency () const noexcept
 Subdivision frequency f = 2^subdivision.
 
std::int32_t cellCount () const noexcept
 Number of cells (10 * f^2 + 2).
 
std::int32_t pentagonCount () const noexcept
 Number of pentagonal cells (12 for every non-empty topology).
 
std::int32_t edgeCount () const noexcept
 Number of cell-to-cell edges (30 * f^2).
 
std::int32_t cornerCount () const noexcept
 Number of distinct corners (20 * f^2), each shared by three cells.
 
bool contains (HexSphereCell cell) const noexcept
 Whether cell is a valid id of this topology.
 
bool isPentagon (HexSphereCell cell) const noexcept
 Whether cell has five edges instead of six; false when out of range.
 
std::int32_t neighborCount (HexSphereCell cell) const noexcept
 Number of edges of cell (5 or 6), or 0 when out of range.
 
HexSphereCell neighbor (HexSphereCell cell, std::int32_t direction) const noexcept
 Neighbour of cell across edge direction.
 
std::int32_t directionOf (HexSphereCell cell, HexSphereCell other) const noexcept
 Edge index of the edge shared with other.
 
std::int32_t oppositeDirection (HexSphereCell cell, std::int32_t direction) const noexcept
 Edge index of cell's edge towards its neighbour across direction.
 
HexVec3 direction (HexSphereCell cell) const noexcept
 Unit direction from the sphere centre to the centre of cell.
 
std::int32_t cornerCountOf (HexSphereCell cell) const noexcept
 Number of corners of cell (5 or 6), or 0 when out of range.
 
HexVec3 corner (HexSphereCell cell, std::int32_t corner) const noexcept
 Unit direction of corner corner of cell.
 
HexSphereCell cellAt (HexVec3 unitDirection) const noexcept
 The cell whose centre direction is nearest to unitDirection.
 

静态 Public 成员函数

static Result< HexSphereTopology > build (std::int32_t subdivision)
 Builds the topology of one subdivision level.
 
static float angularDistance (HexVec3 a, HexVec3 b) noexcept
 Great-circle angle between two directions, in radians.
 

详细描述

Icosahedral (Goldberg) hex topology for a spherical hex map.

The polyhedron is the dual of a geodesic sphere: an icosahedron subdivided subdivision times at frequency f = 2^subdivision, whose vertices become the cells. A cell therefore has six neighbours, except the twelve cells that descend from the original icosahedron vertices, which have five. That makes cellCount() == 10 * f^2 + 2 and pentagonCount() == 12 for every level, matching the mesh.hexplanet recipe of the procgen module.

Cell ids are dense and stable: cells [0, 12) are exactly the twelve pentagons, because midpoint subdivision never renumbers the original vertices.

Directions are not arithmetic. The six planar directions of HexMetrics are constant integer offsets in one global frame; on a sphere the edge order around a cell depends on the cell, and a pentagon has only five edges, so there is no opposite(direction) offset that works everywhere. Every cross-edge query goes through directionOf instead.

Direction d of a cell is the edge between corner(d) and corner((d + 1) % neighbourCount). Both corners are shared with the neighbour across that edge, in the opposite order, which is what lets a mesh builder walk a boundary from either side.

Ownership and lifetime: a value type owning three flat arrays; no I/O, no GPU resources, no callbacks. Immutable once built, so it is safe to share.

Determinism: the construction is a pure function of subdivision; two builds at the same level produce identical ids, directions, neighbours and corners.

在文件 HexSphereTopology.h 第 54 行定义.

构造及析构函数说明

◆ HexSphereTopology()

eve::hexmap::HexSphereTopology::HexSphereTopology ( )
default

Hex sphere topology.

成员函数说明

◆ angularDistance()

float eve::hexmap::HexSphereTopology::angularDistance ( HexVec3  a,
HexVec3  b 
)
staticnoexcept

Great-circle angle between two directions, in radians.

在文件 HexSphereTopology.cpp 第 367 行定义.

引用了 a , 以及 b.

◆ build()

Result< HexSphereTopology > eve::hexmap::HexSphereTopology::build ( std::int32_t  subdivision)
static

Builds the topology of one subdivision level.

参数
subdivisionSubdivision level in [0, kMaxHexSphereSubdivision]; level 0 is the bare icosahedron dual (12 pentagons, 20 corners).
返回
The topology, or InvalidArgument when the level is out of range, or a construction failure when the half-edge walk cannot close (an internal consistency error that a valid icosahedron never triggers). @cost Builds all five tables at once; proportional to the cell count and dominated by the 10 * 4^subdivision cells, amortized over every query the caller makes afterwards.

在文件 HexSphereTopology.cpp 第 92 行定义.

引用了 eve::hexmap::kMaxHexSphereSubdivision, subdivision(), topology, triangles , 以及 vertices.

被这些函数引用 eve::hexmap::HexSphereMap::reset().

◆ cellAt()

HexSphereCell eve::hexmap::HexSphereTopology::cellAt ( HexVec3  unitDirection) const
noexcept

The cell whose centre direction is nearest to unitDirection.

Descends the neighbour graph from the best of the twelve pentagons, which makes the query cost proportional to the angular distance walked rather than to the cell count.

参数
unitDirectionAny non-zero direction; normalized internally.
返回
The containing cell, or kNoHexSphereCell when the topology is empty.

在文件 HexSphereTopology.cpp 第 334 行定义.

引用了 best, cell, current, direction, eve::hexmap::kNoHexSphereCell, score , 以及 target.

被这些函数引用 eve::hexmap::HexSphereMap::pickCell().

◆ cellCount()

std::int32_t eve::hexmap::HexSphereTopology::cellCount ( ) const
inlinenoexcept

Number of cells (10 * f^2 + 2).

在文件 HexSphereTopology.h 第 80 行定义.

被这些函数引用 eve::hexmap::HexSphereMap::reset().

◆ contains()

bool eve::hexmap::HexSphereTopology::contains ( HexSphereCell  cell) const
inlinenoexcept

Whether cell is a valid id of this topology.

在文件 HexSphereTopology.h 第 91 行定义.

引用了 cell.

◆ corner()

HexVec3 eve::hexmap::HexSphereTopology::corner ( HexSphereCell  cell,
std::int32_t  corner 
) const
noexcept

Unit direction of corner corner of cell.

Corner d lies between edge d - 1 and edge d (both cyclic), and is shared by three cells. On a sphere a corner is not a fixed angular offset of its cell, so the mesh builder reads it here instead of deriving it.

返回
A unit vector, or the sphere's north pole when an argument is out of range (callers gate on contains).

在文件 HexSphereTopology.cpp 第 327 行定义.

引用了 cell , 以及 id.

◆ cornerCount()

std::int32_t eve::hexmap::HexSphereTopology::cornerCount ( ) const
inlinenoexcept

Number of distinct corners (20 * f^2), each shared by three cells.

在文件 HexSphereTopology.h 第 86 行定义.

◆ cornerCountOf()

std::int32_t eve::hexmap::HexSphereTopology::cornerCountOf ( HexSphereCell  cell) const
noexcept

Number of corners of cell (5 or 6), or 0 when out of range.

在文件 HexSphereTopology.cpp 第 325 行定义.

引用了 cell.

◆ direction()

HexVec3 eve::hexmap::HexSphereTopology::direction ( HexSphereCell  cell) const
noexcept

Unit direction from the sphere centre to the centre of cell.

在文件 HexSphereTopology.cpp 第 320 行定义.

引用了 cell.

◆ directionOf()

std::int32_t eve::hexmap::HexSphereTopology::directionOf ( HexSphereCell  cell,
HexSphereCell  other 
) const
noexcept

Edge index of the edge shared with other.

The spherical replacement for opposite: a hexagon-hexagon edge happens to satisfy ‘d’ == (d + 3) % 6`, but a hexagon-pentagon edge has no arithmetic form, so callers must always ask this instead of computing an offset.

返回
Edge index in [0, neighborCount(cell)), or kNoHexSphereCell when other is not adjacent to cell.

在文件 HexSphereTopology.cpp 第 304 行定义.

引用了 begin, cell, direction , 以及 eve::hexmap::kNoHexSphereCell.

◆ edgeCount()

std::int32_t eve::hexmap::HexSphereTopology::edgeCount ( ) const
inlinenoexcept

Number of cell-to-cell edges (30 * f^2).

在文件 HexSphereTopology.h 第 84 行定义.

◆ empty()

bool eve::hexmap::HexSphereTopology::empty ( ) const
inlinenoexcept

Whether the topology holds no cell.

在文件 HexSphereTopology.h 第 74 行定义.

◆ frequency()

std::int32_t eve::hexmap::HexSphereTopology::frequency ( ) const
inlinenoexcept

Subdivision frequency f = 2^subdivision.

在文件 HexSphereTopology.h 第 78 行定义.

◆ isPentagon()

bool eve::hexmap::HexSphereTopology::isPentagon ( HexSphereCell  cell) const
inlinenoexcept

Whether cell has five edges instead of six; false when out of range.

在文件 HexSphereTopology.h 第 93 行定义.

引用了 cell.

◆ neighbor()

HexSphereCell eve::hexmap::HexSphereTopology::neighbor ( HexSphereCell  cell,
std::int32_t  direction 
) const
noexcept

Neighbour of cell across edge direction.

参数
cellSource cell.
directionEdge index in [0, neighborCount(cell)).
返回
The neighbouring cell, or kNoHexSphereCell when either argument is out of range.

在文件 HexSphereTopology.cpp 第 299 行定义.

引用了 cell, direction , 以及 eve::hexmap::kNoHexSphereCell.

被这些函数引用 eve::hexmap::HexSphereMap::addRoad(), eve::hexmap::HexSphereMap::collectBrush(), eve::hexmap::HexSphereMap::distance(), eve::hexmap::HexSphereMap::removeRiver(), eve::hexmap::HexSphereMap::removeRoads(), eve::hexmap::HexSphereMap::setElevation() , 以及 eve::hexmap::HexSphereMap::setOutgoingRiver().

◆ neighborCount()

std::int32_t eve::hexmap::HexSphereTopology::neighborCount ( HexSphereCell  cell) const
noexcept

Number of edges of cell (5 or 6), or 0 when out of range.

在文件 HexSphereTopology.cpp 第 294 行定义.

引用了 cell.

被这些函数引用 eve::hexmap::HexSphereMap::collectBrush() , 以及 eve::hexmap::HexSphereMap::distance().

◆ oppositeDirection()

std::int32_t eve::hexmap::HexSphereTopology::oppositeDirection ( HexSphereCell  cell,
std::int32_t  direction 
) const
noexcept

Edge index of cell's edge towards its neighbour across direction.

在文件 HexSphereTopology.cpp 第 314 行定义.

引用了 cell, direction , 以及 eve::hexmap::kNoHexSphereCell.

被这些函数引用 eve::hexmap::HexSphereMap::addRoad(), eve::hexmap::HexSphereMap::removeRiver(), eve::hexmap::HexSphereMap::removeRoads() , 以及 eve::hexmap::HexSphereMap::setOutgoingRiver().

◆ pentagonCount()

std::int32_t eve::hexmap::HexSphereTopology::pentagonCount ( ) const
inlinenoexcept

Number of pentagonal cells (12 for every non-empty topology).

在文件 HexSphereTopology.h 第 82 行定义.

◆ subdivision()

std::int32_t eve::hexmap::HexSphereTopology::subdivision ( ) const
inlinenoexcept

The subdivision level this topology was built at.

在文件 HexSphereTopology.h 第 76 行定义.

被这些函数引用 build().


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