0
\$\begingroup\$

I have the following problem. I would like to check in bullet whether only the AABB collides or the mesh collider itself. Unfortunately I can't find out how to do this

Within the screenshot you can see that there is a very big aabb between the houses and the car with tree. So its impossible for the player to move through this area.

So i try to approach that the collision from the manifold only rise the the even when the player shape collides with an real triangle within this ConvexTriangleMesh.

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ Please explain the context of your question in more detail. Are you looking for a way to check if two arbitrary colliders are currently intersecting with each other, or are you trying to understand an event raised by Bullet? What programming language and development framework are you using? Is this question in regards to the Bullet C++ SDK or the awful PyBullet wrapper for Python? \$\endgroup\$
    – Kevin
    Commented Feb 23 at 2:14
  • \$\begingroup\$ edited the question. \$\endgroup\$
    – Andy
    Commented Feb 23 at 2:31
  • 1
    \$\begingroup\$ You didn't answer some of my questions (which language and SDK). \$\endgroup\$
    – Kevin
    Commented Feb 23 at 2:37
  • \$\begingroup\$ Oh sorry. I use C# and BulletSharp github.com/AndresTraks/BulletSharp \$\endgroup\$
    – Andy
    Commented Feb 23 at 9:22

2 Answers 2

0
\$\begingroup\$

I don't have a lot of experience with Bullet, but based on the limited information you've provided:

You've said that you're using a Convex Mesh. A Convex collision mesh can't have any voids or empty spaces. It looks like you are combining multiple triangles into one composite collider. If this is the case, in this specific circumstance your AABB and collision mesh are the same. Bullet will not have any information about whether there are triangles inside the collider.

If you want to be able to walk into the gap between the house on the right and the van on the far right, you should not be combining all of these objects into one convex mesh. You should probably do something like this, where each red box is its own convex collision mesh.

Better collider layout

There is technically a higher performance cost for having more colliders, but a handful of static box colliders like this should be a non-issue on any modern device.

\$\endgroup\$
0
\$\begingroup\$

Ah ok, i created an CompoundShape and all all the tiles into this shape. It get debuged wrong but behaves like it should

enter image description here

This is my code atm

public void CreateRigidBody(float mass, PhysicHandler handler)
{
    if (this.Parent.GetType() == typeof(BufferedSprite))
    {
        var bufferedSprite = (BufferedSprite)this.Parent;
        //var Childshape = new ConvexHullShape(bufferedSprite.Verticies.ToArray());
        //var shape = new Convex2DShape(Childshape);

        var mesh = new TriangleMesh();

        CompoundShape compoundShape = new CompoundShape(true);

        foreach(var deffinition in bufferedSprite.ShapeDeffinitions)
        {
            Box2DShape box2DShape = new Box2DShape(new Vector3(deffinition.sizeX, deffinition.sizeY, 0f) / 2);
            BulletSharp.Math.Matrix boxtransform = BulletSharp.Math.Matrix.Translation(new Vector3(deffinition.locX, deffinition.locY, 0f));
            compoundShape.AddChildShape(boxtransform, box2DShape);

            //Vector3 v1 = new Vector3(deffinition.verticies[0], deffinition.verticies[1], deffinition.verticies[2]);
            //Vector3 v2 = new Vector3(deffinition.verticies[3], deffinition.verticies[4], deffinition.verticies[5]);
            //Vector3 v3 = new Vector3(deffinition.verticies[6], deffinition.verticies[7], deffinition.verticies[8]);
            //mesh.AddTriangle(v1, v2, v3, true);

            //v1 = new Vector3(deffinition.verticies[0], deffinition.verticies[1], deffinition.verticies[2]);
            //v2 = new Vector3(deffinition.verticies[3], deffinition.verticies[4], deffinition.verticies[5]);
            //v3 = new Vector3(deffinition.verticies[6], deffinition.verticies[7], deffinition.verticies[8]);
            //mesh.AddTriangle(v1, v2, v3, true);
        }
        //ConvexTriangleMeshShape shape = new ConvexTriangleMeshShape(mesh, true);
        //var shape = new Convex2DShape(meshShape);

        RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(mass, null, compoundShape, compoundShape.CalculateLocalInertia(mass));
        BulletSharp.Math.Matrix transform = BulletSharp.Math.Matrix.Translation(bufferedSprite.Location.ToBulletVec3());
        Matrix startTransform = transform;
        info.MotionState = new DefaultMotionState(startTransform);


        RigidBody = new BulletSharp.RigidBody(info);
        RigidBody.UserObject = this.Parent;
        RigidBody.LinearFactor = this.LinearFactor.ToBulletVec3();
        RigidBody.AngularFactor = this.AngularFactor.ToBulletVec3();
        RigidBody.CollisionFlags = CollisionFlags.StaticObject;

        handler.ManageElement(this);
    }
    else
    {
        throw new InvalidOperationException("Invalid element for this Behavior");
    }
}
\$\endgroup\$
2
  • \$\begingroup\$ What do you mean by "it get debuged wrong"? \$\endgroup\$
    – DMGregory
    Commented Feb 23 at 12:16
  • \$\begingroup\$ Its only shows the AABB's not the single boxes. \$\endgroup\$
    – Andy
    Commented Feb 23 at 17:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .