Collision between Soft Body and Rigid

Post Reply
ENGine
Posts: 15
Joined: Thu Feb 26, 2015 7:04 am

Collision between Soft Body and Rigid

Post by ENGine »

Hi, all.

Please, help me to understand why my bodies don't collision. I created one Rigid Body - Player and Soft Body.

Code: Select all

btCollisionShape *shape; world = _world;
	
	_attachedNode = _node;
	Ogre::Vector3 BB = _ent.ent->getBoundingBox().getSize();
	Ogre::Vector3 scale = _node.node->getScale();
	BB *= scale;
            
        float radius = BB.x / 2.0;
			float height = BB.y / 2.0;
			shape = new btCapsuleShape(radius, height);
            
   
	btVector3 inertia = btVector3(0.0f, 0.0f, 0.0f);
    shape->calculateLocalInertia(_mass, inertia);
	
	tempNode = _node;
    MyMotionState *motionState = new MyMotionState(_node.node);
    _body = new btRigidBody(_mass, motionState, shape, inertia);
	
	_node.btObjName = name;
	 _body->setUserPointer((__bridge void *)name);
	
	if (_default) {
		btTransform tr = _body->getWorldTransform();
		tr.setOrigin(btVector3([_node getPosition].x, [_node getPosition].y, [_node getPosition].z));
		tr.setRotation(btQuaternion([_node getOrientation].x, [_node getOrientation].y, [_node getOrientation].z, [_node getOrientation].w));
		_body->setWorldTransform(tr);
	}
	
	_body->setActivationState(DISABLE_DEACTIVATION);
	state = AS_DISABLE_DEACTIVATION;

Code: Select all

world = _world;
	m_softBodyWorldInfo.air_density = (btScalar)1.2;
    m_softBodyWorldInfo.m_gravity = btVector3(0, 0, 0);//_world.world->getGravity();
	m_softBodyWorldInfo.m_dispatcher = _world.dispatcher;
	m_softBodyWorldInfo.m_sparsesdf.Reset();
	m_softBodyWorldInfo.m_broadphase = _world.broadPhase;
	m_softBodyWorldInfo.m_sparsesdf.Initialize();
	
	staticSoftBoby = nil; dynamicSoftBody = nil;
	
		staticSoftBoby = new StaticMeshToSoftBodyConverter(&m_softBodyWorldInfo);
		staticSoftBoby->addEntity(_entity.ent);
		psb = staticSoftBoby->createSoftBodyFromTrimesh();

	btSoftBody::Material *pm=psb->appendMaterial();
	pm->m_kLST = 0.1;
	psb->m_cfg.piterations = 2;
	psb->m_cfg.kDF = 0.5;
	psb->m_cfg.collisions |= btSoftBody::fCollision::VF_SS;
	psb->generateClusters(300);
	psb->randomizeConstraints();
	psb->setTotalMass(100,true);
	
	
    psb->setUserPointer((__bridge void *)_name);
	btSoftRigidDynamicsWorld *softWorld = (btSoftRigidDynamicsWorld *)_world.world;
	softWorld->addSoftBody(psb);
Please, help me finding the error. Thanks.
ENGine
Posts: 15
Joined: Thu Feb 26, 2015 7:04 am

Re: Collision between Soft Body and Rigid

Post by ENGine »

Also what param is necessary to set up for rigidity/inflexibility/hardness? I mean if I need to create Soft body for very easy deformation? Thanks.
User avatar
Dokthar
Posts: 8
Joined: Thu Aug 13, 2015 4:57 pm

Re: Collision between Soft Body and Rigid

Post by Dokthar »

I think you can try theses collisions flag : (for the m_cfg.collisions)

fCollision::RVSmask = 0x000f //Config collision flag : Rigid versus soft mask.
fCollision::SDF_RS = 0x0001 // Config collision flag : SDF based rigid vs soft.
fCollision::CL_RS = 0x0002 // Config collision flag : Cluster vs convex rigid vs soft.
Post Reply