Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ropes Lagging
#3
Thanks for the quick reply.

Here's my OnParticleCollisionCode:

Code:
private void Solver_OnParticleCollision (object sender, ObiSolver.ObiCollisionEventArgs e) {
       
        allNonCollidingRopes = new List<Ropes> (ropes);
        ObiSolver.ParticleInActor pa = null;
        ObiSolver.ParticleInActor po = null;

        Ropes r1 = null;
        Ropes r2 = null;

        int particleIndex = 0;
        int particleIndex2  = 0;
     
        foreach (var contact in e.contacts) {

            if (contact.distance < 0.01f) {

                int simplexStart = _solver.simplexCounts.GetSimplexStartAndSize (contact.bodyA, out int simplexSize);

                for (int i = 0; i < simplexSize; ++i) {
                    particleIndex = _solver.simplices[simplexStart + i];

                    pa = _solver.particleToActor[particleIndex];
                    r1 = pa.actor.transform.GetComponent<Ropes> ();
                }

                int simplexStart2 = _solver.simplexCounts.GetSimplexStartAndSize (contact.bodyB, out int simplexSize2);

                for (int i = 0; i < simplexSize2; ++i) {
                    particleIndex2 = _solver.simplices[simplexStart2 + i];

                    po = _solver.particleToActor[particleIndex2];
                    r2 = po.actor.transform.GetComponent<Ropes> ();
                }

                if (r1.attacht1 == r2.attacht1 || r1.attacht1 == r2.attacht2 || r1.attacht2 == r2.attacht1 || r1.attacht2 == r2.attacht2)
                {
                    pa = null;
                    po = null;
                }

                if (pa != null && po != null) {
                    r1.colliding = true;
                    r2.colliding = true;

                    allNonCollidingRopes.Remove (r1);
                    allNonCollidingRopes.Remove (r2);

                    if (r1.partnerRope == null && !r1.hasErrormark && r2.partnerRope != r1)
                    {
                        r1.partnerRope = r2;
                        r1.hasErrormark = true;
                        r1.errorMark.SetActive(true);
                    }

                    if (r1.partnerRope == r2)
                    {
                        r1.errorMarkPos = _solver.positions[particleIndex];
                    }

                    StopCoroutine(ResetRopes());
                }
            }
        }

        if (!resetRopes) {
            resetRopes = true;
            StartCoroutine (ResetRopes ());
        }
    }
Reply


Messages In This Thread
Ropes Lagging - by Gauri7 - 13-07-2022, 12:51 PM
RE: Ropes Lagging - by josemendez - 13-07-2022, 01:55 PM
RE: Ropes Lagging - by Gauri7 - 13-07-2022, 02:25 PM
RE: Ropes Lagging - by josemendez - 13-07-2022, 03:11 PM