From 0a09dad23a1ee13c9d16a4eac7cfed6d439472c7 Mon Sep 17 00:00:00 2001 From: enn0x Date: Thu, 4 Apr 2013 20:30:10 +0000 Subject: [PATCH] Alternate CTOR for BulletHingeConstraint --- panda/src/bullet/bulletHingeConstraint.cxx | 39 ++++++++++++++++++++++ panda/src/bullet/bulletHingeConstraint.h | 10 ++++++ 2 files changed, 49 insertions(+) diff --git a/panda/src/bullet/bulletHingeConstraint.cxx b/panda/src/bullet/bulletHingeConstraint.cxx index 9cca52b373..7f3dbb1a46 100644 --- a/panda/src/bullet/bulletHingeConstraint.cxx +++ b/panda/src/bullet/bulletHingeConstraint.cxx @@ -19,6 +19,45 @@ TypeHandle BulletHingeConstraint::_type_handle; +//////////////////////////////////////////////////////////////////// +// Function: BulletHingeConstraint::Constructor +// Access: Published +// Description: Creates a hinge constraint which connects one +// rigid body with some fixe dpoint in the world. +//////////////////////////////////////////////////////////////////// +BulletHingeConstraint:: +BulletHingeConstraint(const BulletRigidBodyNode *node_a, + const TransformState *ts_a, + bool use_frame_a) { + + btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object()); + btTransform frame_a = TransformState_to_btTrans(ts_a); + + _constraint = new btHingeConstraint(*ptr_a, frame_a, use_frame_a); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletHingeConstraint::Constructor +// Access: Published +// Description: Constructs a hinge constraint which connects two +// rigid bodies. +//////////////////////////////////////////////////////////////////// +BulletHingeConstraint:: +BulletHingeConstraint(const BulletRigidBodyNode *node_a, + const BulletRigidBodyNode *node_b, + const TransformState *ts_a, + const TransformState *ts_b, + bool use_frame_a) { + + btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object()); + btTransform frame_a = TransformState_to_btTrans(ts_a); + + btRigidBody *ptr_b = btRigidBody::upcast(node_b->get_object()); + btTransform frame_b = TransformState_to_btTrans(ts_b); + + _constraint = new btHingeConstraint(*ptr_a, *ptr_b, frame_a, frame_b, use_frame_a); +} + //////////////////////////////////////////////////////////////////// // Function: BulletHingeConstraint::Constructor // Access: Published diff --git a/panda/src/bullet/bulletHingeConstraint.h b/panda/src/bullet/bulletHingeConstraint.h index b8af6546c3..c116212db9 100644 --- a/panda/src/bullet/bulletHingeConstraint.h +++ b/panda/src/bullet/bulletHingeConstraint.h @@ -45,6 +45,16 @@ PUBLISHED: const LVector3 &axis_a, const LVector3 &axis_b, bool use_frame_a=false); + + BulletHingeConstraint(const BulletRigidBodyNode *node_a, + const TransformState *ts_a, + bool use_frame_a=false); + BulletHingeConstraint(const BulletRigidBodyNode *node_a, + const BulletRigidBodyNode *node_b, + const TransformState *ts_a, + const TransformState *ts_b, + bool use_frame_a=false); + INLINE ~BulletHingeConstraint(); PN_stdfloat get_hinge_angle();