Hello,
There is a crash happening if we try to hide a bone in skeletal mesh with EPhysBodyOp::PBO_Term
. What happens is that bone (and below bones), their body instances will be terminated. When we call terminateBody on a body instance, we reset its BodySetup to null and reset other things but we do not reset InstanceBoneIndex
to INDEX_NONE (void FBodyInstance::TermBody(bool bNeverDeferRelease
).
If we were having ticks disabled on a mesh(deffered kinematic enabled, as by default for any mesh), remove a bone, and at any point start the tick on the mesh, Chaos Physics scene in void FPhysScene_Chaos::UpdateKinematicsOnDeferredSkelMeshes()
will try to update that bone in its ParallelFor. The BoneSetup is null, and in
if (!BodyInst->IsInstanceSimulatingPhysics())
{
const int32 BoneIndex = BodyInst->InstanceBoneIndex;
if (BoneIndex != INDEX_NONE)
{
const FTransform BoneTransform = ComponentSpaceTransforms[BoneIndex] * CurrentLocalToWorld;
TeleportActorsPool[ActorPoolStartIndex + i] = ActorHandle;
// TODO: Kinematic targets. Check Teleport type on FDeferredKinematicUpdateInfo and don't always teleport.
Body_External.SetX(BoneTransform.GetLocation(), false); // only set dirty once in SetR
Body_External.SetR(BoneTransform.GetRotation());
Body_External.UpdateShapeBounds(BoneTransform);
as the BodyInst->IsInstanceSimulatingPhysics() returns false since BodySetup
is null, and BoneIndex is not INDEX_NONE, it will try to set values to Body_External, but Body_External is null. And thus the crash happens.
Is this a known issue, or is there something that I am doing in a wrong way that is not supported by skeletal mesh/physics?