{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A ray emitted from an origin in a given direction.
-- 
-- The contents of the @graphene_ray_t@ structure are private, and should not
-- be modified directly.
-- 
-- /Since: 1.4/

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Graphene.Structs.Ray
    ( 

-- * Exported types
    Ray(..)                                 ,
    newZeroRay                              ,
    noRay                                   ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveRayMethod                        ,
#endif


-- ** alloc #method:alloc#

    rayAlloc                                ,


-- ** equal #method:equal#

#if defined(ENABLE_OVERLOADING)
    RayEqualMethodInfo                      ,
#endif
    rayEqual                                ,


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    RayFreeMethodInfo                       ,
#endif
    rayFree                                 ,


-- ** getClosestPointToPoint #method:getClosestPointToPoint#

#if defined(ENABLE_OVERLOADING)
    RayGetClosestPointToPointMethodInfo     ,
#endif
    rayGetClosestPointToPoint               ,


-- ** getDirection #method:getDirection#

#if defined(ENABLE_OVERLOADING)
    RayGetDirectionMethodInfo               ,
#endif
    rayGetDirection                         ,


-- ** getDistanceToPlane #method:getDistanceToPlane#

#if defined(ENABLE_OVERLOADING)
    RayGetDistanceToPlaneMethodInfo         ,
#endif
    rayGetDistanceToPlane                   ,


-- ** getDistanceToPoint #method:getDistanceToPoint#

#if defined(ENABLE_OVERLOADING)
    RayGetDistanceToPointMethodInfo         ,
#endif
    rayGetDistanceToPoint                   ,


-- ** getOrigin #method:getOrigin#

#if defined(ENABLE_OVERLOADING)
    RayGetOriginMethodInfo                  ,
#endif
    rayGetOrigin                            ,


-- ** getPositionAt #method:getPositionAt#

#if defined(ENABLE_OVERLOADING)
    RayGetPositionAtMethodInfo              ,
#endif
    rayGetPositionAt                        ,


-- ** init #method:init#

#if defined(ENABLE_OVERLOADING)
    RayInitMethodInfo                       ,
#endif
    rayInit                                 ,


-- ** initFromRay #method:initFromRay#

#if defined(ENABLE_OVERLOADING)
    RayInitFromRayMethodInfo                ,
#endif
    rayInitFromRay                          ,


-- ** initFromVec3 #method:initFromVec3#

#if defined(ENABLE_OVERLOADING)
    RayInitFromVec3MethodInfo               ,
#endif
    rayInitFromVec3                         ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import {-# SOURCE #-} qualified GI.Graphene.Structs.Plane as Graphene.Plane
import {-# SOURCE #-} qualified GI.Graphene.Structs.Point3D as Graphene.Point3D
import {-# SOURCE #-} qualified GI.Graphene.Structs.Vec3 as Graphene.Vec3

-- | Memory-managed wrapper type.
newtype Ray = Ray (ManagedPtr Ray)
    deriving (Ray -> Ray -> Bool
(Ray -> Ray -> Bool) -> (Ray -> Ray -> Bool) -> Eq Ray
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ray -> Ray -> Bool
$c/= :: Ray -> Ray -> Bool
== :: Ray -> Ray -> Bool
$c== :: Ray -> Ray -> Bool
Eq)
foreign import ccall "graphene_ray_get_type" c_graphene_ray_get_type :: 
    IO GType

instance BoxedObject Ray where
    boxedType :: Ray -> IO GType
boxedType _ = IO GType
c_graphene_ray_get_type

-- | Convert 'Ray' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Ray where
    toGValue :: Ray -> IO GValue
toGValue o :: Ray
o = do
        GType
gtype <- IO GType
c_graphene_ray_get_type
        Ray -> (Ptr Ray -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Ray
o (GType -> (GValue -> Ptr Ray -> IO ()) -> Ptr Ray -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Ray -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
        
    fromGValue :: GValue -> IO Ray
fromGValue gv :: GValue
gv = do
        Ptr Ray
ptr <- GValue -> IO (Ptr Ray)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Ray)
        (ManagedPtr Ray -> Ray) -> Ptr Ray -> IO Ray
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Ray -> Ray
Ray Ptr Ray
ptr
        
    

-- | Construct a `Ray` struct initialized to zero.
newZeroRay :: MonadIO m => m Ray
newZeroRay :: m Ray
newZeroRay = IO Ray -> m Ray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Ray -> m Ray) -> IO Ray -> m Ray
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Ray)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 32 IO (Ptr Ray) -> (Ptr Ray -> IO Ray) -> IO Ray
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Ray -> Ray) -> Ptr Ray -> IO Ray
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Ray -> Ray
Ray

instance tag ~ 'AttrSet => Constructible Ray tag where
    new :: (ManagedPtr Ray -> Ray) -> [AttrOp Ray tag] -> m Ray
new _ attrs :: [AttrOp Ray tag]
attrs = do
        Ray
o <- m Ray
forall (m :: * -> *). MonadIO m => m Ray
newZeroRay
        Ray -> [AttrOp Ray 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set Ray
o [AttrOp Ray tag]
[AttrOp Ray 'AttrSet]
attrs
        Ray -> m Ray
forall (m :: * -> *) a. Monad m => a -> m a
return Ray
o


-- | A convenience alias for `Nothing` :: `Maybe` `Ray`.
noRay :: Maybe Ray
noRay :: Maybe Ray
noRay = Maybe Ray
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Ray
type instance O.AttributeList Ray = RayAttributeList
type RayAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method Ray::alloc
-- method type : Constructor
-- Args: []
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Graphene" , name = "Ray" })
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_alloc" graphene_ray_alloc :: 
    IO (Ptr Ray)

-- | Allocates a new t'GI.Graphene.Structs.Ray.Ray' structure.
-- 
-- The contents of the returned structure are undefined.
-- 
-- /Since: 1.4/
rayAlloc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Ray
    -- ^ __Returns:__ the newly allocated t'GI.Graphene.Structs.Ray.Ray'.
    --   Use 'GI.Graphene.Structs.Ray.rayFree' to free the resources allocated by
    --   this function
rayAlloc :: m Ray
rayAlloc  = IO Ray -> m Ray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Ray -> m Ray) -> IO Ray -> m Ray
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
result <- IO (Ptr Ray)
graphene_ray_alloc
    Text -> Ptr Ray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "rayAlloc" Ptr Ray
result
    Ray
result' <- ((ManagedPtr Ray -> Ray) -> Ptr Ray -> IO Ray
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Ray -> Ray
Ray) Ptr Ray
result
    Ray -> IO Ray
forall (m :: * -> *) a. Monad m => a -> m a
return Ray
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Ray::equal
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "a"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "b"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_equal" graphene_ray_equal :: 
    Ptr Ray ->                              -- a : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Ray ->                              -- b : TInterface (Name {namespace = "Graphene", name = "Ray"})
    IO CInt

-- | Checks whether the two given t'GI.Graphene.Structs.Ray.Ray' are equal.
-- 
-- /Since: 1.4/
rayEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@a@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> Ray
    -- ^ /@b@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> m Bool
    -- ^ __Returns:__ @true@ if the given rays are equal
rayEqual :: Ray -> Ray -> m Bool
rayEqual a :: Ray
a b :: Ray
b = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
a' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
a
    Ptr Ray
b' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
b
    CInt
result <- Ptr Ray -> Ptr Ray -> IO CInt
graphene_ray_equal Ptr Ray
a' Ptr Ray
b'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
a
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
b
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data RayEqualMethodInfo
instance (signature ~ (Ray -> m Bool), MonadIO m) => O.MethodInfo RayEqualMethodInfo Ray signature where
    overloadedMethod = rayEqual

#endif

-- method Ray::free
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_free" graphene_ray_free :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    IO ()

-- | Frees the resources allocated by 'GI.Graphene.Structs.Ray.rayAlloc'.
-- 
-- /Since: 1.4/
rayFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> m ()
rayFree :: Ray -> m ()
rayFree r :: Ray
r = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Ray -> IO ()
graphene_ray_free Ptr Ray
r'
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data RayFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RayFreeMethodInfo Ray signature where
    overloadedMethod = rayFree

#endif

-- method Ray::get_closest_point_to_point
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "p"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Point3D" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_point3d_t"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "res"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Point3D" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "return location for the closest point3d"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_get_closest_point_to_point" graphene_ray_get_closest_point_to_point :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Graphene.Point3D.Point3D ->         -- p : TInterface (Name {namespace = "Graphene", name = "Point3D"})
    Ptr Graphene.Point3D.Point3D ->         -- res : TInterface (Name {namespace = "Graphene", name = "Point3D"})
    IO ()

-- | Computes the point on the given t'GI.Graphene.Structs.Ray.Ray' that is closest to the
-- given point /@p@/.
-- 
-- /Since: 1.4/
rayGetClosestPointToPoint ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> Graphene.Point3D.Point3D
    -- ^ /@p@/: a t'GI.Graphene.Structs.Point3D.Point3D'
    -> m (Graphene.Point3D.Point3D)
rayGetClosestPointToPoint :: Ray -> Point3D -> m Point3D
rayGetClosestPointToPoint r :: Ray
r p :: Point3D
p = IO Point3D -> m Point3D
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point3D -> m Point3D) -> IO Point3D -> m Point3D
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Point3D
p' <- Point3D -> IO (Ptr Point3D)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point3D
p
    Ptr Point3D
res <- Int -> IO (Ptr Point3D)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 12 :: IO (Ptr Graphene.Point3D.Point3D)
    Ptr Ray -> Ptr Point3D -> Ptr Point3D -> IO ()
graphene_ray_get_closest_point_to_point Ptr Ray
r' Ptr Point3D
p' Ptr Point3D
res
    Point3D
res' <- ((ManagedPtr Point3D -> Point3D) -> Ptr Point3D -> IO Point3D
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Point3D -> Point3D
Graphene.Point3D.Point3D) Ptr Point3D
res
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Point3D -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Point3D
p
    Point3D -> IO Point3D
forall (m :: * -> *) a. Monad m => a -> m a
return Point3D
res'

#if defined(ENABLE_OVERLOADING)
data RayGetClosestPointToPointMethodInfo
instance (signature ~ (Graphene.Point3D.Point3D -> m (Graphene.Point3D.Point3D)), MonadIO m) => O.MethodInfo RayGetClosestPointToPointMethodInfo Ray signature where
    overloadedMethod = rayGetClosestPointToPoint

#endif

-- method Ray::get_direction
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "direction"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Vec3" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "return location for the direction"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_get_direction" graphene_ray_get_direction :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Graphene.Vec3.Vec3 ->               -- direction : TInterface (Name {namespace = "Graphene", name = "Vec3"})
    IO ()

-- | Retrieves the direction of the given t'GI.Graphene.Structs.Ray.Ray'.
-- 
-- /Since: 1.4/
rayGetDirection ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> m (Graphene.Vec3.Vec3)
rayGetDirection :: Ray -> m Vec3
rayGetDirection r :: Ray
r = IO Vec3 -> m Vec3
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Vec3 -> m Vec3) -> IO Vec3 -> m Vec3
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Vec3
direction <- Int -> IO (Ptr Vec3)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 16 :: IO (Ptr Graphene.Vec3.Vec3)
    Ptr Ray -> Ptr Vec3 -> IO ()
