]> git.localhorst.tv Git - blobs.git/blob - src/world/sim.cpp
basic needs
[blobs.git] / src / world / sim.cpp
1 #include "Simulation.hpp"
2
3 #include "Body.hpp"
4 #include "Planet.hpp"
5 #include "Sun.hpp"
6
7
8 namespace blobs {
9 namespace world {
10
11 Simulation::Simulation(Body &r)
12 : root(r)
13 , bodies()
14 , planets()
15 , suns()
16 , time(0.0) {
17         AddBody(r);
18 }
19
20 Simulation::~Simulation() {
21 }
22
23
24 void Simulation::AddBody(Body &b) {
25         b.SetSimulation(*this);
26         bodies.insert(&b);
27 }
28
29 void Simulation::AddPlanet(Planet &p) {
30         AddBody(p);
31         planets.insert(&p);
32 }
33
34 void Simulation::AddSun(Sun &s) {
35         AddBody(s);
36         suns.insert(&s);
37 }
38
39 void Simulation::Tick() {
40         constexpr double dt = 0.01666666666666666666666666666666;
41         time += dt;
42         for (auto body : bodies) {
43                 body->Tick(dt);
44         }
45 }
46
47 }
48 }