30-09-2019, 01:07 PM
(This post was last modified: 30-09-2019, 01:17 PM by josemendez.)
I don't think I understand the original question. To determine the length of a rope (including any stretching/compression), simply do:
This works regardless of your rope/solver parameters, and will always return the actual length of your rope.
However, you also mention that the rope stretches too much. This is probably due to excessive rope resolution, resulting in lots of particles/constraints, that need a large amount of iterations and/or a short timestep to converge.
Also, having a distance constraint stretching scale of 0.01 will set the rope target length to 1% of its rest (initial) length. This is most probably not what you want, set it to 1 (100%) instead.
If by "determine" you mean "set", it depends. You can always correctly determine the length of the rope as I showed earlier, no matter what your parameters are. Now, whether the rest length of the rope can be reached at runtime (0% stretch), depends on whether your time budget (determined by the timestep and amount of iterations) is enough for the solver to do all the work. If it has to stop before reaching convergence (because you limited iterations to a low number, or have a large timestep), the residual error will manifest as unwanted stretching.
Note this is not specific to Obi, all iterative engines (99% of game engines/physics solvers) work like this.
Also, to change the simulation timestep you don't need to globally adjust the timestep of your scene if you can't/don't want to. You can just use substeps:
http://obi.virtualmethodstudio.com/tutor...olver.html
Code:
float length = rope.CalculateLength();
This works regardless of your rope/solver parameters, and will always return the actual length of your rope.
However, you also mention that the rope stretches too much. This is probably due to excessive rope resolution, resulting in lots of particles/constraints, that need a large amount of iterations and/or a short timestep to converge.
Also, having a distance constraint stretching scale of 0.01 will set the rope target length to 1% of its rest (initial) length. This is most probably not what you want, set it to 1 (100%) instead.
Code:
Okay, let's try a simple yes-or-no question:
Could it be that it is technically not possible to determine the length of an Obi Rope without changing overall parameters like the time step?
If by "determine" you mean "set", it depends. You can always correctly determine the length of the rope as I showed earlier, no matter what your parameters are. Now, whether the rest length of the rope can be reached at runtime (0% stretch), depends on whether your time budget (determined by the timestep and amount of iterations) is enough for the solver to do all the work. If it has to stop before reaching convergence (because you limited iterations to a low number, or have a large timestep), the residual error will manifest as unwanted stretching.
Note this is not specific to Obi, all iterative engines (99% of game engines/physics solvers) work like this.
Also, to change the simulation timestep you don't need to globally adjust the timestep of your scene if you can't/don't want to. You can just use substeps:
http://obi.virtualmethodstudio.com/tutor...olver.html