@@ -4,7 +4,7 @@ use std::fmt;
4
4
5
5
use glib:: translate:: * ;
6
6
7
- use crate :: { ffi, Point3D , Ray , Vec3 } ;
7
+ use crate :: { ffi, Box , Point3D , Ray , RayIntersectionKind , Sphere , Triangle , Vec3 } ;
8
8
9
9
impl Ray {
10
10
#[ doc( alias = "graphene_ray_init" ) ]
@@ -35,6 +35,54 @@ impl Ray {
35
35
ray
36
36
}
37
37
}
38
+
39
+ #[ doc( alias = "graphene_ray_intersect_box" ) ]
40
+ pub fn intersect_box ( & self , b : & Box ) -> ( RayIntersectionKind , Option < f32 > ) {
41
+ unsafe {
42
+ let mut t_out = std:: mem:: MaybeUninit :: uninit ( ) ;
43
+ let ret = from_glib ( ffi:: graphene_ray_intersect_box (
44
+ self . to_glib_none ( ) . 0 ,
45
+ b. to_glib_none ( ) . 0 ,
46
+ t_out. as_mut_ptr ( ) ,
47
+ ) ) ;
48
+ match ret {
49
+ RayIntersectionKind :: None => ( ret, None ) ,
50
+ _ => ( ret, Some ( t_out. assume_init ( ) ) ) ,
51
+ }
52
+ }
53
+ }
54
+
55
+ #[ doc( alias = "graphene_ray_intersect_sphere" ) ]
56
+ pub fn intersect_sphere ( & self , s : & Sphere ) -> ( RayIntersectionKind , Option < f32 > ) {
57
+ unsafe {
58
+ let mut t_out = std:: mem:: MaybeUninit :: uninit ( ) ;
59
+ let ret = from_glib ( ffi:: graphene_ray_intersect_sphere (
60
+ self . to_glib_none ( ) . 0 ,
61
+ s. to_glib_none ( ) . 0 ,
62
+ t_out. as_mut_ptr ( ) ,
63
+ ) ) ;
64
+ match ret {
65
+ RayIntersectionKind :: None => ( ret, None ) ,
66
+ _ => ( ret, Some ( t_out. assume_init ( ) ) ) ,
67
+ }
68
+ }
69
+ }
70
+
71
+ #[ doc( alias = "graphene_ray_intersect_triangle" ) ]
72
+ pub fn intersect_triangle ( & self , t : & Triangle ) -> ( RayIntersectionKind , Option < f32 > ) {
73
+ unsafe {
74
+ let mut t_out = std:: mem:: MaybeUninit :: uninit ( ) ;
75
+ let ret = from_glib ( ffi:: graphene_ray_intersect_triangle (
76
+ self . to_glib_none ( ) . 0 ,
77
+ t. to_glib_none ( ) . 0 ,
78
+ t_out. as_mut_ptr ( ) ,
79
+ ) ) ;
80
+ match ret {
81
+ RayIntersectionKind :: None => ( ret, None ) ,
82
+ _ => ( ret, Some ( t_out. assume_init ( ) ) ) ,
83
+ }
84
+ }
85
+ }
38
86
}
39
87
40
88
impl fmt:: Debug for Ray {
0 commit comments