Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualDgekGD

Posted 10 December 2012 - 01:07 PM

Hi!

When using Bullet Physics in your game you implement some BulletInternalTickCallback( btDynamicsWorld * const world, btScalar const timeStep ) method bullet uses as internal callback.
dynamicsWorld->setInternalTickCallback( BulletInternalTickCallback );
dynamicsWorld declared as btDynamicsWorld*
In this method you want to make loop like that:

// look at all contacts
btDispatcher * const pDispatcher = world->getDispatcher();
for ( int manifoldInd=0; manifoldIdx<pDispatcher->getNumManifolds(); manifoldInd++ )
{
  //get manifold
  btPersistentManifold const * const pManifold = pDispatcher->getManifoldByIndexInternal( manifoldInd );
  assert( manifold );

  // get colliding bodies
  btRigidBody const * const pBody0 = static_cast<btRigidBody const *>(pManifold->getBody0());
  btRigidBody const * const pBody1 = static_cast<btRigidBody const *>(pManifold->getBody1());

  ...


So you acquired pointers to your colliding bodies. The next thing you want to do is: make an external list of colliding pairs of objects and update it every frame. So you can compare if the pair of colliding objects is already in the list, so you have continuous contact, otherwise they are just collided. Other data about collision you can get from btPersistentManifoldobject. For keeping material data of the object you can create external wrapper for every physics body like:

struct PhysicsBody
{
     btRigidBody const * const pBody;
     enum Material                    m_Mat;
};

#3DgekGD

Posted 10 December 2012 - 01:05 PM

Hi!

When using Bullet Physics in your game you implement some BulletInternalTickCallback( btDynamicsWorld * const world, btScalar const timeStep ) method bullet uses as internal callback.
dynamicsWorld->setInternalTickCallback( BulletInternalTickCallback );
dynamicsWorld declared as btDynamicsWorld*
In this method you want to make loop like that:

// look at all contacts
btDispatcher * const pDispatcher = world->getDispatcher();
for ( int manifoldInd=0; manifoldIdx<pDispatcher->getNumManifolds(); manifoldInd++ )
{
  //get manifold
  btPersistentManifold const * const pManifold = pDispatcher->getManifoldByIndexInternal( manifoldInd );
  assert( manifold );

  // get colliding bodies
  btRigidBody const * const pBody0 = static_cast<btRigidBody const *>(pManifold->getBody0());
  btRigidBody const * const pBody1 = static_cast<btRigidBody const *>(pManifold->getBody1());

  ...


So you acquired pointers to your colliding bodies. The next thing you want to do is: make an external list of colliding pairs of objects and update it every frame. So you can compare is the pair of colliding objects already is in the list, so you have continous contact, otherwise they are just collided. Other data about collision you can get from btPersistentManifoldobject. For keeping material data of the object you can create external wrapper for every physics body like:

struct PhysicsBody
{
     btRigidBody const * const pBody;
     enum Material                    m_Mat;
};

#2DgekGD

Posted 10 December 2012 - 01:05 PM

Hi!

When using Bullet Physics in your game you implement some BulletInternalTickCallback( btDynamicsWorld * const world, btScalar const timeStep ) method bullet uses as internal callback.
dynamicsWorld->setInternalTickCallback( BulletInternalTickCallback );
dynamicsWorld declared as btDynamicsWorld*
In this method you want to make loop like that:

// look at all contacts
btDispatcher * const pDispatcher = world->getDispatcher();
for ( int manifoldInd=0; manifoldIdx<pDispatcher->getNumManifolds(); manifoldInd++ )
{
  //get manifold
  btPersistentManifold const * const pManifold = pDispatcher->getManifoldByIndexInternal( manifoldInd );
  assert( manifold );

  // get colliding bodies
  btRigidBody const * const pBody0 = static_cast<btRigidBody const *>(pManifold->getBody0());
  btRigidBody const * const pBody1 = static_cast<btRigidBody const *>(pManifold->getBody1());

  ...


So you acquired pointers to your colliding bodies. The next thing you want to do is: make an external list of colliding pairs of objects and update it every frame. So you can compare is the pair of colliding objects already is in the list, so you have continous contact, otherwise they are just collided. Other data about collision you can get from btPersistentManifoldobject. For keeping material data of the object you can create external wrapper for every physics body like:

struct PhysicsBody
{
     btRigidBody const * const pBody;
     enum Material                    m_Mat;
};

#1DgekGD

Posted 10 December 2012 - 01:03 PM

Hi!

When using Bullet Physics in your game you implement some BulletInternalTickCallback( btDynamicsWorld * const world, btScalar const timeStep ) method bullet uses as internal callback.
dynamicsWorld->setInternalTickCallback( BulletInternalTickCallback );
dynamicsWorld declared as btDynamicsWorld*
In this method you want to make loop like that:
// look at all existing contacts
btDispatcher * const pDispatcher = world->getDispatcher();
for ( int manifoldInd=0; manifoldIdx<pDispatcher->getNumManifolds(); manifoldInd++ )
{
  // get the "manifold", which is the set of data corresponding to a contact point
  //   between two physics objects
  btPersistentManifold const * const pManifold = pDispatcher->getManifoldByIndexInternal( manifoldInd );
  assert( manifold );
 
  // get colliding bodies
  btRigidBody const * const pBody0 = static_cast<btRigidBody const *>(pManifold->getBody0());
  btRigidBody const * const pBody1 = static_cast<btRigidBody const *>(pManifold->getBody1());


So you acquired pointers to your colliding bodies. The next thing you want to do is: make an external list of colliding pairs of objects and update it every frame. So you can compare is the pair of colliding objects already is in the list, so you have continous contact, otherwise they are just collided. Other data about collision you can get from btPersistentManifoldobject. For keeping material data of the object you can create external wrapper for every physics body like:

struct PhysicsBody
{
     btRigidBody const * const pBody;
     enum Material                    m_Mat;
};

PARTNERS