]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/Body.hpp
basic creature model
[blobs.git] / src / world / Body.hpp
index 1b9e2e3a2a65036b75f370aa47a58b3730374545..fba121b90995d113c2fad374c39db8bd7ae28942 100644 (file)
@@ -16,6 +16,7 @@ namespace graphics {
 }
 namespace world {
 
+class Creature;
 class Simulation;
 
 class Body {
@@ -70,14 +71,24 @@ public:
        double OrbitalPeriod() const noexcept;
        double RotationalPeriod() const noexcept;
 
-       glm::dmat4 LocalTransform() const noexcept;
-       glm::dmat4 InverseTransform() const noexcept;
+       const glm::dmat4 &LocalTransform() const noexcept { return local; }
+       const glm::dmat4 &InverseTransform() const noexcept { return inverse_local; }
 
-       glm::dmat4 ToParent() const noexcept;
-       glm::dmat4 FromParent() const noexcept;
+       const glm::dmat4 &ToParent() const noexcept { return inverse_orbital; }
+       const glm::dmat4 &FromParent() const noexcept { return orbital; }
+
+       glm::dmat4 ToUniverse() const noexcept;
+       glm::dmat4 FromUniverse() const noexcept;
 
        virtual void Draw(app::Assets &, graphics::Viewport &) { }
 
+       void Cache() noexcept;
+
+       // body takes over ownership of given pointer
+       void AddCreature(Creature *);
+       std::vector<Creature *> &Creatures() noexcept { return creatures; }
+       const std::vector<Creature *> &Creatures() const noexcept { return creatures; }
+
 private:
        void AddChild(Body &);
        void RemoveChild(Body &);
@@ -94,6 +105,13 @@ private:
        double rotation;
        double angular;
 
+       glm::dmat4 orbital;
+       glm::dmat4 inverse_orbital;
+       glm::dmat4 local;
+       glm::dmat4 inverse_local;
+
+       std::vector<Creature *> creatures;
+
 };
 
 }