il2cpp_bridge_rs/structs/math/
math.rs1pub use glam::*;
3
4pub type Vector2 = Vec2;
5pub type Vector3 = Vec3;
6pub type Vector4 = Vec4;
7pub type Quaternion = Quat;
8pub type Matrix4x4 = Mat4;
9pub type Matrix3x3 = Mat3;
10pub type Matrix2x2 = Mat2;
11
12#[repr(C)]
13#[derive(Debug, Clone, Copy, PartialEq)]
14pub struct Color {
15 pub r: f32,
17 pub g: f32,
19 pub b: f32,
21 pub a: f32,
23}
24
25impl Color {
26 pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self {
28 Self { r, g, b, a }
29 }
30
31 pub const WHITE: Self = Self::new(1.0, 1.0, 1.0, 1.0);
32 pub const BLACK: Self = Self::new(0.0, 0.0, 0.0, 1.0);
33 pub const RED: Self = Self::new(1.0, 0.0, 0.0, 1.0);
34 pub const GREEN: Self = Self::new(0.0, 1.0, 0.0, 1.0);
35 pub const BLUE: Self = Self::new(0.0, 0.0, 1.0, 1.0);
36 pub const YELLOW: Self = Self::new(1.0, 1.0, 0.0, 1.0);
37 pub const CYAN: Self = Self::new(0.0, 1.0, 1.0, 1.0);
38 pub const MAGENTA: Self = Self::new(1.0, 0.0, 1.0, 1.0);
39 pub const TRANSPARENT: Self = Self::new(0.0, 0.0, 0.0, 0.0);
40}
41
42impl From<Vec4> for Color {
43 fn from(v: Vec4) -> Self {
44 Self::new(v.x, v.y, v.z, v.w)
45 }
46}
47
48impl From<Color> for Vec4 {
49 fn from(c: Color) -> Self {
50 Vec4::new(c.r, c.g, c.b, c.a)
51 }
52}
53
54#[repr(C)]
55#[derive(Debug, Clone, Copy, PartialEq)]
56pub struct Bounds {
57 pub center: Vector3,
59 pub extents: Vector3,
61}
62
63impl Default for Bounds {
64 fn default() -> Self {
65 Self {
66 center: Vector3::ZERO,
67 extents: Vector3::ZERO,
68 }
69 }
70}
71
72#[repr(C)]
73#[derive(Debug, Clone, Copy, PartialEq)]
74pub struct Ray {
75 pub origin: Vector3,
77 pub direction: Vector3,
79}
80
81impl Default for Ray {
82 fn default() -> Self {
83 Self {
84 origin: Vector3::ZERO,
85 direction: Vector3::ZERO,
86 }
87 }
88}
89
90#[repr(C)]
91#[derive(Debug, Clone, Copy, PartialEq)]
92pub struct Rect {
93 pub x: f32,
95 pub y: f32,
97 pub width: f32,
99 pub height: f32,
101}
102
103impl Default for Rect {
104 fn default() -> Self {
105 Self {
106 x: 0.0,
107 y: 0.0,
108 width: 0.0,
109 height: 0.0,
110 }
111 }
112}
113
114impl Rect {
115 pub fn new(x: f32, y: f32, width: f32, height: f32) -> Self {
126 Self {
127 x,
128 y,
129 width,
130 height,
131 }
132 }
133}
134
135#[repr(C)]
136#[derive(Debug, Clone, Copy, PartialEq)]
137pub struct Plane {
138 pub normal: Vector3,
140 pub distance: f32,
142}
143
144impl Default for Plane {
145 fn default() -> Self {
146 Self {
147 normal: Vector3::ZERO,
148 distance: 0.0,
149 }
150 }
151}
152
153impl Plane {
154 pub fn new(normal: Vector3, distance: f32) -> Self {
163 Self { normal, distance }
164 }
165}
166
167use std::ffi::c_void;
168
169#[repr(C)]
170#[derive(Debug, Clone, Copy, PartialEq)]
171pub struct RaycastHit {
172 pub point: Vector3,
174 pub normal: Vector3,
176 pub barycentric_coordinate: Vector3,
178 pub distance: f32,
180 pub triangle_index: i32,
182 pub texture_coord: Vector2,
184 pub texture_coord2: Vector2,
186 pub lightmap_coord: Vector2,
188 pub collider: *mut c_void,
190 pub rigidbody: *mut c_void,
192 pub articulation_body: *mut c_void,
194 pub transform: *mut c_void,
196 pub collider_entity_id: u32,
198}
199
200impl Default for RaycastHit {
201 fn default() -> Self {
202 Self {
203 point: Vector3::ZERO,
204 normal: Vector3::ZERO,
205 barycentric_coordinate: Vector3::ZERO,
206 distance: 0.0,
207 triangle_index: 0,
208 texture_coord: Vector2::ZERO,
209 texture_coord2: Vector2::ZERO,
210 lightmap_coord: Vector2::ZERO,
211 collider: std::ptr::null_mut(),
212 rigidbody: std::ptr::null_mut(),
213 articulation_body: std::ptr::null_mut(),
214 transform: std::ptr::null_mut(),
215 collider_entity_id: 0,
216 }
217 }
218}