我正在使用 BulletSharp,子弹库的 C# 发行版。我一直在一个据说恢复为 0.0f 的对象中出现一些弹跳。
我有一个动态圆柱体(即将成为网格)落在两个静态圆柱体上。像这样:
顶部的圆柱体经常剧烈地弹跳,通常弹到一边。
这是我用来设置场景的代码:
//now figure out bulletsharp stuff...
CollisionConfiguration collConfig = new DefaultCollisionConfiguration();
Dispatcher collDispatch = new CollisionDispatcher(collConfig);
BroadphaseInterface broadphase = new DbvtBroadphase();
ConstraintSolver sol = new SequentialImpulseConstraintSolver();
world = new DiscreteDynamicsWorld(collDispatch, broadphase, sol, collConfig);
world.Gravity = new Vector3(0.0f, -10.0f, 0.0f);
//log (moving object)
MotionState still = new DefaultMotionState();
CylinderShape shape = new CylinderShapeZ(0.5f, 1.0f, 1.0f);
still.WorldTransform = Matrix.Translation(0.0f, 0.4f, 0.0f);
RigidBodyConstructionInfo constructInfo = new RigidBodyConstructionInfo(1.0f, still, shape);
logBody = new RigidBody(constructInfo);
logBody.SetDamping(0.04f, 0.1f);
world.AddRigidBody(logBody);
//rollers (static objects)
CylinderShape r1s = new CylinderShapeZ(0.1f, 1.0f, 1.0f);
MotionState r1m = new DefaultMotionState();
r1m.WorldTransform = Matrix.Translation(-0.2f, -0.4f, 0.0f);
RigidBodyConstructionInfo r1ci = new RigidBodyConstructionInfo(0.0f, r1m, r1s);
r1 = new RigidBody(r1ci);
world.AddRigidBody(r1);
CylinderShape r2s = new CylinderShapeZ(0.1f, 1.0f, 1.0f);
MotionState r2m = new DefaultMotionState();
r2m.WorldTransform = Matrix.Translation(0.2f, -0.4f, 0.0f);
RigidBodyConstructionInfo r2ci = new RigidBodyConstructionInfo(0.0f, r2m, r2s);
r2 = new RigidBody(r2ci);
world.AddRigidBody(r2);
以及我world.StepSimulation(0.05f, 100, 0.0005f);
用来更新物理模拟的每一帧。
我是否缺少任何明显的设置?为什么我的模拟会这样做?
小更新:我已经成功地在 Blender 的 Bullet 中进行了类似的模拟。那里没有弹跳……我不知道那和这之间可能有什么区别。