Just updating GhostObject transform after RigidBody is not enough -- if RigidBody is moving fast enough (15-20 units per second or so), the GhostObject can easily "miss" collision with world (tri-mesh CollisionObject).
It seems that I need 'hard'-constraint GhostObject to RigidBody, but constraints are only working with RigidBodies, not CollisionObjects.
Any suggestions?
How do I properly 'link' GhostObject to (moving) RigidBody?
-
- Posts: 8
- Joined: Fri Sep 03, 2010 9:03 am
-
- Posts: 8
- Joined: Thu Nov 24, 2011 3:08 pm
Re: How do I properly 'link' GhostObject to (moving) RigidBo
Show us your code -- are you using convexSweepTest?
-
- Posts: 8
- Joined: Fri Sep 03, 2010 9:03 am
Re: How do I properly 'link' GhostObject to (moving) RigidBo
No, I don't use convexSweepTest.trollington wrote:Show us your code -- are you using convexSweepTest?
Collisions for phantoms are checked like this:
Code: Select all
static btManifoldArray manifold;
btBroadphasePairArray& pair = (static_cast<btPairCachingGhostObject*>(_obj))->getOverlappingPairCache()->getOverlappingPairArray();
int pair_cnt = pair.size();
btOverlappingPairCache* pair_cache = PhysWorld::Instance()->dynamics_world()->getPairCache();
bool do_clear = pair_cnt == 0;
for( int i=0; i!=pair_cnt; ++i )
{
manifold.clear();
btBroadphasePair* cd_pair = pair_cache->findPair( pair[i].m_pProxy0, pair[i].m_pProxy1 );
if( cd_pair )
{
if( cd_pair->m_algorithm )
cd_pair->m_algorithm->getAllContactManifolds( manifold );
for( int m=0; m<manifold.size(); ++m )
{
// get contact-points etc.
}
}
}
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: How do I properly 'link' GhostObject to (moving) RigidBo
For fast moving objects it is best to use the convexSweepTest.
The btGhostObject has some way to perform such sweep test too. You can check the implementation in Bullet/src/BulletDynamics/Character/btKinematicCharacterController:
The btGhostObject has some way to perform such sweep test too. You can check the implementation in Bullet/src/BulletDynamics/Character/btKinematicCharacterController:
Code: Select all
if (m_useGhostObjectSweepTest)
{
m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
} else
{
collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration);
}
-
- Posts: 8
- Joined: Fri Sep 03, 2010 9:03 am
Re: How do I properly 'link' GhostObject to (moving) RigidBo
Yes, now I understand that, thanks for clarification.Erwin Coumans wrote:For fast moving objects it is best to use the convexSweepTest.
There's one thing about btCollisionWorld::ConvexResultCallback that I don't quite understand:
what happens when there're multiple points of contact between ghost-object and some other collision-object -- do I get all of them, first one?
UPD:
Actually, all the contact points (if there're multiple contacts) are passed to btCollisionWorld::ConvexResultCallback::addSingleResult(),
so it's all works fine.