From a18bc5db6e0c9d1976269f8c69f2b31443004395 Mon Sep 17 00:00:00 2001 From: David Gilbert <gilbert@vr.rwth-aachen.de> Date: Wed, 13 Mar 2024 18:09:41 +0100 Subject: [PATCH] fix(Navigation): Dirty fix for Trigger volumes blocking movement. Needs to be revisited. --- .../Navigation/CollisionHandlingMovement.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp b/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp index d6969c08..a13dd015 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp @@ -342,19 +342,14 @@ TOptional<FVector> UCollisionHandlingMovement::GetOverlapResolveDirection() cons { TArray<UPrimitiveComponent*> OverlappingComponents; TArray<TEnumAsByte<EObjectTypeQuery>> traceObjectTypes; - traceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Visibility)); + traceObjectTypes.Add(EObjectTypeQuery::ObjectTypeQuery_MAX); + UKismetSystemLibrary::CapsuleOverlapComponents(GetWorld(), CapsuleColliderComponent->GetComponentLocation(), CapsuleColliderComponent->GetScaledCapsuleRadius(), CapsuleColliderComponent->GetScaledCapsuleHalfHeight(), traceObjectTypes, nullptr, ActorsToIgnore, OverlappingComponents); - if (OverlappingComponents.Num() == 0) - { - // return unset optional - return TOptional<FVector>(); - } - - FVector ResolveVector = FVector::ZeroVector; + TOptional<FVector> ResolveVector; // check what to do to move out of these collisions (or nothing if none is there) // we just add the penetrations so in very unfortunate conditions this can become problematic/blocking but for now // and our regular use cases this works @@ -362,7 +357,13 @@ TOptional<FVector> UCollisionHandlingMovement::GetOverlapResolveDirection() cons { FHitResult Hit = CreateCapsuleTrace(CapsuleColliderComponent->GetComponentLocation(), OverlappingComp->GetComponentLocation(), false); - ResolveVector += Hit.ImpactNormal * Hit.PenetrationDepth; + + if (Hit.bBlockingHit) + { + FVector Change = Hit.ImpactNormal * Hit.PenetrationDepth; + ResolveVector = ResolveVector.IsSet() ? ResolveVector.GetValue() + Change : Change; + } } + return ResolveVector; } -- GitLab