Browse Source

Bullet: experimental support for linear/angular soft body joints

enn0x 12 years ago
parent
commit
a2a0b485ac

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

@@ -217,6 +217,28 @@ set_friction(PN_stdfloat friction) {
   return get_object()->setFriction(friction);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletBodyNode::get_rolling_friction
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PN_stdfloat BulletBodyNode::
+get_rolling_friction() const {
+
+  return get_object()->getRollingFriction();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BulletBodyNode::set_rolling_friction
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void BulletBodyNode::
+set_rolling_friction(PN_stdfloat friction) {
+
+  return get_object()->setRollingFriction(friction);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: BulletBodyNode::has_anisotropic_friction
 //       Access: Published

+ 65 - 2
panda/src/bullet/bulletSoftBodyNode.cxx

@@ -680,7 +680,7 @@ append_anchor(int node, BulletRigidBodyNode *body, bool disable) {
 
   body->sync_p2b();
 
-  btRigidBody *ptr =(btRigidBody *)body->get_object();
+  btRigidBody *ptr = (btRigidBody *)body->get_object();
   _soft->appendAnchor(node, ptr, disable);
 }
 
@@ -698,7 +698,7 @@ append_anchor(int node, BulletRigidBodyNode *body, const LVector3 &pivot, bool d
 
   body->sync_p2b();
 
-  btRigidBody *ptr =(btRigidBody *)body->get_object();
+  btRigidBody *ptr = (btRigidBody *)body->get_object();
   _soft->appendAnchor(node, ptr, LVecBase3_to_btVector3(pivot), disable);
 }
 
@@ -1070,3 +1070,66 @@ make_tet_mesh(BulletSoftBodyWorldInfo &info, const char *ele, const char *face,
   return sbnode;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletSoftBodyNode::append_linear_joint
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void BulletSoftBodyNode::
+append_linear_joint(BulletBodyNode *body, int cluster, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split) {
+
+  nassertv(body);
+
+  btCollisionObject *ptr = body->get_object();
+
+  btSoftBody::LJoint::Specs ls;
+  ls.erp = erp;
+  ls.cfm = cfm;
+  ls.split = split;
+  ls.position = _soft->clusterCom(cluster);
+
+  _soft->appendLinearJoint(ls, ptr);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BulletSoftBodyNode::append_linear_joint
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void BulletSoftBodyNode::
+append_linear_joint(BulletBodyNode *body, const LPoint3 &pos, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split) {
+
+  nassertv(body);
+
+  btCollisionObject *ptr = body->get_object();
+
+  btSoftBody::LJoint::Specs ls;
+  ls.erp = erp;
+  ls.cfm = cfm;
+  ls.split = split;
+  ls.position = LVecBase3_to_btVector3(pos);
+
+  _soft->appendLinearJoint(ls, ptr);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BulletSoftBodyNode::append_angular_joint
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void BulletSoftBodyNode::
+append_angular_joint(BulletBodyNode *body, const LVector3 &axis, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split) {
+
+  nassertv(body);
+
+  btCollisionObject *ptr = body->get_object();
+
+  btSoftBody::AJoint::Specs as;
+  as.erp = erp;
+  as.cfm = cfm;
+  as.split = split;
+  as.axis = LVecBase3_to_btVector3(axis);
+
+  _soft->appendAngularJoint(as, ptr);
+}
+

+ 16 - 0
panda/src/bullet/bulletSoftBodyNode.h

@@ -123,6 +123,22 @@ PUBLISHED:
       const LVector3 &pivot,
       bool disable=false);
 
+  // Links
+  void append_linear_joint(BulletBodyNode *body, int cluster,
+    PN_stdfloat erp=1.0,
+    PN_stdfloat cfm=1.0,
+    PN_stdfloat split=1.0);
+
+  void append_linear_joint(BulletBodyNode *body, const LPoint3 &pos,
+    PN_stdfloat erp=1.0,
+    PN_stdfloat cfm=1.0,
+    PN_stdfloat split=1.0);
+
+  void append_angular_joint(BulletBodyNode *body, const LVector3 &axis,
+    PN_stdfloat erp=1.0,
+    PN_stdfloat cfm=1.0,
+    PN_stdfloat split=1.0);
+
   // Materials
   int get_num_materials() const;
   BulletSoftBodyMaterial get_material(int idx) const;