[ODE] multiple contacts and sticking on the cusp
David McClurg
dmcclurg at pandemicstudios.com.au
Mon Oct 28 18:19:02 2002
This is a multi-part message in MIME format.
------_=_NextPart_001_01C27EE9.1ED0102A
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
i've found that i need to combine contacts when sphere bodies roll from =
one static geom to another. to understand the problem, let me show you =
an example...
attached is a modified version of test_boxstack.cpp. hit the 's' key to =
drop a sphere and watch what happens. see how it sticks on the cusp =
between the ramp and the ground plane?
that is kind of weird. it happens when spheres are rolling over boxes, =
planes, or meshes. it can even happen if you embed a ccylinder into the =
ground and roll up next to it. you will stick for a while before you =
can pull yourself away from the ccylinder.
is this expected or is it a bug? if it is expected, perhaps it should =
automatically be handled because it is so common to run up against. =
erwin handles it within a single tri-list by merging the contacts into a =
single contact. but you need to do this on a higher level as well =
between different trilists, boxes, and planes.
------_=_NextPart_001_01C27EE9.1ED0102A
Content-Type: application/octet-stream;
name="test_boxstack.cpp"
Content-Transfer-Encoding: base64
Content-Description: test_boxstack.cpp
Content-Disposition: attachment;
filename="test_boxstack.cpp"
LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioNCiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqDQogKiBPcGVuIER5bmFtaWNzIEVu
Z2luZSwgQ29weXJpZ2h0IChDKSAyMDAxLDIwMDIgUnVzc2VsbCBMLiBTbWl0aC4gICAgICAgKg0K
ICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gIEVtYWlsOiBydXNzQHExMi5vcmcgICBXZWI6IHd3dy5x
MTIub3JnICAgICAgICAgICoNCiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqDQogKiBUaGlzIGxpYnJhcnkgaXMg
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