From 747c89f4c0d95082e113ef13c5278b0055637ff9 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 8 Nov 2017 12:33:43 +0100 Subject: Fix entity node elimination. --- src/world.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/world.cpp') diff --git a/src/world.cpp b/src/world.cpp index ef056db..3d21789 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -107,12 +107,25 @@ bool world_t::find_path(v2f_t src, v2f_t dst, cmodel_t *cmodel, entity_t *ignore finder.eliminate_nodes(combined); } - bounds = rectf_t(src, dst).norm(); + bounds = finder.bounds; + bounds[0] -= cmodel_dims / 2; + bounds[1] += cmodel_dims / 2; - for (entity_t *ent : get_entities(bounds, cmodel->cflags)) - if (ent != ignore) - finder.eliminate_nodes(ent->cmodel.bounds); + for (entity_t *ent : get_entities(bounds, cmodel->cflags)) { + v2f_t center; + v2f_t combined_dims; + rectf_t combined; + + if (ent == ignore) + continue; + center = ent->cmodel.bounds.center(); + combined_dims = ent->cmodel.bounds.dims() + cmodel_dims; + combined[0] = center - combined_dims / 2; + combined[1] = center + combined_dims / 2; + + finder.eliminate_nodes(combined); + } if (!finder.find()) return false; -- cgit