Surface snapping causes erratic changes in scale to StaticMeshActors that have children of the same type.
The user also has provided a potential solution to this bug (Please see the code below. Note the + is for code additions, while the - is for code deletions)
+ +static void GetAttachedActorsRecursive(const AActor* InActor, TArray<AActor*>& OutActors) +{ + TArray<AActor*> AttachedActors; + InActor->GetAttachedActors(AttachedActors); + for (AActor* AttachedActor : AttachedActors) + { + GetAttachedActorsRecursive(AttachedActor, OutActors); + } + OutActors.Append(OutActors); +}; + void FLevelEditorViewportClient::ProjectActorsIntoWorld(const TArray<AActor*>& Actors, FViewport* InViewport, const FVector& Drag, const FRotator& Rot) { // Compile an array of selected actors @@ -2317,6 +2329,11 @@ if (bIsOnScreen) { + + TArray<AActor*> IgnoreActors; + IgnoreActors.Add(Actor); + GetAttachedActorsRecursive(Actor, IgnoreActors); + // Determine how we're going to attempt to project the object onto the world if (CurrentAxis == EAxisList::XY || CurrentAxis == EAxisList::XZ || CurrentAxis == EAxisList::YZ) { @@ -2335,11 +2352,11 @@ TrimLineToFrustum(Frustum, RayStart, RayEnd); - TraceResult = FActorPositioning::TraceWorldForPosition(*GetWorld(), *SceneView, RayStart, RayEnd, &Actors); + TraceResult = FActorPositioning::TraceWorldForPosition(*GetWorld(), *SceneView, RayStart, RayEnd, &IgnoreActors); } else { - TraceResult = FActorPositioning::TraceWorldForPosition(Cursor, *SceneView, &Actors); + TraceResult = FActorPositioning::TraceWorldForPosition(Cursor, *SceneView, &IgnoreActors); } } }
Tested in 4.20.3 (CL - 4369336), 4.21.2 (CL - 4753647), 4.22.1 (CL - 6063286), 4.23 (CL - 6543257)
Expected:The parent cube and its children cubes would snap to the nearest surface
Result: All of the cubes rapidly oscillate in scale
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-74804 in the post.