graphene_ray_get_direction Ptr Ray
r' Ptr Vec3
direction
    Vec3
direction' <- ((ManagedPtr Vec3 -> Vec3) -> Ptr Vec3 -> IO Vec3
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Vec3 -> Vec3
Graphene.Vec3.Vec3) Ptr Vec3
direction
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Vec3 -> IO Vec3
forall (m :: * -> *) a. Monad m => a -> m a
return Vec3
direction'

#if defined(ENABLE_OVERLOADING)
data RayGetDirectionMethodInfo
instance (signature ~ (m (Graphene.Vec3.Vec3)), MonadIO m) => O.MethodInfo RayGetDirectionMethodInfo Ray signature where
    overloadedMethod = rayGetDirection

#endif

-- method Ray::get_distance_to_plane
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "p"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Plane" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_plane_t"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TFloat)
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_get_distance_to_plane" graphene_ray_get_distance_to_plane :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Graphene.Plane.Plane ->             -- p : TInterface (Name {namespace = "Graphene", name = "Plane"})
    IO CFloat

-- | Computes the distance of the origin of the given t'GI.Graphene.Structs.Ray.Ray' from the
-- given plane.
-- 
-- If the ray does not intersect the plane, this function returns @INFINITY@.
-- 
-- /Since: 1.4/
rayGetDistanceToPlane ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> Graphene.Plane.Plane
    -- ^ /@p@/: a t'GI.Graphene.Structs.Plane.Plane'
    -> m Float
    -- ^ __Returns:__ the distance of the origin of the ray from the plane
