[Bf-extensions-cvs] [2bc3cae4] master: Fixed duplicate nodes bug + added alpha socket + you can set limit for temp folder

Kalle-Samuli Riihikoski noreply at git.blender.org
Tue Mar 12 12:41:48 CET 2019


Commit: 2bc3cae4cd731670480e7c47f35c5394e457b60d
Author: Kalle-Samuli Riihikoski
Date:   Tue Mar 12 13:40:44 2019 +0200
Branches: master
https://developer.blender.org/rBA2bc3cae4cd731670480e7c47f35c5394e457b60d

Fixed duplicate nodes bug + added alpha socket + you can set limit for temp folder

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

M	io_coat3D/__init__.py
M	io_coat3D/tex.py

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

diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py
index 8d3ded05..472867ec 100644
--- a/io_coat3D/__init__.py
+++ b/io_coat3D/__init__.py
@@ -69,17 +69,20 @@ def update_exe_path():
 
 def folder_size(path):
 
-    tosi = True
-    while tosi:
-        list_of_files = []
-        for file in os.listdir(path):
-            list_of_files.append(path + os.sep + file)
-
-        if len(list_of_files) >= 400:
-            oldest_file = min(list_of_files, key=os.path.getctime)
-            os.remove(os.path.abspath(oldest_file))
-        else:
-            tosi = False
+    folder_size_max = int(bpy.context.scene.coat3D.folder_size)
+
+    if(bpy.context.scene.coat3D.defaultfolder == ''):
+        tosi = True
+        while tosi:
+            list_of_files = []
+            for file in os.listdir(path):
+                list_of_files.append(path + os.sep + file)
+
+            if len(list_of_files) >= folder_size_max:
+                oldest_file = min(list_of_files, key=os.path.getctime)
+                os.remove(os.path.abspath(oldest_file))
+            else:
+                tosi = False
 
 def set_exchange_folder():
     platform = os.sys.platform
@@ -1362,6 +1365,9 @@ class SCENE_PT_Settings_Folders(ObjectButtonsPanel, bpy.types.Panel):
         col = flow.column()
         col.prop(coat3D, "coat3D_exe", text="3D-Coat.exe")
 
+        col = flow.column()
+        col.prop(coat3D, "folder_size", text="Max count in Applink folder")
+
 class SCENE_PT_Settings_DeleteNodes(ObjectButtonsPanel, bpy.types.Panel):
     bl_label = "Delete 3DC nodes from selected..."
     bl_parent_id = "SCENE_PT_Settings"
@@ -1385,11 +1391,13 @@ class SCENE_PT_Settings_DeleteNodes(ObjectButtonsPanel, bpy.types.Panel):
         col.operator("delete_collection_nodes.pilgway_3d_coat", text="Collection")
 
         col.operator("delete_scene_nodes.pilgway_3d_coat", text="Scene")
+
         col = flow.column()
         col.prop(coat3D, "delete_images", text="Delete nodes images")
 
 
 
+
 # 3D-Coat Dynamic Menu
 class VIEW3D_MT_Coat_Dynamic_Menu(bpy.types.Menu):
     bl_label = "3D-Coat Applink Menu"
@@ -1653,6 +1661,18 @@ class SceneCoat3D(PropertyGroup):
                ),
         default="res_1024"
     )
