VPhysics-Jolt icon indicating copy to clipboard operation
VPhysics-Jolt copied to clipboard

Should pulleys be supported?

Open jrouwe opened this issue 1 year ago • 4 comments

Hello,

Looking at the feature matrix there's a big cross next to 'Pully'. Should I implement pulley support for Jolt (I assume we're talking about a rope and pulley system as described here https://en.wikipedia.org/wiki/Pulley)?

The way I envision this working is similar to a GearConstraint. Basically you create 2 SliderConstraints to constrain both bodies at the end of a rope to a linear path. Then there will be a PulleyConstraint that links SliderConstraint::GetCurrentPosition of the 1st constraint to the 2nd via a ratio.

Would that allow you to implement it?

jrouwe avatar Aug 29 '22 20:08 jrouwe

That sounds like a step in the right direction.

What we get on our end is the two object positions, the two pulley points, a ratio, whether or not the rope in the pulley is slack/rigid or not, the total length of the rope in the pulley system (excluding parts not under tension, so ignoring the horizontal that's just visual and does not affect the system) .

Joshua-Ashton avatar Aug 29 '22 21:08 Joshua-Ashton

This corresponds to phys_pulleyconstraint. How it functioned was more like a distance constraint, implementing things like this: image The two cages are the physics bodies, suspended from the two pulley points above.

TeamSpen210 avatar Aug 31 '22 08:08 TeamSpen210

Thanks! It sounds a bit more complicated than what I had in mind but I'll try to make something.

jrouwe avatar Aug 31 '22 19:08 jrouwe

I just submitted support for pulley joints. I think it should trivially map onto the source engine:

mFixedPosition1/2 = pulleyPosition[0/1] mBodyPosition1/2 = objectPosition[0/1] mMinLength = isRigid? totalLength : 0 mMaxLength = totalLength mRatio = gearRatio

https://github.com/jrouwe/JoltPhysics/commit/a30434a1b921d58120bb056aedc46afcadf88aab

jrouwe avatar Sep 11 '22 14:09 jrouwe