Ejemplo n.º 1
0
    void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        Oni.Contact[] contacts = e.contacts.Data;
        for (int i = 0; i < e.contacts.Count; ++i)
        {
            Oni.Contact c = contacts[i];
            // make sure this is an actual contact:
            if (c.distance < 0.01f)
            {
                // get the collider:
                Collider collider = ObiCollider.idToCollider[c.other] as Collider;

                if (collider != null)
                {
                    // make it blink:
                    Blinker blinker = collider.GetComponent <Blinker>();

                    if (blinker)
                    {
                        blinker.Blink();
                    }
                }
            }
        }
    }
    void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        var colliderWorld = ObiColliderWorld.GetInstance();

        Oni.Contact[] contacts = e.contacts.Data;
        for (int i = 0; i < e.contacts.Count; ++i)
        {
            Oni.Contact c = contacts[i];
            // make sure this is an actual contact:
            if (c.distance < 0.01f)
            {
                // get the collider:
                var col = colliderWorld.colliderHandles[c.other].owner;

                if (col != null)
                {
                    // make it blink:
                    Blinker blinker = col.GetComponent <Blinker>();

                    if (blinker)
                    {
                        blinker.Blink();
                    }
                }
            }
        }
    }
 private static int CompareByRef(ref Oni.Contact a, ref Oni.Contact b, ObiSolver solver)
 {
     if (a.other == b.other)
     {
         int hashA = solver.particleToActor[a.particle].actor.GetInstanceID();
         int hashB = solver.particleToActor[b.particle].actor.GetInstanceID();
         return(hashA.CompareTo(hashB));
     }
     return(a.other.CompareTo(b.other));
 }
Ejemplo n.º 4
0
        private void TriggerCollisionEvents()
        {
            int numCollisions = Oni.GetConstraintCount(oniSolver, (int)Oni.ConstraintType.Collision);

            if (OnCollision != null)
            {
                Oni.Contact[] contacts = new Oni.Contact[numCollisions];

                if (numCollisions > 0)
                {
                    Oni.GetCollisionContacts(oniSolver, contacts, numCollisions);
                }

                OnCollision(this, new ObiCollisionEventArgs(contacts));
            }
        }