+    folder_size: EnumProperty(
+        name="Applink folder size",
+        description="Applink folder size.",
+        items=(("10", "10", ""),
+               ("100", "100", ""),
+               ("500", "500", ""),
+               ("1000", "1000", ""),
+               ("5000", "5000", ""),
+               ("10000", "10000", ""),
+               ),
+        default="500"
+    )
     bake_textures: BoolProperty(
         name="Bake all textures",
         description="Add Modifiers and export",
diff --git a/io_coat3D/tex.py b/io_coat3D/tex.py
index 1d029d21..2ef732bf 100644
--- a/io_coat3D/tex.py
+++ b/io_coat3D/tex.py
@@ -287,16 +287,33 @@ def createnodes(active_mat,texcoat, create_group_node, tile_list, objekti, ind,
 
     print('TeXture UPDATE happens')
     for node in act_material.nodes:
-        if(node.type == 'TEX_IMAGE'):
-            if(node.name == '3DC_color'):
+        if (node.type != 'GROUP'):
+            if (node.type != 'GROUP_OUTPUT'):
+                if (node.type == 'TEX_IMAGE'):
+                    if (node.name == '3DC_color'):
+                        bring_color = False
+                    elif (node.name == '3DC_metalness'):
+                        bring_metalness = False
+                    elif (node.name == '3DC_roughness'):
+                        bring_roughness = False
+                    elif (node.name == '3DC_nmap'):
+                        bring_normal = False
+                    elif (node.name == '3DC_displacement'):
+                        bring_displacement = False
+                    elif (node.name == '3DC_emissive'):
+                        bring_emissive = False
+                    elif (node.name == '3DC_AO'):
+                        bring_AO = False
+        elif (node.type == 'GROUP' and node.name.startswith('3DC_')):
+            if (node.name == '3DC_color'):
                 bring_color = False
-            elif(node.name == '3DC_metalness'):
+            elif (node.name == '3DC_metalness'):
                 bring_metalness = False
-            elif(node.name == '3DC_rough'):
+            elif (node.name == '3DC_roughness'):
                 bring_roughness = False
-            elif(node.name == '3DC_nmap'):
+            elif (node.name == '3DC_nmap'):
                 bring_normal = False
-            elif(node.name == '3DC_displacement'):
+            elif (node.name == '3DC_displacement'):
                 bring_displacement = False
             elif (node.name == '3DC_emissive'):
                 bring_emissive = False
@@ -323,6 +340,7 @@ def createnodes(active_mat,texcoat, create_group_node, tile_list, objekti, ind,
             group_tree.outputs.new("NodeSocketColor", "Displacement")
             group_tree.outputs.new("NodeSocketColor", "Emissive Power")
             group_tree.outputs.new("NodeSocketColor", "AO")
+            group_tree.outputs.new("NodeSocketColor", "Alpha")
             applink_tree = act_material.nodes.new('ShaderNodeGroup')
             applink_tree.name = '3DC_Applink'
             applink_tree.node_tree = group_tree
@@ -401,6 +419,7 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup,
         texture_name = coatMat.name + '_' + type['name']
         texture_tree = bpy.data.node_groups.new(type="ShaderNodeTree", name=texture_name)
         texture_tree.outputs.new("NodeSocketColor", "Color")
+        texture_tree.outputs.new("NodeSocketColor", "Alpha")
         texture_node_tree = act_material.nodes.new('ShaderNodeGroup')
         texture_node_tree.name = '3DC_' + type['name']
         texture_node_tree.node_tree = texture_tree
@@ -457,6 +476,7 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup,
                 nodes.append(tex_img_node.name)
             if(count == 1):
                 texture_tree.links.new(tex_img_node.outputs[0], notegroupend.inputs[0])
+                texture_tree.links.new(tex_img_node.outputs[1], notegroupend.inputs[1])
 
             if(index > 0):
                 mix_node = texture_tree.nodes.new('ShaderNodeMixRGB')
@@ -466,8 +486,17 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup,
                 mix_loc[1] -= 300
                 texture_tree.links.new(tex_img_node.outputs[0], mix_node.inputs[2])
                 texture_tree.links.new(texture_tree.nodes[nodes[0]].outputs[0], mix_node.inputs[1])
+
+                mix_node_alpha = texture_tree.nodes.new('ShaderNodeMixRGB')
+                mix_node_alpha.blend_type = 'ADD'
+                mix_node_alpha.inputs[0].default_value = 1
+                mix_node_alpha.location = mix_loc
+                mix_loc[1] -= 200
+                texture_tree.links.new(tex_img_node.outputs[1], mix_node_alpha.inputs[2])
+                texture_tree.links.new(texture_tree.nodes[nodes[0]].outputs[0], mix_node_alpha.inputs[1])
                 nodes.clear()
                 nodes.append(mix_node.name)
+                nodes.append(mix_node_alpha.name)
 
 
             elif(index > 1):
@@ -478,6 +507,15 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup,
                 mix_loc[1] -= 300
                 texture_tree.links.new(texture_tree.nodes[nodes[0]].outputs[0], mix_node.inputs[1])
                 texture_tree.links.new(tex_img_node.outputs[0], mix_node.inputs[2])
+
+                mix_node_alpha = texture_tree.nodes.new('ShaderNodeMixRGB')
+                mix_node_alpha.blend_type = 'ADD'
+                mix_node_alpha.inputs[0].default_value = 1
+                mix_node_alpha.location = mix_loc
+                mix_loc[1] -= 200
+                texture_tree.links.new(texture_tree.nodes[nodes[0]].outputs[1], mix_node_alpha.inputs[1])
+                texture_tree.links.new(tex_img_node.outputs[1], mix_node_alpha.inputs[2])
+
                 nodes.clear()
                 nodes.append(tex_img_node.name)
                 nodes.append(mix_node.name)
@@ -491,11 +529,14 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup,
 
         if(count > 1):
             texture_tree.links.new(mix_node.outputs[0], notegroupend.inputs[0])
+            texture_tree.links.new(mix_node_alpha.outputs[0], notegroupend.inputs[1])
 
 
 
     if(tile_list):
         node = texture_node_tree
+        act_material.links.new(node.outputs[1], notegroup.inputs[8])
+
 
     else:
         node = act_material.nodes.new('ShaderNodeTexImage')
@@ -573,6 +614,9 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup,
 
         else:
 
+            if(type['name'] == 'color'):
+                act_material.links.new(node.outputs[1], notegroup.inputs[8])
+
             huenode = createExtraNodes(act_material, node, type)
 
             act_material.links.new(huenode.outputs[0], notegroup.inputs[type['input']])



More information about the Bf-extensions-cvs mailing list