public Object pairAdded(final Object proxyUserData1, final Object proxyUserData2) { Shape shape1 = (Shape) proxyUserData1; Shape shape2 = (Shape) proxyUserData2; Body body1 = shape1.getBody(); Body body2 = shape2.getBody(); if (body1.isStatic() && body2.isStatic()) { return m_nullContact; } if (shape1.getBody() == shape2.getBody()) { return m_nullContact; } if (body2.isConnected(body1)) { return m_nullContact; } if (m_world.m_contactFilter != null && m_world.m_contactFilter.shouldCollide(shape1, shape2) == false) { return m_nullContact; } // Call the factory. final Contact c = Contact.createContact(shape1, shape2); if (c == null) { return m_nullContact; } // Contact creation may swap shapes. shape1 = c.getShape1(); shape2 = c.getShape2(); body1 = shape1.getBody(); body2 = shape2.getBody(); // Insert into the world. c.m_prev = null; c.m_next = m_world.m_contactList; if (m_world.m_contactList != null) { m_world.m_contactList.m_prev = c; } m_world.m_contactList = c; // Connect to island graph. // Connect to body 1 c.m_node1.contact = c; c.m_node1.other = body2; c.m_node1.prev = null; c.m_node1.next = body1.m_contactList; if (body1.m_contactList != null) { body1.m_contactList.prev = c.m_node1; } body1.m_contactList = c.m_node1; // Connect to body 2 c.m_node2.contact = c; c.m_node2.other = body1; c.m_node2.prev = null; c.m_node2.next = body2.m_contactList; if (body2.m_contactList != null) { body2.m_contactList.prev = c.m_node2; } body2.m_contactList = c.m_node2; ++m_world.m_contactCount; return c; }