X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fworld%2Fworld.cpp;h=c22434a47c754b8f3b028bcbabcb8888c04d7671;hp=02c142ac5af08f52ecd42114bc8b6019d556bcad;hb=3989da924c4e33c52f500aead5ae62bb40294781;hpb=41ee8b5d0229752576a55e102d8510ea1dbc909b diff --git a/src/world/world.cpp b/src/world/world.cpp index 02c142a..c22434a 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -115,6 +115,14 @@ double Body::RotationalPeriod() const noexcept { } } +double Body::SphereOfInfluence() const noexcept { + if (HasParent()) { + return orbit.SemiMajorAxis() * std::pow(Mass() / Parent().Mass(), 2.0 / 5.0); + } else { + return std::numeric_limits::infinity(); + } +} + glm::dmat4 Body::ToUniverse() const noexcept { glm::dmat4 m(1.0); const Body *b = this; @@ -184,13 +192,13 @@ void Body::CheckCollision() noexcept { collisions.clear(); auto end = Creatures().end(); for (auto i = Creatures().begin(); i != end; ++i) { - math::AABB i_box((*i)->CollisionBox()); + math::AABB i_box((*i)->CollisionBounds()); glm::dmat4 i_mat((*i)->CollisionTransform()); for (auto j = (i + 1); j != end; ++j) { glm::dvec3 diff((*i)->GetSituation().Position() - (*j)->GetSituation().Position()); double max_dist = ((*i)->Size() + (*j)->Size()) * 1.74; if (glm::length2(diff) > max_dist * max_dist) continue; - math::AABB j_box((*j)->CollisionBox()); + math::AABB j_box((*j)->CollisionBounds()); glm::dmat4 j_mat((*j)->CollisionTransform()); glm::dvec3 normal; double depth;