Description

GetClosestPointonCollision returns point on parent instead of welded child.

 

From user: "The problem appears to be in PhysicsInterfacePhysX.cpp in GetSquaredDistanceToBody, line 2873. When UPrimitiveComponent::GetClosestPointOnCollision gets a physics body to query (PrimiteComponentPhysics.cpp, line 833) it is sure to get the unwelded FBodyInstance of the component itself rather than anything it is welded to, which is then passed to FPhysicsInterface_PhysX::GetSquaredDistanceToBody. However, if this body is welded to anything, FPhysicsInterface_PhysX::GetSquaredDistanceToBody ignores it and queries the weld parent instead, undoing what was done in UPrimitiveComponent::GetClosestPointOnCollision to ensure the correct FBodyInstance is used: const FBodyInstance* UseBI = InInstance->WeldParent ? InInstance->WeldParent : InInstance; While the parent FBodyInstance will include any bodies of the child which has been welded to it, FPhysicsInterface_PhysX::GetSquaredDistanceToBody later excludes any bodies in UseBI which do not originate in UseBI (Line 2905: if(UseBI->IsShapeBoundToBody(ShapeRef) == false) //skip welded shapes that do not belong to us) causing it to ignore any physics bodies originating from the child physics body we were querying in the first place and, in effect, only querying the welded parent."

 

Confirmed in 4.23 Main @ CL 5446668

Steps to Reproduce

4.20 Example Project Attached

  1. Create a blueprint with 2 static meshes, 1 as root and 1 as child.
  2. Call Get Closest Point on Collision with child mesh as target
  3. Place another actor in the world to serve as 'Point' input or manually enter point
  4. Simulate

4.20 Result: Closest point on child mesh is returned (Expected)

4.21+ Result: Closest point on parent mesh is returned

Have Comments or More Details?

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

13
Login to Vote

Won't Fix
ComponentUE - Simulation - Physics
Affects Versions4.224.234.21.2
CreatedMar 21, 2019
ResolvedAug 27, 2021
UpdatedAug 27, 2021
Pull Requests
6227 - Teiwaz83
View Jira Issue