X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fworld%2Fworld.cpp;h=738fa4ad9b06bb7256f66886bfeca86bd5e3bd2c;hb=1bc2f230105ad6e1ee8d999ddc079cd85d244bf9;hp=5e3420d525494f646ea85ad3789c1d83c6b011ad;hpb=7354c74fb8f409336db3a6d70455fbc10232ae64;p=blank.git diff --git a/src/world/world.cpp b/src/world/world.cpp index 5e3420d..738fa4a 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -340,7 +340,20 @@ World::World(const BlockTypeRegistry &types, const Config &config) } World::~World() { - + for (Entity &e : entities) { + e.Kill(); + } + std::size_t removed = 0; + do { + removed = 0; + for (auto e = entities.begin(), end = entities.end(); e != end; ++e) { + if (e->CanRemove()) { + e = RemoveEntity(e); + end = entities.end(); + ++removed; + } + } + } while (removed > 0 && !entities.empty()); } @@ -524,15 +537,18 @@ bool World::Intersection(const Entity &e, const EntityState &s, std::vector 1) { - // chunk is not one of the 3x3x3 surrounding the entity - // since there's no entity which can extent over 16 blocks, they can be skipped - continue; - } - if (cur_chunk.Intersection(e, M, cur_chunk.Transform(reference), col)) { - any = true; + for (ExactLocation::Coarse pos(begin); pos.z < end.y; ++pos.z) { + for (pos.y = begin.y; pos.y < end.y; ++pos.y) { + for (pos.x = begin.x; pos.x < end.x; ++pos.x) { + Chunk *chunk = chunks.Get(pos); + if (chunk && chunk->Intersection(e, M, chunk->Transform(reference), col)) { + any = true; + } + } } } return any;