]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/world.cpp
real days
[blobs.git] / src / world / world.cpp
index 2f0d130312916bd6a289ae9bcc2ca50c7f9cce2b..525222f284b77c9c6bc57cd3a40df77849be5fd8 100644 (file)
@@ -115,6 +115,16 @@ double Body::RotationalPeriod() const noexcept {
        }
 }
 
+double Body::DayLength() const noexcept {
+       if (!HasParent()) {
+               return RotationalPeriod();
+       }
+       double year = OrbitalPeriod();
+       double sidereal = RotationalPeriod();
+       double grade = (angular < 0.0 ? -1.0 : 1.0) * (std::abs(axis_tilt.x) > PI * 0.5 ? -1.0 : 1.0);
+       return std::abs((year * sidereal) / ( year + (grade * sidereal)));
+}
+
 double Body::SphereOfInfluence() const noexcept {
        if (HasParent()) {
                return orbit.SemiMajorAxis() * std::pow(Mass() / Parent().Mass(), 2.0 / 5.0);
@@ -208,11 +218,12 @@ void Body::CheckCollision() noexcept {
                }
        }
        for (auto &c : collisions) {
+               c.A().OnCollide(c.B());
+               c.B().OnCollide(c.A());
                c.A().GetSituation().Move(c.Normal() * (c.Depth() * -0.5));
                c.B().GetSituation().Move(c.Normal() * (c.Depth() * 0.5));
                c.A().GetSituation().Accelerate(c.Normal() * -glm::dot(c.Normal(), c.AVel()));
                c.B().GetSituation().Accelerate(c.Normal() * -glm::dot(c.Normal(), c.BVel()));
-               // TODO: notify participants so they can be annoyed
        }
 }