From: Daniel Karbach Date: Tue, 28 Nov 2017 18:30:07 +0000 (+0100) Subject: fix creature iteration X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=e22daa10d55c26f15a170ab76645e656e956901c;p=blobs.git fix creature iteration --- diff --git a/src/world/world.cpp b/src/world/world.cpp index 19f6f4a..eee1283 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -138,11 +138,15 @@ glm::dmat4 Body::FromUniverse() const noexcept { return m; } +namespace { +std::vector 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();) {