JBullet - 静态时凸形无法正常工作

JBullet - Convex Shapes not working properly when static

我在 JBullet 中使用动态盒形物体进行碰撞。他们正确地相互碰撞。但是我正在忙于构建世界并遇到了一些奇怪的问题。

当我尝试使凸刚体(BoxShape 或 TriangleShape)成为静态(通过将质量设置为 0)时,碰撞仅在 (0,0,0) 的某种点而不是给定形状处发生.如果它是动态的,则效果很好。

其他问题,也许还有一些 link:如果我使用 BvhTriangleMeshShape 或 GImpactMeshShape,它只有在动态时才能正常工作,而当它是静态时无论如何都不会发生碰撞(尽管事实上 BvhTriangleMeshShape 将用于静态物体) .

这是我初始化世界的方式:

BroadphaseInterface broadphase = new DbvtBroadphase();
CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
ConstraintSolver solver = new SequentialImpulseConstraintSolver();
dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
dynamicsWorld.setGravity(new Vector3f(0, 0, 0));
GImpactCollisionAlgorithm.registerAlgorithm(dispatcher);

问题对象:

Vector3f inertia = new Vector3f(0, 0, 0);
MotionState motion = new DefaultMotionState(new Transform());

//BvhTriangleMeshShape shape = ShapeUtil.getShapeFromModel(testSphere);
//CompoundShape shape = ShapeUtil.getCompoundShapeFromModel(testSphere);
//GImpactMeshShape shape = ShapeUtil.getGImpactShapeFromModel(testSphere);
BoxShape shape = new BoxShape (new Vector3f(2,2,2));
//TriangleShape shape = new TriangleShape(new Vector3f(-20,0,-10), new Vector3f(20,20,-10), new Vector3f(20,-20,-10));

RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo(0, motion, shape, inertia);
RigidBody body = new RigidBody(constructionInfo);
//body.setCollisionFlags(CollisionFlags.STATIC_OBJECT);

dynamicsWorld.addRigidBody(body);
this.bodies[64] = body;

谁能帮帮我?我使用的是 2010 年 10 月 10 日的 JBullet 版本。 提前致谢。

看来我找到问题了。我通过替换行

解决了它
MotionState motion = new DefaultMotionState(new Transform());

来自

Transform transform = new Transform();
transform.setIdentity();
MotionState motion = new DefaultMotionState(transform);

看起来 Transform 的默认构造函数不会像我期望的那样创建身份转换。