soft body not deforming after collision

dlx
Posts: 7
Joined: Fri Aug 03, 2012 8:39 pm

soft body not deforming after collision

Post by dlx »

Hi Guys,

I'm still on my jorney with soft bodies. I've managed to succefully make my soft body to collide against rigid bodies, set anchors and so on. But what I have noticed is that if I throw some rigid body against my soft one it doesn't deform as I expected and the rigid body is rebound.

Following is my code(It's been written within SoftDemo.cpp), notice I've anchored my soft body with a rigid one so I can constrain the soft body movements(I'm working with a 2d notion so it's a strong requirement).

Have anybody faced something like this? have anybody worked with similar requirements?

Thanks in advance....

Code: Select all

static void Init_SoftTesting(SoftDemo *pdemo)
{
    int i = 0;
    btTransform trans;
    btRigidBody *rigid_body;

    btTransform trans_grd;
    trans_grd.setIdentity();
    trans_grd.setOrigin(btVector3(0, 0, 0));

    btSoftBody*	soft_body = btSoftBodyHelpers::CreateFromTriMesh(
                        pdemo->m_softBodyWorldInfo, cube_vertices,
		        &cube_indices[0][0],
		        CUBE_NUM_TRIANGLES);

    soft_body->scale(btVector3(5, 5, 5));

    soft_body->generateClusters(0);

    soft_body->m_cfg.collisions += btSoftBody::fCollision::SDF_RS;

    soft_body->m_cfg.kAHR = 0.03;
    soft_body->m_materials[0]->m_kLST = 0.03;
    soft_body->m_materials[0]->m_kAST = 0.03;
    soft_body->m_materials[0]->m_kVST = 0.03;

    soft_body->generateBendingConstraints(10, soft_body->m_materials[0]);

    trans.setIdentity();
    trans.setOrigin(btVector3(0, 0, 0));
    rigid_body = pdemo->localCreateRigidBody(1,trans,
                               new btBoxShape(btVector3(0.2, 0.2, 0.2)));

    rigid_body->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);

    rigid_body->setLinearFactor(btVector3(1, 1, 0));
    rigid_body->setAngularFactor(btVector3(0, 0, 1));
    
    for (; i < soft_body->m_nodes.size(); i++)
        soft_body->appendAnchor(i, rigid_body);

    pdemo->getSoftDynamicsWorld()->addSoftBody(soft_body);

    trans.setIdentity();
    trans.setOrigin(btVector3(-10, 0, 0));
    rigid_body = pdemo->localCreateRigidBody(1, trans,
                            new btBoxShape(btVector3(5, 5, 5)));

    rigid_body->setLinearFactor(btVector3(1, 1, 0));
    rigid_body->setAngularFactor(btVector3(0, 0, 1));
}
damian0815
Posts: 4
Joined: Thu Oct 18, 2012 8:29 am

Re: soft body not deforming after collision

Post by damian0815 »

hey,

i'm not sure if you're still having this problem, but i found giving the body a mass by calling softBody->setTotalMass( mass, true ); made rigid objects deform the soft object as expected. the mass i used was of a similar magnitude to the mass of the rigid body.