rayGetDistanceToPlane :: Ray -> Plane -> m Float
rayGetDistanceToPlane r :: Ray
r p :: Plane
p = IO Float -> m Float
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Float -> m Float) -> IO Float -> m Float
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Plane
p' <- Plane -> IO (Ptr Plane)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Plane
p
    CFloat
result <- Ptr Ray -> Ptr Plane -> IO CFloat
graphene_ray_get_distance_to_plane Ptr Ray
r' Ptr Plane
p'
    let result' :: Float
result' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
result
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Plane -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Plane
p
    Float -> IO Float
forall (m :: * -> *) a. Monad m => a -> m a
return Float
result'

#if defined(ENABLE_OVERLOADING)
data RayGetDistanceToPlaneMethodInfo
instance (signature ~ (Graphene.Plane.Plane -> m Float), MonadIO m) => O.MethodInfo RayGetDistanceToPlaneMethodInfo Ray signature where
    overloadedMethod = rayGetDistanceToPlane

#endif

-- method Ray::get_distance_to_point
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "p"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Point3D" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_point3d_t"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TFloat)
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_get_distance_to_point" graphene_ray_get_distance_to_point :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Graphene.Point3D.Point3D ->         -- p : TInterface (Name {namespace = "Graphene", name = "Point3D"})
    IO CFloat

