Description

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)

Steps to Reproduce
  1. Download the attached project 
  2. Open NewMap
  3. Select the Cube in the scene
  4. Move it towards and away from the camera

Expected:The parent cube and its children cubes would snap to the nearest surface

Result: All of the cubes rapidly oscillate in scale

 

Have Comments or More Details?

There's no existing public thread on this issue, so head over toAnswerHub just mention UE-74804 in the post.

0
Login to Vote

Fixed
ComponentTools
Affects Versions4.20.34.234.21.24.22.1
Target Fix4.23
Fix Commit6664208
Main Commit6838042
Release Commit6955818
CreatedMay 17, 2019
ResolvedMay 29, 2019
UpdatedJul 26, 2019