Axial coordinates of one hex cell. 更多...
#include <HexCoordinates.h>
Public 成员函数 | |
| constexpr | HexCoordinates () noexcept=default |
| Hex coordinates. | |
| constexpr | HexCoordinates (std::int32_t xValue, std::int32_t zValue) noexcept |
| Hex coordinates. | |
| constexpr std::int32_t | y () const noexcept |
Cube Y component (-x - z). | |
| constexpr bool | operator== (const HexCoordinates &other) const noexcept |
| constexpr bool | operator!= (const HexCoordinates &other) const noexcept |
| Operator !=. | |
| constexpr HexCoordinates | step (HexDirection direction, std::int32_t distance=1) const noexcept |
Returns the neighbouring coordinates one step in direction. | |
| constexpr std::int32_t | distanceTo (const HexCoordinates &other) const noexcept |
| Cube distance to another cell (wrapping is not supported). | |
| constexpr float | hexX () const noexcept |
| Hex-space X: east-west neighbour spacing is 1. | |
| constexpr float | hexZ () const noexcept |
Hex-space Z: row spacing is outerToInner. | |
| constexpr std::int32_t | chunkColumn () const noexcept |
| Chunk column this cell belongs to. | |
| constexpr std::int32_t | chunkRow () const noexcept |
| Chunk row this cell belongs to. | |
| constexpr std::int32_t | offsetX () const noexcept |
| Offset X of this cell inside the rectangular grid. | |
| constexpr std::int32_t | offsetZ () const noexcept |
| Offset Z (row) of this cell inside the rectangular grid. | |
静态 Public 成员函数 | |
| static constexpr HexCoordinates | fromOffset (std::int32_t offsetX, std::int32_t offsetZ) noexcept |
| Converts an odd-row offset pair into axial coordinates. | |
| static HexVec3 | toWorldPosition (HexCoordinates coordinates) noexcept |
| World-space centre of a cell before elevation and perturbation. | |
| static HexCoordinates | fromWorldPosition (HexVec3 position) noexcept |
| Converts a world-space XZ position back to cell coordinates. | |
Public 属性 | |
| std::int32_t | x = 0 |
| std::int32_t | z = 0 |
详细描述
Axial coordinates of one hex cell.
The third cube component is derived: y = -x - z. The map uses the odd-row-offset-right layout of the reference hex-map project, so the axial pair is directly the (column, row) pair with even rows starting at column 0 and odd rows shifted half a cell to the right.
在文件 HexCoordinates.h 第 22 行定义.
构造及析构函数说明
◆ HexCoordinates() [1/2]
|
constexprdefaultnoexcept |
Hex coordinates.
◆ HexCoordinates() [2/2]
|
inlineconstexprnoexcept |
Hex coordinates.
在文件 HexCoordinates.h 第 29 行定义.
成员函数说明
◆ chunkColumn()
|
inlineconstexprnoexcept |
◆ chunkRow()
|
inlineconstexprnoexcept |
◆ distanceTo()
|
inlineconstexprnoexcept |
◆ fromOffset()
|
inlinestaticconstexprnoexcept |
Converts an odd-row offset pair into axial coordinates.
在文件 HexCoordinates.h 第 84 行定义.
引用了 offsetX.
被这些函数引用 eve::hexmap::HexMap::chunkCell(), eve::hexmap::HexMap::collectBrush(), eve::hexmap::HexMap::coordinatesAt() , 以及 eve::hexmap::HexMap::pickCell().
◆ fromWorldPosition()
|
staticnoexcept |
Converts a world-space XZ position back to cell coordinates.
Uses the cube-rounding correction so the result is the hex containing the sample point rather than its nearest centre.
- 参数
-
position World position; only X and Z are read.
- 返回
- The containing cell coordinates (may be outside the grid bounds).
在文件 HexCoordinates.cpp 第 5 行定义.
引用了 ax, ay, dx, dy, dz, eve::hexmap::HexMetrics::innerDiameter(), offset, eve::hexmap::HexMetrics::outerRadius(), position , 以及 x.
被这些函数引用 eve::hexmap::HexMap::pickCell().
◆ hexX()
|
inlineconstexprnoexcept |
◆ hexZ()
|
inlineconstexprnoexcept |
◆ offsetX()
|
inlineconstexprnoexcept |
◆ offsetZ()
|
inlineconstexprnoexcept |
◆ operator!=()
|
inlineconstexprnoexcept |
Operator !=.
在文件 HexCoordinates.h 第 38 行定义.
◆ operator==()
|
inlineconstexprnoexcept |
在文件 HexCoordinates.h 第 34 行定义.
◆ step()
|
inlineconstexprnoexcept |
Returns the neighbouring coordinates one step in direction.
- 注解
- The row offset is implicit in the axial pair, so stepping is a pure integer offset and never needs the odd-row correction.
在文件 HexCoordinates.h 第 45 行定义.
引用了 direction, distance, x , 以及 z.
被这些函数引用 eve::hexmap::HexMap::getNeighbor().
◆ toWorldPosition()
|
inlinestaticnoexcept |
World-space centre of a cell before elevation and perturbation.
The odd-row offset of an axial pair is x + z/2, so the reference layout (offsetX + (z odd ? 0.5 : 0)) * innerDiameter collapses to (x + 0.5 * z) * innerDiameter and the result is the exact inverse of fromWorldPosition.
- 参数
-
coordinates Cell coordinates.
- 返回
- Centre position on the XZ plane; Y is always 0.
在文件 HexCoordinates.h 第 105 行定义.
被这些函数引用 eve::hexmap::HexMap::cellPosition().
◆ y()
|
inlineconstexprnoexcept |
类成员变量说明
◆ x
| std::int32_t eve::hexmap::HexCoordinates::x = 0 |
在文件 HexCoordinates.h 第 23 行定义.
被这些函数引用 fromWorldPosition().
◆ z
| std::int32_t eve::hexmap::HexCoordinates::z = 0 |
在文件 HexCoordinates.h 第 24 行定义.
该结构体的文档由以下文件生成:
- src/modules/hexmap/HexCoordinates.h
- src/modules/hexmap/HexCoordinates.cpp