1use std::fmt;
4
5use glib::translate::*;
6
7use crate::{ffi, Point3D, Ray, Vec3};
8
9impl Ray {
10 #[doc(alias = "graphene_ray_init")]
21 pub fn new(origin: Option<&Point3D>, direction: Option<&Vec3>) -> Self {
22 assert_initialized_main_thread!();
23 unsafe {
24 let mut ray = Self::uninitialized();
25 ffi::graphene_ray_init(
26 ray.to_glib_none_mut().0,
27 origin.to_glib_none().0,
28 direction.to_glib_none().0,
29 );
30 ray
31 }
32 }
33
34 #[doc(alias = "graphene_ray_init_from_vec3")]
44 #[doc(alias = "init_from_vec3")]
45 pub fn from_vec3(origin: Option<&Vec3>, direction: Option<&Vec3>) -> Self {
46 assert_initialized_main_thread!();
47 unsafe {
48 let mut ray = Self::uninitialized();
49 ffi::graphene_ray_init_from_vec3(
50 ray.to_glib_none_mut().0,
51 origin.to_glib_none().0,
52 direction.to_glib_none().0,
53 );
54 ray
55 }
56 }
57}
58
59impl fmt::Debug for Ray {
60 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
61 f.debug_struct("Ray")
62 .field("origin", &self.origin())
63 .field("direction", &self.direction())
64 .finish()
65 }
66}