+ glm::dvec3 force(steering.Force(s));
+ // gravity = antinormal * mass * Gm / r²
+ double elevation = s.pos[(situation.Surface() + 2) % 3];
+ glm::dvec3 normal(world::Planet::SurfaceNormal(situation.Surface()));
+ force += glm::dvec3(
+ -normal
+ * Mass() * situation.GetPlanet().GravitationalParameter()
+ / (elevation * elevation));
+ // if net force is applied and in contact with surface
+ if (!allzero(force) && std::abs(std::abs(elevation) - situation.GetPlanet().Radius()) < 0.001) {
+ // apply friction = -|normal force| * tangential force * coefficient
+ glm::dvec3 fn(normal * dot(force, normal));
+ glm::dvec3 ft(force - fn);
+ double u = 0.4;
+ glm::dvec3 friction(-length(fn) * ft * u);
+ force += friction;
+ }