Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,33 +171,35 @@ bool GetMeshes(PhysicsShapeAuthoring shape, out List<UnityEngine.Mesh> meshes, o
meshes.Add(shape.CustomMesh);
childrenToShape.Add(float4x4.identity);
}

// Try to get all the meshes in the children
var meshFilters = GetComponentsInChildren<MeshFilter>();

foreach (var meshFilter in meshFilters)
else
{
if (meshFilter != null && meshFilter.sharedMesh != null)
// Try to get all the meshes in the children
var meshFilters = GetComponentsInChildren<MeshFilter>();

foreach (var meshFilter in meshFilters)
{
var shapeAuthoring = GetComponent<PhysicsShapeAuthoring>(meshFilter);
if (shapeAuthoring != null && shapeAuthoring != shape)
{
// Skip this case, since it will be treated independently
continue;
}

meshes.Add(meshFilter.sharedMesh);

// Don't calculate the children to shape if not needed, to avoid approximation that could prevent collider to be shared
if (shape.transform.localToWorldMatrix.Equals(meshFilter.transform.localToWorldMatrix))
childrenToShape.Add(float4x4.identity);
else
if (meshFilter != null && meshFilter.sharedMesh != null)
{
var transform = math.mul(shape.transform.worldToLocalMatrix, meshFilter.transform.localToWorldMatrix);
childrenToShape.Add(transform);
var shapeAuthoring = GetComponent<PhysicsShapeAuthoring>(meshFilter);
if (shapeAuthoring != null && shapeAuthoring != shape)
{
// Skip this case, since it will be treated independently
continue;
}

meshes.Add(meshFilter.sharedMesh);

// Don't calculate the children to shape if not needed, to avoid approximation that could prevent collider to be shared
if (shape.transform.localToWorldMatrix.Equals(meshFilter.transform.localToWorldMatrix))
childrenToShape.Add(float4x4.identity);
else
{
var transform = math.mul(shape.transform.worldToLocalMatrix, meshFilter.transform.localToWorldMatrix);
childrenToShape.Add(transform);
}

DependsOn(meshes.Last());
}

DependsOn(meshes.Last());
}
}

Expand Down