From 6a5c0abf06d1881427574532b08889579d31f361 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Sun, 10 Jul 2022 17:38:42 +0700 Subject: [PATCH] Refactor `KF1_TracingIterator`'s code --- .../KF1Frontend/World/KF1_TracingIterator.uc | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc b/sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc index 030b674..549802c 100644 --- a/sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc +++ b/sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc @@ -68,11 +68,19 @@ public function Vector GetTracingEnd() return endPosition; } +private final function bool IsActorVisible(Actor actorToCheck) +{ + if (actorToCheck == none) return false; + if (actorToCheck.bHidden && !actorToCheck.bWorldGeometry) return false; + if (actorToCheck.drawType == DT_None) return false; + + return true; +} + // Does actual tracing, but only once per iterator's lifecycle. // Assumes `initialized` is `true`. private final function TryTracing() { - local bool isVisible; local Pawn nextPawn; local Actor nextActor; local class targetClass; @@ -92,20 +100,15 @@ private final function TryTracing() targetClass = class'Actor'; } core = ServerLevelCore(class'ServerLevelCore'.static.GetInstance()); - foreach core.TraceActors(class'Actor', + foreach core.TraceActors(targetClass, nextActor, nextHitLocation, nextHitNormal, endPosition, startPosition) { - if (onlyVisible) - { - isVisible = (!nextActor.bHidden || nextActor.bWorldGeometry); - isVisible = isVisible && (nextActor.drawType != DT_None); - if (!isVisible) { - continue; - } + if (onlyVisible && !IsActorVisible(nextActor)) { + continue; } hitLocations[hitLocations.length] = nextHitLocation; hitNormals[hitNormals.length] = nextHitNormal;