I had tried all the solver iteration paramaters yesterday, varying them from 0, 1 -> 20. No real difference except velocity, and raising it made my body fall through the plane.
I've spent all last night stripping my code to use the SoftDemo code. The fact there seems to be bugs in the SoftDemo source doesn't help, but I eventually crated a world using the SoftDemo parameters, and created the ellipsoid soft body using the code from SoftDemo, although i reduces the number of nodes to 64 to make it smaller.
Once I finally go the code running again, I've spent all morning stepping through some world->stepSimulation steps, line by line. With the ellipsoid, it has no clusters, and is only affects by it's pressure setting, which is 2500. Using this value, the rotations happen, but it does first one way for a couple of seconds, then stops and goes back the other way. Dropping the pressure down to 100 makes the ellipsoid half-deflate, but then it sits on the plane without moving.
This code in btSoftBody.cpp seems to be the key area that updates node velocities
Code: Select all
/* Prepare */
m_sst.sdt = dt*m_cfg.timescale;
m_sst.isdt = 1/m_sst.sdt;
m_sst.velmrg = m_sst.sdt*3;
m_sst.radmrg = getCollisionShape()->getMargin();
m_sst.updmrg = m_sst.radmrg*(btScalar)0.25;
/* Forces */
addVelocity(m_worldInfo->m_gravity*m_sst.sdt);
applyForces();
/* Integrate */
for(i=0,ni=m_nodes.size();i<ni;++i)
{
Node& n=m_nodes[i];
n.m_q = n.m_x;
n.m_v += n.m_f*n.m_im*m_sst.sdt;
n.m_x += n.m_v*m_sst.sdt;
n.m_f = btVector3(0,0,0);
}
m_sst is the solver state. It's a bit hard deciphering the exact impact of these yet, as a lot has to do with clusters, which aren't used on this body. These are the values calculated at runtime for a 1/120th timestep.
Code: Select all
sdt 0.0083333338 float
isdt 119.99999 float
velmrg 0.025000002 float
radmrg 0.25000000 float
updmrg 0.062500000 float
the "mrg" values are margins used in various places to tell what is in or out of the margin.
addVelocity simply adds the gravity * timestep to each nodes m_v value, if it's inverse mass m_im is > 0.
applyForces is where all the action happens with the pressure, volume and aero values, with the end result being that the node force accumulator, m_f has values set based on the amount of each of these forces present, based on shape volume or area * parameter.
After those two, as you can see above, the new node velocity is accumulated from the current velocity + force * inverse mass * timestep. The new node position is then accumulated with the velocity * timestep, and the force accumulator is reset.
So, from that, as long as gravity or pressure (in this case) is set, there is going to be a position change. I'm trying to find where the forces are damped and resisted by other objects, but somehow I keep missing it. Its a long slow process stepping through every line of code execution trying to decide if it's relevant or not.
One thing I can say from what I've seen so far, I don't think it's my specific code causing the issue Either it's all down to parameter tweaking, or there's some bug in the bullet code, but then why does the SoftDemo code run fine, and why does it run at all given there are bugs in the source code????
Back to head scratching.