From 007150f7093cc6eea6ec719287ff68b624f90385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Lescaudey=20de=20Maneville?= Date: Wed, 31 Jan 2024 16:15:38 +0100 Subject: [PATCH] rustdoc inlining, extra direction const values --- CHANGELOG.md | 2 ++ src/direction/diagonal_direction.rs | 25 +++++++++++++++++++------ src/direction/hex_direction.rs | 13 +++++++++++++ src/layout.rs | 2 +- src/lib.rs | 15 +++++++++++---- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7355bd1..70fc9c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/direction/diagonal_direction.rs b/src/direction/diagonal_direction.rs index 3e38330..d10ea81 100644 --- a/src/direction/diagonal_direction.rs +++ b/src/direction/diagonal_direction.rs @@ -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: /// @@ -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: /// @@ -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: /// @@ -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: /// @@ -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: /// @@ -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: /// @@ -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) /// diff --git a/src/direction/hex_direction.rs b/src/direction/hex_direction.rs index a1a91a3..42d889e 100644 --- a/src/direction/hex_direction.rs +++ b/src/direction/hex_direction.rs @@ -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) /// diff --git a/src/layout.rs b/src/layout.rs index debd4b7..c048759 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -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* diff --git a/src/lib.rs b/src/lib.rs index 8188f3a..c0a893c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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;