Box2DX.Dynamics.ContactManager.PairAdded C# (CSharp) Метод

PairAdded() публичный Метод

public PairAdded ( object proxyUserData1, object proxyUserData2 ) : object
proxyUserData1 object
proxyUserData2 object
Результат object
        public override object PairAdded(object proxyUserData1, object proxyUserData2)
        {
            Shape shape1 = proxyUserData1 as Shape;
            Shape shape2 = proxyUserData2 as Shape;

            Body body1 = shape1.GetBody();
            Body body2 = shape2.GetBody();

            if (body1.IsStatic() && body2.IsStatic())
            {
                return _nullContact;
            }

            if (shape1.GetBody() == shape2.GetBody())
            {
                return _nullContact;
            }

            if (body2.IsConnected(body1))
            {
                return _nullContact;
            }

            if (_world._contactFilter != null && _world._contactFilter.ShouldCollide(shape1, shape2) == false)
            {
                return _nullContact;
            }

            // Call the factory.
            Contact c = Contact.Create(shape1, shape2);

            if (c == null)
            {
                return _nullContact;
            }

            // Contact creation may swap shapes.
            shape1 = c.GetShape1();
            shape2 = c.GetShape2();
            body1 = shape1.GetBody();
            body2 = shape2.GetBody();

            // Insert into the world.
            c._prev = null;
            c._next = _world._contactList;
            if (_world._contactList != null)
            {
                _world._contactList._prev = c;
            }
            _world._contactList = c;

            // Connect to island graph.

            // Connect to body 1
            c._node1.Contact = c;
            c._node1.Other = body2;

            c._node1.Prev = null;
            c._node1.Next = body1._contactList;
            if (body1._contactList != null)
            {
                body1._contactList.Prev = c._node1;
            }
            body1._contactList = c._node1;

            // Connect to body 2
            c._node2.Contact = c;
            c._node2.Other = body1;

            c._node2.Prev = null;
            c._node2.Next = body2._contactList;
            if (body2._contactList != null)
            {
                body2._contactList.Prev = c._node2;
            }
            body2._contactList = c._node2;

            ++_world._contactCount;
            return c;
        }