]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/Body.hpp
real days
[blobs.git] / src / world / Body.hpp
index df68984915bdf8e22b375280c7df6a10f073a449..6f85efd97b4946db46f224ef143e9b91ea1ec1b5 100644 (file)
@@ -2,8 +2,10 @@
 #define BLOBS_WORLD_BODY_HPP_
 
 #include "Orbit.hpp"
+#include "../math/geometry.hpp"
 #include "../math/glm.hpp"
 
+#include <string>
 #include <vector>
 
 
@@ -35,6 +37,7 @@ public:
 
 public:
        bool HasSimulation() const noexcept { return sim; }
+       Simulation &GetSimulation() noexcept { return *sim; }
        const Simulation &GetSimulation() const noexcept { return *sim; }
        void SetSimulation(Simulation &) noexcept;
 
@@ -46,6 +49,9 @@ public:
 
        const std::vector<Body *> &Children() const noexcept { return children; }
 
+       const std::string &Name() const noexcept { return name; }
+       void Name(const std::string &n) noexcept { name = n; }
+
        double Mass() const noexcept { return mass; }
        void Mass(double m) noexcept { mass = m; }
 
@@ -72,6 +78,14 @@ public:
        double GravitationalParameter() const noexcept;
        double OrbitalPeriod() const noexcept;
        double RotationalPeriod() const noexcept;
+       /// day length relative to parent, not neccessarily a sun
+       /// gives absolute value in seconds
+       /// returns sidereal day for parent-less bodies
+       double DayLength() const noexcept;
+       double SphereOfInfluence() const noexcept;
+
+       math::Sphere CollisionBounds() const noexcept { return math::Sphere{ glm::dvec3(0.0), Radius() }; }
+       const glm::dmat4 &CollisionTransform() const noexcept { return local; }
 
        const glm::dmat4 &LocalTransform() const noexcept { return local; }
        const glm::dmat4 &InverseTransform() const noexcept { return inverse_local; }
@@ -86,8 +100,8 @@ public:
 
        void Tick(double dt);
        void Cache() noexcept;
+       void CheckCollision() noexcept;
 
-       // body takes over ownership of given pointer
        void AddCreature(creature::Creature *);
        void RemoveCreature(creature::Creature *);
        std::vector<creature::Creature *> &Creatures() noexcept { return creatures; }
@@ -105,6 +119,7 @@ private:
        Simulation *sim;
        Body *parent;
        std::vector<Body *> children;
+       std::string name;
        double mass;
        double radius;
        Orbit orbit;