X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fsim.cpp;h=aedc5cf01017df98b217b87dcc4991b9ddf8848e;hb=bcf776b6d51aeb9147bde32da8dd0768b10db993;hp=46454fd2952197311b72db9bfeace430a44bebdc;hpb=c5556cf5f6813887a3503433c021ccd2e7fae865;p=blobs.git diff --git a/src/world/sim.cpp b/src/world/sim.cpp index 46454fd..aedc5cf 100644 --- a/src/world/sim.cpp +++ b/src/world/sim.cpp @@ -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,14 +23,24 @@ 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) { - body->Rotation(body->Rotation() + dt * body->AngularMomentum() / body->Inertia()); + for (auto body : bodies) { + body->Tick(dt); } }