Bullet physics stops collision after a while

So I am trying to use bullet physics library in my opengl game engine for collision detection.

I am not trying to do anything complicated, I only want to know when things collide in the 3d world. I am only using box shapes and I have no interest in moving the objects using physics (I have even disabled collision response for my rigid bodies).

I have managed to get the collision to work doing the following:

  • First, each frame I update the rigid bodies world transform based on the entity's transform it is attached to. For example I move my player right, the rigid body (and the bounding box) moves with me.

  • I am checking if 2 objects are colliding using this code:

    void PhysicsManager::myTickCallback(btDynamicsWorld *world, btScalar timeStep)
    {
        int numManifolds = world->getDispatcher()->getNumManifolds();
        if (numManifolds > 0)
            cout << "COLLISION" << endl;
    }
    
  • myTickCallback is the dynamics world internal tick call back: dynamicsWorld->setInternalTickCallback(myTickCallback);

    What is weird now is that when I start up the game, I move my player on the other object I want it to collide with and it starts spamming COLLISION. If I leave the player on the object it will keep spamming it. However, if go away from the object and go back into it several times, after a while it just stops writing COLLISION.

    I have checked if the rigid bodies are moving (if there is collision response) and there isn't.

    This could be a problem in the game I am trying to create because I want the player to be hit by projectiles and it wouldn't be right if he stops getting hit after a while.

    Thank you for reading, any help would be appreciated.

    链接地址: http://www.djcxy.com/p/95480.html

    上一篇: Xna(C#)和C ++的网络?

    下一篇: 一段时间后,子弹物理停止碰撞