没有摩擦力的 Box2d 物体在碰撞时以某种方式获得速度

Box2d objects with no friction somehow gaining velocity when colliding

我的模拟是什么样的:image

所有圆圈都在矩形内弹跳。所有对象的恢复设置为 1.f,摩擦设置为 0.f。

不知何故,由于发生了大量碰撞,物体似乎随着时间的推移而加速。

这是因为浮点数不准确吗?我该如何解决这个问题?

使用大于零的阻尼系数 and/or 降低 1.f 的恢复力。调整这两个设置,直到获得所需的效果。是的,数值不准确会影响所见效果。

online Box2D 2.3.0 manual 还提供了以下见解:

When a shape develops multiple contacts, restitution is simulated approximately. This is because Box2D uses an iterative solver. Box2D also uses inelastic collisions when the collision velocity is small. This is done to prevent jitter. See b2_velocityThreshold in b2Settings.h.