69 const TArray<AActor*>& IgnoredActors,
70 const TArray<UPrimitiveComponent*>& IgnoredComponents)
77 const FVector Start = Location + FVector(0.0f, 0.0f, 200.0f);
78 const FVector End = Location - FVector(0.0f, 0.0f, 10000.0f);
80 FCollisionQueryParams CollisionParams;
81 CollisionParams.bTraceComplex =
true;
82 CollisionParams.bReturnPhysicalMaterial =
false;
83 CollisionParams.AddIgnoredActors(IgnoredActors);
84 CollisionParams.AddIgnoredComponents(IgnoredComponents);
94 TArray<FHitResult> HitResults;
95 World->LineTraceMultiByChannel(
96 HitResults, Start, End, ECC_GameTraceChannel3, CollisionParams);
98 constexpr float ZOffsetSignToGround = 0.5f;
99 for (
const FHitResult &HitResult : HitResults)
101 if (IsGroundHit(HitResult))
103 Location.Z = HitResult.
Location.Z + ZOffsetSignToGround;
113 const TArray<AActor*>& IgnoredActors,
114 const TArray<UPrimitiveComponent*>& IgnoredComponents)
126 const FVector OriginalLocation = Sign->GetActorLocation();
127 FVector AdjustedLocation = OriginalLocation;
130 World, AdjustedLocation, IgnoredActors, IgnoredComponents))
132 UE_LOG(LogCarla, Verbose,
133 TEXT(
"Could not find ground for traffic sign %s at %s"),
134 *Sign->GetName(), *OriginalLocation.ToString());
138 const float ZOffset = AdjustedLocation.Z - OriginalLocation.Z;
140 USceneComponent* Root = Sign->GetRootComponent();
141 const EComponentMobility::Type OriginalMobility =
142 Root ? Root->Mobility.GetValue() : EComponentMobility::Static;
145 Root->SetMobility(EComponentMobility::Movable);
148 Sign->SetActorLocation(AdjustedLocation);
158 FVector BoxLocation = BoxComp->GetRelativeLocation();
159 BoxLocation.Z -= ZOffset;
160 BoxComp->SetRelativeLocation(BoxLocation);
163 Sign->UpdateComponentTransforms();
166 Root->SetMobility(OriginalMobility);
170 UE_LOG(LogCarla, Log, TEXT(
"Adjusted sign %s height by %f cm"),
171 *Sign->GetName(), ZOffset);