1use std::fmt;
4
5use glib::translate::*;
6
7use crate::{ffi, Point3D, Ray, Vec3};
8
9impl Ray {
10 #[doc(alias = "graphene_ray_init")]
11 pub fn new(origin: Option<&Point3D>, direction: Option<&Vec3>) -> Self {
12 assert_initialized_main_thread!();
13 unsafe {
14 let mut ray = Self::uninitialized();
15 ffi::graphene_ray_init(
16 ray.to_glib_none_mut().0,
17 origin.to_glib_none().0,
18 direction.to_glib_none().0,
19 );
20 ray
21 }
22 }
23
24 #[doc(alias = "graphene_ray_init_from_vec3")]
25 #[doc(alias = "init_from_vec3")]
26 pub fn from_vec3(origin: Option<&Vec3>, direction: Option<&Vec3>) -> Self {
27 assert_initialized_main_thread!();
28 unsafe {
29 let mut ray = Self::uninitialized();
30 ffi::graphene_ray_init_from_vec3(
31 ray.to_glib_none_mut().0,
32 origin.to_glib_none().0,
33 direction.to_glib_none().0,
34 );
35 ray
36 }
37 }
38}
39
40impl fmt::Debug for Ray {
41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42 f.debug_struct("Ray")
43 .field("origin", &self.origin())
44 .field("direction", &self.direction())
45 .finish()
46 }
47}