From 83f82afbc8c509d8c7bb57ceae7ef99b7cea95ce Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 27 Aug 2020 11:37:39 -0500 Subject: [PATCH] Optimized P_CheckPosition. (#1161) - If the actor passed into the function has THRUACTORS, PIT_CheckThing won't be called anymore. - Moved THRUACTORS check to just under the self clipping check in PIT_CheckThing. --- src/p_map.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 15223df83..69dc8fb9d 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1310,6 +1310,9 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (thing == tm.thing) return true; + if ((thing->flags2 | tm.thing->flags2) & MF2_THRUACTORS) + return true; + if (!((thing->flags & (MF_SOLID | MF_SPECIAL | MF_SHOOTABLE)) || thing->flags6 & MF6_TOUCHY)) return true; // can't hit thing @@ -1317,9 +1320,6 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (fabs(thing->X() - cres.Position.X) >= blockdist || fabs(thing->Y() - cres.Position.Y) >= blockdist) return true; - if ((thing->flags2 | tm.thing->flags2) & MF2_THRUACTORS) - return true; - if ((tm.thing->flags6 & MF6_THRUSPECIES) && (tm.thing->GetSpecies() == thing->GetSpecies())) return true; @@ -1799,6 +1799,7 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo FMultiBlockThingsIterator it2(pcheck, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, false, newsec); FMultiBlockThingsIterator::CheckResult tcres; + if (!(thing->flags2 & MF2_THRUACTORS)) while ((it2.Next(&tcres))) { if (!PIT_CheckThing(it2, tcres, it2.Box(), tm))