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, 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_intersects_box")]
89    pub fn intersects_box(&self, b: &Box) -> bool {
90        unsafe { ffi::graphene_ray_intersects_box(self.to_glib_none().0, b.to_glib_none().0) }
91    }
92
93    #[doc(alias = "graphene_ray_intersects_sphere")]
94    pub fn intersects_sphere(&self, s: &Sphere) -> bool {
95        unsafe { ffi::graphene_ray_intersects_sphere(self.to_glib_none().0, s.to_glib_none().0) }
96    }
97
98    #[doc(alias = "graphene_ray_intersects_triangle")]
99    pub fn intersects_triangle(&self, t: &Triangle) -> bool {
100        unsafe { ffi::graphene_ray_intersects_triangle(self.to_glib_none().0, t.to_glib_none().0) }
101    }
102}
103
104impl PartialEq for Ray {
105    #[inline]
106    fn eq(&self, other: &Self) -> bool {
107        self.equal(other)
108    }
109}
110
111impl Eq for Ray {}