-- | Computes the distance from the origin of the given ray to the given point.
-- 
-- /Since: 1.4/
rayGetDistanceToPoint ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> Graphene.Point3D.Point3D
    -- ^ /@p@/: a t'GI.Graphene.Structs.Point3D.Point3D'
    -> m Float
    -- ^ __Returns:__ the distance of the point
rayGetDistanceToPoint :: Ray -> Point3D -> m Float
rayGetDistanceToPoint r :: Ray
r p :: Point3D
p = IO Float -> m Float
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Float -> m Float) -> IO Float -> m Float
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Point3D
p' <- Point3D -> IO (Ptr Point3D)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point3D
p
    CFloat
result <- Ptr Ray -> Ptr Point3D -> IO CFloat
graphene_ray_get_distance_to_point Ptr Ray
r' Ptr Point3D
p'
    let result' :: Float
result' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
result
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Point3D -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Point3D
p
    Float -> IO Float
forall (m :: * -> *) a. Monad m => a -> m a
return Float
result'

#if defined(ENABLE_OVERLOADING)
data RayGetDistanceToPointMethodInfo
instance (signature ~ (Graphene.Point3D.Point3D -> m Float), MonadIO m) => O.MethodInfo RayGetDistanceToPointMethodInfo Ray signature where
    overloadedMethod = rayGetDistanceToPoint

#endif

-- method Ray::get_origin
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Point3D" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "return location for the origin"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_get_origin" graphene_ray_get_origin :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Graphene.Point3D.Point3D ->         -- origin : TInterface (Name {namespace = "Graphene", name = "Point3D"})
    IO ()

-- | Retrieves the origin of the given t'GI.Graphene.Structs.Ray.Ray'.
-- 
-- /Since: 1.4/
rayGetOrigin ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> m (Graphene.Point3D.Point3D)
rayGetOrigin :: Ray -> m Point3D
rayGetOrigin r :: Ray
r = IO Point3D -> m Point3D
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point3D -> m Point3D) -> IO Point3D -> m Point3D
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Point3D
origin <- Int -> IO (Ptr Point3D)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 12 :: IO (Ptr Graphene.Point3D.Point3D)
    Ptr Ray -> Ptr Point3D -> IO ()
graphene_ray_get_origin Ptr Ray
r' Ptr Point3D
origin
    Point3D
origin' <- ((ManagedPtr Point3D -> Point3D) -> Ptr Point3D -> IO Point3D
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Point3D -> Point3D
Graphene.Point3D.Point3D) Ptr Point3D
origin
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Point3D -> IO Point3D
forall (m :: * -> *) a. Monad m => a -> m a
return Point3D
origin'

