Browse Source

Added missing methods for modifying Bullet constraint frames.

enn0x 12 years ago
parent
commit
0ee060aefd

+ 2 - 5
panda/src/bullet/bulletBodyNode.cxx

@@ -165,7 +165,7 @@ output(ostream &out) const {
 //  Description:
 ////////////////////////////////////////////////////////////////////
 void BulletBodyNode::
-add_shape(BulletShape *shape, CPT(TransformState) ts) {
+add_shape(BulletShape *shape, const TransformState *ts) {
 
   nassertv(get_object());
 
@@ -173,10 +173,7 @@ add_shape(BulletShape *shape, CPT(TransformState) ts) {
     && ((btConvexHullShape *)shape->ptr())->getNumVertices() == 0));
 
   // Transform
-  btTransform trans = btTransform::getIdentity();
-  if (ts) {
-    trans = TransformState_to_btTrans(ts);
-  }
+  btTransform trans = TransformState_to_btTrans(ts);
 
   // Reset the shape scaling before we add a shape, and remember the current
   // Scale so we can restore it later...

+ 1 - 1
panda/src/bullet/bulletBodyNode.h

@@ -38,7 +38,7 @@ PUBLISHED:
   INLINE ~BulletBodyNode();
 
   // Shapes
-  void add_shape(BulletShape *shape, CPT(TransformState) xform=NULL);
+  void add_shape(BulletShape *shape, const TransformState *xform=TransformState::make_identity());
   void remove_shape(BulletShape *shape);
 
   INLINE int get_num_shapes() const;

+ 22 - 0
panda/src/bullet/bulletConeTwistConstraint.I

@@ -23,3 +23,25 @@ INLINE BulletConeTwistConstraint::
   delete _constraint;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletConeTwistConstraint::get_frame_a
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE CPT(TransformState) BulletConeTwistConstraint::
+get_frame_a() const {
+
+  return btTrans_to_TransformState(_constraint->getAFrame());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BulletConeTwistConstraint::get_frame_b
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE CPT(TransformState) BulletConeTwistConstraint::
+get_frame_b() const {
+
+  return btTrans_to_TransformState(_constraint->getBFrame());
+}
+

+ 17 - 3
panda/src/bullet/bulletConeTwistConstraint.cxx

@@ -26,7 +26,7 @@ TypeHandle BulletConeTwistConstraint::_type_handle;
 ////////////////////////////////////////////////////////////////////
 BulletConeTwistConstraint::
 BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, 
-                          CPT(TransformState) frame_a) {
+                          const TransformState *frame_a) {
 
   btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
   btTransform trans_a = TransformState_to_btTrans(frame_a);
@@ -42,8 +42,8 @@ BulletConeTwistConstraint(const BulletRigidBodyNode *node_a,
 BulletConeTwistConstraint::
 BulletConeTwistConstraint(const BulletRigidBodyNode *node_a,
                           const BulletRigidBodyNode *node_b,
-                          CPT(TransformState) frame_a,
-                          CPT(TransformState) frame_b) {
+                          const TransformState *frame_a,
+                          const TransformState *frame_b) {
 
   btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
   btTransform trans_a = TransformState_to_btTrans(frame_a);
@@ -181,3 +181,17 @@ set_motor_target_in_constraint_space(const LQuaternion &quat) {
   _constraint->setMotorTargetInConstraintSpace(LQuaternion_to_btQuat(quat));
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletConeTwistConstraint::set_frames
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+void BulletConeTwistConstraint::
+set_frames(const TransformState *ts_a, const TransformState *ts_b) {
+
+  btTransform frame_a = TransformState_to_btTrans(ts_a);
+  btTransform frame_b = TransformState_to_btTrans(ts_b);
+
+  _constraint->setFrames(frame_a, frame_b);
+}
+

+ 7 - 3
panda/src/bullet/bulletConeTwistConstraint.h

@@ -33,11 +33,11 @@ class EXPCL_PANDABULLET BulletConeTwistConstraint : public BulletConstraint {
 
 PUBLISHED:
   BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, 
-                            CPT(TransformState) frame_a);
+                            const TransformState *frame_a);
   BulletConeTwistConstraint(const BulletRigidBodyNode *node_a,
                             const BulletRigidBodyNode *node_b,
-                            CPT(TransformState) frame_a,
-                            CPT(TransformState) frame_b);
+                            const TransformState *frame_a,
+                            const TransformState *frame_b);
   INLINE ~BulletConeTwistConstraint();
 
   void set_limit(int index, PN_stdfloat value);
@@ -54,6 +54,10 @@ PUBLISHED:
   void set_motor_target(const LQuaternion &quat);
   void set_motor_target_in_constraint_space(const LQuaternion &quat);
 
+  void set_frames(const TransformState *ts_a, const TransformState *ts_b);
+  INLINE CPT(TransformState) get_frame_a() const;
+  INLINE CPT(TransformState) get_frame_b() const;
+
 public:
   virtual btTypedConstraint *ptr() const;
 

+ 1 - 1
panda/src/bullet/bulletConvexHullShape.cxx

@@ -78,7 +78,7 @@ add_array(const PTA_LVecBase3 &points) {
 //  Description:
 ////////////////////////////////////////////////////////////////////
 void BulletConvexHullShape::
-add_geom(const Geom *geom, CPT(TransformState) ts) {
+add_geom(const Geom *geom, const TransformState *ts) {
 
   nassertv(geom);
   nassertv(ts);

+ 1 - 1
panda/src/bullet/bulletConvexHullShape.h

@@ -39,7 +39,7 @@ PUBLISHED:
   void add_point(const LPoint3 &p);
   void add_array(const PTA_LVecBase3 &points);
   void add_geom(const Geom *geom,
-                CPT(TransformState) ts=TransformState::make_identity());
+                const TransformState *ts=TransformState::make_identity());
 
 public:
   virtual btCollisionShape *ptr() const;

+ 22 - 0
panda/src/bullet/bulletGenericConstraint.I

@@ -23,3 +23,25 @@ INLINE BulletGenericConstraint::
   delete _constraint;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletGenericConstraint::get_frame_a
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE CPT(TransformState) BulletGenericConstraint::
+get_frame_a() const {
+
+  return btTrans_to_TransformState(_constraint->getFrameOffsetA());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BulletGenericConstraint::get_frame_b
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE CPT(TransformState) BulletGenericConstraint::
+get_frame_b() const {
+
+  return btTrans_to_TransformState(_constraint->getFrameOffsetB());
+}
+

+ 17 - 3
panda/src/bullet/bulletGenericConstraint.cxx

@@ -24,7 +24,7 @@ TypeHandle BulletGenericConstraint::_type_handle;
 ////////////////////////////////////////////////////////////////////
 BulletGenericConstraint::
 BulletGenericConstraint(const BulletRigidBodyNode *node_a, 
-                        CPT(TransformState) frame_a,
+                        const TransformState *frame_a,
                         bool use_frame_a) {
 
   btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
@@ -41,8 +41,8 @@ BulletGenericConstraint(const BulletRigidBodyNode *node_a,
 BulletGenericConstraint::
 BulletGenericConstraint(const BulletRigidBodyNode *node_a,
                         const BulletRigidBodyNode *node_b,
-                        CPT(TransformState) frame_a,
-                        CPT(TransformState) frame_b,
+                        const TransformState *frame_a,
+                        const TransformState *frame_b,
                         bool use_frame_a) {
 
   btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
@@ -165,3 +165,17 @@ get_translational_limit_motor() {
   return BulletTranslationalLimitMotor(*_constraint->getTranslationalLimitMotor());
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletGenericConstraint::set_frames
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+void BulletGenericConstraint::
+set_frames(const TransformState *ts_a, const TransformState *ts_b) {
+
+  btTransform frame_a = TransformState_to_btTrans(ts_a);
+  btTransform frame_b = TransformState_to_btTrans(ts_b);
+
+  _constraint->setFrames(frame_a, frame_b);
+}
+

+ 8 - 3
panda/src/bullet/bulletGenericConstraint.h

@@ -36,12 +36,12 @@ class EXPCL_PANDABULLET BulletGenericConstraint : public BulletConstraint {
 
 PUBLISHED:
   BulletGenericConstraint(const BulletRigidBodyNode *node_a, 
-                          CPT(TransformState) frame_a,
+                          const TransformState *frame_a,
                           bool use_frame_a);
   BulletGenericConstraint(const BulletRigidBodyNode *node_a,
                           const BulletRigidBodyNode *node_b,
-                          CPT(TransformState) frame_a,
-                          CPT(TransformState) frame_b,
+                          const TransformState *frame_a,
+                          const TransformState *frame_b,
                           bool use_frame_a);
   INLINE ~BulletGenericConstraint();
 
@@ -58,6 +58,11 @@ PUBLISHED:
   BulletRotationalLimitMotor get_rotational_limit_motor(int axis);
   BulletTranslationalLimitMotor get_translational_limit_motor();
 
+  // Frames
+  void set_frames(const TransformState *ts_a, const TransformState *ts_b);
+  INLINE CPT(TransformState) get_frame_a() const;
+  INLINE CPT(TransformState) get_frame_b() const;
+
 public:
   virtual btTypedConstraint *ptr() const;
 

+ 22 - 0
panda/src/bullet/bulletHingeConstraint.I

@@ -23,3 +23,25 @@ INLINE BulletHingeConstraint::
   delete _constraint;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletHingeConstraint::get_frame_a
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE CPT(TransformState) BulletHingeConstraint::
+get_frame_a() const {
+
+  return btTrans_to_TransformState(_constraint->getAFrame());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BulletHingeConstraint::get_frame_b
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE CPT(TransformState) BulletHingeConstraint::
+get_frame_b() const {
+
+  return btTrans_to_TransformState(_constraint->getBFrame());
+}
+

+ 14 - 0
panda/src/bullet/bulletHingeConstraint.cxx

@@ -267,3 +267,17 @@ set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt) {
   _constraint->setMotorTarget(target_angle, dt);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletHingeConstraint::set_frames
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+void BulletHingeConstraint::
+set_frames(const TransformState *ts_a, const TransformState *ts_b) {
+
+  btTransform frame_a = TransformState_to_btTrans(ts_a);
+  btTransform frame_b = TransformState_to_btTrans(ts_b);
+
+  _constraint->setFrames(frame_a, frame_b);
+}
+

+ 4 - 0
panda/src/bullet/bulletHingeConstraint.h

@@ -72,6 +72,10 @@ PUBLISHED:
   void set_motor_target(const LQuaternion &quat, PN_stdfloat dt);
   void set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt);
 
+  void set_frames(const TransformState *ts_a, const TransformState *ts_b);
+  INLINE CPT(TransformState) get_frame_a() const;
+  INLINE CPT(TransformState) get_frame_b() const;
+
 public:
   virtual btTypedConstraint *ptr() const;
 

+ 1 - 1
panda/src/bullet/bulletRigidBodyNode.cxx

@@ -606,7 +606,7 @@ sync_b2p(PandaNode *node) {
 //               by calling MotionState::setGlobalTransform.
 ////////////////////////////////////////////////////////////////////
 void BulletRigidBodyNode::MotionState::
-set_net_transform(CPT(TransformState) &ts) {
+set_net_transform(const TransformState *ts) {
 
   nassertv(ts);
 

+ 1 - 1
panda/src/bullet/bulletRigidBodyNode.h

@@ -110,7 +110,7 @@ private:
     virtual void getWorldTransform(btTransform &trans) const;
     virtual void setWorldTransform(const btTransform &trans);
 
-    void set_net_transform(CPT(TransformState) &ts);
+    void set_net_transform(const TransformState *ts);
 
     void sync_b2p(PandaNode *node);
     bool sync_disabled() const;

+ 22 - 0
panda/src/bullet/bulletSliderConstraint.I

@@ -23,3 +23,25 @@ INLINE BulletSliderConstraint::
   delete _constraint;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletSliderConstraint::get_frame_a
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE CPT(TransformState) BulletSliderConstraint::
+get_frame_a() const {
+
+  return btTrans_to_TransformState(_constraint->getFrameOffsetA());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BulletSliderConstraint::get_frame_b
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE CPT(TransformState) BulletSliderConstraint::
+get_frame_b() const {
+
+  return btTrans_to_TransformState(_constraint->getFrameOffsetB());
+}
+

+ 17 - 3
panda/src/bullet/bulletSliderConstraint.cxx

@@ -26,7 +26,7 @@ TypeHandle BulletSliderConstraint::_type_handle;
 ////////////////////////////////////////////////////////////////////
 BulletSliderConstraint::
 BulletSliderConstraint(const BulletRigidBodyNode *node_a, 
-                       CPT(TransformState) frame_a,
+                       const TransformState *frame_a,
                        bool use_frame_a) {
 
   btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
@@ -43,8 +43,8 @@ BulletSliderConstraint(const BulletRigidBodyNode *node_a,
 BulletSliderConstraint::
 BulletSliderConstraint(const BulletRigidBodyNode *node_a,
                        const BulletRigidBodyNode *node_b,
-                       CPT(TransformState) frame_a,
-                       CPT(TransformState) frame_b,
+                       const TransformState *frame_a,
+                       const TransformState *frame_b,
                        bool use_frame_a) {
 
   btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
@@ -309,3 +309,17 @@ get_max_angular_motor_force() const {
   return (PN_stdfloat)_constraint->getMaxAngMotorForce();
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletSliderConstraint::set_frames
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+void BulletSliderConstraint::
+set_frames(const TransformState *ts_a, const TransformState *ts_b) {
+
+  btTransform frame_a = TransformState_to_btTrans(ts_a);
+  btTransform frame_b = TransformState_to_btTrans(ts_b);
+
+  _constraint->setFrames(frame_a, frame_b);
+}
+

+ 8 - 3
panda/src/bullet/bulletSliderConstraint.h

@@ -33,12 +33,12 @@ class EXPCL_PANDABULLET BulletSliderConstraint : public BulletConstraint {
 
 PUBLISHED:
   BulletSliderConstraint(const BulletRigidBodyNode *node_a, 
-                         CPT(TransformState) frame_a,
+                         const TransformState *frame_a,
                          bool useFrame_a);
   BulletSliderConstraint(const BulletRigidBodyNode *node_a,
                          const BulletRigidBodyNode *node_b,
-                         CPT(TransformState) frame_a,
-                         CPT(TransformState) frame_b,
+                         const TransformState *frame_a,
+                         const TransformState *frame_b,
                          bool use_frame_a);
   INLINE ~BulletSliderConstraint();
 
@@ -71,6 +71,11 @@ PUBLISHED:
   PN_stdfloat get_target_angular_motor_velocity() const;
   PN_stdfloat get_max_angular_motor_force() const;
 
+  // Frames
+  void set_frames(const TransformState *ts_a, const TransformState *ts_b);
+  INLINE CPT(TransformState) get_frame_a() const;
+  INLINE CPT(TransformState) get_frame_b() const;
+
 public:
   virtual btTypedConstraint *ptr() const;
 

+ 1 - 1
panda/src/bullet/bulletSphericalConstraint.h

@@ -46,9 +46,9 @@ PUBLISHED:
                             const LPoint3 &pivot_b);
   INLINE ~BulletSphericalConstraint();
 
+  // Pivots
   void set_pivot_a(const LPoint3 &pivot_a);
   void set_pivot_b(const LPoint3 &pivot_b);
-
   LPoint3 get_pivot_in_a() const;
   LPoint3 get_pivot_in_b() const;
 

+ 1 - 1
panda/src/bullet/bulletTriangleMesh.cxx

@@ -101,7 +101,7 @@ get_welding_distance() const {
 //  Description:
 ////////////////////////////////////////////////////////////////////
 void BulletTriangleMesh::
-add_geom(const Geom *geom, bool remove_duplicate_vertices, CPT(TransformState) ts) {
+add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState *ts) {
 
   nassertv(geom);
   nassertv(ts);

+ 1 - 1
panda/src/bullet/bulletTriangleMesh.h

@@ -46,7 +46,7 @@ PUBLISHED:
                  bool remove_duplicate_vertices=false);
   void add_geom(const Geom *geom, 
                 bool remove_duplicate_vertices=false,
-                CPT(TransformState) ts=TransformState::make_identity());
+                const TransformState *ts=TransformState::make_identity());
 
   void set_welding_distance(PN_stdfloat distance);
   void preallocate(int num_verts, int num_indices);