@@ -325,6 +325,7 @@ void PhysicsManager::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
325325 b2FixtureData_map fxdata = fixtureMapSolidBlock->GetUserData ();
326326 PhysicsComponent* physicsObject = (PhysicsComponent*) fixturePed->GetBody ()->GetUserData ();
327327 debug_assert (physicsObject);
328+
328329 // detect height
329330 float height = gGameMap .GetHeightAtPosition (physicsObject->GetPosition ());
330331 hasCollision = HasCollisionPedestrianVsMap (fxdata.mX , fxdata.mZ , height);
@@ -406,7 +407,7 @@ void PhysicsManager::FixedStepGravity()
406407 // process fall
407408 float newHeight = gGameMap .GetHeightAtPosition (position, false );
408409
409- bool onTheGround = newHeight > (position.y - 0 .01f );
410+ bool onTheGround = newHeight > (position.y - 0 .00f );
410411 if (physicsComponent->mFalling )
411412 {
412413 if (onTheGround)
@@ -452,23 +453,24 @@ bool PhysicsManager::CollidePedVsPed(b2Contact* contact, PedPhysicsComponent* pe
452453
453454bool PhysicsManager::HasCollisionPedestrianVsMap (int mapx, int mapz, float height) const
454455{
455- int map_layer = (int ) (height + 0 .5f );
456+ int mapLayer = (int ) (Convert::MetersToMapUnits ( height) + 0 .5f );
456457
457458 // todo: temporary implementation
458459
459- BlockStyle* blockData = gGameMap .GetBlockClamp (mapx, mapz, map_layer );
460+ BlockStyle* blockData = gGameMap .GetBlockClamp (mapx, mapz, mapLayer );
460461 return (blockData->mGroundType == eGroundType_Building);
461462}
462463
463464bool PhysicsManager::HasCollisionCarVsMap (b2Contact* contact, b2Fixture* fixtureCar, int mapx, int mapz) const
464465{
465466 CarPhysicsComponent* carPhysicsComponent = (CarPhysicsComponent*) fixtureCar->GetBody ()->GetUserData ();
466467 debug_assert (carPhysicsComponent);
467- int map_layer = (int ) (carPhysicsComponent->mHeight + 0 .5f );
468+
469+ int mapLayer = (int ) (Convert::MetersToMapUnits (carPhysicsComponent->mHeight ) + 0 .5f );
468470
469471 // todo: temporary implementation
470472
471- BlockStyle* blockData = gGameMap .GetBlockClamp (mapx, mapz, map_layer );
473+ BlockStyle* blockData = gGameMap .GetBlockClamp (mapx, mapz, mapLayer );
472474 return (blockData->mGroundType == eGroundType_Building);
473475}
474476
0 commit comments