From 4e8ddec4e1be8e67da90fe244707fb2077837604 Mon Sep 17 00:00:00 2001
From: Jacques Lucke <mail@jlucke.com>
Date: Wed, 30 Jan 2019 12:44:08 +0100
Subject: [PATCH] Fix: Material.diffuse_color has an alpha component now

---
 add_curve_extra_objects/add_curve_torus_knots.py |  4 ++--
 archimesh/achm_tools.py                          | 16 ++++++++--------
 io_curve_svg/import_svg.py                       |  4 ++--
 io_scene_obj/import_obj.py                       |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/add_curve_extra_objects/add_curve_torus_knots.py b/add_curve_extra_objects/add_curve_torus_knots.py
index a3c05ff63..30d19b583 100644
--- a/add_curve_extra_objects/add_curve_torus_knots.py
+++ b/add_curve_extra_objects/add_curve_torus_knots.py
@@ -325,10 +325,10 @@ def addLinkColors(self, curveData):
 
         # set material color
         if self.options_plus and self.random_colors:
-            mat.diffuse_color = random(), random(), random()
+            mat.diffuse_color = (random(), random(), random(), 1.0)
         else:
             cID = i % (len(colors))  # cycle through predefined colors
-            mat.diffuse_color = colors[cID]
+            mat.diffuse_color = (*colors[cID], 1.0)
 
         if self.options_plus:
             mat.diffuse_color.s = self.saturation
diff --git a/archimesh/achm_tools.py b/archimesh/achm_tools.py
index 8d44fe0cd..3a7755168 100644
--- a/archimesh/achm_tools.py
+++ b/archimesh/achm_tools.py
@@ -328,7 +328,7 @@ def create_diffuse_material(matname, replace, r, g, b, rv=0.8, gv=0.8, bv=0.8, m
                 return m
     # Create material
     mat = bpy.data.materials.new(matname)
-    mat.diffuse_color = (rv, gv, bv)  # viewport color
+    mat.diffuse_color = (rv, gv, bv, 1.0)  # viewport color
     mat.use_nodes = True
     nodes = mat.node_tree.nodes
 
@@ -412,7 +412,7 @@ def create_translucent_material(matname, replace, r, g, b, rv=0.8, gv=0.8, bv=0.
                 return m
     # Create material
     mat = bpy.data.materials.new(matname)
-    mat.diffuse_color = (rv, gv, bv)  # viewport color
+    mat.diffuse_color = (rv, gv, bv, 1.0)  # viewport color
     mat.use_nodes = True
     nodes = mat.node_tree.nodes
 
@@ -465,7 +465,7 @@ def create_glass_material(matname, replace, rv=0.333, gv=0.342, bv=0.9):
     # Create material
     mat = bpy.data.materials.new(matname)
     mat.use_nodes = True
-    mat.diffuse_color = (rv, gv, bv)
+    mat.diffuse_color = (rv, gv, bv, 1.0)
     nodes = mat.node_tree.nodes
 
     # support for multilanguage
@@ -544,7 +544,7 @@ def create_transparent_material(matname, replace, r=1, g=1, b=1, alpha=0):
     # Create material
     mat = bpy.data.materials.new(matname)
     mat.use_nodes = True
-    mat.diffuse_color = (r, g, b)
+    mat.diffuse_color = (r, g, b, 1.0)
     nodes = mat.node_tree.nodes
 
     # support for multilanguage
@@ -580,7 +580,7 @@ def create_glossy_material(matname, replace, r, g, b, rv=0.578, gv=0.555, bv=0.7
     # Create material
     mat = bpy.data.materials.new(matname)
     mat.use_nodes = True
-    mat.diffuse_color = (rv, gv, bv)
+    mat.diffuse_color = (rv, gv, bv, 1.0)
     nodes = mat.node_tree.nodes
 
     # support for multilanguage
@@ -653,7 +653,7 @@ def create_old_glass_material(matname, replace, rv=0.352716, gv=0.760852, bv=0.9
     # Create material
     mat = bpy.data.materials.new(matname)
     mat.use_nodes = True
-    mat.diffuse_color = (rv, gv, bv)
+    mat.diffuse_color = (rv, gv, bv, 1.0)
     nodes = mat.node_tree.nodes
 
     # support for multilanguage
@@ -726,7 +726,7 @@ def create_brick_material(matname, replace, r, g, b, rv=0.8, gv=0.636, bv=0.315)
     # Create material
     mat = bpy.data.materials.new(matname)
     mat.use_nodes = True
-    mat.diffuse_color = (rv, gv, bv)
+    mat.diffuse_color = (rv, gv, bv, 1.0)
     nodes = mat.node_tree.nodes
 
     # support for multilanguage
@@ -782,7 +782,7 @@ def create_fabric_material(matname, replace, r, g, b, rv=0.8, gv=0.636, bv=0.315
     # Create material
     mat = bpy.data.materials.new(matname)
     mat.use_nodes = True
-    mat.diffuse_color = (rv, gv, bv)
+    mat.diffuse_color = (rv, gv, bv, 1.0)
     nodes = mat.node_tree.nodes
 
     # support for multilanguage
diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py
index c73027111..072bbc19d 100644
--- a/io_curve_svg/import_svg.py
+++ b/io_curve_svg/import_svg.py
@@ -52,7 +52,7 @@ def srgb_to_linearrgb(c):
         return pow((c + 0.055) * (1.0 / 1.055), 2.4)
 
 def check_points_equal(point_a, point_b):
-    return (abs(point_a[0] - point_b[0]) < 1e-6 and 
+    return (abs(point_a[0] - point_b[0]) < 1e-6 and
             abs(point_a[1] - point_b[1]) < 1e-6)
 
 
@@ -308,7 +308,7 @@ def SVGGetMaterial(color, context):
         diffuse_color[2] = srgb_to_linearrgb(diffuse_color[2])
 
     mat = bpy.data.materials.new(name='SVGMat')
-    mat.diffuse_color = diffuse_color
+    mat.diffuse_color = (*diffuse_color, 1.0)
 
     materials[color] = mat
 
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index f58ca0836..ddb2658f8 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -205,7 +205,7 @@ def create_materials(filepath, relpath,
             if emit_value > 1e-6:
                 print("WARNING, emit value unsupported by Principled BSDF shader, skipped.")
                 # We have to adapt it to diffuse color too...
-                emit_value /= sum(context_material.diffuse_color) / 3.0
+                emit_value /= sum(tuple(context_material.diffuse_color)[:3]) / 3.0
             # ~ context_material.emit = emit_value
 
             # FIXME, how else to use this?
-- 
GitLab