]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/world.cpp
fix creature iteration
[blobs.git] / src / world / world.cpp
index 91f9bc6751fbaedcda6f67fd1378720c87eda680..eee12833b39ca80d467d0f8fc19868284f796419 100644 (file)
@@ -138,10 +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()) {
+       ccache = Creatures();
+       for (creature::Creature *c : ccache) {
                c->Tick(dt);
        }
        for (auto c = Creatures().begin(); c != Creatures().end();) {