Example #1
0
void 
HumanPhysics::HandleContact(b2Contact* contact, bool began)
{
	b2Fixture* pA = contact->GetFixtureA();
	b2Fixture* pB = contact->GetFixtureB();
	if (!pA || !pB)
	{
		return;
	}

    FixtureUserData* fudA = (FixtureUserData*)pA->GetUserData();
    FixtureUserData* fudB = (FixtureUserData*)pB->GetUserData();
    if (!fudA || !fudB)
	{
		return;
	}

    if (fudA->getType() == PHYSICS_FIXTURE_TYPE_ZOMBIE || fudB->getType() == PHYSICS_FIXTURE_TYPE_GROUND)
	{
		HumanVsGroundArea(pA, pB, began);
	}
	else if (fudA->getType() == PHYSICS_FIXTURE_TYPE_GROUND || fudB->getType() == PHYSICS_FIXTURE_TYPE_ZOMBIE)
	{
		HumanVsGroundArea(pB, pA, began);
	}
}
void handleContact(b2Contact* contact, bool began)
{
	b2Fixture* a = contact->GetFixtureA();
	b2Fixture* b = contact->GetFixtureB();
	FixtureUserData* fudA = (FixtureUserData*)a->GetUserData();
	FixtureUserData* fudB = (FixtureUserData*)b->GetUserData();

	if ( !fudA || !fudB )
	{
		return;
	}

	if ( fudA->getType() == FUD_CAR_TIRE || fudB->getType() == FUD_GROUND_AREA )
	{
		tire_vs_groundArea(a, b, began);
	}
	else if ( fudA->getType() == FUD_GROUND_AREA || fudB->getType() == FUD_CAR_TIRE )
	{
		tire_vs_groundArea(b, a, began);
	}
}
Example #3
0
void RaceManager::handleContact(b2Contact* contact, bool began)
{
	b2Fixture* a = contact->GetFixtureA();
	b2Fixture* b = contact->GetFixtureB();
	FixtureUserData* fudA = (FixtureUserData*)a->GetUserData();
	FixtureUserData* fudB = (FixtureUserData*)b->GetUserData();

	if (a->GetFilterData().categoryBits == CATEGORY_STATIC && fudA == NULL)
	{
		if (fudB != NULL && fudB->getType() == FUD_CAR)
		{
			TopdownCar* car = getCarFromID(((CarFUD*)fudB)->getId());
			if (car != NULL)
			{
				car->getFitnessData()->data[FT_NUMCRASHES]++;
			}
		}
	}
	if (b->GetFilterData().categoryBits == CATEGORY_STATIC && fudB == NULL)
	{
		if (fudA != NULL && fudA->getType() == FUD_CAR)
		{
			TopdownCar* car = getCarFromID(((CarFUD*)fudA)->getId());
			if (car != NULL)
			{
				car->getFitnessData()->data[FT_NUMCRASHES]++;
			}
		}
	}

	if (!fudA || !fudB)
		return;


	if (fudA->getType() == FUD_CAR || fudB->getType() == FUD_RACE_SECTOR)
		carVsGroundArea(a, b, began);
	else if (fudA->getType() == FUD_RACE_SECTOR || fudB->getType() == FUD_CAR)
		carVsGroundArea(b, a, began);
}