@@ -138,8 +138,8 @@ void ALargeMapManager::PostWorldOriginOffset(UWorld* InWorld, FIntVector InSrcOr
138138
139139bool ALargeMapManager::AdjustSignHeightToGround (FVector& SpawnLocation, const FString& ActorName, const TArray<AActor*>& ActorsToIgnore) const
140140{
141- const FVector Start = SpawnLocation + FVector (0 , 0 , 10 .0f );
142- const FVector End = SpawnLocation - FVector (0 , 0 , 20000 .0f );
141+ const FVector Start = SpawnLocation + FVector (0 , 0 , 200 .0f );
142+ const FVector End = SpawnLocation - FVector (0 , 0 , 10000 .0f );
143143
144144 FHitResult HitResult;
145145 FCollisionQueryParams CollisionParams;
@@ -177,12 +177,45 @@ void ALargeMapManager::AdjustAllSignsToHeightGround()
177177 continue ;
178178 if (TrafficSign->bPositioned )
179179 continue ;
180- FVector SpawnLocation = Actor->GetActorLocation ();
181- TrafficSign->bPositioned = AdjustSignHeightToGround (SpawnLocation, Actor->GetName (), ActorsToIgnore);
182-
183- Actor->GetRootComponent ()->SetMobility (EComponentMobility::Movable);
184- Actor->SetActorLocation (SpawnLocation);
185- Actor->GetRootComponent ()->SetMobility (EComponentMobility::Static);
180+ FVector OriginalLocation = Actor->GetActorLocation ();
181+ FVector AdjustedLocation = OriginalLocation;
182+
183+ TrafficSign->bPositioned = AdjustSignHeightToGround (AdjustedLocation, Actor->GetName (), ActorsToIgnore);
184+
185+ if (TrafficSign->bPositioned )
186+ {
187+ float ZOffset = AdjustedLocation.Z - OriginalLocation.Z ;
188+
189+ Actor->GetRootComponent ()->SetMobility (EComponentMobility::Movable);
190+
191+ // Get all static mesh components
192+ TArray<UStaticMeshComponent*> StaticMeshComps;
193+ Actor->GetComponents <UStaticMeshComponent>(StaticMeshComps);
194+
195+ for (UStaticMeshComponent* MeshComp : StaticMeshComps)
196+ {
197+ if (!MeshComp) continue ;
198+
199+ // Skip if this has a mesh parent (it's a child)
200+ USceneComponent* ParentComp = MeshComp->GetAttachParent ();
201+ if (ParentComp && Cast<UStaticMeshComponent>(ParentComp))
202+ {
203+ continue ;
204+ }
205+
206+ // Move the mesh component down
207+ FVector CompLocation = MeshComp->GetRelativeLocation ();
208+ CompLocation.Z += ZOffset;
209+ MeshComp->SetRelativeLocation (CompLocation);
210+
211+ MeshComp->UpdateBounds ();
212+
213+ LM_LOG (Log, " Moved mesh %s by %f cm" , *Actor->GetName (), ZOffset);
214+ }
215+
216+ Actor->UpdateComponentTransforms ();
217+ Actor->GetRootComponent ()->SetMobility (EComponentMobility::Static);
218+ }
186219 }
187220}
188221
0 commit comments