1use crate::{ffi, Matrix, Point3D, Vec3};
6use glib::translate::*;
7
8glib::wrapper! {
9 pub struct Plane(BoxedInline<ffi::graphene_plane_t>);
10
11 match fn {
12 copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_plane_get_type(), ptr as *mut _) as *mut ffi::graphene_plane_t,
13 free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_plane_get_type(), ptr as *mut _),
14 type_ => || ffi::graphene_plane_get_type(),
15 }
16}
17
18impl Plane {
19 #[doc(alias = "graphene_plane_distance")]
20 pub fn distance(&self, point: &Point3D) -> f32 {
21 unsafe { ffi::graphene_plane_distance(self.to_glib_none().0, point.to_glib_none().0) }
22 }
23
24 #[doc(alias = "graphene_plane_equal")]
25 fn equal(&self, b: &Plane) -> bool {
26 unsafe { ffi::graphene_plane_equal(self.to_glib_none().0, b.to_glib_none().0) }
27 }
28
29 #[doc(alias = "graphene_plane_get_constant")]
30 #[doc(alias = "get_constant")]
31 pub fn constant(&self) -> f32 {
32 unsafe { ffi::graphene_plane_get_constant(self.to_glib_none().0) }
33 }
34
35 #[doc(alias = "graphene_plane_get_normal")]
36 #[doc(alias = "get_normal")]
37 pub fn normal(&self) -> Vec3 {
38 unsafe {
39 let mut normal = Vec3::uninitialized();
40 ffi::graphene_plane_get_normal(self.to_glib_none().0, normal.to_glib_none_mut().0);
41 normal
42 }
43 }
44
45 #[doc(alias = "graphene_plane_negate")]
46 #[must_use]
47 pub fn negate(&self) -> Plane {
48 unsafe {
49 let mut res = Plane::uninitialized();
50 ffi::graphene_plane_negate(self.to_glib_none().0, res.to_glib_none_mut().0);
51 res
52 }
53 }
54
55 #[doc(alias = "graphene_plane_normalize")]
56 #[must_use]
57 pub fn normalize(&self) -> Plane {
58 unsafe {
59 let mut res = Plane::uninitialized();
60 ffi::graphene_plane_normalize(self.to_glib_none().0, res.to_glib_none_mut().0);
61 res
62 }
63 }
64
65 #[doc(alias = "graphene_plane_transform")]
66 #[must_use]
67 pub fn transform(&self, matrix: &Matrix, normal_matrix: Option<&Matrix>) -> Plane {
68 unsafe {
69 let mut res = Plane::uninitialized();
70 ffi::graphene_plane_transform(
71 self.to_glib_none().0,
72 matrix.to_glib_none().0,
73 normal_matrix.to_glib_none().0,
74 res.to_glib_none_mut().0,
75 );
76 res
77 }
78 }
79}
80
81impl PartialEq for Plane {
82 #[inline]
83 fn eq(&self, other: &Self) -> bool {
84 self.equal(other)
85 }
86}
87
88impl Eq for Plane {}