Jbullet: NPE when removing body with TRIANGLE_MESH shape.

Post Reply
Goran
Posts: 3
Joined: Tue Dec 23, 2014 1:00 pm

Jbullet: NPE when removing body with TRIANGLE_MESH shape.

Post by Goran »

I have 3 rigid bodies (all TRIANGLE_MESH shapes) that are touching, I remove one, and I get:

Code: Select all

Exception in thread "LWJGL Application" java.lang.NullPointerException
        at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(CollisionDispatcher.java:126)
        at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.cleanOverlappingPair(HashedOverlappingPairCache.java:225)
        at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache$CleanPairCallback.processOverlap(HashedOverlappingPairCache.java:453)
        at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.processAllOverlappingPairs(HashedOverlappingPairCache.java:196)
        at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.cleanProxyFromPairs(HashedOverlappingPairCache.java:213)
        at com.bulletphysics.collision.dispatch.CollisionWorld.removeCollisionObject(CollisionWorld.java:175)
        at com.bulletphysics.dynamics.DiscreteDynamicsWorld.removeRigidBody(DiscreteDynamicsWorld.java:442)
Any idea as to why this is happening, and how to avoid it?
Raco
Posts: 2
Joined: Sun Feb 11, 2018 6:50 am

Re: Jbullet: NPE when removing body with TRIANGLE_MESH shape.

Post by Raco »

Hello,

I'm having the same issue with:

Code: Select all

body.collisionFlags == CollisionFlags.KINEMATIC_OBJECT
It would be helpful if anyone of the support team could confirm if this issue is either known or unknown.

I did manage to by-pass the problem by re-adding the body to the world immediately after setting the body's collision shape. Contact manifolds are updated next.

Code: Select all

body.setCollisionShape(shape);
...
world.removeRigidBody(body);
world.addRigidBody(body);
...
body.getUserPointer().contactManifolds.add(world.getDispatcher().getManifoldByIndexInternal(i));
...
So a better question might be:

Should a rigid body always be re-added to the world after setting the collision shape, or is this only necessary with KINEMATIC_OBJECT because there's a bug?

Many thanks,

Raf
hyyou
Posts: 96
Joined: Wed Mar 16, 2016 10:11 am

Re: Jbullet: NPE when removing body with TRIANGLE_MESH shape.

Post by hyyou »

Raco wrote: Sun Feb 11, 2018 8:41 am Should a rigid body always be re-added to the world after setting the collision shape
I don't know about Java port, but this is a well-known Bullet (C++) limitation/restriction of usage.
A workaround is to encapsulate it. I check change-of-shape every time-step.

Reference (C++) :
https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=5194
Raco
Posts: 2
Joined: Sun Feb 11, 2018 6:50 am

Re: Jbullet: NPE when removing body with TRIANGLE_MESH shape.

Post by Raco »

hyyou wrote: Sun Feb 11, 2018 8:52 amthis is a well-known Bullet (C++) limitation/restriction of usage
Thanks for that information.
Post Reply