graphene/auto/
ray.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, Box, Plane, Point3D, RayIntersectionKind, Sphere, Triangle, Vec3};
6use glib::translate::*;
7
8glib::wrapper! {
9    pub struct Ray(BoxedInline<ffi::graphene_ray_t>);
10
11    match fn {
12        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_ray_get_type(), ptr as *mut _) as *mut ffi::graphene_ray_t,
13        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_ray_get_type(), ptr as *mut _),
14        type_ => || ffi::graphene_ray_get_type(),
15    }
16}
17
18impl Ray {
19    #[doc(alias = "graphene_ray_equal")]
20    fn equal(&self, b: &Ray) -> bool {
21        unsafe { ffi::graphene_ray_equal(self.to_glib_none().0, b.to_glib_none().0) }
22    }
23
24    #[doc(alias = "graphene_ray_get_closest_point_to_point")]
25    #[doc(alias = "get_closest_point_to_point")]
26    pub fn closest_point_to_point(&self, p: &Point3D) -> Point3D {
27        unsafe {
28            let mut res = Point3D::uninitialized();
29            ffi::graphene_ray_get_closest_point_to_point(
30                self.to_glib_none().0,
31                p.to_glib_none().0,
32                res.to_glib_none_mut().0,
33            );
34            res
35        }
36    }
37
38    #[doc(alias = "graphene_ray_get_direction")]
39    #[doc(alias = "get_direction")]
40    pub fn direction(&self) -> Vec3 {
41        unsafe {
42            let mut direction = Vec3::uninitialized();
43            ffi::graphene_ray_get_direction(self.to_glib_none().0, direction.to_glib_none_mut().0);
44            direction
45        }
46    }
47
48    #[doc(alias = "graphene_ray_get_distance_to_plane")]
49    #[doc(alias = "get_distance_to_plane")]
50    pub fn distance_to_plane(&self, p: &Plane) -> f32 {
51        unsafe {
52            ffi::graphene_ray_get_distance_to_plane(self.to_glib_none().0, p.to_glib_none().0)
53        }
54    }
55
56    #[doc(alias = "graphene_ray_get_distance_to_point")]
57    #[doc(alias = "get_distance_to_point")]
58    pub fn distance_to_point(&self, p: &Point3D) -> f32 {
59        unsafe {
60            ffi::graphene_ray_get_distance_to_point(self.to_glib_none().0, p.to_glib_none().0)
61        }
62    }
63
64    #[doc(alias = "graphene_ray_get_origin")]
65    #[doc(alias = "get_origin")]
66    pub fn origin(&self) -> Point3D {
67        unsafe {
68            let mut origin = Point3D::uninitialized();
69            ffi::graphene_ray_get_origin(self.to_glib_none().0, origin.to_glib_none_mut().0);
70            origin
71        }
72    }
73
74    #[doc(alias = "graphene_ray_get_position_at")]
75    #[doc(alias = "get_position_at")]
76    pub fn position_at(&self, t: f32) -> Point3D {
77        unsafe {
78            let mut position = Point3D::uninitialized();
79            ffi::graphene_ray_get_position_at(
80                self.to_glib_none().0,
81                t,
82                position.to_glib_none_mut().0,
83            );
84            position
85        }
86    }
87
88    #[doc(alias = "graphene_ray_intersect_box")]
89    pub fn intersect_box(&self, b: &Box) -> (RayIntersectionKind, f32) {
90        unsafe {
91            let mut t_out = std::mem::MaybeUninit::uninit();
92            let ret = from_glib(ffi::graphene_ray_intersect_box(
93                self.to_glib_none().0,
94                b.to_glib_none().0,
95                t_out.as_mut_ptr(),
96            ));
97            (ret, t_out.assume_init())
98        }
99    }
100
101    #[doc(alias = "graphene_ray_intersect_sphere")]
102    pub fn intersect_sphere(&self, s: &Sphere) -> (RayIntersectionKind, f32) {
103        unsafe {
104            let mut t_out = std::mem::MaybeUninit::uninit();
105            let ret = from_glib(ffi::graphene_ray_intersect_sphere(
106                self.to_glib_none().0,
107                s.to_glib_none().0,
108                t_out.as_mut_ptr(),
109            ));
110            (ret, t_out.assume_init())
111        }
112    }
113
114    #[doc(alias = "graphene_ray_intersect_triangle")]
115    pub fn intersect_triangle(&self, t: &Triangle) -> (RayIntersectionKind, f32) {
116        unsafe {
117            let mut t_out = std::mem::MaybeUninit::uninit();
118            let ret = from_glib(ffi::graphene_ray_intersect_triangle(
119                self.to_glib_none().0,
120                t.to_glib_none().0,
121                t_out.as_mut_ptr(),
122            ));
123            (ret, t_out.assume_init())
124        }
125    }
126
127    #[doc(alias = "graphene_ray_intersects_box")]
128    pub fn intersects_box(&self, b: &Box) -> bool {
129        unsafe { ffi::graphene_ray_intersects_box(self.to_glib_none().0, b.to_glib_none().0) }
130    }
131
132    #[doc(alias = "graphene_ray_intersects_sphere")]
133    pub fn intersects_sphere(&self, s: &Sphere) -> bool {
134        unsafe { ffi::graphene_ray_intersects_sphere(self.to_glib_none().0, s.to_glib_none().0) }
135    }
136
137    #[doc(alias = "graphene_ray_intersects_triangle")]
138    pub fn intersects_triangle(&self, t: &Triangle) -> bool {
139        unsafe { ffi::graphene_ray_intersects_triangle(self.to_glib_none().0, t.to_glib_none().0) }
140    }
141}
142
143impl PartialEq for Ray {
144    #[inline]
145    fn eq(&self, other: &Self) -> bool {
146        self.equal(other)
147    }
148}
149
150impl Eq for Ray {}