summaryrefslogtreecommitdiff
path: root/src/world.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-11-08 12:33:43 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-11-08 12:33:43 +0100
commit747c89f4c0d95082e113ef13c5278b0055637ff9 (patch)
tree702822df5f91f74da8b8bb54bcde8aa197f5b124 /src/world.cpp
parentcdd75000effac0216588766234cfa5b3e8e304d5 (diff)
Fix entity node elimination.
Diffstat (limited to 'src/world.cpp')
-rw-r--r--src/world.cpp21
1 files changed, 17 insertions, 4 deletions
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;