#if defined(ENABLE_OVERLOADING)
data RayGetOriginMethodInfo
instance (signature ~ (m (Graphene.Point3D.Point3D)), MonadIO m) => O.MethodInfo RayGetOriginMethodInfo Ray signature where
    overloadedMethod = rayGetOrigin

#endif

-- method Ray::get_position_at
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "t"
--           , argType = TBasicType TFloat
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the distance along the ray"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "position"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Point3D" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "return location for the position"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_get_position_at" graphene_ray_get_position_at :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    CFloat ->                               -- t : TBasicType TFloat
    Ptr Graphene.Point3D.Point3D ->         -- position : TInterface (Name {namespace = "Graphene", name = "Point3D"})
    IO ()

-- | Retrieves the coordinates of a point at the distance /@t@/ along the
-- given t'GI.Graphene.Structs.Ray.Ray'.
-- 
-- /Since: 1.4/
rayGetPositionAt ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> Float
    -- ^ /@t@/: the distance along the ray
    -> m (Graphene.Point3D.Point3D)
rayGetPositionAt :: Ray -> Float -> m Point3D
rayGetPositionAt r :: Ray
r t :: Float
t = IO Point3D -> m Point3D
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point3D -> m Point3D) -> IO Point3D -> m Point3D
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    let t' :: CFloat
t' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
t
    Ptr Point3D
position <- Int -> IO (Ptr Point3D)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 12 :: IO (Ptr Graphene.Point3D.Point3D)
    Ptr Ray -> CFloat -> Ptr Point3D -> IO ()
graphene_ray_get_position_at Ptr Ray
r' CFloat
t' Ptr Point3D
position
    Point3D
position' <- ((ManagedPtr Point3D -> Point3D) -> Ptr Point3D -> IO Point3D
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Point3D -> Point3D
Graphene.Point3D.Point3D) Ptr Point3D
position
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Point3D -> IO Point3D
forall (m :: * -> *) a. Monad m => a -> m a
return Point3D
position'

#if defined(ENABLE_OVERLOADING)
data RayGetPositionAtMethodInfo
instance (signature ~ (Float -> m (Graphene.Point3D.Point3D)), MonadIO m) => O.MethodInfo RayGetPositionAtMethodInfo Ray signature where
    overloadedMethod = rayGetPositionAt

#endif

-- method Ray::init
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #graphene_ray_t to initialize"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Point3D" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the origin of the ray"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "direction"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Vec3" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the direction vector"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Graphene" , name = "Ray" })
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_init" graphene_ray_init :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Graphene.Point3D.Point3D ->         -- origin : TInterface (Name {namespace = "Graphene", name = "Point3D"})
    Ptr Graphene.Vec3.Vec3 ->               -- direction : TInterface (Name {namespace = "Graphene", name = "Vec3"})
    IO (Ptr Ray)

-- | Initializes the given t'GI.Graphene.Structs.Ray.Ray' using the given /@origin@/
-- and /@direction@/ values.
-- 
-- /Since: 1.4/
rayInit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: the t'GI.Graphene.Structs.Ray.Ray' to initialize
    -> Maybe (Graphene.Point3D.Point3D)
    -- ^ /@origin@/: the origin of the ray
    -> Maybe (Graphene.Vec3.Vec3)
    -- ^ /@direction@/: the direction vector
    -> m Ray
    -- ^ __Returns:__ the initialized ray
rayInit :: Ray -> Maybe Point3D -> Maybe Vec3 -> m Ray
rayInit r :: Ray
r origin :: Maybe Point3D
origin direction :: Maybe Vec3
direction = IO Ray -> m Ray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Ray -> m Ray) -> IO Ray -> m Ray
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Point3D
maybeOrigin <- case Maybe Point3D
origin of
        Nothing -> Ptr Point3D -> IO (Ptr Point3D)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Point3D
forall a. Ptr a
nullPtr
        Just jOrigin :: Point3D
jOrigin -> do
            Ptr Point3D
jOrigin' <- Point3D -> IO (Ptr Point3D)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point3D
jOrigin
            Ptr Point3D -> IO (Ptr Point3D)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Point3D
jOrigin'
    Ptr Vec3
maybeDirection <- case Maybe Vec3
direction of
        Nothing -> Ptr Vec3 -> IO (Ptr Vec3)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Vec3
forall a. Ptr a
nullPtr
        Just jDirection :: Vec3
jDirection -> do
            Ptr Vec3
jDirection' <- Vec3 -> IO (Ptr Vec3)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Vec3
jDirection
            Ptr Vec3 -> IO (Ptr Vec3)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Vec3
jDirection'
    Ptr Ray
result <- Ptr Ray -> Ptr Point3D -> Ptr Vec3 -> IO (Ptr Ray)
graphene_ray_init Ptr Ray
r' Ptr Point3D
maybeOrigin Ptr Vec3
maybeDirection
    Text -> Ptr Ray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "rayInit" Ptr Ray
result
    Ray
result' <- ((ManagedPtr Ray -> Ray) -> Ptr Ray -> IO Ray
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Ray -> Ray
Ray) Ptr Ray
result
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Maybe Point3D -> (Point3D -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Point3D
origin Point3D -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Maybe Vec3 -> (Vec3 -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Vec3
direction Vec3 -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ray -> IO Ray
forall (m :: * -> *) a. Monad m => a -> m a
return Ray
result'

#if defined(ENABLE_OVERLOADING)
data RayInitMethodInfo
instance (signature ~ (Maybe (Graphene.Point3D.Point3D) -> Maybe (Graphene.Vec3.Vec3) -> m Ray), MonadIO m) => O.MethodInfo RayInitMethodInfo Ray signature where
    overloadedMethod = rayInit

#endif

-- method Ray::init_from_ray
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #graphene_ray_t to initialize"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "src"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_ray_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Graphene" , name = "Ray" })
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_init_from_ray" graphene_ray_init_from_ray :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Ray ->                              -- src : TInterface (Name {namespace = "Graphene", name = "Ray"})
    IO (Ptr Ray)

-- | Initializes the given t'GI.Graphene.Structs.Ray.Ray' using the origin and direction
-- values of another t'GI.Graphene.Structs.Ray.Ray'.
-- 
-- /Since: 1.4/
rayInitFromRay ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: the t'GI.Graphene.Structs.Ray.Ray' to initialize
    -> Ray
    -- ^ /@src@/: a t'GI.Graphene.Structs.Ray.Ray'
    -> m Ray
    -- ^ __Returns:__ the initialized ray
rayInitFromRay :: Ray -> Ray -> m Ray
rayInitFromRay r :: Ray
r src :: Ray
src = IO Ray -> m Ray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Ray -> m Ray) -> IO Ray -> m Ray
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Ray
src' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
src
    Ptr Ray
result <- Ptr Ray -> Ptr Ray -> IO (Ptr Ray)
graphene_ray_init_from_ray Ptr Ray
r' Ptr Ray
src'
    Text -> Ptr Ray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "rayInitFromRay" Ptr Ray
result
    Ray
result' <- ((ManagedPtr Ray -> Ray) -> Ptr Ray -> IO Ray
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Ray -> Ray
Ray) Ptr Ray
result
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
src
    Ray -> IO Ray
forall (m :: * -> *) a. Monad m => a -> m a
return Ray
result'

#if defined(ENABLE_OVERLOADING)
data RayInitFromRayMethodInfo
instance (signature ~ (Ray -> m Ray), MonadIO m) => O.MethodInfo RayInitFromRayMethodInfo Ray signature where
    overloadedMethod = rayInitFromRay

#endif

-- method Ray::init_from_vec3
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "r"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Ray" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #graphene_ray_t to initialize"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Vec3" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_vec3_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "direction"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Vec3" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #graphene_vec3_t" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Graphene" , name = "Ray" })
-- throws : False
-- Skip return : False

foreign import ccall "graphene_ray_init_from_vec3" graphene_ray_init_from_vec3 :: 
    Ptr Ray ->                              -- r : TInterface (Name {namespace = "Graphene", name = "Ray"})
    Ptr Graphene.Vec3.Vec3 ->               -- origin : TInterface (Name {namespace = "Graphene", name = "Vec3"})
    Ptr Graphene.Vec3.Vec3 ->               -- direction : TInterface (Name {namespace = "Graphene", name = "Vec3"})
    IO (Ptr Ray)

