Fix vehicle crash caused when trying to create a convex hull around no vertices. The real issue here was inside PhAT which will now do the right thing and give a warning.

#JIRA UE-19418

[CL 2644184 by Ori Cohen in Main branch]
This commit is contained in:
Ori Cohen
2015-08-04 17:43:12 -04:00
committed by Ori.Cohen@epicgames.com
parent 518d4fa682
commit 6a172dd118
2 changed files with 23 additions and 10 deletions
+7 -2
View File
@@ -2186,8 +2186,13 @@ void FPhAT::OnResetBoneCollision()
int32 BoneIndex = SharedData->EditorSkelMesh->RefSkeleton.FindBoneIndex(BodySetup->BoneName);
check(BoneIndex != INDEX_NONE);
FPhysicsAssetUtils::CreateCollisionFromBone(BodySetup, SharedData->EditorSkelMesh, BoneIndex, SharedData->NewBodyData, (SharedData->NewBodyData.VertWeight == EVW_DominantWeight)? SharedData->DominantWeightBoneInfos: SharedData->AnyWeightBoneInfos);
BodyIndices.AddUnique(SharedData->SelectedBodies[i].Index);
if(FPhysicsAssetUtils::CreateCollisionFromBone(BodySetup, SharedData->EditorSkelMesh, BoneIndex, SharedData->NewBodyData, (SharedData->NewBodyData.VertWeight == EVW_DominantWeight)? SharedData->DominantWeightBoneInfos: SharedData->AnyWeightBoneInfos))
{
BodyIndices.AddUnique(SharedData->SelectedBodies[i].Index);
}else
{
FPhysicsAssetUtils::DestroyBody(SharedData->PhysicsAsset, SharedData->SelectedBodies[i].Index);
}
}
//deselect first
@@ -442,16 +442,24 @@ bool CreateCollisionFromBone( UBodySetup* bs, USkeletalMesh* skelMesh, int32 Bon
// Deal with creating a single convex hull
else if (Params.GeomType == EFG_SingleConvexHull)
{
FKConvexElem ConvexElem;
// Add all of the vertices for this bone to the convex element
for( int32 index=0; index<BoneInfo->Positions.Num(); index++ )
if (BoneInfo->Positions.Num())
{
ConvexElem.VertexData.Add(BoneInfo->Positions[index]);
}
ConvexElem.UpdateElemBox();
FKConvexElem ConvexElem;
bs->AggGeom.ConvexElems.Add(ConvexElem);
// Add all of the vertices for this bone to the convex element
for( int32 index=0; index<BoneInfo->Positions.Num(); index++ )
{
ConvexElem.VertexData.Add(BoneInfo->Positions[index]);
}
ConvexElem.UpdateElemBox();
bs->AggGeom.ConvexElems.Add(ConvexElem);
}else
{
FMessageLog EditorErrors("EditorErrors");
EditorErrors.Warning(NSLOCTEXT("PhysicsAssetUtils", "ConvexNoPositions", "Unable to create a convex hull for the given bone as there are no vertices associated with the bone."));
EditorErrors.Open();
return false;
}
}
else if (Params.GeomType == EFG_MultiConvexHull)
{