FarseerPhysics.Dynamics.ContactManager.collide C# (CSharp) Method

collide() private method

private collide ( ) : void
return void
		internal void collide()
		{
			// Update awake contacts.
#if USE_ACTIVE_CONTACT_SET
			ActiveList.AddRange(ActiveContacts);

			foreach (var c in ActiveList)
			{
#else
			for( var i = 0; i < contactList.Count; i++ )
			{
				var c = contactList[i];
#endif
				var fixtureA = c.fixtureA;
				var fixtureB = c.fixtureB;
				var indexA = c.childIndexA;
				var indexB = c.childIndexB;
				var bodyA = fixtureA.body;
				var bodyB = fixtureB.body;

				// Do no try to collide disabled bodies
				if( !bodyA.enabled || !bodyB.enabled )
					continue;

				// Is this contact flagged for filtering?
				if( c.filterFlag )
				{
					// Should these bodies collide?
					if( bodyB.shouldCollide( bodyA ) == false )
					{
						var cNuke = c;
						destroy( cNuke );
						continue;
					}

					// Check default filtering
					if( shouldCollide( fixtureA, fixtureB ) == false )
					{
						var cNuke = c;
						destroy( cNuke );
						continue;
					}

					// Check user filtering.
					if( onContactFilter != null && onContactFilter( fixtureA, fixtureB ) == false )
					{
						var cNuke = c;
						destroy( cNuke );
						continue;
					}

					// Clear the filtering flag.
					c.filterFlag = false;
				}

				var activeA = bodyA.isAwake && bodyA.bodyType != BodyType.Static;
				var activeB = bodyB.isAwake && bodyB.bodyType != BodyType.Static;

				// At least one body must be awake and it must be dynamic or kinematic.
				if( activeA == false && activeB == false )
				{
#if USE_ACTIVE_CONTACT_SET
					ActiveContacts.Remove(c);
#endif
					continue;
				}

				var proxyIdA = fixtureA.proxies[indexA].proxyId;
				var proxyIdB = fixtureB.proxies[indexB].proxyId;

				var overlap = broadPhase.testOverlap( proxyIdA, proxyIdB );

				// Here we destroy contacts that cease to overlap in the broad-phase.
				if( overlap == false )
				{
					var cNuke = c;
					destroy( cNuke );
					continue;
				}

				// The contact persists.
				c.update( this );
			}

#if USE_ACTIVE_CONTACT_SET
			ActiveList.Clear();
#endif
		}