How to enable static mesh-vs-mesh collision detection?

Post Reply
nictosi
Posts: 11
Joined: Mon Jul 06, 2015 9:25 am

How to enable static mesh-vs-mesh collision detection?

Post by nictosi »

Hi,
I am using BulletSharp (http://andrestraks.github.io/BulletSharp/) to integrate Bullet into a WPF application. My scene includes 2 instances of CollisionObject whose CollisionShape is a BvhTriangleMeshShape(), and a sphere.

Sphere-mesh collision works properly on both models. However, when I try to check mesh-mesh collision detection it doesn't work. I see this might be more a Bullet problem rather than a BulletSharp problem.

QUESTION: How can I enable mesh-mesh collision detection? Perhaps sphere objects default to a different mask group? Is there a different configuration to enable mesh-mesh collision detection?

Code: Select all

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();
Attachments
collision2.png
collision2.png (32.11 KiB) Viewed 4007 times
collision.png
collision.png (37.69 KiB) Viewed 4007 times
Post Reply