网格-网格子弹碰撞检测

Mesh-mesh Bullet collision detection

我正在 BulletSharp to integrate Bullet 中使用 WPF 应用程序。我的场景包括 2 个 CollisionObject 实例,其 CollisionShape 是 BvhTriangleMeshShape() 和一个球体。

 DefaultCollisionConfiguration collisionConf = new DefaultCollisionConfiguration();
        CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConf);
        CollisionWorld world;
        world = new CollisionWorld(dispatcher, broadphase, collisionConf);

        CollisionFilterGroups myGroup = (CollisionFilterGroups) 1;
        CollisionFilterGroups collideMask = (CollisionFilterGroups) 4; 

        foreach(var ob in obstacles)
            world.AddCollisionObject(ob.BulletObj.ColObj);

        CollisionObject sphere_A = new CollisionObject();
        double radius_A = 700;
        Point3D ptA = new Point3D(3000, -200, 2800);
        BulletSharp.Matrix tr_A = new BulletSharp.Matrix();
        tr_A.set_Rows(0, new Vector4(1, 0, 0, 0));
        tr_A.set_Rows(1, new Vector4(0, 1, 0, 0));
        tr_A.set_Rows(2, new Vector4(0, 0, 1, 0));
        tr_A.set_Rows(3, new Vector4((float)ptA.X, (float)ptA.Y, (float)ptA.Z, 1));
        sphere_A.WorldTransform = tr_A;

        SphereShape sphere_shape_A = new SphereShape((float)radius_A);

        //Set the shape of the sphere
        sphere_A.CollisionShape = sphere_shape_A;
        world.AddCollisionObject(sphere_A);


        world.PerformDiscreteCollisionDetection();

球体网格碰撞在两个模型上都能正常工作。但是,当我尝试检查网格碰撞检测时,它不起作用。我认为这可能更像是 Bullet 问题而不是 BulletSharp 问题。

问题:球体对象是否默认为不同的遮罩组?是否有不同的配置来启用网格碰撞检测?

问题是 BvhTriangleMeshShape 只支持静态对象。三角形网格没有适当的碰撞处理。相反,Bullet 建议用户对动态对象使用凸分解,并使用由 btConvexHullShapes 组成的 btCompoundShape。