1 #ifndef BLOBS_WORLD_BODY_HPP_
2 #define BLOBS_WORLD_BODY_HPP_
5 #include "../math/glm.hpp"
30 Body(const Body &) = delete;
31 Body &operator =(const Body &) = delete;
33 Body(Body &&) = delete;
34 Body &operator =(Body &&) = delete;
37 bool HasSimulation() const noexcept { return sim; }
38 Simulation &GetSimulation() noexcept { return *sim; }
39 const Simulation &GetSimulation() const noexcept { return *sim; }
40 void SetSimulation(Simulation &) noexcept;
42 bool HasParent() const { return parent; }
43 Body &Parent() { return *parent; }
44 const Body &Parent() const { return *parent; }
45 void SetParent(Body &);
48 const std::vector<Body *> &Children() const noexcept { return children; }
50 double Mass() const noexcept { return mass; }
51 void Mass(double m) noexcept { mass = m; }
53 double Radius() const noexcept { return radius; }
54 void Radius(double r) noexcept { radius = r; }
56 Orbit &GetOrbit() noexcept { return orbit; }
57 const Orbit &GetOrbit() const noexcept { return orbit; }
59 const glm::dvec2 &SurfaceTilt() const noexcept { return surface_tilt; }
60 void SurfaceTilt(const glm::dvec2 &t) noexcept { surface_tilt = t; }
62 const glm::dvec2 &AxialTilt() const noexcept { return axis_tilt; }
63 void AxialTilt(const glm::dvec2 &t) noexcept { axis_tilt = t; }
65 double Rotation() const noexcept { return rotation; }
66 void Rotation(double r) noexcept { rotation = r; }
68 double AngularMomentum() const noexcept { return angular; }
69 void AngularMomentum(double m) noexcept { angular = m; }
71 double Inertia() const noexcept;
73 double GravitationalParameter() const noexcept;
74 double OrbitalPeriod() const noexcept;
75 double RotationalPeriod() const noexcept;
77 const glm::dmat4 &LocalTransform() const noexcept { return local; }
78 const glm::dmat4 &InverseTransform() const noexcept { return inverse_local; }
80 const glm::dmat4 &ToParent() const noexcept { return inverse_orbital; }
81 const glm::dmat4 &FromParent() const noexcept { return orbital; }
83 glm::dmat4 ToUniverse() const noexcept;
84 glm::dmat4 FromUniverse() const noexcept;
86 virtual void Draw(app::Assets &, graphics::Viewport &) { }
89 void Cache() noexcept;
90 void CheckCollision() noexcept;
92 void AddCreature(creature::Creature *);
93 void RemoveCreature(creature::Creature *);
94 std::vector<creature::Creature *> &Creatures() noexcept { return creatures; }
95 const std::vector<creature::Creature *> &Creatures() const noexcept { return creatures; }
97 void Atmosphere(int a) noexcept { atmosphere = a; }
98 int Atmosphere() const noexcept { return atmosphere; }
99 bool HasAtmosphere() const noexcept { return atmosphere >= 0; }
102 void AddChild(Body &);
103 void RemoveChild(Body &);
108 std::vector<Body *> children;
112 glm::dvec2 surface_tilt;
113 glm::dvec2 axis_tilt;
118 glm::dmat4 inverse_orbital;
120 glm::dmat4 inverse_local;
122 std::vector<creature::Creature *> creatures;