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);