Rope: Stretchable and non-stretchable

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Posts: 92
Joined: Fri Apr 17, 2015 11:42 pm

Rope: Stretchable and non-stretchable

Post by mcmonkey » Wed Oct 19, 2016 11:54 pm

For some insane reason, I have decided it would be useful to simulate a rope.

A rope reasonably can wrap around objects and extend to a known-at-construction-time base length.

Two forms of rope exist in my conceptualize of how rope works: Stretchable and non-stretchable.

Non-stretchable is theoretically the simpler form, it would simple behave like a rope - wrapping around things or just lying flat or hanging. It should be able to carry weight (within reason).

Stretchable rope is a bit more complex, it does all that but stretches based on how much force is pulling it apart, and it makes an attempt with a bit of force to bring it back to the base length any chance it gets.
It would scale in a sane manner: no force pulling = base length, some force = some stretching, much force = more stretching, but not as much relative stretching. What I mean is, if you move from 10 units of force to 100 units of force, it would maybe double in stretched length, and NOT stretch ten times longer. Probably a log scale or similar here.

I imagine the basic set up is a long chain of small static physical objects - cylinders perhaps, or thin boxes. connected by joints. However, this wouldn't stretch well without some applied cleverness, and I'm also not sure which joints within BEPU would best manage either type of rope.

So the question is: How would you set up each type of rope? If there are multiple ways to try it, what are the advantages and disadvantages of each method?

In an ideal "best situation", one should be able to stretch a rope around a cylindrical pole, and then release it, and watch it whip around rapidly at first then slowing as it unwraps the pole to shorten it's stretch length.

Site Admin
Posts: 4815
Joined: Tue Jul 04, 2006 4:45 am

Re: Rope: Stretchable and non-stretchable

Post by Norbo » Thu Oct 20, 2016 3:29 am

The good news:
All constraints in BEPUphysics are, in fact, springs that happen to be very rigid by default. So it's actually not a question of stretchy versus not stretchy, but rather just how stretchy. Adjusting the stiffness and damping constants within the SpringSettings of constraints can support the desired behaviors. A bunch of demos use this functionality; check out the SelfCollidingClothDemo and the SuspensionCarDemo for a couple of examples.

So, a bunch of entities connected by BallSocketJoints would do the trick. You'll probably want to disable collisions between directly connected entities and make sure that the joint anchors are touching or within the volume of their involved entities to avoid long lever arms.

The bad news:
Ropes are a pathological case for the most common form of game physics solvers. In the current solver of BEPUphysics, you'll probably have to bite at least one of these bullets:
1) A high number of solver iterations.
2) A short time step duration.
3) Not many entity links composing the ropes.
4) Not much mass relying on the rope relative to the mass of the rope.
5) Links down the rope chain may need to have progressively less mass.
6) Scale up the inertia tensor on the individual links.

#1 and #2 are the 'brute force' solution. If you have the spare CPU cycles to burn, it usually produces the best results.

Unfortunately, it can sometimes be difficult to get complex articulated structures with high mass ratios (like ropes) working great in a reasonable budget. This type of solver simply isn't ideal for it. The best solution would look like a specialized subsolver that can guarantee good propagation of forces throughout the local constraint graph. For restricted subsets of the simulation, there are a lot of options available. I have had an eye on doing something in this vein for a long time but... it's going to be a while yet, if I get to it at all :P

Post Reply