04-02-2018, 10:08 PM
(This post was last modified: 04-02-2018, 10:31 PM by josemendez.)
(04-02-2018, 08:03 PM)jonworks Wrote: I feel like if there were a direct solver for something like tethers that could be applied after the iterative solver has done its thing, this problem could be solved. All it would do is start at the fixed particle and then move the first particle toward the fixed particle such that the constraint is never violated, then move the 2nd particle toward the first particle and etc. The correction would be minuscule because it would happen every frame so a large deviation could never accumulate. Is there any way to set this up? (Possibly does the api allow direct manipulation of particle positions after the iterative solver runs?)
This algorithm you describe is called FTL (follow the leader):http://matthias-mueller-fischer.ch/publications/FTLHairFur.pdf. A similar idea is the basis for the FABRIK IK solver.
Unfortunately, its raw version which is the one you described doesn't work at all for dynamic simulation. The issue with this approach is that every constraint behaves as if the previous particle has infinite mass (as it is only allowed to move the next one). As a result, the rope behaves in a extremely weird way, similar to a whip. The only solution is to modify particle velocities in a non-physical way, which introduces a lot of damping (dynamic follow the leader or DFTL). This method is generally used for hair simulation, as it is very cheap and hair itself usually has a lot of damping due to air drag and collisions with neighboring hairs, so the weird behavior and high damping are not a big problem. Tried it for ropes, and believe me it does not look like a rope.
I also experimented with a direct tridiagonal matrix solver (the Thomas algorithm), and it was even included in Obi for a short time (versions 2.0-2.3 I believe) with the name of "Chain constraints". It does yield a perfectly stiff rope in a single iteration and unlike DFTL it supported fixing the rope at arbitrary points (not just one end). However it becomes extremely unstable when there's no possible solution to the equation system (e.g, an overstretched rope) due to the linearization of the problem. In the end it caused more pain than it was worth, so we just dropped it from Obi. Distance constraints at low timesteps work much better, take less time to calculate, and are unconditionally stable.
(04-02-2018, 08:03 PM)jonworks Wrote: It's probably a little hacky and I wouldn't suggest it except that I'm really floundering trying to get this to work. When I apply tethers for each particle linked to the fixed particle the rope always wants to fold into a squiggly line and rotate around never settling down. And when I pull the rope (use cursor to reduce the length) it becomes extremely jerky like tugging the rope every few frames instead of pulling it smoothly. I've tried other tether strategies like changing the stiffness, only tethering every nth particle to the fixed particle, and even chaining them together (like tethering the 32nd particle to the 24th, the 28th to the 20th and etc). Nothing seems to give me anything other than a rubber band or a squiggly line that won't shorten with any degree of stability.
May I ask, what exactly is your end goal? tethers have proven to behave in a more than acceptable way for most cases (pendulums, cranes, etc), and reducing the timestep/increasing iterations with just distance constraints works also really good for most uses. Unless you need very long ropes (+10 meters) with very accurate collision detection and absolutely zero compliance, It shouldn't be difficult at all to get quite realistic rope simulation going on. At this point I'm a bit baffled that none of the proposed solutions worked well enough for you. Maybe I can offer better help if I understand what you're after.
cheers!