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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::Box;
use crate::Matrix;
use crate::Plane;
use crate::Point3D;
use crate::Sphere;
use glib::translate::*;

glib::wrapper! {
    /// A 3D volume delimited by 2D clip planes.
    ///
    /// The contents of the `graphene_frustum_t` are private, and should not be
    /// modified directly.
    #[derive(Debug, PartialOrd, Ord, Hash)]
    pub struct Frustum(Boxed<ffi::graphene_frustum_t>);

    match fn {
        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_frustum_get_type(), ptr as *mut _) as *mut ffi::graphene_frustum_t,
        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_frustum_get_type(), ptr as *mut _),
        init => |_ptr| (),
        clear => |_ptr| (),
        type_ => || ffi::graphene_frustum_get_type(),
    }
}

impl Frustum {
    /// Checks whether a point is inside the volume defined by the given
    /// [`Frustum`][crate::Frustum].
    /// ## `point`
    /// a [`Point3D`][crate::Point3D]
    ///
    /// # Returns
    ///
    /// `true` if the point is inside the frustum
    #[doc(alias = "graphene_frustum_contains_point")]
    pub fn contains_point(&self, point: &Point3D) -> bool {
        unsafe {
            from_glib(ffi::graphene_frustum_contains_point(
                self.to_glib_none().0,
                point.to_glib_none().0,
            ))
        }
    }

    /// Checks whether the two given [`Frustum`][crate::Frustum] are equal.
    /// ## `b`
    /// a [`Frustum`][crate::Frustum]
    ///
    /// # Returns
    ///
    /// `true` if the given frustums are equal
    #[doc(alias = "graphene_frustum_equal")]
    fn equal(&self, b: &Frustum) -> bool {
        unsafe {
            from_glib(ffi::graphene_frustum_equal(
                self.to_glib_none().0,
                b.to_glib_none().0,
            ))
        }
    }

    //#[doc(alias = "graphene_frustum_get_planes")]
    //#[doc(alias = "get_planes")]
    //pub fn planes(&self, planes: /*Unimplemented*/FixedArray TypeId { ns_id: 1, id: 8 }; 6) {
    //    unsafe { TODO: call ffi:graphene_frustum_get_planes() }
    //}

    /// Initializes the given [`Frustum`][crate::Frustum] using the provided
    /// clipping planes.
    /// ## `p0`
    /// a clipping plane
    /// ## `p1`
    /// a clipping plane
    /// ## `p2`
    /// a clipping plane
    /// ## `p3`
    /// a clipping plane
    /// ## `p4`
    /// a clipping plane
    /// ## `p5`
    /// a clipping plane
    ///
    /// # Returns
    ///
    /// the initialized frustum
    #[doc(alias = "graphene_frustum_init")]
    pub fn init(&mut self, p0: &Plane, p1: &Plane, p2: &Plane, p3: &Plane, p4: &Plane, p5: &Plane) {
        unsafe {
            ffi::graphene_frustum_init(
                self.to_glib_none_mut().0,
                p0.to_glib_none().0,
                p1.to_glib_none().0,
                p2.to_glib_none().0,
                p3.to_glib_none().0,
                p4.to_glib_none().0,
                p5.to_glib_none().0,
            );
        }
    }

    /// Initializes the given [`Frustum`][crate::Frustum] using the clipping
    /// planes of another [`Frustum`][crate::Frustum].
    /// ## `src`
    /// a [`Frustum`][crate::Frustum]
    ///
    /// # Returns
    ///
    /// the initialized frustum
    #[doc(alias = "graphene_frustum_init_from_frustum")]
    pub fn init_from_frustum(&mut self, src: &Frustum) {
        unsafe {
            ffi::graphene_frustum_init_from_frustum(
                self.to_glib_none_mut().0,
                src.to_glib_none().0,
            );
        }
    }

    /// Initializes a [`Frustum`][crate::Frustum] using the given `matrix`.
    /// ## `matrix`
    /// a [`Matrix`][crate::Matrix]
    ///
    /// # Returns
    ///
    /// the initialized frustum
    #[doc(alias = "graphene_frustum_init_from_matrix")]
    pub fn init_from_matrix(&mut self, matrix: &Matrix) {
        unsafe {
            ffi::graphene_frustum_init_from_matrix(
                self.to_glib_none_mut().0,
                matrix.to_glib_none().0,
            );
        }
    }

    /// Checks whether the given `box_` intersects a plane of
    /// a [`Frustum`][crate::Frustum].
    /// ## `box_`
    /// a [`Box`][crate::Box]
    ///
    /// # Returns
    ///
    /// `true` if the box intersects the frustum
    #[doc(alias = "graphene_frustum_intersects_box")]
    pub fn intersects_box(&self, box_: &Box) -> bool {
        unsafe {
            from_glib(ffi::graphene_frustum_intersects_box(
                self.to_glib_none().0,
                box_.to_glib_none().0,
            ))
        }
    }

    /// Checks whether the given `sphere` intersects a plane of
    /// a [`Frustum`][crate::Frustum].
    /// ## `sphere`
    /// a [`Sphere`][crate::Sphere]
    ///
    /// # Returns
    ///
    /// `true` if the sphere intersects the frustum
    #[doc(alias = "graphene_frustum_intersects_sphere")]
    pub fn intersects_sphere(&self, sphere: &Sphere) -> bool {
        unsafe {
            from_glib(ffi::graphene_frustum_intersects_sphere(
                self.to_glib_none().0,
                sphere.to_glib_none().0,
            ))
        }
    }
}

impl PartialEq for Frustum {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.equal(other)
    }
}

impl Eq for Frustum {}