Bullet Physics Simplest Collision Example

前端 未结 3 2523
醉酒成梦
醉酒成梦 2021-02-20 11:44

I\'m trying to use Bullet Physics for collision detection only. I don\'t need it to move any objects for me or handle rendering with callbacks. I just want to update object loca

3条回答
  •  星月不相逢
    2021-02-20 12:09

    I am writing an IOS app with flighter shooting each other on 3D scene. I use bullet physics for collision detection I set the flighter as kinematic object, my logic move the flighter and then update the btMotionState worldTransform of the kinematic object. I also don't get any collision detections until i change the following two statements (set the masking and group to the same for both player and enemy)

    dynamicsWorld->addRigidBody(mPlayerObject,1,1);
    dynamicsWorld->addRigidBody(mEnemyObject,1,1);
    ...
    dynamicsWorld->setInternalTickCallback(myTickCallback);
    

    then i can see the

    void myTickCallback(btDynamicsWorld *world, btScalar timeStep) {
        int numManifolds = world->getDispatcher()->getNumManifolds();
        printf("numManifolds = %d\n",numManifolds);
    }
    

    numManifolds value become 1 when object collides.

提交回复
热议问题