X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fworld%2Fworld.cpp;h=d7e293a5509d2d456c88cbca5b09daa44fdb49ba;hp=9cd1e02df56a7f185a299f3337248cfbb22f417e;hb=b4deadd9f4e399207e2530ea39a447c0d9d260a3;hpb=f5fc0c2bd1c0d1e2737d2b4ed49c3de16aa67c67 diff --git a/src/world/world.cpp b/src/world/world.cpp index 9cd1e02..d7e293a 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -208,7 +208,8 @@ void Body::CheckCollision() noexcept { for (auto &c : collisions) { c.A().GetSituation().Move(c.Normal() * (c.Depth() * -0.5)); c.B().GetSituation().Move(c.Normal() * (c.Depth() * 0.5)); - // TODO: adjust velocities as well + c.A().GetSituation().Accelerate(c.Normal() * -dot(c.Normal(), c.AVel())); + c.B().GetSituation().Accelerate(c.Normal() * -dot(c.Normal(), c.BVel())); // TODO: notify participants so they can be annoyed } } @@ -232,10 +233,18 @@ const glm::dvec3 &CreatureCreatureCollision::APos() const noexcept { return a->GetSituation().Position(); } +const glm::dvec3 &CreatureCreatureCollision::AVel() const noexcept { + return a->GetSituation().Velocity(); +} + const glm::dvec3 &CreatureCreatureCollision::BPos() const noexcept { return b->GetSituation().Position(); } +const glm::dvec3 &CreatureCreatureCollision::BVel() const noexcept { + return b->GetSituation().Velocity(); +} + Orbit::Orbit() : sma(1.0)