Collision bug in 4.13 for auto convex meshes

Hello,

As of 4.13, if a user imports a static mesh with Auto Generate Collision disabled, the user will not be able to generate collision for this mesh until they either,

  • Import a new mesh w/ the same path/name and override its settings
  • OR delete the mesh and re-import (normally the worse of the two known choices)

This is due to this change in

bool UnFbx::FFbxImporter::BuildStaticMeshFromGeometry(FbxNode* Node, UStaticMesh* StaticMesh, TArray& MeshMaterials, int32 LODIndex,FRawMesh& RawMesh,
	EVertexColorImportOption::Type VertexColorImportOption, const TMap& ExistingVertexColorData, const FColor& VertexOverrideColor)

Specifically,

	//If we import a collision or we "generate one and remove the degenerates triangles" we will automatically set the section collision boolean.
	bool bEnableCollision = bImportedCollision || (GBuildStaticMeshCollision && LODIndex == 0 && ImportOptions->bAutoGenerateCollision);
	for(int32 SectionIndex=MaterialIndexOffset; SectionIndexSectionInfoMap.Get(LODIndex, SectionIndex);
		Info.bEnableCollision = bEnableCollision;
		StaticMesh->SectionInfoMap.Set(LODIndex, SectionIndex, Info);
	}

As of 4.13, each section has collision disabled, however, when auto convex is ran, it never checks the current setting of whether to allow collision to be enabled. It just checks each section and only generates the sections that have collision enabled in,
void FStaticMeshEditor::DoDecomp(float InAccuracy, int32 InMaxHullVerts)
{
// Check we have a selected StaticMesh
if(StaticMesh && StaticMesh->RenderData)
{
FStaticMeshLODResources& LODModel = StaticMesh->RenderData->LODResources[0];

		// Start a busy cursor so the user has feedback while waiting
		const FScopedBusyCursor BusyCursor;

		// Make vertex buffer
		int32 NumVerts = LODModel.VertexBuffer.GetNumVertices();
		TArray Verts;
		for(int32 i=0; i AllIndices;
		LODModel.IndexBuffer.GetCopy(AllIndices);

		// Only copy indices that have collision enabled
		TArray CollidingIndices;
		for(const FStaticMeshSection& Section : LODModel.Sections)
		{
			if(Section.bEnableCollision)
			{
				for (uint32 IndexIdx = Section.FirstIndex; IndexIdx < Section.FirstIndex + (Section.NumTriangles * 3); IndexIdx++)
				{
					CollidingIndices.Add(AllIndices[IndexIdx]);
				}
			}
		}

I suppose the correct fix would be either updating the sections for collision when the auto generate collision option changes, or if needed, have the auto convex portion check this setting and update accordingly in a deferred manner.

We fixed a bug in 4.14 where disabling auto generate collision would disable collision entirely on the mesh. The changelist is 3182164 if you want to get it directly. It seems like just enabling collision on each section before running auto-convex would work too but it was definitely not intended that we disable collision on all sections when importing without auto-generate on.

Thanks for the fix!