rendered paste bodyvoid WorldObject::GetContactPoint( const WorldObject* runner, float &x, float &y, float &z, float distance ) const
{
Map* map = MapManager::Instance().GetMap(runner->GetMapId(), runner);
float zNew, angle, xTarget, yTarget;
x = runner->GetPositionX();
y = runner->GetPositionY();
z = map->GetHeight(x, y);
xTarget = GetPositionX();
yTarget = GetPositionY();
angle = runner->GetAngle(this); // This is GetAngleTo, so gave me Vector Director.
x += 0.5f * cos(angle);
y += 0.5f * sin(angle);
do
{
zNew = map->GetHeight(x, y);
if( sqrt((zNew*zNew)) <= sqrt((z*z)) + 1 )
{
z = zNew;
x += 0.5f * cos(angle);
y += 0.5f * sin(angle);
}
else
break;
}while(sqrt(runner->GetDistanceSq(x,y,0)) + (runner->GetObjectSize()/2) <
sqrt(runner->GetDistanceSq(xTarget, yTarget, 0)) );
}