From e19c15d60c1b4154b8c99e685ad6e92b5679e943 Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Wed, 1 Apr 2020 17:16:53 -0700 Subject: [PATCH] An easy-to-read error is now reported when a mesh material is empty --- src/psk/builder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/psk/builder.py b/src/psk/builder.py index 10a083a..2078fc2 100644 --- a/src/psk/builder.py +++ b/src/psk/builder.py @@ -32,7 +32,7 @@ class PskBuilder(object): # TODO: probably requires at least one bone? not sure mesh_data = object.data - # TODO: if there is an edge-split modifier, we need to apply it. + # TODO: if there is an edge-split modifier, we need to apply it (maybe?) # TODO: duplicate all the data mesh = bpy.data.meshes.new('export') @@ -40,7 +40,6 @@ class PskBuilder(object): # copy the contents of the mesh bm = bmesh.new() bm.from_mesh(mesh_data) - # triangulate everything bmesh.ops.triangulate(bm, faces=bm.faces) bm.to_mesh(mesh) bm.free() @@ -74,6 +73,8 @@ class PskBuilder(object): # MATERIALS for i, m in enumerate(object.data.materials): + if m is None: + raise RuntimeError('Material cannot be empty (index ' + str(i) + ')') material = Psk.Material() material.name = bytes(m.name, encoding='utf-8') material.texture_index = i