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()
|
default |
Hex sphere topology.
成员函数说明
◆ angularDistance()
Great-circle angle between two directions, in radians.
在文件 HexSphereTopology.cpp 第 367 行定义.
◆ build()
|
static |
Builds the topology of one subdivision level.
- 参数
-
subdivision Subdivision 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^subdivisioncells, amortized over every query the caller makes afterwards.
在文件 HexSphereTopology.cpp 第 92 行定义.
引用了 eve::hexmap::kMaxHexSphereSubdivision, subdivision(), topology, triangles , 以及 vertices.
被这些函数引用 eve::hexmap::HexSphereMap::reset().
◆ cellAt()
|
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.
- 参数
-
unitDirection Any non-zero direction; normalized internally.
- 返回
- The containing cell, or
kNoHexSphereCellwhen the topology is empty.
在文件 HexSphereTopology.cpp 第 334 行定义.
引用了 best, cell, current, direction, eve::hexmap::kNoHexSphereCell, score , 以及 target.
◆ cellCount()
|
inlinenoexcept |
Number of cells (10 * f^2 + 2).
在文件 HexSphereTopology.h 第 80 行定义.
被这些函数引用 eve::hexmap::HexSphereMap::reset().
◆ contains()
|
inlinenoexcept |
◆ corner()
|
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 行定义.
◆ cornerCount()
|
inlinenoexcept |
Number of distinct corners (20 * f^2), each shared by three cells.
在文件 HexSphereTopology.h 第 86 行定义.
◆ cornerCountOf()
|
noexcept |
Number of corners of cell (5 or 6), or 0 when out of range.
在文件 HexSphereTopology.cpp 第 325 行定义.
引用了 cell.
◆ direction()
|
noexcept |
Unit direction from the sphere centre to the centre of cell.
在文件 HexSphereTopology.cpp 第 320 行定义.
引用了 cell.
◆ directionOf()
|
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)), orkNoHexSphereCellwhenotheris not adjacent tocell.
在文件 HexSphereTopology.cpp 第 304 行定义.
引用了 begin, cell, direction , 以及 eve::hexmap::kNoHexSphereCell.
◆ edgeCount()
|
inlinenoexcept |
Number of cell-to-cell edges (30 * f^2).
在文件 HexSphereTopology.h 第 84 行定义.
◆ empty()
|
inlinenoexcept |
Whether the topology holds no cell.
在文件 HexSphereTopology.h 第 74 行定义.
◆ frequency()
|
inlinenoexcept |
Subdivision frequency f = 2^subdivision.
在文件 HexSphereTopology.h 第 78 行定义.
◆ isPentagon()
|
inlinenoexcept |
Whether cell has five edges instead of six; false when out of range.
在文件 HexSphereTopology.h 第 93 行定义.
引用了 cell.
◆ neighbor()
|
noexcept |
Neighbour of cell across edge direction.
- 参数
-
cell Source cell. direction Edge index in [0, neighborCount(cell)).
- 返回
- The neighbouring cell, or
kNoHexSphereCellwhen 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()
|
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()
|
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()
|
inlinenoexcept |
Number of pentagonal cells (12 for every non-empty topology).
在文件 HexSphereTopology.h 第 82 行定义.
◆ subdivision()
|
inlinenoexcept |
The subdivision level this topology was built at.
在文件 HexSphereTopology.h 第 76 行定义.
被这些函数引用 build().
该类的文档由以下文件生成:
- src/modules/hexmap/HexSphereTopology.h
- src/modules/hexmap/HexSphereTopology.cpp