Description

PhAT is inconsistent on when it does and doesn't apply scale to Constraint positions. This leads to cases where the positions provided create constraints that may not work when the Preview Skeletal Mesh has a non-identity Scale.

Testing this issue in 4.13 and 4.14 with the provided mesh, the default constraints created would cause the mesh to collapse into itself because the constraints didn't have scale. Deleting bodies / re-initializing the constraints would cause things to work because the constraints did have scale.

In 4.15, changes were added to skeletal mesh to handle constraints in terms of Component and Skeletal Mesh scale. This meant the previous behavior flipped (constraints would work upon creation, but not after re-initializing).

Fixing the consistency issues won't fix already broken content, but that should be limited. Unfortunately, since we never tracked scale with FConstraintInstances, there's no fool-proof way to fix already broken content.

Steps to Reproduce

Provided Phys Asset

  1. Download the attached project.
  2. Start the project, and attach the debugger to it.
  3. In SkeletalMeshComponentPhysics.cpp, find the USkeletalMeshComponent::InstantiatePhysicsAsset method.
  4. Inside this method, look for the following code snippet (near the bottom):
    // Do this separately so both are logged if invalid.
    const bool Body1Valid = ValidateBody(Body1, ConInst->ConstraintBone1);
    const bool Body2Valid = ValidateBody(Body2, ConInst->ConstraintBone2);
  5. Set a breakpoint on the first line.
  6. Add the following values to the watch window:
    ((((UPhysicsConstraintTemplate **)((PhysAsset).ConstraintSetup).AllocatorInstance.Data)[0])->DefaultInstance).Pos1
    ((((UPhysicsConstraintTemplate **)((PhysAsset).ConstraintSetup).AllocatorInstance.Data)[0])->DefaultInstance).Pos2
    ((((UPhysicsConstraintTemplate **)((PhysAsset).ConstraintSetup).AllocatorInstance.Data)[1])->DefaultInstance).Pos1
    ((((UPhysicsConstraintTemplate **)((PhysAsset).ConstraintSetup).AllocatorInstance.Data)[1])->DefaultInstance).Pos2
    ((((UPhysicsConstraintTemplate **)((PhysAsset).ConstraintSetup).AllocatorInstance.Data)[2])->DefaultInstance).Pos1
    ((((UPhysicsConstraintTemplate **)((PhysAsset).ConstraintSetup).AllocatorInstance.Data)[2])->DefaultInstance).Pos2
    ((((UPhysicsConstraintTemplate **)((PhysAsset).ConstraintSetup).AllocatorInstance.Data)[3])->DefaultInstance).Pos1
    ((((UPhysicsConstraintTemplate **)((PhysAsset).ConstraintSetup).AllocatorInstance.Data)[3])->DefaultInstance).Pos2
    
  7. Add the Skeletal Mesh to a level, set Simulate Physics to true, and PIE.

EXPECTED:
All Pos1 values in the watch window should be 0 vectors (0, 0, 0).
All Pos2 values in the watch window should be non-0 vectors with the values (0, 0, 0.2)
Notes: Some amount of rounding error is OK, not all constraint may have values (e.g. [2] and [3] won't have values.

ACTUAL:
All Pos1 values in the watch window should be 0 vectors (0, 0, 0).
All Pos2 values in the watch window are non-0 vectors with the values (0, 0, 20).

Created Phys Asset

  1. Continue, and Exit PIE.
  2. Create and assign a new Physics Asset for the Skeletal Mesh.
  3. Use Minimum Bone Size = 0.01 and Collision Geometry = Box.
  4. PIE.

EXPECTED:
All Pos1 values in the watch window should be 0 vectors (0, 0, 0).
All Pos2 values in the watch window should be non-0 vectors with the values (0, 0, 0.1)
Notes: Some amount of rounding error is OK, not all constraint may have values.

ACTUAL:
Matches expected in this case.

Created Phys Asset with Removed Bodies

  1. Continue, and Exit PIE.
  2. Open the newly created Physics Asset for the Skeletal Mesh.
  3. Delete the bodies on Joint3 and Joint4.
  4. PIE

EXPECTED:
All Pos1 values in the watch window should be 0 vectors (0, 0, 0).
All Pos2 values in the watch window should be non-0 vectors with the values (0, 0, 0.2)
Notes: Some amount of rounding error is OK, not all constraint may have values.

ACTUAL:
All Pos1 values in the watch window should be 0 vectors (0, 0, 0).
All Pos2 values in the watch window are non-0 vectors with the values (0, 0, 20).

Have Comments or More Details?

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

0
Login to Vote

Fixed
ComponentUE - Simulation - Physics
Affects Versions4.15
Target Fix4.17
Fix Commit3494937
Main Commit3502661
CreatedMar 3, 2017
ResolvedJun 16, 2017
UpdatedApr 27, 2018