FBodyInstance::Weld did not check to see whether or not child components were already welded to a parent. This meant that whenever Weld was called, ShapeToBodiesMap would continue to grow in size, even if there were no new bodies.

Steps to Reproduce

1. Create a new C++ project. Use the 3rd person template (for convenience).

2. Compile and run this in Debug mode.

3. Create a BP class derived from the standard ThirdPersonCharacter with nested primitive components (e.g. a sphere component that contains another sphere component).

4. Create a way to toggle physics on and off for the parent primitive component.
e.g. Add an Input Event for Left Mouse.
Add an Event Handler in the new BP class for this event.
Create a Flip Flop node.
For both A and B exec pins, call SetSimulatePhysics on the Parent
Sphere Component with the IsA output pin connected to the
input pin

5. Create a BP class derived from the standard ThirdPersonGameMode class.

6. Change the default Game Mode to the new Game Mode, and set the default pawn to the new pawn.
e.g. Edit > Project Settings > Maps and Modes > Default Modes
> Default GameMode = NewMode
> Default Pawn Class = NewPawnClass

7. Set a break point in the beginning of the BodyInstance.cpp FBodyInstance::Weld method.

8. Toggle Physics on and off repeatedly (using the event handler above, noting this will only be hit when physics switched from off to on).

Expectation: First toggle, ShapeToBodiesMap is be empty.
Subsequent toggles, ShapeToBodiesMap contains a
single reference to each of the child components.

Actual: First toggle, ShapeToBodiesMap is empty.
Subsequent toggles, ShapeToBodiesMap contains multiple references to each of the child components
(namely, the number of times toggled number of references).

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-31189 in the post.

Login to Vote

ComponentUE - Simulation - Physics
Affects Versions4.114.124.13
Target Fix4.13
Fix Commit2988123
Main Commit2994701
CreatedMay 23, 2016
ResolvedMay 24, 2016
UpdatedApr 27, 2018
View Jira Issue