]> git.localhorst.tv Git - blobs.git/commitdiff
fix creature iteration
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 28 Nov 2017 18:30:07 +0000 (19:30 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 28 Nov 2017 18:30:07 +0000 (19:30 +0100)
src/world/world.cpp

index 19f6f4af6603607c3eb709a832defcad0215a26c..eee12833b39ca80d467d0f8fc19868284f796419 100644 (file)
@@ -138,11 +138,15 @@ glm::dmat4 Body::FromUniverse() const noexcept {
        return m;
 }
 
+namespace {
+std::vector<creature::Creature *> ccache;
+}
+
 void Body::Tick(double dt) {
        rotation += dt * AngularMomentum() / Inertia();
        Cache();
-       for (creature::Creature *c : Creatures()) {
-               // TODO: this is self modifying, fix it fix it fix it
+       ccache = Creatures();
+       for (creature::Creature *c : ccache) {
                c->Tick(dt);
        }
        for (auto c = Creatures().begin(); c != Creatures().end();) {