From 231356fb353d530c6b5eae974b7e57e8c2a58bb0 Mon Sep 17 00:00:00 2001 From: Ehret <jw210150@WIN.RZ.RWTH-AACHEN.DE> Date: Fri, 20 May 2022 12:59:35 +0200 Subject: [PATCH] slight performance improvement --- Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp | 7 ++++--- Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp b/Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp index 59da4c3d..84708a50 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp @@ -247,11 +247,12 @@ void UVRPawnMovement::ShiftVertically(float Distance, float VerticalAcceleration } } -FHitResult UVRPawnMovement::CreateCapsuleTrace(const FVector Start, FVector End, bool DrawDebug) const +FHitResult UVRPawnMovement::CreateCapsuleTrace(const FVector Start, FVector End, bool DrawDebug) { const EDrawDebugTrace::Type DrawType = DrawDebug ? EDrawDebugTrace::Type::ForDuration : EDrawDebugTrace::Type::None; - TArray<AActor*> ActorsToIgnore; - ActorsToIgnore.Add(GetOwner()); + if(ActorsToIgnore.Num()==0){ + ActorsToIgnore.Add(GetOwner()); + } //UE_LOG(LogTemp, Warning, TEXT("Capsule from %s to %s"), *Start.ToString(), *End.ToString()) diff --git a/Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h b/Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h index 53ea5ecd..275bbb34 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h +++ b/Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h @@ -4,6 +4,7 @@ #include "GameFramework/FloatingPawnMovement.h" #include "Components/CapsuleComponent.h" #include "Camera/CameraComponent.h" +#include "Actor.h" #include "VRPawnMovement.generated.h" @@ -64,7 +65,7 @@ public: private: //check for - FHitResult CreateCapsuleTrace(const FVector Start, FVector End, bool DrawDebug=false) const; + FHitResult CreateCapsuleTrace(const FVector Start, FVector End, bool DrawDebug=false); void SetCapsuleColliderToUserSize(); void CheckForPhysWalkingCollision(); FVector GetCollisionSafeVirtualSteeringVec(FVector InputVector, float DeltaTime); @@ -77,4 +78,7 @@ private: float VerticalSpeed = 0.0f; FVector LastCapsulePosition; FVector LastSteeringCollisionVector; + + //just stored for performance gains; + TArray<AActor*> ActorsToIgnore; }; -- GitLab