浏览代码

Alternate CTOR for BulletHingeConstraint

enn0x 12 年之前
父节点
当前提交
0a09dad23a
共有 2 个文件被更改,包括 49 次插入0 次删除
  1. 39 0
      panda/src/bullet/bulletHingeConstraint.cxx
  2. 10 0
      panda/src/bullet/bulletHingeConstraint.h

+ 39 - 0
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

+ 10 - 0
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();