Include patch into trunk? - [ 1478244 ] ERP and CFM for fixed joint and ball joint

Irrisor <[email protected]>
Newsgroups gmane.comp.lib.ode
Message-ID <[email protected]>
Hi,

can someone add the patch 1478244 in the tracker into the trunk? It contains 
access to parameters of ball and fixed joint. It should not harm anyone as the 
only performance impact should be the additional read of two fields and two 
floats memorywise.
We are using this in ODEJava and would love to use an unpatched ODE for it.

Link:
<https://sourceforge.net/tracker/?func=detail&aid=1478244&group_id=24884&atid=382801>
Patch ist attached, too.

Best regards, and TIA for applying or any answer why it's not applied ;),
Irrisor

_______________________________________________
ODE mailing list
[email protected]
http://ode.org/mailman/listinfo/ode
ode.patch (text/plain, 6.5 KB)
Index: include/ode/common.h
===================================================================
--- include/ode/common.h	(revision 996)
+++ include/ode/common.h	(working copy)
@@ -304,7 +304,8 @@
   dParamStopCFM, \
   /* parameters for suspension */ \
   dParamSuspensionERP, \
-  dParamSuspensionCFM,
+  dParamSuspensionCFM, \
+  dParamERP,
 
 #define D_ALL_PARAM_NAMES_X(start,x) \
   /* parameters for limits and motors */ \
@@ -319,7 +320,8 @@
   dParamStopCFM ## x, \
   /* parameters for suspension */ \
   dParamSuspensionERP ## x, \
