# Collision bug in 4.13 for auto convex meshes

**URL:** <https://forums.unrealengine.com/t/collision-bug-in-4-13-for-auto-convex-meshes/381369>\
**Category:** World Creation\
**Tags:** fyi, UE4-13, unreal-engine, Collision, question\
**Created:** [January 9, 2017, 7:11pm UTC](https://forums.unrealengine.com/t/collision-bug-in-4-13-for-auto-convex-meshes/381369 "2017-01-09T19:11:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Answers.Archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Answers.Archive](https://forums.unrealengine.com/u/Answers.Archive)\
**Post date:** [January 9, 2017, 7:11pm UTC](https://forums.unrealengine.com/t/collision-bug-in-4-13-for-auto-convex-meshes/381369/1 "2017-01-09T19:11:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Answers.Archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Answers.Archive](https://forums.unrealengine.com/u/Answers.Archive)\
**Post date:** [January 9, 2017, 7:11pm UTC](https://forums.unrealengine.com/t/collision-bug-in-4-13-for-auto-convex-meshes/381369/2 "2017-01-09T19:11:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Answers.Archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Answers.Archive](https://forums.unrealengine.com/u/Answers.Archive)\
**Post date:** [January 9, 2017, 7:11pm UTC](https://forums.unrealengine.com/t/collision-bug-in-4-13-for-auto-convex-meshes/381369/3 "2017-01-09T19:11:12Z")

</div>

Thanks for the fix!
