Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Undo Tear
#1
Hi everyone!
I recently discovered the Tear function which is perfect for our game in order to cut the rope between two game objects.
Our other feature is to be able to undo that tear by progressively moving one of the cut ropes to its other fragment until they are linked again.
Is that something achievable with the current version of ObiRope?

Thanks in advance!
Reply
#2
(21-08-2020, 03:34 PM)flaurens Wrote: Hi everyone!
I recently discovered the Tear function which is perfect for our game in order to cut the rope between two game objects.
Our other feature is to be able to undo that tear by progressively moving one of the cut ropes to its other fragment until they are linked again.
Is that something achievable with the current version of ObiRope?

Thanks in advance!

Unfortunately not. Rope tearing is a topology change, that cannot be undone except by re-loading the rope blueprint. You can't "re-weld" together torn pieces of rope.
Reply
#3
(21-08-2020, 04:23 PM)josemendez Wrote: Unfortunately not. Rope tearing is a topology change, that cannot be undone except by re-loading the rope blueprint. You can't "re-weld" together torn pieces of rope.
Ok I understand, Is there any method to do the re-loading of the blueprint? Or I have to do it manually?
When you say blueprint I understand that you talk about the blueprint field on the ObiRope component right?

PS: I know that you said that is not possible to undo the tearing process, but I was wondering if it's possible to move one of the particles (once the rope has been cut) in order to go to the other constrain particle (where the tear has occurred)
Reply
#4
(21-08-2020, 04:23 PM)josemendez Wrote: Unfortunately not. Rope tearing is a topology change, that cannot be undone except by re-loading the rope blueprint. You can't "re-weld" together torn pieces of rope.

Hi, why can't we just do this ?
Code:
public static void MergeParticles( this Obi.ObiRope obiRope, int indexOfElementBefore, int indexOfElementOfInterest )
{
    var solver = obiRope.solver;
            
    var previousElement   = obiRope.elements[ indexOfElementBefore ];
    var elementOfInterest = obiRope.elements[ indexOfElementOfInterest ];

    // Revert previous halving of the particle mass.
    solver.invMasses[ previousElement.particle2 ] /= 2;

    obiRope.DeactivateParticle( solver.particleToActor[ elementOfInterest.particle1 ].indexInActor );

    elementOfInterest.particle1 = previousElement.particle2;
}


Followed by a
Code:
obiRope.RebuildConstraintsFromElements();

It works for my use case by the way, it perfectly welds torn pieces of Rope back, with a satisfying snap-back I might add.
Reply