[Bf-extensions-cvs] [96036641] master: glTF importer: create only 1 slot by material, if multiple primitive use same material

Julien Duroure noreply at git.blender.org
Thu Sep 26 18:16:00 CEST 2019


Commit: 96036641899e5a9c84b5fd9963b49e6737328d4e
Author: Julien Duroure
Date:   Thu Sep 26 17:20:50 2019 +0200
Branches: master
https://developer.blender.org/rBA96036641899e5a9c84b5fd9963b49e6737328d4e

glTF importer: create only 1 slot by material, if multiple primitive use same material

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/imp/gltf2_blender_mesh.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 23745bcf..8ce7d155 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
-    "version": (0, 9, 76),
+    "version": (0, 9, 77),
     'blender': (2, 81, 6),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
index cfe73058..0ba34dd5 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
@@ -61,9 +61,9 @@ class BlenderMesh():
                 material = bpy.data.materials[material_name]
 
                 try:
-                    material_idx = materials.index(material)
+                    material_idx = materials.index(material.name)
                 except ValueError:
-                    materials.append(material)
+                    materials.append(material.name)
                     material_idx = len(materials) - 1
 
             BlenderPrimitive.add_primitive_to_bmesh(gltf, bme, pymesh, prim, material_idx)
@@ -72,8 +72,8 @@ class BlenderMesh():
         mesh = bpy.data.meshes.new(name)
         BlenderMesh.bmesh_to_mesh(gltf, pymesh, bme, mesh)
         bme.free()
-        for material in materials:
-            mesh.materials.append(material)
+        for name_material in materials:
+            mesh.materials.append(bpy.data.materials[name_material])
         mesh.update()
 
         pymesh.blender_name = mesh.name



More information about the Bf-extensions-cvs mailing list