]> git.localhorst.tv Git - blobs.git/blob - src/world/sim.cpp
more orbits and stuff
[blobs.git] / src / world / sim.cpp
1 #include "Simulation.hpp"
2
3 #include "Body.hpp"
4
5
6 namespace blobs {
7 namespace world {
8
9 Simulation::Simulation(Body &r)
10 : root(r)
11 , all_bodies()
12 , time(0.0) {
13         AddBody(r);
14 }
15
16 Simulation::~Simulation() {
17 }
18
19
20 void Simulation::AddBody(Body &b) {
21         b.SetSimulation(*this);
22         all_bodies.push_back(&b);
23 }
24
25 void Simulation::Tick() {
26         constexpr double dt = 0.01666666666666666666666666666666;
27         time += dt;
28         for (auto body : all_bodies) {
29                 body->Rotation(body->Rotation() + dt * body->AngularMomentum() / body->Inertia());
30         }
31 }
32
33 }
34 }