[ODE] removing inertia torque...

Adam D. Moss adam at gimp.org
Wed Apr 13 10:00:14 MST 2005


This patch does the same thing as my earlier patch, but
for all the ODE solvers.

The aim is to avoid bodies spinning faster and faster until
the maths explode.  The penalty is that some hard-to-notice
realism is lost.

--Adam
-- 
Adam D. Moss   -   adam at gimp.org
-------------- next part --------------
Index: quickstep.cpp
===================================================================
--- quickstep.cpp	(revision 4096)
+++ quickstep.cpp	(working copy)
@@ -550,9 +550,13 @@
 		// compute inverse inertia tensor in global frame
 		dMULTIPLY2_333 (tmp,body[i]->invI,body[i]->R);
 		dMULTIPLY0_333 (invI+i*12,body[i]->R,tmp);
+#ifndef USE_TORQUE_INERTIA
+                // inertia torque experimentally omitted for stability
+#else
 		// compute rotational force
 		dMULTIPLY0_331 (tmp,I+i*12,body[i]->avel);
-		dCROSS (body[i]->tacc,-=,body[i]->avel,tmp);
+                dCROSS (body[i]->tacc,-=,body[i]->avel,tmp);
+#endif
 	}
 
 	// add the gravity force to all bodies
Index: step.cpp
===================================================================
--- step.cpp	(revision 4000)
+++ step.cpp	(working copy)
@@ -248,9 +248,13 @@
     // compute inverse inertia tensor in global frame
     dMULTIPLY2_333 (tmp,body[i]->invI,body[i]->R);
     dMULTIPLY0_333 (invI+i*12,body[i]->R,tmp);
+#ifndef USE_TORQUE_INERTIA
+    // inertia torque experimentally omitted for stability
+#else
     // compute rotational force
     dMULTIPLY0_331 (tmp,I+i*12,body[i]->avel);
     dCROSS (body[i]->tacc,-=,body[i]->avel,tmp);
+#endif
   }
 
   // add the gravity force to all bodies
@@ -560,9 +564,13 @@
     // compute inverse inertia tensor in global frame
     dMULTIPLY2_333 (tmp,body[i]->invI,body[i]->R);
     dMULTIPLY0_333 (invI+i*12,body[i]->R,tmp);
+#ifndef USE_TORQUE_INERTIA
+    // inertia torque experimentally omitted for stability
+#else
     // compute rotational force
     dMULTIPLY0_331 (tmp,I+i*12,body[i]->avel);
     dCROSS (body[i]->tacc,-=,body[i]->avel,tmp);
+#endif
   }
 
   // add the gravity force to all bodies
Index: stepfast.cpp
===================================================================
--- stepfast.cpp	(revision 4000)
+++ stepfast.cpp	(working copy)
@@ -810,9 +810,13 @@
 
 			for (i = 0; i < 4; i++)
 				body->tacc[i] = saveTacc[b * 4 + i];
+#ifndef USE_TORQUE_INERTIA
+                        // inertia torque experimentally omitted for stability
+#else
 			// compute rotational force
-			dMULTIPLY0_331 (tmp, globalI + b * 12, body->avel);
-			dCROSS (body->tacc, -=, body->avel, tmp);
+                        dMULTIPLY0_331 (tmp, globalI + b * 12, body->avel);
+                        dCROSS (body->tacc, -=, body->avel, tmp);
+#endif
 
 			// add the gravity force to all bodies
 			if ((body->flags & dxBodyNoGravity) == 0)


More information about the ODE mailing list