stephengold / Minie

Integrate Bullet Physics and V-HACD into jMonkeyEngine projects (code has New BSD license)
https://stephengold.github.io/Minie/minie/overview.html
Other
123 stars 23 forks source link

soft-body simulation hangs with ConfigFlag.VF_SS #35

Open stephengold opened 1 year ago

stephengold commented 1 year ago

This issue was reported by Tharg, using the HelloSoftBody tutorial app with VF_SS set.

Here is a native stack (from GDB):

(gdb) bt
#0  0x00007f75f30c1d35 in buildTreeBottomUp (leafNodes=..., adj=...)
    at /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/BulletSoftBody/btSoftBody.cpp:85
#1  0x00007f75f30d206e in btSoftBody::rebuildNodeTree (this=0x7f75c0b680b0)
    at /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/BulletSoftBody/btSoftBody.cpp:2729
#2  0x00007f75f30d1b7a in btSoftBody::initializeFaceTree (this=0x7f75c0b680b0)
    at /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/BulletSoftBody/btSoftBody.cpp:2693
#3  0x00007f75f30ce6cb in btSoftBody::predictMotion (this=0x7f75c0b680b0, 
    dt=0.0166666675)
    at /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/BulletSoftBody/btSoftBody.cpp:2111
#4  0x00007f75f3336ee5 in btDefaultSoftBodySolver::predictMotion (
    this=0x7f75c0b51f60, timeStep=0.0166666675)
    at /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/BulletSoftBody/btDefaultSoftBodySolver.cpp:143
#5  0x00007f75f32e1e5f in btSoftRigidDynamicsWorld::predictUnconstraintMotion (
    this=0x7f75c0b10160, timeStep=0.0166666675)
    at /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/BulletSoftBody/btSoftRigidDynamicsWorld.cpp:74
#6  0x00007f75f32fe8f5 in btDiscreteDynamicsWorld::internalSingleStepSimulation
    (this=0x7f75c0b10160, timeStep=0.0166666675)
    at /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp:463
#7  0x00007f75f32e1f2d in btSoftRigidDynamicsWorld::internalSingleStepSimulation (this=0x7f75c0b10160, timeStep=0.0166666675)
    at /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/BulletSoftBody/btSoftRigidDynamicsWorld.cpp:88
stephengold commented 1 year ago

TODO:

  1. Verify this is the first simulation step.
  2. Verify N = 2459
stephengold commented 1 year ago

Actually, N = 4914.

Then newLeafNodes.size() = 2597, then 1398, then 773, then 455, then 290, then 203, then 156, ...

It eventually gets to 1, but then buildTreeBottomUp() gets invoked again (on the same simulation step), and that's when the hang occurs.

Note that buildTreeBottomUp() is invoked from initializeFaceTree() the 1st time and then from rebuildNodeTree() the 2nd time, both times on the same soft body.

The 2nd time, N seems to be stuck at 2459.

stephengold commented 1 year ago

The 2nd time, adj is based on the soft body's links, but the body has zero links!

stephengold commented 1 year ago

Adding links to the body resolves this issue. I'll add an option to the SoftBodyControl constructor.

stephengold commented 1 year ago

Added at b2cd3339fd0990f334ce63c2896f861fe1cc708e