Soft body angular factor?

silenthunter
Posts: 8
Joined: Wed Apr 06, 2011 7:48 pm

Soft body angular factor?

Post by silenthunter »

I'm trying to create a user controlled sphere that will interact with rigid bodies. I imported a sphere from blender and then added a central node that links to all of the other nodes in the sphere. This works well for moving the sphere through that central node, but it has a tendency to start spinning. Is there anything like and angular factor with rigid bodies to prevent this? I've tried setting

Code: Select all

material->m_kAST = 1
but that hasn't stopped the spinning, so I think the center node itself might be rotating.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Soft body angular factor?

Post by dphil »

I get similar behaviour with soft bodies sometimes. If I drop one on the ground, it'll kinda mush a bit and then slowly start rolling away. There's not really any notion of angular factor for soft bodies as their is for rigid bodies, because soft bodies don't have their own transform. The only way I could tell to really control the soft body motion was by increasing the soft body's m_cfg.kDP (min 0, max 1), which stands for the "damping" coefficient. This just damps all motion of the soft body nodes, which isn't always what you want as it makes the body a bit more plastic than elastic, but it helps stop perpetual oscillations or random shifting/rolling.

By the way, kAST and kVST don't do anything. I discovered this after going through the soft body code. They are not used anywhere in soft body nor in any other bullet class. At least not based on my Xcode project's search function. Theoretically kAST would control the strength of angular springs, but as far as I can tell angular springs are not implemented in bullet's soft body. Instead angular strength is simulated by bending springs (softBody->generateBendingConstraints(...)), which just use kLST like other links.
Last edited by dphil on Sun Apr 17, 2011 1:12 am, edited 1 time in total.
winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

Re: Soft body angular factor?

Post by winspear »

I know the answer to the softbody problem that dphil mentions here. You dont have to increase damping to solve this. All you have to do is to set the proper number of clusters that are used to solve the soft body.
You have to figure this out based on the number of nodes and elements a soft body contains. I found that usually for a soft body with 1500 nodes, a cluster value or 8 works pretty good. For lower number of clusters, try a higher value for position iteration to get more stability.

Also most of the problems I know in soft body collisions is caused by the CL_RS (Cluster vs convex rigid vs soft). I would recommend to use SDF_RS for collisions between rigid and soft bodies. Try the following combination for better collision behavior and non-drifting.

psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS +
btSoftBody::fCollision::CL_SS +
btSoftBody::fCollision::CL_SELF;

Hope this helps.
silenthunter
Posts: 8
Joined: Wed Apr 06, 2011 7:48 pm

Re: Soft body angular factor?

Post by silenthunter »

Changing the dampening seems to have stopped it from spinning while not colliding with anything, but it seems my soft body sphere passes through my static rigid body cube. There is some slight resistance as it hits the cube, but then it just passes right through the center of it and then stops briefly on the other side.

Any suggestions? I'll recheck the soft body demo to see if I missed anything.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Soft body angular factor?

Post by dphil »

Interesting, thanks for the info winspear. I didn't know collision groups helped with stability.