]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_scene.py
Compare materials when looking for object clones while exporting a scene
[libs/gl.git] / blender / io_mspgl / export_scene.py
index bec779cc9097a9f0256c2df6b9cb45f51a30d1e6..18cdcbca2404cea30f14b89f863e9aecef512c38 100644 (file)
@@ -35,16 +35,15 @@ class SceneExporter:
                                continue
 
                        clones = [o]
-                       if not any(s.link=="OBJECT" for s in o.material_slots):
-                               for u in objs:
-                                       if u is o:
-                                               continue
-                                       if u.data.name!=o.data.name:
-                                               continue
-                                       if any(s.link=="OBJECT" for s in u.material_slots):
-                                               continue
+                       for u in objs:
+                               if u is o:
+                                       continue
+                               if u.data.name!=o.data.name:
+                                       continue
+                               if any(m1.name!=m2.name for m1, m2 in zip(o.material_slots, u.material_slots)):
+                                       continue
 
-                                       clones.append(u)
+                               clones.append(u)
 
                        prefix = o.name
                        for c in clones:
@@ -77,7 +76,7 @@ class SceneExporter:
                        filter = None
                        if self.skip_existing:
                                filter = lambda r: not os.path.exists(os.path.join(path, r.name))
-                       scene_res.write_collection(os.path.join(path, base+"_resources.mdc"), exclude=self=True, filter)
+                       scene_res.write_collection(os.path.join(path, base+"_resources.mdc"), exclude_self=True, filter=filter)
                else:
                        res_dir = os.path.join(path, base+"_resources")
                        if not os.path.exists(res_dir):
@@ -92,11 +91,11 @@ class SceneExporter:
                object_export = ObjectExporter()
                object_export.single_file = False
 
-               material_atlass = {}
+               material_atlases = {}
 
                for i, o in enumerate(objs):
                        progress.push_task_slice(o.name, i, len(objs))
-                       object_export.export_object_resources(context, o, resources, progress, material_atlass=material_atlass)
+                       object_export.export_object_resources(context, o, resources, progress, material_atlases=material_atlases)
                        obj_name = o.name+".object"
                        resources[obj_name] = object_export.export_object(context, o, progress, resources=resources)
                        progress.pop_task()