Skip to content

Commit

Permalink
Merge pull request #210 from muchcharles/muchcharles-footstep-less-al…
Browse files Browse the repository at this point in the history
…locations

Reduce allocations on footsteps
  • Loading branch information
dyanikoglu authored May 11, 2021
2 parents db5d0f7 + fefc8d9 commit d80cfc2
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,26 @@ void UALSAnimNotifyFootstep::Notify(USkeletalMeshComponent* MeshComp, UAnimSeque
const FVector TraceEnd = FootLocation - MeshOwner->GetActorUpVector() * TraceLength;

FHitResult Hit;
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(MeshOwner);
ActorsToIgnore.Append(MeshOwner->Children);
if (UKismetSystemLibrary::LineTraceSingle(World, FootLocation, TraceEnd, TraceChannel, true, ActorsToIgnore,
DrawDebugType, Hit, true))

ECollisionChannel CollisionChannel = UEngineTypes::ConvertToCollisionChannel(TraceChannel);

FCollisionQueryParams Params(SCENE_QUERY_STAT(ALSFootstep), true /*bTraceComplex*/, MeshOwner);
Params.bReturnPhysicalMaterial = true;
for (auto& Child : MeshOwner->Children)
{
Params.AddIgnoredActor(Child);
}

bool const bHit = MeshComp->GetWorld() ? World->LineTraceSingleByChannel(Hit, FootLocation, TraceEnd, CollisionChannel, Params) : false;

#if ENABLE_DRAW_DEBUG
if (MeshComp->GetWorld())
{
DrawDebugLineTraceSingle(MeshComp->GetWorld(), FootLocation, TraceEnd, DrawDebugType, bHit, Hit, TraceColor, TraceHitColor, DrawTime);
}
#endif

if (bHit)
{
if (!Hit.PhysMaterial.Get())
{
Expand All @@ -58,7 +73,11 @@ void UALSAnimNotifyFootstep::Notify(USkeletalMeshComponent* MeshComp, UAnimSeque

const EPhysicalSurface SurfaceType = Hit.PhysMaterial.Get()->SurfaceType;

TArray<FALSHitFX*> HitFXRows;
check(IsInGameThread());
checkNoRecursion();
static TArray<FALSHitFX*> HitFXRows;
HitFXRows.Reset();

HitDataTable->GetAllRows<FALSHitFX>(FString(), HitFXRows);

FALSHitFX* HitFX = nullptr;
Expand Down

0 comments on commit d80cfc2

Please sign in to comment.