Browse Source

Refactor `KF1_TracingIterator`'s code

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
6a5c0abf06
  1. 21
      sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc

21
sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc

@ -68,11 +68,19 @@ public function Vector GetTracingEnd()
return endPosition; 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. // Does actual tracing, but only once per iterator's lifecycle.
// Assumes `initialized` is `true`. // Assumes `initialized` is `true`.
private final function TryTracing() private final function TryTracing()
{ {
local bool isVisible;
local Pawn nextPawn; local Pawn nextPawn;
local Actor nextActor; local Actor nextActor;
local class<Actor> targetClass; local class<Actor> targetClass;
@ -92,20 +100,15 @@ private final function TryTracing()
targetClass = class'Actor'; targetClass = class'Actor';
} }
core = ServerLevelCore(class'ServerLevelCore'.static.GetInstance()); core = ServerLevelCore(class'ServerLevelCore'.static.GetInstance());
foreach core.TraceActors(class'Actor', foreach core.TraceActors(targetClass,
nextActor, nextActor,
nextHitLocation, nextHitLocation,
nextHitNormal, nextHitNormal,
endPosition, endPosition,
startPosition) startPosition)
{ {
if (onlyVisible) if (onlyVisible && !IsActorVisible(nextActor)) {
{ continue;
isVisible = (!nextActor.bHidden || nextActor.bWorldGeometry);
isVisible = isVisible && (nextActor.drawType != DT_None);
if (!isVisible) {
continue;
}
} }
hitLocations[hitLocations.length] = nextHitLocation; hitLocations[hitLocations.length] = nextHitLocation;
hitNormals[hitNormals.length] = nextHitNormal; hitNormals[hitNormals.length] = nextHitNormal;

Loading…
Cancel
Save