Skip to content

Commit

Permalink
rustdoc inlining, extra direction const values
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF committed Jan 31, 2024
1 parent 190a1fe commit 007150f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ nodes instead of one, allowing for more use cases (#130, #128)
* Added `HexLayout::world_pos_to_fract_hex` method (#141, #138, #140)
* Added `HexOrientationData::forward` method (#141)
* Added `HexOrientationData::inverse` method (#141)
* Added coordinate expressive const values for `Direction` (#144)
* Added coordinate expressive const values for `DiagonalDirection` (#144)

### Mesh generation

Expand Down
25 changes: 19 additions & 6 deletions src/direction/diagonal_direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use crate::{Direction, HexOrientation};
#[cfg_attr(feature = "bevy_reflect", derive(bevy_reflect::Reflect))]
pub enum DiagonalDirection {
#[default]
/// Direction to (2, -1)
/// Direction to (2, -1) or (2, -1, -1)
///
/// Angles:
///
Expand All @@ -71,7 +71,7 @@ pub enum DiagonalDirection {
/// ```
#[doc(alias = "East")]
Right = 0,
/// Direction to (1, -2)
/// Direction to (1, -2) or (1, -2, 1)
///
/// Angles:
///
Expand All @@ -95,7 +95,7 @@ pub enum DiagonalDirection {
/// ```
#[doc(alias = "NorthEast")]
TopRight = 1,
/// Direction to (-1, -1)
/// Direction to (-1, -1) or (-1, -1, 2)
///
/// Angles:
///
Expand All @@ -119,7 +119,7 @@ pub enum DiagonalDirection {
/// ```
#[doc(alias = "NorthWest")]
TopLeft = 2,
/// Direction to (-2, 1)
/// Direction to (-2, 1) or (-2, 1, 1)
///
/// Angles:
///
Expand All @@ -143,7 +143,7 @@ pub enum DiagonalDirection {
/// ```
#[doc(alias = "West")]
Left = 3,
/// Direction to (-1, 2)
/// Direction to (-1, 2) or (-1, 2, -1)
///
/// Angles:
///
Expand All @@ -167,7 +167,7 @@ pub enum DiagonalDirection {
/// ```
#[doc(alias = "SouthWest")]
BottomLeft = 4,
/// Direction to (1, 1)
/// Direction to (1, 1) or (1, 1, -2)
///
/// Angles:
///
Expand All @@ -194,6 +194,19 @@ pub enum DiagonalDirection {
}

impl DiagonalDirection {
/// Direction towards `X, -Y, Z`
pub const X_NEG_Y_Z: Self = Self::TopRight;
/// Direction towards `X, -Y, -Z`
pub const X_NEG_Y_NEG_Z: Self = Self::Right;
/// Direction towards `X, Y, -Z`
pub const X_Y: Self = Self::BottomRight;
/// Direction towards `-X, Y, -Z`
pub const NEG_X_Y_NEG_Z: Self = Self::BottomLeft;
/// Direction towards `-X, Y, Z`
pub const NEG_X_Y_Z: Self = Self::Left;
/// Direction towards `-X, Y, Z`
pub const NEG_X_NEG_Y: Self = Self::TopLeft;

/// All 6 diagonal directions matching
/// [`Hex::DIAGONAL_COORDS`](crate::Hex::DIAGONAL_COORDS)
///
Expand Down
13 changes: 13 additions & 0 deletions src/direction/hex_direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@ pub enum Direction {
}

impl Direction {
/// Direction towards `X`
pub const X: Self = Self::BottomRight;
/// Direction towards `Y`
pub const Y: Self = Self::Bottom;
/// Direction towards `-X`
pub const NEG_X: Self = Self::TopLeft;
/// Direction towards `-Y`
pub const NEG_Y: Self = Self::Top;
/// Direction towards `-X, Y`
pub const NEG_X_Y: Self = Self::BottomLeft;
/// Direction towards `X, -Y`
pub const X_NEG_Y: Self = Self::TopRight;

/// All 6 hexagonal directions matching
/// [`Hex::NEIGHBORS_COORDS`](crate::Hex::NEIGHBORS_COORDS)
///
Expand Down
2 changes: 1 addition & 1 deletion src/layout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Direction, Hex, HexOrientation, SQRT_3};
use crate::{orientation::SQRT_3, Direction, Hex, HexOrientation};
use glam::Vec2;

/// Hexagonal layout. This type is the bridge between your *world*/*pixel*
Expand Down
15 changes: 11 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,19 @@ pub mod orientation;
/// Map shapes generation functions
pub mod shapes;

pub use bounds::*;
#[doc(inline)]
pub use bounds::HexBounds;
#[doc(inline)]
pub use conversions::*;
#[doc(inline)]
pub use direction::*;
#[doc(hidden)]
pub use glam::{IVec2, IVec3, Quat, Vec2, Vec3};
pub use hex::*;
pub use layout::*;
#[doc(inline)]
pub use hex::{Hex, HexIterExt};
#[doc(inline)]
pub use layout::HexLayout;
#[cfg(feature = "mesh")]
pub use mesh::*;
pub use orientation::*;
#[doc(inline)]
pub use orientation::HexOrientation;

0 comments on commit 007150f

Please sign in to comment.