Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Tearing Cloth manually with ParticleInActor.indexInActor...
#1
Hey,

I am seeing some issues trying to manually 'Tear()' a ObiTearableCloth, upon detecting a collision via the ObiSolver OnCollision event.

I'm using the following method:
Code:
    private void HandleSailCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e) {
        foreach(Oni.Contact contact in e.contacts) {
            if(contact.distance < 0.01) {
                Collider collider = ObiColliderBase.idToCollider[contact.other] as Collider;
                ObiSolver.ParticleInActor pa = sail.Solver.particleToActor[contact.particle];

                if(collider.tag == "Projectile" && pa.actor == sail) {
                    (sail as ObiTearableCloth).Tear(pa.indexInActor);
                    break;
                }
            }
        }
    }

This works, and Tear() is called with a valid particle index (I've also confirmed this is the index I'd expect, based on the collision - center of the Mesh), however the Tare() call fails. Triste

I can confirm the Logic flows through the following code, and that the particle to be Torn has invMass > 0. It is the following 'Oni' call - TearDeformableMeshAtVertex, that appears to be rejecting my Tear request (both calls to it return false). I'm not really sure on the inner workings of this, perhaps it is to do with 'updatedHalfEdges'?

Code:
        if (invMasses[splitIndex] == 0 ||
            !Oni.TearDeformableMeshAtVertex(deformableMesh,splitIndex,ref v1,ref normal,updatedHalfEdges,ref numUpdatedHalfEdges))
        {
            // Try to split the other particle:
            int aux = splitIndex;
            splitIndex = intactIndex;
           intactIndex = aux;

            v1 = transform.worldToLocalMatrix.MultiplyPoint3x4(solver.positions[particleIndices[splitIndex]]);
            v2 = transform.worldToLocalMatrix.MultiplyPoint3x4(solver.positions[particleIndices[intactIndex]]);
            normal = (v2-v1).normalized;
           
            if (invMasses[splitIndex] == 0 ||
                !Oni.TearDeformableMeshAtVertex(deformableMesh,splitIndex,ref v1,ref normal,updatedHalfEdges,ref numUpdatedHalfEdges))
                return;
        }

For context I am using a local space solver with world space ObiColliders.

My ObiTareableCloth has the following settings:
[Image: 888IDhw.png]
(I've set tearRate to 0, to ensure no 'miss-firings' and so Tears only happen when I explicitly call it)

Thanks again for the support, much appreacited!
Reply
#2
Sorry to *bump* this but still having issues with this. Any help would be greatly appreciated.
Reply