Convex sweep test (ClosestNotMe)

O-san
Posts: 19
Joined: Mon May 11, 2009 8:46 am

Convex sweep test (ClosestNotMe)

Post by O-san »

Hello!

I am trying to do a sweep test with convex shapes (a capsule). I thought I could reuse a class I found in the CharacterDemo project file “DynamicCharacterController.cpp” called ClosestNotMe. I have tried to rewrite this class so it accommodates for convex shapes but I have not been successful. I found that there are structures that correspond to each other called LocalRayResult/LocalConvexResult. I guess I should be using the latter somehow.

This is what I got so far:

Code: Select all

class ClosestNotMeSweep : public btCollisionWorld::ClosestConvexResultCallback
{
public:
  ClosestNotMeSweep (btRigidBody* me) : btCollisionWorld::ClosestConvexResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0))
  {
    m_me = me;
  }

  virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult,bool normalInWorldSpace)
  {
    if (convexResult.m_hitCollisionObject == m_me)
      return 1.0;

    return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace
  );
}
protected:
  btRigidBody* m_me;
};
The original class uses a variable called LocalRayResult.m_collisionObject. This variable is not present in LocalConvexResult but I found m_hitCollisionObject. But I guess they don’t work the same way.

Any guidance appreciated. Thanks for reading!
O-san
Posts: 19
Joined: Mon May 11, 2009 8:46 am

Re: Convex sweep test (ClosestNotMe)

Post by O-san »

Well, I found that there actually is a class that does what I am trying to do btClosestNotMeConvexResultCallback. However I can't figure out how to use it. My compiler tells me that it hasn't been declared. Up until now I have only needed btBulletDynamicsCommon.h. Do I need some other header files for this class? Thanks in advance
O-san
Posts: 19
Joined: Mon May 11, 2009 8:46 am

Re: Convex sweep test (ClosestNotMe)

Post by O-san »

I must have been doing something wrong because now I got the class above to work.. oh well