载入中...
搜索中...
未找到
eve::hexmap::HexCoordinates结构体 参考

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]

constexpr eve::hexmap::HexCoordinates::HexCoordinates ( )
constexprdefaultnoexcept

Hex coordinates.

◆ HexCoordinates() [2/2]

constexpr eve::hexmap::HexCoordinates::HexCoordinates ( std::int32_t  xValue,
std::int32_t  zValue 
)
inlineconstexprnoexcept

Hex coordinates.

在文件 HexCoordinates.h 第 29 行定义.

成员函数说明

◆ chunkColumn()

constexpr std::int32_t eve::hexmap::HexCoordinates::chunkColumn ( ) const
inlineconstexprnoexcept

Chunk column this cell belongs to.

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

引用了 x , 以及 z.

◆ chunkRow()

constexpr std::int32_t eve::hexmap::HexCoordinates::chunkRow ( ) const
inlineconstexprnoexcept

Chunk row this cell belongs to.

在文件 HexCoordinates.h 第 81 行定义.

引用了 z.

◆ distanceTo()

constexpr std::int32_t eve::hexmap::HexCoordinates::distanceTo ( const HexCoordinates &  other) const
inlineconstexprnoexcept

Cube distance to another cell (wrapping is not supported).

在文件 HexCoordinates.h 第 58 行定义.

引用了 dx, dy, dz, v, x, y , 以及 z.

被这些函数引用 eve::hexmap::HexUnitRegistry::beginTravel().

◆ fromOffset()

static constexpr HexCoordinates eve::hexmap::HexCoordinates::fromOffset ( std::int32_t  offsetX,
std::int32_t  offsetZ 
)
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()

HexCoordinates eve::hexmap::HexCoordinates::fromWorldPosition ( HexVec3  position)
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.

参数
positionWorld 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()

constexpr float eve::hexmap::HexCoordinates::hexX ( ) const
inlineconstexprnoexcept

Hex-space X: east-west neighbour spacing is 1.

在文件 HexCoordinates.h 第 67 行定义.

引用了 x , 以及 z.

◆ hexZ()

constexpr float eve::hexmap::HexCoordinates::hexZ ( ) const
inlineconstexprnoexcept

Hex-space Z: row spacing is outerToInner.

在文件 HexCoordinates.h 第 73 行定义.

引用了 z.

◆ offsetX()

constexpr std::int32_t eve::hexmap::HexCoordinates::offsetX ( ) const
inlineconstexprnoexcept

Offset X of this cell inside the rectangular grid.

在文件 HexCoordinates.h 第 89 行定义.

引用了 x , 以及 z.

◆ offsetZ()

constexpr std::int32_t eve::hexmap::HexCoordinates::offsetZ ( ) const
inlineconstexprnoexcept

Offset Z (row) of this cell inside the rectangular grid.

在文件 HexCoordinates.h 第 92 行定义.

引用了 z.

◆ operator!=()

constexpr bool eve::hexmap::HexCoordinates::operator!= ( const HexCoordinates &  other) const
inlineconstexprnoexcept

Operator !=.

在文件 HexCoordinates.h 第 38 行定义.

◆ operator==()

constexpr bool eve::hexmap::HexCoordinates::operator== ( const HexCoordinates &  other) const
inlineconstexprnoexcept

在文件 HexCoordinates.h 第 34 行定义.

引用了 x , 以及 z.

◆ step()

constexpr HexCoordinates eve::hexmap::HexCoordinates::step ( HexDirection  direction,
std::int32_t  distance = 1 
) const
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()

static HexVec3 eve::hexmap::HexCoordinates::toWorldPosition ( HexCoordinates  coordinates)
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.

参数
coordinatesCell coordinates.
返回
Centre position on the XZ plane; Y is always 0.

在文件 HexCoordinates.h 第 105 行定义.

被这些函数引用 eve::hexmap::HexMap::cellPosition().

◆ y()

constexpr std::int32_t eve::hexmap::HexCoordinates::y ( ) const
inlineconstexprnoexcept

Cube Y component (-x - z).

在文件 HexCoordinates.h 第 32 行定义.

引用了 x , 以及 z.

类成员变量说明

◆ 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 行定义.


该结构体的文档由以下文件生成: