module Box2D.Joint
( destroy
, isValid
, getType
, getBodyA
, getBodyB
, getWorld
, setLocalFrameA
, getLocalFrameA
, getLocalFrameAInto
, setLocalFrameB
, getLocalFrameB
, getLocalFrameBInto
, setCollideConnected
, getCollideConnected
, setUserData
, getUserData
, wakeBodies
, getConstraintForce
, getConstraintForceInto
, getConstraintTorque
, getLinearSeparation
, getAngularSeparation
, setConstraintTuning
, getConstraintTuning
, setForceThreshold
, getForceThreshold
, setTorqueThreshold
, getTorqueThreshold
)
where
import Foreign
import Foreign.C.Types (CBool(..), CInt(..))
import Data.Coerce (coerce)
import Box2D.Id (BodyId(..), JointId(..), WorldId(..))
import Box2D.MathTypes (Transform, Vec2)
import Box2D.Types (JointType(..))
foreign import ccall unsafe "b2DestroyJoint"
c_b2DestroyJoint :: JointId -> CBool -> IO ()
foreign import ccall unsafe "b2Joint_IsValid"
c_b2Joint_IsValid :: JointId -> IO CBool
foreign import ccall unsafe "b2Joint_GetType"
c_b2Joint_GetType :: JointId -> IO CInt
foreign import ccall unsafe "b2Joint_GetBodyA"
c_b2Joint_GetBodyA :: JointId -> IO BodyId
foreign import ccall unsafe "b2Joint_GetBodyB"
c_b2Joint_GetBodyB :: JointId -> IO BodyId
foreign import ccall unsafe "b2Joint_GetWorld"
c_b2Joint_GetWorld :: JointId -> IO WorldId
foreign import ccall unsafe "hsg_b2Joint_SetLocalFrameA"
c_b2Joint_SetLocalFrameA :: JointId -> Ptr Transform -> IO ()
foreign import ccall unsafe "hsg_b2Joint_GetLocalFrameA"
c_b2Joint_GetLocalFrameA :: JointId -> Ptr Transform -> IO ()
foreign import ccall unsafe "hsg_b2Joint_SetLocalFrameB"
c_b2Joint_SetLocalFrameB :: JointId -> Ptr Transform -> IO ()
foreign import ccall unsafe "hsg_b2Joint_GetLocalFrameB"
c_b2Joint_GetLocalFrameB :: JointId -> Ptr Transform -> IO ()
foreign import ccall unsafe "b2Joint_SetCollideConnected"
c_b2Joint_SetCollideConnected :: JointId -> CBool -> IO ()
foreign import ccall unsafe "b2Joint_GetCollideConnected"
c_b2Joint_GetCollideConnected :: JointId -> IO CBool
foreign import ccall unsafe "b2Joint_SetUserData"
c_b2Joint_SetUserData :: JointId -> Ptr () -> IO ()
foreign import ccall unsafe "b2Joint_GetUserData"
c_b2Joint_GetUserData :: JointId -> IO (Ptr ())
foreign import ccall unsafe "b2Joint_WakeBodies"
c_b2Joint_WakeBodies :: JointId -> IO ()
foreign import ccall unsafe "hsg_b2Joint_GetConstraintForce"
c_b2Joint_GetConstraintForce :: JointId -> Ptr Vec2 -> IO ()
foreign import ccall unsafe "b2Joint_GetConstraintTorque"
c_b2Joint_GetConstraintTorque :: JointId -> IO Float
foreign import ccall unsafe "b2Joint_GetLinearSeparation"
c_b2Joint_GetLinearSeparation :: JointId -> IO Float
foreign import ccall unsafe "b2Joint_GetAngularSeparation"
c_b2Joint_GetAngularSeparation :: JointId -> IO Float
foreign import ccall unsafe "b2Joint_SetConstraintTuning"
c_b2Joint_SetConstraintTuning :: JointId -> Float -> Float -> IO ()
foreign import ccall unsafe "b2Joint_GetConstraintTuning"
c_b2Joint_GetConstraintTuning :: JointId -> Ptr Float -> Ptr Float -> IO ()
foreign import ccall unsafe "b2Joint_SetForceThreshold"
c_b2Joint_SetForceThreshold :: JointId -> Float -> IO ()
foreign import ccall unsafe "b2Joint_GetForceThreshold"
c_b2Joint_GetForceThreshold :: JointId -> IO Float
foreign import ccall unsafe "b2Joint_SetTorqueThreshold"
c_b2Joint_SetTorqueThreshold :: JointId -> Float -> IO ()
foreign import ccall unsafe "b2Joint_GetTorqueThreshold"
c_b2Joint_GetTorqueThreshold :: JointId -> IO Float
destroy
:: JointId
-> Bool
-> IO ()
destroy :: JointId -> Bool -> IO ()
destroy JointId
a0 Bool
a1 =
JointId -> CBool -> IO ()
c_b2DestroyJoint JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)
isValid
:: JointId
-> IO Bool
isValid :: JointId -> IO Bool
isValid JointId
a0 =
CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b2Joint_IsValid JointId
a0)
getType
:: JointId
-> IO JointType
getType :: JointId -> IO JointType
getType JointId
a0 =
CInt -> JointType
forall a b. Coercible a b => a -> b
coerce (CInt -> JointType) -> IO CInt -> IO JointType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CInt
c_b2Joint_GetType JointId
a0)
getBodyA
:: JointId
-> IO BodyId
getBodyA :: JointId -> IO BodyId
getBodyA JointId
a0 =
JointId -> IO BodyId
c_b2Joint_GetBodyA JointId
a0
getBodyB
:: JointId
-> IO BodyId
getBodyB :: JointId -> IO BodyId
getBodyB JointId
a0 =
JointId -> IO BodyId
c_b2Joint_GetBodyB JointId
a0
getWorld
:: JointId
-> IO WorldId
getWorld :: JointId -> IO WorldId
getWorld JointId
a0 =
JointId -> IO WorldId
c_b2Joint_GetWorld JointId
a0
setLocalFrameA
:: JointId
-> Transform
-> IO ()
setLocalFrameA :: JointId -> Transform -> IO ()
setLocalFrameA JointId
a0 Transform
a1 =
Transform -> (Ptr Transform -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Transform
a1 ((Ptr Transform -> IO ()) -> IO ())
-> (Ptr Transform -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Transform
p1 ->
JointId -> Ptr Transform -> IO ()
c_b2Joint_SetLocalFrameA JointId
a0 Ptr Transform
p1
getLocalFrameA
:: JointId
-> IO Transform
getLocalFrameA :: JointId -> IO Transform
getLocalFrameA JointId
a0 =
(Ptr Transform -> IO Transform) -> IO Transform
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Transform -> IO Transform) -> IO Transform)
-> (Ptr Transform -> IO Transform) -> IO Transform
forall a b. (a -> b) -> a -> b
$ \Ptr Transform
pOut -> JointId -> Ptr Transform -> IO ()
c_b2Joint_GetLocalFrameA JointId
a0 Ptr Transform
pOut IO () -> IO Transform -> IO Transform
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Transform -> IO Transform
forall a. Storable a => Ptr a -> IO a
peek Ptr Transform
pOut
getLocalFrameAInto
:: JointId
-> Ptr Transform
-> IO ()
getLocalFrameAInto :: JointId -> Ptr Transform -> IO ()
getLocalFrameAInto JointId
a0 Ptr Transform
out =
JointId -> Ptr Transform -> IO ()
c_b2Joint_GetLocalFrameA JointId
a0 Ptr Transform
out
setLocalFrameB
:: JointId
-> Transform
-> IO ()
setLocalFrameB :: JointId -> Transform -> IO ()
setLocalFrameB JointId
a0 Transform
a1 =
Transform -> (Ptr Transform -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Transform
a1 ((Ptr Transform -> IO ()) -> IO ())
-> (Ptr Transform -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Transform
p1 ->
JointId -> Ptr Transform -> IO ()
c_b2Joint_SetLocalFrameB JointId
a0 Ptr Transform
p1
getLocalFrameB
:: JointId
-> IO Transform
getLocalFrameB :: JointId -> IO Transform
getLocalFrameB JointId
a0 =
(Ptr Transform -> IO Transform) -> IO Transform
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Transform -> IO Transform) -> IO Transform)
-> (Ptr Transform -> IO Transform) -> IO Transform
forall a b. (a -> b) -> a -> b
$ \Ptr Transform
pOut -> JointId -> Ptr Transform -> IO ()
c_b2Joint_GetLocalFrameB JointId
a0 Ptr Transform
pOut IO () -> IO Transform -> IO Transform
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Transform -> IO Transform
forall a. Storable a => Ptr a -> IO a
peek Ptr Transform
pOut
getLocalFrameBInto
:: JointId
-> Ptr Transform
-> IO ()
getLocalFrameBInto :: JointId -> Ptr Transform -> IO ()
getLocalFrameBInto JointId
a0 Ptr Transform
out =
JointId -> Ptr Transform -> IO ()
c_b2Joint_GetLocalFrameB JointId
a0 Ptr Transform
out
setCollideConnected
:: JointId
-> Bool
-> IO ()
setCollideConnected :: JointId -> Bool -> IO ()
setCollideConnected JointId
a0 Bool
a1 =
JointId -> CBool -> IO ()
c_b2Joint_SetCollideConnected JointId
a0 (Bool -> CBool
forall a. Num a => Bool -> a
fromBool Bool
a1)
getCollideConnected
:: JointId
-> IO Bool
getCollideConnected :: JointId -> IO Bool
getCollideConnected JointId
a0 =
CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (JointId -> IO CBool
c_b2Joint_GetCollideConnected JointId
a0)
setUserData
:: JointId
-> Ptr ()
-> IO ()
setUserData :: JointId -> Ptr () -> IO ()
setUserData JointId
a0 Ptr ()
a1 =
JointId -> Ptr () -> IO ()
c_b2Joint_SetUserData JointId
a0 Ptr ()
a1
getUserData
:: JointId
-> IO (Ptr ())
getUserData :: JointId -> IO (Ptr ())
getUserData JointId
a0 =
JointId -> IO (Ptr ())
c_b2Joint_GetUserData JointId
a0
wakeBodies
:: JointId
-> IO ()
wakeBodies :: JointId -> IO ()
wakeBodies JointId
a0 =
JointId -> IO ()
c_b2Joint_WakeBodies JointId
a0
getConstraintForce
:: JointId
-> IO Vec2
getConstraintForce :: JointId -> IO Vec2
getConstraintForce JointId
a0 =
(Ptr Vec2 -> IO Vec2) -> IO Vec2
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Vec2 -> IO Vec2) -> IO Vec2)
-> (Ptr Vec2 -> IO Vec2) -> IO Vec2
forall a b. (a -> b) -> a -> b
$ \Ptr Vec2
pOut -> JointId -> Ptr Vec2 -> IO ()
c_b2Joint_GetConstraintForce JointId
a0 Ptr Vec2
pOut IO () -> IO Vec2 -> IO Vec2
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ptr Vec2 -> IO Vec2
forall a. Storable a => Ptr a -> IO a
peek Ptr Vec2
pOut
getConstraintForceInto
:: JointId
-> Ptr Vec2
-> IO ()
getConstraintForceInto :: JointId -> Ptr Vec2 -> IO ()
getConstraintForceInto JointId
a0 Ptr Vec2
out =
JointId -> Ptr Vec2 -> IO ()
c_b2Joint_GetConstraintForce JointId
a0 Ptr Vec2
out
getConstraintTorque
:: JointId
-> IO Float
getConstraintTorque :: JointId -> IO Float
getConstraintTorque JointId
a0 =
JointId -> IO Float
c_b2Joint_GetConstraintTorque JointId
a0
getLinearSeparation
:: JointId
-> IO Float
getLinearSeparation :: JointId -> IO Float
getLinearSeparation JointId
a0 =
JointId -> IO Float
c_b2Joint_GetLinearSeparation JointId
a0
getAngularSeparation
:: JointId
-> IO Float
getAngularSeparation :: JointId -> IO Float
getAngularSeparation JointId
a0 =
JointId -> IO Float
c_b2Joint_GetAngularSeparation JointId
a0
setConstraintTuning
:: JointId
-> Float
-> Float
-> IO ()
setConstraintTuning :: JointId -> Float -> Float -> IO ()
setConstraintTuning JointId
a0 Float
a1 Float
a2 =
JointId -> Float -> Float -> IO ()
c_b2Joint_SetConstraintTuning JointId
a0 Float
a1 Float
a2
getConstraintTuning
:: JointId
-> Ptr Float
-> Ptr Float
-> IO ()
getConstraintTuning :: JointId -> Ptr Float -> Ptr Float -> IO ()
getConstraintTuning JointId
a0 Ptr Float
a1 Ptr Float
a2 =
JointId -> Ptr Float -> Ptr Float -> IO ()
c_b2Joint_GetConstraintTuning JointId
a0 Ptr Float
a1 Ptr Float
a2
setForceThreshold
:: JointId
-> Float
-> IO ()
setForceThreshold :: JointId -> Float -> IO ()
setForceThreshold JointId
a0 Float
a1 =
JointId -> Float -> IO ()
c_b2Joint_SetForceThreshold JointId
a0 Float
a1
getForceThreshold
:: JointId
-> IO Float
getForceThreshold :: JointId -> IO Float
getForceThreshold JointId
a0 =
JointId -> IO Float
c_b2Joint_GetForceThreshold JointId
a0
setTorqueThreshold
:: JointId
-> Float
-> IO ()
setTorqueThreshold :: JointId -> Float -> IO ()
setTorqueThreshold JointId
a0 Float
a1 =
JointId -> Float -> IO ()
c_b2Joint_SetTorqueThreshold JointId
a0 Float
a1
getTorqueThreshold
:: JointId
-> IO Float
getTorqueThreshold :: JointId -> IO Float
getTorqueThreshold JointId
a0 =
JointId -> IO Float
c_b2Joint_GetTorqueThreshold JointId
a0