dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.97k stars 248 forks source link

Revolute joint limits not working #523

Closed noih closed 8 months ago

noih commented 1 year ago

I followed the example in the document, and the code is as follows:

const param = RAPIER.JointData.revolute({ x: 0, y: 0 }, { x: 0, y: 0 })
param.limitsEnabled = true
param.limits = [-45 * (Math.PI / 180),  45 * (Math.PI / 180)]
const joint = world.createImpulseJoint(param, body1, body2, true)

body1 is a square, body2 is a long and narrow rectangle, with the joint connecting their centers, and the rectangle being larger than the square.

When the rectangle collides with something, the rotation angle isn't restricted. Did I misunderstand the meaning of "limits"?

https://github.com/dimforge/rapier/assets/33519169/89483811-e60d-4d96-a58e-871ece54b9ce

JS @dimforge/rapier2d 0.11.2

sebcrozet commented 8 months ago

There was a bug with the way joint limits were specified, addressed in https://github.com/dimforge/rapier/pull/579. I recommend trying again with rapier JS 0.12, and reopen this issue if the problem persists.