Cloth vs Cylinder penetration

DIMEDROLL
Posts: 5
Joined: Fri May 21, 2010 12:11 pm

Cloth vs Cylinder penetration

Post by DIMEDROLL »

I've made some tests on Bullet Cloth. I've added Cloth(triangle mesh) and a Cylinder. The Cloth object tries to collide with it but easily penetrates the primitive cylinder. Here is the video, I used

Code: Select all

psb->generateClusters(0);
here
http://www.youtube.com/watch?v=SOI45ieMsHk
Then I tried to use

Code: Select all

psb->generateClusters(1024);
And the Cloth object seems to not penetrate cylinder, but it constantly receives impulses and cannot go to sleep(always moving):
http://www.youtube.com/watch?v=JXVjMPhYaFk

Here is my code:

Code: Select all

    // adding cloth
    {
        size_t   num_verts = 0;
        size_t   num_faces = 0;
        float *vertexes = NULL;
        int   *faces    = NULL;

        readObjDataDigest("D:\\top2.obj", num_verts, num_faces, faces, vertexes);


        btSoftBody*	psb=btSoftBodyHelpers::CreateFromTriMesh(
            pdemo->m_softBodyWorldInfo,(btScalar*)vertexes,faces,num_faces);
        btSoftBody::Material* pm=psb->appendMaterial();
        pm->m_kLST		=	0.4;
        pm->m_flags		-=	btSoftBody::fMaterial::DebugDraw;
        psb->m_cfg.kDF	=	1;
        psb->m_cfg.kSRHR_CL		=	1;
        psb->m_cfg.kSR_SPLT_CL	=	0;
        psb->m_cfg.collisions	=	btSoftBody::fCollision::CL_SS+

            btSoftBody::fCollision::CL_RS;
        psb->generateBendingConstraints(2,pm);

        psb->getCollisionShape()->setMargin(0.05);
        psb->setTotalMass(0.5);

        ///pass zero in generateClusters to create  cluster for each tetrahedron or triangle
        psb->generateClusters(1024);
        //psb->generateClusters(64);

        pdemo->getSoftDynamicsWorld()->addSoftBody(psb);
    }

    // adding cylinder here
    {
        btCompoundShape* cylinderCompound = new btCompoundShape;
        btCollisionShape* cylinderShape = new btCylinderShape (btVector3(0.5,10,CUBE_HALF_EXTENTS));
        btTransform localTransform;
        localTransform.setIdentity();
        //localTransform.setOrigin(btVector3(0,-10,0));
        cylinderCompound->addChildShape(localTransform,cylinderShape);
        btQuaternion orn(btVector3(0,1,0),SIMD_PI);
        localTransform.setRotation(orn);
        cylinderCompound->addChildShape(localTransform,cylinderShape);

        //m_dynamicsWorld->addRigidBody(cylinderCompound);
        btTransform startTransform;
        startTransform.setIdentity();
        startTransform.setOrigin(btVector3(0,7.5,0));
        btQuaternion rotation;
        rotation.setRotation(btVector3(0,0,1), 1.57);
        startTransform.setRotation(rotation);
        btRigidBody *m_manBody = pdemo->localCreateRigidBody(0, startTransform, cylinderCompound);
    }
I've played with lots of parameters, used different polygonality level but it still penetrates this cylinder(I am using generateClusters(0);). How do I make this cloth to hang on the cylinder?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Cloth vs Cylinder penetration

Post by Erwin Coumans »

There are probably some bugs in the cloth/rigid body interaction.

Could you create a small test project (including the .obj file) and file an issue in the tracker, so we can try to fix it in the future?
http://code.google.com/p/bullet/issues/list

Thanks a lot,
Erwin
DIMEDROLL
Posts: 5
Joined: Fri May 21, 2010 12:11 pm

Re: Cloth vs Cylinder penetration

Post by DIMEDROLL »

I've made my Cloth object more simple and set FIXED_STEP simulation

Code: Select all

#define FIXED_STEP
#ifdef FIXED_STEP
        dt=1.0f/160.f;
		m_dynamicsWorld->stepSimulation(dt,20, dt);

#else
//..
#endif
This helped and Cloth do not penetrate objects so easily, but this killed realtime