Issues with Physics Asset Body Instances Copied Values

Hello,

we have been having issues when instantiating a physics asset using another one as a template.

Some of the physics bodies have incorrect collision data.

After looking into it, we have seen that the copy constructor completely ignores and does not copy the CollisionEnabled property.

Is this as intended, and if so why is that?

[Image Removed]

Steps to Reproduce
Create a physics asset from another one:

[Image Removed]

Then simply assign it to a mesh:

[Image Removed]

What I’m seeing as well is that the point in time this was added, it was added this way without taking into account the copied value and using only the same value as the other constructors, in case it provides more info:

[Image Removed]

Hi David,

Sorry about the delay. This does not seem intentional, but rather a copy-paste bug introduced on CL 12566363 / Commit f464650 as you mentioned. The main in-source evidence is that the copy assignment operator and the CloneElem() function do copy the CollisionEnabled property as expected. I also followed along the code to see where this could create bugs, and I found that this affects the operation of the Static Mesh Editor’s “Duplicate Selected Collision” command, as well as the Modeling Mode’s “Inspect Collision” and “Simple Collision Editor” tools.

I have filed an internal bug report about this issue. Here’s the bug tracker link: UE-317189. You should be able to access it once the engine devs mark it as public. Until this is fixed, you can either fix the copy constructor yourself on the engine source code, or avoid passing/returning FKShapeElem by value and making sure to always manually copy the value of the CollisionEnabled property after triggering the copy constructor (the copy assignment operator and the CloneElem() function can also help).

For reference, here are the repro steps I included in the bug report:

*Preparation*
1. Place a Cube or Sphere Actor on a level
2. Use the Details Panel to find its static mesh asset on the Content Browser.
3. Copy the static mesh asset to the project directory
4. Open the Static Mesh Editor for the copy
5. Enable visualization of simple collision (Show -- Simple Collision).
6. Make sure there is a Box or Sphere Collision.
7. On the Details Panel, under "Collision -- Primitives -- Boxes/Spheres -- Index[0]", change the "Collision Enabled" property from the "Collision Enabled (Query and Physics)" default, for example to "Query Only".
 
*Bug 1*
1. Perform the preparation steps above
2. Click the collision box/sphere on the viewport
3. Duplicate it (Ctrl+D | Collision -- Duplicate Selected Collision)
4. On the Details Panel, note that the duplicate has "Collision Enabled (Query and Physics)", which is incorrect.
 
*Bug 2*
1. Perform the preparation steps above
2. Place the edited static mesh on a level and select it
3. Switch the Editor to the Modeling Mode (Shift + 5)
4. Select tool "Attribs -- Inspect Collision"
5. Under "Physics Inspector -- Physics Data -- Boxes -- Index[0] -- Element", note that the "Collision Enabled" property incorrectly shows "Collision Enabled (Query and Physics)"
6. Select tool "Attribs -- Simple Collision Editor"
7. Select the collision on the level editor viewport
8. Click "Simple Collision Geometry Editor -- Actions -- Duplicate"
9. Click "Accept" on the lower part of the viewport
10. Open the Static Mesh Editor for the edited mesh
11. On the Details Panel, note that BOTH the original primitive and the duplicate have "Collision Enabled (Query and Physics)", which is incorrect.

I hope this is helpful. Please let me know if you need anything further.

Best regards,

Vitor