[ODE] trimesh performance

Ian McMeans imcmeans at telus.net
Sun Mar 27 03:06:22 MST 2005


Sorry about the super-slow reply, I've been busy with classes.

For anyone who's forgotten about my problem: it's that my trimesh 
collisions were really slow,
on the order of taking up 100ms per frame.

Geoff Carlton said:

> Wow, are you saying the colliding a single body against this 60-poly 
> trimesh took 100ms just for the contact generation?  Or was it in the 
> solver?  Even with some worst case Opcode problem it sounds extreme.


When things go bad, it's not that dWorldStep and dCollide take hundreds 
of milliseconds
per call, rather my profiler is giving me per-frame statistics and when 
things go bad, the
physics code gets called many times per frame (since it's running at 
fixed 200Hz, unlike the
rendering), so the physics code is taking up 95% of my program's 
terribly-slow-framerate.

I've been tinkering with the code for a few days, and trimesh-trimesh 
collisions are the only
slow thing. Trimesh-box and box-box are both very fast and stable. The 
trimesh collisions
are slow and unstable no matter what meshes I use, most of my meshes are 
loaded from
small .3ds files.

Although to be clear, the performance when things become unstable is 
awful. After the first
trimesh-trimesh collision, the framrate drops below 1 (!!!) and the 
simulation is unresponsive.
In addition to being slow, it's also unstable - and slowness and 
instability seem to happen
together right after the first trimesh-trimesh collision. By 
instability, I mean one of the two
colliding  objects will fly off to infinity (literally... to position #NAN).

The slowdown (according to my profiler) is mostly from dWorldStep. Changing
maxContacts to low numbers (to 5) doesn't seem to help. Running a 
physics timestep of 1ms
doesn't fix the problem either (in case it was timestep stability). What 
else should I look at?

Contact generation isn't that slow, dCollide seems to be eating about 
1/7th as much CPU time
as dWorldStep. Why would it be so slow for trimesh-trimesh but not slow 
in collisions
between other pairs of object types?

I guess I can try to tear out all the relevant code to try to isolate 
whatever is going on. I'm
using plane2D joints, from 
http://www.mathematik.uni-bielefeld.de/~pserocka/ODE-Plane2D/
However, when I run my program with the joints disabled, it isn't any 
more stable.

Ian


More information about the ODE mailing list