]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/sim.cpp
more orbits and stuff
[blobs.git] / src / world / sim.cpp
index 0e0b46616694dfd9bf05fbf7089a3cb21b831024..46454fd2952197311b72db9bfeace430a44bebdc 100644 (file)
@@ -1,18 +1,33 @@
 #include "Simulation.hpp"
 
+#include "Body.hpp"
+
 
 namespace blobs {
 namespace world {
 
 Simulation::Simulation(Body &r)
-: root(r) {
+: root(r)
+, all_bodies()
+, time(0.0) {
+       AddBody(r);
 }
 
 Simulation::~Simulation() {
 }
 
 
+void Simulation::AddBody(Body &b) {
+       b.SetSimulation(*this);
+       all_bodies.push_back(&b);
+}
+
 void Simulation::Tick() {
+       constexpr double dt = 0.01666666666666666666666666666666;
+       time += dt;
+       for (auto body : all_bodies) {
+               body->Rotation(body->Rotation() + dt * body->AngularMomentum() / body->Inertia());
+       }
 }
 
 }