Obi Official Forum
Possible Bug in ObiRopeCursor Class Leading to Infinite Rope Length - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Possible Bug in ObiRopeCursor Class Leading to Infinite Rope Length (/thread-4342.html)



Possible Bug in ObiRopeCursor Class Leading to Infinite Rope Length - Destro26 - 25-08-2024

Hi. I've recently upgraded to Obi 7 and believe I've encountered a bug in the "ObiRopeCursor" class. Specifically, I'm able to increase the length of a rope indefinitely.

The issue arises when the maximum number of particles is reached. As the rope's length continues to increase, additional length is added to "m_CursorElement.restLength", but there appears to be no limit in place. This causes a section of the rope to appear as a straight line, which doesn't seem intended.

To confirm, I replicated this issue in the Crane example scene within a fresh Unity project with Obi 7 installed.

I found a potential solution by modifying the code on line 208 in the Rope_OnSimulate method:

Original Code (Line 208):
Code:
// Line 208
if (lengthChange > 0)
m_CursorElement.restLength += lengthChange;

Proposed Solution:

Code:
if (lengthChange > 0 && m_CursorElement.restLength < rope.ropeBlueprint.interParticleDistance)
{
      m_CursorElement.restLength = Mathf.Min(m_CursorElement.restLength + lengthChange, rope.ropeBlueprint.interParticleDistance)
}

This change ensures that the 'restLength' does not exceed the 'interParticleDistance', preventing the unintended straight-line section of the rope.


RE: Possible Bug in ObiRopeCursor Class Leading to Infinite Rope Length - josemendez - 25-08-2024

Hi!

This change is intentional, requested by several users. Once the rope runs out of pooled particles, it is not possible to keep resolution constant anymore but is conceptually possible to continue making the rope longer. So even though there's no more particles available, the total length of the rope is increased by making the element where the cursor is placed longer.

If you need the old behavior, a simple way to obtain it is to clamp the change in length passed to ChangeLength() so that the resulting rest length doesn't exceed a desired maximum length.

Let me know if you need further help,

kind regards


RE: Possible Bug in ObiRopeCursor Class Leading to Infinite Rope Length - Destro26 - 25-08-2024

ah that makes sense. Thanks for the quick reply.

I have been having a few issues with upgrading from Obi 6. I'll probably make another post about it in a few days once I'm able to better explain the issues.

Thanks