X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FBody.hpp;h=6f85efd97b4946db46f224ef143e9b91ea1ec1b5;hb=1c385fe716fda927843cdbb83805bc467f517f92;hp=5f82be232b4dc3e78029fd27338b122ab4a41421;hpb=98770f59a02c76f02de0a46ed36d9cfd52f5071b;p=blobs.git diff --git a/src/world/Body.hpp b/src/world/Body.hpp index 5f82be2..6f85efd 100644 --- a/src/world/Body.hpp +++ b/src/world/Body.hpp @@ -2,8 +2,10 @@ #define BLOBS_WORLD_BODY_HPP_ #include "Orbit.hpp" -#include "../graphics/glm.hpp" +#include "../math/geometry.hpp" +#include "../math/glm.hpp" +#include #include @@ -11,6 +13,9 @@ namespace blobs { namespace app { class Assets; } +namespace creature { + class Creature; +} namespace graphics { class Viewport; } @@ -32,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; @@ -43,6 +49,9 @@ public: const std::vector &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; } @@ -69,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; } @@ -81,7 +98,18 @@ public: virtual void Draw(app::Assets &, graphics::Viewport &) { } + void Tick(double dt); void Cache() noexcept; + void CheckCollision() noexcept; + + void AddCreature(creature::Creature *); + void RemoveCreature(creature::Creature *); + std::vector &Creatures() noexcept { return creatures; } + const std::vector &Creatures() const noexcept { return creatures; } + + void Atmosphere(int a) noexcept { atmosphere = a; } + int Atmosphere() const noexcept { return atmosphere; } + bool HasAtmosphere() const noexcept { return atmosphere >= 0; } private: void AddChild(Body &); @@ -91,6 +119,7 @@ private: Simulation *sim; Body *parent; std::vector children; + std::string name; double mass; double radius; Orbit orbit; @@ -104,6 +133,9 @@ private: glm::dmat4 local; glm::dmat4 inverse_local; + std::vector creatures; + int atmosphere; + }; }