(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.