Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Undo Tear
#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


Messages In This Thread
Undo Tear - by flaurens - 21-08-2020, 03:34 PM
RE: Undo Tear - by josemendez - 21-08-2020, 04:23 PM
RE: Undo Tear - by flaurens - 21-08-2020, 04:34 PM
RE: Undo Tear - by sbrabi - 29-09-2022, 09:19 PM