]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/sim.cpp
(slightly) better camera handling
[blobs.git] / src / world / sim.cpp
index 46454fd2952197311b72db9bfeace430a44bebdc..185046d4cfc4eed8e73270513c7568e3a55a9561 100644 (file)
@@ -1,6 +1,8 @@
 #include "Simulation.hpp"
 
 #include "Body.hpp"
+#include "Planet.hpp"
+#include "Sun.hpp"
 
 
 namespace blobs {
@@ -8,7 +10,9 @@ namespace world {
 
 Simulation::Simulation(Body &r)
 : root(r)
-, all_bodies()
+, bodies()
+, planets()
+, suns()
 , time(0.0) {
        AddBody(r);
 }
@@ -19,13 +23,23 @@ Simulation::~Simulation() {
 
 void Simulation::AddBody(Body &b) {
        b.SetSimulation(*this);
-       all_bodies.push_back(&b);
+       bodies.insert(&b);
+}
+
+void Simulation::AddPlanet(Planet &p) {
+       AddBody(p);
+       planets.insert(&p);
+}
+
+void Simulation::AddSun(Sun &s) {
+       AddBody(s);
+       suns.insert(&s);
 }
 
 void Simulation::Tick() {
        constexpr double dt = 0.01666666666666666666666666666666;
        time += dt;
-       for (auto body : all_bodies) {
+       for (auto body : bodies) {
                body->Rotation(body->Rotation() + dt * body->AngularMomentum() / body->Inertia());
        }
 }