Refs #2612 - Added an error message and tried preventing exports of empty primitive meshes

This commit is contained in:
Christian Petry
2025-03-17 07:34:26 +01:00
parent 38c4313d95
commit 33ff6e5759
3 changed files with 10 additions and 3 deletions

View File

@@ -310,9 +310,6 @@ namespace UniGLTF
{
var node = data.GLTF.nodes[channel.target.node];
var mesh = data.GLTF.meshes[node.mesh];
var primitive = mesh.primitives.FirstOrDefault();
var targets = primitive.targets;
if (!gltf_mesh_extras_targetNames.TryGet(mesh, out List<string> targetNames))
{
throw new UniGLTFNotSupportedException("glTF BlendShape Animation. targetNames invalid.");

View File

@@ -78,6 +78,10 @@ namespace UniGLTF
{
return false;
}
if (Mesh.triangles.Length == 0)
{
return false;
}
if (Materials == null)
{
return false;

View File

@@ -273,6 +273,12 @@ namespace UniGLTF
? MeshExporter_DividedVertexBuffer.Export(_data, unityMesh, Materials, m_settings.InverseAxis.Create(), m_settings)
: MeshExporter_SharedVertexBuffer.Export(_data, unityMesh, Materials, m_settings.InverseAxis.Create(), m_settings)
;
if (gltfMesh.primitives == null || gltfMesh.primitives.Count == 0)
{
Debug.LogError($"gltfMesh.primitives is empty: {unityMesh.Mesh.name}");
}
_gltf.meshes.Add(gltfMesh);
Meshes.Add(unityMesh.Mesh);
if (!MeshBlendShapeIndexMap.ContainsKey(unityMesh.Mesh))