-  dParamSuspensionCFM ## x,
+  dParamSuspensionCFM ## x, \
+  dParamERP ## x,
 
 enum {
   D_ALL_PARAM_NAMES(0)
Index: include/ode/objects.h
===================================================================
--- include/ode/objects.h	(revision 996)
+++ include/ode/objects.h	(working copy)
@@ -1147,6 +1147,14 @@
  */
 ODE_API void dJointSetBallAnchor2 (dJointID, dReal x, dReal y, dReal z);
 
+ODE_API void dJointSetBallParam (dJointID j, int parameter, dReal value);
+
+ODE_API dReal dJointGetBallParam (dJointID j, int parameter);
+
+ODE_API void dJointSetFixedParam (dJointID j, int parameter, dReal value);
+
+ODE_API dReal dJointGetFixedParam (dJointID j, int parameter);
+
 /**
  * @brief Set hinge anchor parameter.
  * @ingroup joints
Index: include/ode/odecpp.h
===================================================================
--- include/ode/odecpp.h	(revision 996)
+++ include/ode/odecpp.h	(working copy)
@@ -343,6 +343,11 @@
     { dJointGetBallAnchor (_id, result); }
   void getAnchor2 (dVector3 result) const
     { dJointGetBallAnchor2 (_id, result); }
+
+  void setParam (int parameter, dReal value)
+    { dJointSetBallParam (_id, parameter, value); }
+  dReal getParam (int parameter) const
+    { return dJointGetBallParam (_id, parameter); }
 } ;
 
 
@@ -536,6 +541,11 @@
 
   void set()
     { dJointSetFixed (_id); }
+
+  void setParam (int parameter, dReal value)
+    { dJointSetFixedParam (_id, parameter, value); }
+  dReal getParam (int parameter) const
+    { return dJointGetFixedParam (_id, parameter); }
 };
 
 
Index: ode/src/error.cpp
===================================================================
--- ode/src/error.cpp	(revision 996)
+++ ode/src/error.cpp	(working copy)
@@ -126,6 +126,8 @@
 
 
 #include "windows.h"
+//#define _snprintf _snprintf_s
+//#define _vsnprintf _snprintf_s
 
 
 extern "C" void dError (int num, const char *msg, ...)
Index: ode/src/joint.cpp
===================================================================
--- ode/src/joint.cpp	(revision 996)
+++ ode/src/joint.cpp	(working copy)
@@ -629,6 +629,8 @@
 {
   dSetZero (j->anchor1,4);
   dSetZero (j->anchor2,4);
+  j->erp = j->world->global_erp;
+  j->cfm = j->world->global_cfm;
 }
 
 
@@ -641,6 +643,10 @@
 
 static void ballGetInfo2 (dxJointBall *joint, dxJoint::Info2 *info)
 {
+  info->erp = joint->erp;
+  info->cfm[0] = joint->cfm;
+  info->cfm[1] = joint->cfm;
+  info->cfm[2] = joint->cfm;
   setBall (joint,info,joint->anchor1,joint->anchor2);
 }
 
@@ -691,7 +697,47 @@
     getAnchor2 (joint,result,joint->anchor2);
 }
 
+void dxJointBall::set (int num, dReal value)
+{
+  switch (num) {
+  case dParamCFM:
+    cfm = value;
+    break;
+  case dParamERP:
+    erp = value;
+    break;
+  }
+}
 
+dReal dxJointBall::get (int num)
+{
+  switch (num) {
+  case dParamCFM:
+    return cfm;
+  case dParamERP:
+    return erp;
+  default:
+	return 0;
+  }
+}
+
+void dJointSetBallParam (dJointID j, int parameter, dReal value)
+{
+  dxJointBall* joint = (dxJointBall*)j;
+  dUASSERT(joint,"bad joint argument");
+  dUASSERT(joint->vtable == &__dball_vtable,"joint is not a ball joint");
+  joint->set (parameter,value);
+}
+
+dReal dJointGetBallParam (dJointID j, int parameter)
+{
+  dxJointBall* joint = (dxJointBall*)j;
+  dUASSERT(joint,"bad joint argument");
+  dUASSERT(joint->vtable == &__dball_vtable,"joint is not a ball joint");
+  return joint->get (parameter);
+}
+
+
 dxJoint::Vtable __dball_vtable = {
   sizeof(dxJointBall),
   (dxJoint::init_fn*) ballInit,
@@ -2893,6 +2939,8 @@
 {
   dSetZero (j->offset,4);
   dSetZero (j->qrel,4);
+  j->erp = j->world->global_erp;
+  j->cfm = j->world->global_cfm;
 }
 
 
@@ -2916,6 +2964,11 @@
   info->J1l[s+1] = 1;
   info->J1l[2*s+2] = 1;
 
+  info->erp = joint->erp;
+  info->cfm[0] = joint->cfm;
+  info->cfm[1] = joint->cfm;
+  info->cfm[2] = joint->cfm;
+
   dVector3 ofs;
   dMULTIPLY0_331 (ofs,joint->node[0].body->posr.R,joint->offset);
   if (joint->node[1].body) {
@@ -2938,8 +2991,7 @@
   }
 }
 
-
-void dJointSetFixed (dJointID j)
+void dJointSetFixed (dJointID j )
 {
   dxJointFixed* joint = (dxJointFixed*)j;
   dUASSERT(joint,"bad joint argument");
@@ -2966,7 +3018,47 @@
   }
 }
 
+void dxJointFixed::set (int num, dReal value)
+{
+  switch (num) {
+  case dParamCFM:
+    cfm = value;
+    break;
+  case dParamERP:
+    erp = value;
+    break;
+  }
+}
 
+dReal dxJointFixed::get (int num)
+{
+  switch (num) {
+  case dParamCFM:
+    return cfm;
+  case dParamERP:
+    return erp;
+  default:
+	return 0;
+  }
+}
+
+void dJointSetFixedParam (dJointID j, int parameter, dReal value)
+{
+  dxJointFixed* joint = (dxJointFixed*)j;
+  dUASSERT(joint,"bad joint argument");
+  dUASSERT(joint->vtable == &__dfixed_vtable,"joint is not a fixed joint");
+  joint->set (parameter,value);
+}
+
+dReal dJointGetFixedParam (dJointID j, int parameter)
+{
+  dxJointFixed* joint = (dxJointFixed*)j;
+  dUASSERT(joint,"bad joint argument");
+  dUASSERT(joint->vtable == &__dfixed_vtable,"joint is not a fixed joint");
+  return joint->get (parameter);
+}
+
+
 dxJoint::Vtable __dfixed_vtable = {
   sizeof(dxJointFixed),
   (dxJoint::init_fn*) fixedInit,
Index: ode/src/joint.h
===================================================================
--- ode/src/joint.h	(revision 996)
+++ ode/src/joint.h	(working copy)
@@ -161,10 +161,13 @@
 struct dxJointBall : public dxJoint {
   dVector3 anchor1;		// anchor w.r.t first body
   dVector3 anchor2;		// anchor w.r.t second body
+  dReal erp;            // error reduction parameter
+  dReal cfm;            // constraint force mix
+  void set (int num, dReal value);
+  dReal get (int num);
 };
 extern struct dxJoint::Vtable __dball_vtable;
 
-
 // hinge
 
 struct dxJointHinge : public dxJoint {
@@ -261,6 +264,10 @@
 struct dxJointFixed : public dxJoint {
   dQuaternion qrel;		// initial relative rotation body1 -> body2
   dVector3 offset;		// relative offset between the bodies
+  dReal erp;            // error reduction parameter
+  dReal cfm;            // constraint force mix
+  void set (int num, dReal value);
+  dReal get (int num);
 };
 extern struct dxJoint::Vtable __dfixed_vtable;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.