-- | Initializes the given t'GI.Graphene.Structs.Ray.Ray' using the given vectors.
-- 
-- /Since: 1.4/
rayInitFromVec3 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ray
    -- ^ /@r@/: the t'GI.Graphene.Structs.Ray.Ray' to initialize
    -> Maybe (Graphene.Vec3.Vec3)
    -- ^ /@origin@/: a t'GI.Graphene.Structs.Vec3.Vec3'
    -> Maybe (Graphene.Vec3.Vec3)
    -- ^ /@direction@/: a t'GI.Graphene.Structs.Vec3.Vec3'
    -> m Ray
    -- ^ __Returns:__ the initialized ray
rayInitFromVec3 :: Ray -> Maybe Vec3 -> Maybe Vec3 -> m Ray
rayInitFromVec3 r :: Ray
r origin :: Maybe Vec3
origin direction :: Maybe Vec3
direction = IO Ray -> m Ray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Ray -> m Ray) -> IO Ray -> m Ray
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ray
r' <- Ray -> IO (Ptr Ray)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Ray
r
    Ptr Vec3
maybeOrigin <- case Maybe Vec3
origin of
        Nothing -> Ptr Vec3 -> IO (Ptr Vec3)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Vec3
forall a. Ptr a
nullPtr
        Just jOrigin :: Vec3
jOrigin -> do
            Ptr Vec3
jOrigin' <- Vec3 -> IO (Ptr Vec3)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Vec3
jOrigin
            Ptr Vec3 -> IO (Ptr Vec3)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Vec3
jOrigin'
    Ptr Vec3
maybeDirection <- case Maybe Vec3
direction of
        Nothing -> Ptr Vec3 -> IO (Ptr Vec3)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Vec3
forall a. Ptr a
nullPtr
        Just jDirection :: Vec3
jDirection -> do
            Ptr Vec3
jDirection' <- Vec3 -> IO (Ptr Vec3)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Vec3
jDirection
            Ptr Vec3 -> IO (Ptr Vec3)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Vec3
jDirection'
    Ptr Ray
result <- Ptr Ray -> Ptr Vec3 -> Ptr Vec3 -> IO (Ptr Ray)
graphene_ray_init_from_vec3 Ptr Ray
r' Ptr Vec3
maybeOrigin Ptr Vec3
maybeDirection
    Text -> Ptr Ray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "rayInitFromVec3" Ptr Ray
result
    Ray
result' <- ((ManagedPtr Ray -> Ray) -> Ptr Ray -> IO Ray
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Ray -> Ray
Ray) Ptr Ray
result
    Ray -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Ray
r
    Maybe Vec3 -> (Vec3 -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Vec3
origin Vec3 -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Maybe Vec3 -> (Vec3 -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Vec3
direction Vec3 -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ray -> IO Ray
forall (m :: * -> *) a. Monad m => a -> m a
return Ray
result'

#if defined(ENABLE_OVERLOADING)
data RayInitFromVec3MethodInfo
instance (signature ~ (Maybe (Graphene.Vec3.Vec3) -> Maybe (Graphene.Vec3.Vec3) -> m Ray), MonadIO m) => O.MethodInfo RayInitFromVec3MethodInfo Ray signature where
    overloadedMethod = rayInitFromVec3

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveRayMethod (t :: Symbol) (o :: *) :: * where
    ResolveRayMethod "equal" o = RayEqualMethodInfo
    ResolveRayMethod "free" o = RayFreeMethodInfo
    ResolveRayMethod "init" o = RayInitMethodInfo
    ResolveRayMethod "initFromRay" o = RayInitFromRayMethodInfo
    ResolveRayMethod "initFromVec3" o = RayInitFromVec3MethodInfo
    ResolveRayMethod "getClosestPointToPoint" o = RayGetClosestPointToPointMethodInfo
    ResolveRayMethod "getDirection" o = RayGetDirectionMethodInfo
    ResolveRayMethod "getDistanceToPlane" o = RayGetDistanceToPlaneMethodInfo
    ResolveRayMethod "getDistanceToPoint" o = RayGetDistanceToPointMethodInfo
    ResolveRayMethod "getOrigin" o = RayGetOriginMethodInfo
    ResolveRayMethod "getPositionAt" o = RayGetPositionAtMethodInfo
    ResolveRayMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRayMethod t Ray, O.MethodInfo info Ray p) => OL.IsLabel t (Ray -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif