[ODE] Stepfast - auto-disable stuff
Adam D. Moss
aspirin at ntlworld.com
Mon Jul 14 11:57:01 2003
This is a multi-part message in MIME format.
--------------050400010603090507000707
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Attached is a patch that describes Aras' changes versus
CVS-ODE-April-2003+Stepfast.
It'll help to see what, in isolation, Aras changed.
Regards,
--Adam
--
Adam D. Moss . ,,^^ adam@gimp.org http://www.foxbox.org/ co:3
"Tell people something they know already and they will thank you for
it. Tell them something new and they will hate you for it."
--------------050400010603090507000707
Content-Type: text/plain;
name="ode-araz-2003-04-20.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ode-araz-2003-04-20.patch"
Only in .: CVS
Only in /shm/lib/ode/src/: build
diff -b -u -r ./collision_std.cpp /shm/lib/ode/src/collision_std.cpp
--- ./collision_std.cpp Sun Dec 1 07:00:02 2002
+++ /shm/lib/ode/src/collision_std.cpp Mon May 19 11:03:52 2003
@@ -1079,7 +1079,7 @@
int maxi = 0;
for (int i=1; i<3; i++) {
dReal tt = dFabs(t[i]);
- if (tt > max) {
+ if (tt < max) { // Araz: was >
max = tt;
maxi = i;
}
diff -b -u -r ./error.cpp /shm/lib/ode/src/error.cpp
--- ./error.cpp Wed Jun 26 00:46:18 2002
+++ /shm/lib/ode/src/error.cpp Tue Apr 29 12:30:22 2003
@@ -1,4 +1,4 @@
-/*************************************************************************
+ /*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
@@ -65,6 +65,11 @@
}
+//****************************************************************************
+// unix
+
+#ifndef WIN32
+
static void printMessage (int num, const char *msg1, const char *msg2,
va_list ap)
{
@@ -77,11 +82,6 @@
fflush (stderr);
}
-//****************************************************************************
-// unix
-
-#ifndef WIN32
-
extern "C" void dError (int num, const char *msg, ...)
{
va_list ap;
@@ -111,6 +111,7 @@
else printMessage (num,"ODE Message",msg,ap);
}
+
#endif
//****************************************************************************
@@ -127,6 +128,19 @@
#include "windows.h"
+static void printMessage (int num, const char *msg1, const char *msg2,
+ va_list ap)
+{
+ // Araz
+ char buf[1000];
+ if (num) sprintf(buf,"\n%s %d: ",msg1,num);
+ else sprintf (buf,"\n%s: ",msg1);
+ OutputDebugString( buf );
+ vsprintf(buf,msg2,ap);
+ OutputDebugString( buf );
+ OutputDebugString( "\n" );
+}
+
extern "C" void dError (int num, const char *msg, ...)
{
Only in .: geom.cpp
Only in .: geom_internal.h
diff -b -u -r ./objects.h /shm/lib/ode/src/objects.h
--- ./objects.h Sun Nov 10 23:15:59 2002
+++ /shm/lib/ode/src/objects.h Fri May 2 11:17:34 2003
@@ -76,6 +76,8 @@
dVector3 lvel,avel; // linear and angular velocity of POR
dVector3 facc,tacc; // force and torque accululators
dVector3 finite_rot_axis; // finite rotation axis, unit length or 0=none
+ // Araz:
+ int mDisableSteps; // auto-disable counter
};
@@ -86,6 +88,9 @@
dVector3 gravity; // gravity vector (m/s/s)
dReal global_erp; // global error reduction parameter
dReal global_cfm; // global costraint force mixing parameter
+ // Araz: auto-disabling stuff
+ dReal mAutoDisableThreshold;
+ int mAutoDisableSteps;
};
diff -b -u -r ./ode.cpp /shm/lib/ode/src/ode.cpp
--- ./ode.cpp Wed Mar 19 08:04:14 2003
+++ /shm/lib/ode/src/ode.cpp Fri May 2 11:17:34 2003
@@ -349,6 +349,8 @@
dSetZero (b->facc,4);
dSetZero (b->tacc,4);
dSetZero (b->finite_rot_axis,4);
+ // Araz: auto-disable
+ b->mDisableSteps = 0;
addObjectToList (b,(dObject **) &w->firstbody);
w->nb++;
return b;
@@ -1164,6 +1166,9 @@
#else
#error dSINGLE or dDOUBLE must be defined
#endif
+ // Araz: auto-disabling stuff
+ w->mAutoDisableSteps = 10;
+ w->mAutoDisableThreshold = REAL(0.008);
return w;
}
@@ -1198,6 +1203,17 @@
delete w;
}
+// Araz: auto-disable stuff
+void dWorldSetAutoDisableSteps( dWorldID w, int steps )
+{
+ dAASSERT(w);
+ w->mAutoDisableSteps = steps;
+}
+void dWorldSetAutoDisableThreshold( dWorldID w, dReal threshold )
+{
+ dAASSERT(w);
+ w->mAutoDisableThreshold = threshold;
+}
void dWorldSetGravity (dWorldID w, dReal x, dReal y, dReal z)
{
Only in .: scrapbook.cpp
Only in .: space.cpp
Only in .: stack.cpp
Only in .: stack.h
diff -b -u -r ./stepfast.cpp /shm/lib/ode/src/stepfast.cpp
--- ./stepfast.cpp Mon Jul 14 19:50:26 2003
+++ /shm/lib/ode/src/stepfast.cpp Fri May 2 11:17:34 2003
@@ -91,7 +91,8 @@
A += Askip + 1;
C += 8;
}
-
}
+
+}
static void
MultiplyAdd2_sym_p8p (dReal * A, dReal * B, dReal * C, int p, int Askip)
@@ -122,7 +123,8 @@
A += Askip + 1;
C += 8;
}
-
}
+
+}
// this assumes the 4th and 8th rows of B are zero.
@@ -1013,6 +1015,30 @@
#ifdef TIMING
dTimerNow ("Island Processing");
#endif
+ // Araz: auto-disabling stuff
+ if( !(bb->flags&dxBodyDisabled) ) {
+ bool disable = true;
+ const dReal *lvel = bb->lvel;;
+ dReal lspeed = dDOT(lvel,lvel);
+ if( lspeed > world->mAutoDisableThreshold ) {
+ disable = false;
+ } else {
+ const dReal *avel = bb->avel;
+ dReal aspeed = dDOT(avel,avel);
+ if( aspeed > world->mAutoDisableThreshold ) {
+ disable = false;
+ }
+ }
+ if( disable )
+ ++bb->mDisableSteps;
+ else
+ bb->mDisableSteps = 0;
+
+ if( bb->mDisableSteps > world->mAutoDisableSteps ) {
+ bb->flags |= dxBodyDisabled;
+ }
+ }
+
// get bb = the next enabled, untagged body, and tag it
if (bb->tag || (bb->flags & dxBodyDisabled))
continue;
@@ -1049,6 +1075,9 @@
if (thisDepth < 0)
continue;
n->body->flags &= ~dxBodyDisabled;
+ // Araz: auto disable stuff
+ n->body->mDisableSteps = 0;
+ // /Araz
n->body->tag = 1;
autostack[stacksize] = thisDepth;
stack[stacksize++] = n->body;
@@ -1070,6 +1099,9 @@
{
body[i]->tag = 1;
body[i]->flags &= ~dxBodyDisabled;
+ // Araz: auto disable stuff
+ //body[i]->mDisableSteps = 0;
+ // /Araz
}
for (i = 0; i < jcount; i++)
joint[i]->tag = 1;
--------------050400010603090507000707--