]> git.localhorst.tv Git - blobs.git/blob - src/world/sim.cpp
camera controls
[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, app::Assets &assets)
12 : root(r)
13 , assets(assets)
14 , bodies()
15 , planets()
16 , suns()
17 , time(0.0) {
18         AddBody(r);
19 }
20
21 Simulation::~Simulation() {
22 }
23
24
25 void Simulation::AddBody(Body &b) {
26         b.SetSimulation(*this);
27         bodies.insert(&b);
28 }
29
30 void Simulation::AddPlanet(Planet &p) {
31         AddBody(p);
32         planets.insert(&p);
33 }
34
35 void Simulation::AddSun(Sun &s) {
36         AddBody(s);
37         suns.insert(&s);
38 }
39
40 void Simulation::Tick(double dt) {
41         time += dt;
42         for (auto body : bodies) {
43                 body->Tick(dt);
44         }
45 }
46
47 }
48 }