1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/// Fast mathematical operations using SIMD-accelerated `glam` types.
///
///This module re-exports all types and functions from the [`glam`] crate, which provides
/// high-performance vector and matrix mathematics using SIMD instructions when available.
///
/// # Common Types
///
/// - [`Vec2`]: 2D vector (x, y)
/// - [`Vec3`]: 3D vector (x, y, z)
/// - [`Vec4`]: 4D vector (x, y, z, w)
/// - [`Mat2`], [`Mat3`], [`Mat4`]: 2x2, 3x3, and 4x4 matrices
/// - [`Quat`]: Quaternion for 3D rotations
///
/// # Examples
///
/// ```
/// use astrelis_core::math::{Vec2, Vec3, Mat4};
///
/// // 2D vectors for positions, velocities, etc.
/// let position = Vec2::new(10.0, 20.0);
/// let velocity = Vec2::new(1.0, 0.5);
/// let new_position = position + velocity * 0.016;
///
/// // 3D transformations
/// let translation = Vec3::new(0.0, 0.0, -5.0);
/// let transform = Mat4::from_translation(translation);
/// ```
///
/// # Performance
///
/// `glam` types use SIMD (Single Instruction, Multiple Data) instructions on supported
/// platforms (x86/x86_64 with SSE, ARM with NEON) for optimal performance. Operations
/// like vector addition, dot products, and matrix multiplication are highly optimized.
///
/// [`glam`]: https://docs.rs/glam
/// Packed vector types for GPU buffer uploads and interoperability.
///
/// This module provides `#[repr(C)]` vector types that can be safely cast to byte slices
/// for GPU buffer uploads using [`bytemuck`]. These types are guaranteed to have a specific
/// memory layout compatible with WGSL shaders and other low-level APIs.
///
/// # When to Use
///
/// Use packed types when:
/// - Uploading vertex or instance data to GPU buffers
/// - Interfacing with C/C++ libraries
/// - Need guaranteed memory layout (`#[repr(C)]`)
///
/// Use [`fast`] module types (re-exported as [`Vec2`], [`Vec3`], [`Vec4`]) for:
/// - CPU-side math calculations (SIMD-accelerated)
/// - Game logic (positions, velocities, etc.)
///
/// # Examples
///
/// ```
/// use astrelis_core::math::PackedVec2;
/// use bytemuck::cast_slice;
///
/// // Create packed vertices for GPU upload
/// let vertices = vec![
/// PackedVec2 { x: -1.0, y: -1.0 },
/// PackedVec2 { x: 1.0, y: -1.0 },
/// PackedVec2 { x: 0.0, y: 1.0 },
/// ];
///
/// // Safely cast to bytes for buffer upload
/// let bytes: &[u8] = cast_slice(&vertices);
/// // ... upload bytes to GPU buffer
/// ```
///
/// # Conversions
///
/// Convert between packed and fast types as needed:
///
/// ```
/// use astrelis_core::math::{Vec2, PackedVec2};
///
/// // Fast type for calculations
/// let velocity = Vec2::new(1.0, 0.5);
///
/// // Convert to packed for GPU upload
/// let packed = PackedVec2 {
/// x: velocity.x,
/// y: velocity.y,
/// };
/// ```
///
/// [`bytemuck`]: https://docs.rs/bytemuck
pub use *;
pub use ;