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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
use crate::Box;
use crate::Plane;
use crate::Point3D;
use crate::RayIntersectionKind;
use crate::Sphere;
use crate::Triangle;
use crate::Vec3;
use glib::translate::*;
use std::mem;
glib::wrapper! {
pub struct Ray(BoxedInline<ffi::graphene_ray_t>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_ray_get_type(), ptr as *mut _) as *mut ffi::graphene_ray_t,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_ray_get_type(), ptr as *mut _),
type_ => || ffi::graphene_ray_get_type(),
}
}
impl Ray {
#[doc(alias = "graphene_ray_equal")]
fn equal(&self, b: &Ray) -> bool {
unsafe { ffi::graphene_ray_equal(self.to_glib_none().0, b.to_glib_none().0) }
}
#[doc(alias = "graphene_ray_get_closest_point_to_point")]
#[doc(alias = "get_closest_point_to_point")]
pub fn closest_point_to_point(&self, p: &Point3D) -> Point3D {
unsafe {
let mut res = Point3D::uninitialized();
ffi::graphene_ray_get_closest_point_to_point(
self.to_glib_none().0,
p.to_glib_none().0,
res.to_glib_none_mut().0,
);
res
}
}
#[doc(alias = "graphene_ray_get_direction")]
#[doc(alias = "get_direction")]
pub fn direction(&self) -> Vec3 {
unsafe {
let mut direction = Vec3::uninitialized();
ffi::graphene_ray_get_direction(self.to_glib_none().0, direction.to_glib_none_mut().0);
direction
}
}
#[doc(alias = "graphene_ray_get_distance_to_plane")]
#[doc(alias = "get_distance_to_plane")]
pub fn distance_to_plane(&self, p: &Plane) -> f32 {
unsafe {
ffi::graphene_ray_get_distance_to_plane(self.to_glib_none().0, p.to_glib_none().0)
}
}
#[doc(alias = "graphene_ray_get_distance_to_point")]
#[doc(alias = "get_distance_to_point")]
pub fn distance_to_point(&self, p: &Point3D) -> f32 {
unsafe {
ffi::graphene_ray_get_distance_to_point(self.to_glib_none().0, p.to_glib_none().0)
}
}
#[doc(alias = "graphene_ray_get_origin")]
#[doc(alias = "get_origin")]
pub fn origin(&self) -> Point3D {
unsafe {
let mut origin = Point3D::uninitialized();
ffi::graphene_ray_get_origin(self.to_glib_none().0, origin.to_glib_none_mut().0);
origin
}
}
#[doc(alias = "graphene_ray_get_position_at")]
#[doc(alias = "get_position_at")]
pub fn position_at(&self, t: f32) -> Point3D {
unsafe {
let mut position = Point3D::uninitialized();
ffi::graphene_ray_get_position_at(
self.to_glib_none().0,
t,
position.to_glib_none_mut().0,
);
position
}
}
#[doc(alias = "graphene_ray_intersect_box")]
pub fn intersect_box(&self, b: &Box) -> (RayIntersectionKind, f32) {
unsafe {
let mut t_out = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::graphene_ray_intersect_box(
self.to_glib_none().0,
b.to_glib_none().0,
t_out.as_mut_ptr(),
));
let t_out = t_out.assume_init();
(ret, t_out)
}
}
#[doc(alias = "graphene_ray_intersect_sphere")]
pub fn intersect_sphere(&self, s: &Sphere) -> (RayIntersectionKind, f32) {
unsafe {
let mut t_out = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::graphene_ray_intersect_sphere(
self.to_glib_none().0,
s.to_glib_none().0,
t_out.as_mut_ptr(),
));
let t_out = t_out.assume_init();
(ret, t_out)
}
}
#[doc(alias = "graphene_ray_intersect_triangle")]
pub fn intersect_triangle(&self, t: &Triangle) -> (RayIntersectionKind, f32) {
unsafe {
let mut t_out = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::graphene_ray_intersect_triangle(
self.to_glib_none().0,
t.to_glib_none().0,
t_out.as_mut_ptr(),
));
let t_out = t_out.assume_init();
(ret, t_out)
}
}
#[doc(alias = "graphene_ray_intersects_box")]
pub fn intersects_box(&self, b: &Box) -> bool {
unsafe { ffi::graphene_ray_intersects_box(self.to_glib_none().0, b.to_glib_none().0) }
}
#[doc(alias = "graphene_ray_intersects_sphere")]
pub fn intersects_sphere(&self, s: &Sphere) -> bool {
unsafe { ffi::graphene_ray_intersects_sphere(self.to_glib_none().0, s.to_glib_none().0) }
}
#[doc(alias = "graphene_ray_intersects_triangle")]
pub fn intersects_triangle(&self, t: &Triangle) -> bool {
unsafe { ffi::graphene_ray_intersects_triangle(self.to_glib_none().0, t.to_glib_none().0) }
}
}
impl PartialEq for Ray {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for Ray {}