An arbiter holds all contact information of two bodies. The contacts are stored in the ContactList. There is a maximum of four contacts which can be added to an arbiter. The arbiter only keeps the best four contacts based on the area spanned by the contact points.
Esempio n. 1
0
        private void UpdateArbiterContacts(Arbiter arbiter)
        {
            if (arbiter.contactList.Count == 0)
            {
                lock (removedArbiterStack) { removedArbiterStack.Push(arbiter); }
                return;
            }

            for (int i = arbiter.contactList.Count - 1; i >= 0; i--)
            {
                Contact c = arbiter.contactList[i];
                c.UpdatePosition();

                if (c.penetration < -contactSettings.breakThreshold)
                {
                    Contact.Pool.GiveBack(c);
                    arbiter.contactList.RemoveAt(i);
                    continue;
                }
                else
                {
                    JVector diff; JVector.Subtract(ref c.p1, ref c.p2, out diff);
                    float distance = JVector.Dot(ref diff, ref c.normal);

                    diff = diff - distance * c.normal;
                    distance = diff.LengthSquared();

                    // hack (multiplication by factor 100) in the
                    // following line.
                    if (distance > contactSettings.breakThreshold * contactSettings.breakThreshold * 100)
                    {
                        Contact.Pool.GiveBack(c);
                        arbiter.contactList.RemoveAt(i);
                        continue;
                    }
                }

            }
        }
Esempio n. 2
0
 internal void Add(ArbiterKey key, Arbiter arbiter)
 {
     dictionary.Add(key, arbiter);
 }
Esempio n. 3
0
 internal void Remove(Arbiter arbiter)
 {
     lookUpKey.SetBodies(arbiter.body1, arbiter.body2);
     dictionary.Remove(lookUpKey);
 }
Esempio n. 4
0
 public bool LookUpArbiter(RigidBody body1, RigidBody body2, out Arbiter arbiter)
 {
     lookUpKey.SetBodies(body1, body2);
     return(dictionary.TryGetValue(lookUpKey, out arbiter));
 }