[Bf-extensions-cvs] [305781bd] blender2.8: FBX import: cleanup: remove 'use_cycles' parameter.

Bastien Montagne noreply at git.blender.org
Thu Oct 11 17:41:19 CEST 2018


Commit: 305781bd5d04e49249aaaa2f9ae52a2d75f97eb0
Author: Bastien Montagne
Date:   Thu Oct 11 16:52:14 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBA305781bd5d04e49249aaaa2f9ae52a2d75f97eb0

FBX import: cleanup: remove 'use_cycles' parameter.

That's now useless in 2.8, we always 'use cycles' materials. :p

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

M	io_scene_fbx/__init__.py
M	io_scene_fbx/fbx_utils.py
M	io_scene_fbx/import_fbx.py

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

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 680f1f5c..d1d0389f 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -226,8 +226,6 @@ class ImportFBX(bpy.types.Operator, ImportHelper):
 
     def execute(self, context):
         keywords = self.as_keywords(ignore=("filter_glob", "directory", "ui_tab"))
-        # XXX TODO get rid of this, EEVEE/Cycles use same nodal system...
-        keywords["use_cycles"] = True #(context.scene.render.engine == 'CYCLES')
 
         from . import import_fbx
         return import_fbx.load(self, context, **keywords)
diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py
index bbf4ac74..ecb6ee28 100644
--- a/io_scene_fbx/fbx_utils.py
+++ b/io_scene_fbx/fbx_utils.py
@@ -1241,7 +1241,7 @@ FBXExportData = namedtuple("FBXExportData", (
 FBXImportSettings = namedtuple("FBXImportSettings", (
     "report", "to_axes", "global_matrix", "global_scale",
     "bake_space_transform", "global_matrix_inv", "global_matrix_inv_transposed",
-    "use_custom_normals", "use_cycles", "use_image_search",
+    "use_custom_normals", "use_image_search",
     "use_alpha_decals", "decal_offset",
     "use_anim", "anim_offset",
     "use_custom_props", "use_custom_props_enum_as_string",
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index e092ee3e..8236abb0 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1334,35 +1334,19 @@ def blen_read_material(fbx_tmpl, fbx_obj, settings):
     ma_refl_factor = elem_props_get_number(fbx_props, b'ReflectionFactor', 0.0)
     ma_refl_color = elem_props_get_color_rgb(fbx_props, b'ReflectionColor', const_color_white)
 
-    if settings.use_cycles:
-        from modules import cycles_shader_compat
-        # viewport color
-        ma.diffuse_color = ma_diff
-
-        ma_wrap = cycles_shader_compat.CyclesShaderWrapper(ma)
-        ma_wrap.diffuse_color_set(ma_diff)
-        ma_wrap.specular_color_set([c * ma_spec_intensity for c in ma_spec])
-        ma_wrap.hardness_value_set(((ma_spec_hardness + 3.0) / 5.0) - 0.65)
-        ma_wrap.alpha_value_set(ma_alpha)
-        ma_wrap.reflect_factor_set(ma_refl_factor)
-        ma_wrap.reflect_color_set(ma_refl_color)
-
-        cycles_material_wrap_map[ma] = ma_wrap
-    else:
-        # TODO, number BumpFactor isnt used yet
-        ma.diffuse_color = ma_diff
-        ma.specular_color = ma_spec
-        ma.alpha = ma_alpha
-        if ma_alpha < 1.0:
-            ma.use_transparency = True
-            ma.transparency_method = 'RAYTRACE'
-        ma.specular_intensity = ma_spec_intensity
-        ma.specular_hardness = ma_spec_hardness * 5.10 + 1.0
-
-        if ma_refl_factor != 0.0:
-            ma.raytrace_mirror.use = True
-            ma.raytrace_mirror.reflect_factor = ma_refl_factor
-            ma.mirror_color = ma_refl_color
+    from modules import cycles_shader_compat
+    # viewport color
+    ma.diffuse_color = ma_diff
+
+    ma_wrap = cycles_shader_compat.CyclesShaderWrapper(ma)
+    ma_wrap.diffuse_color_set(ma_diff)
+    ma_wrap.specular_color_set([c * ma_spec_intensity for c in ma_spec])
+    ma_wrap.hardness_value_set(((ma_spec_hardness + 3.0) / 5.0) - 0.65)
+    ma_wrap.alpha_value_set(ma_alpha)
+    ma_wrap.reflect_factor_set(ma_refl_factor)
+    ma_wrap.reflect_color_set(ma_refl_color)
+
+    cycles_material_wrap_map[ma] = ma_wrap
 
     if settings.use_custom_props:
         blen_read_custom_properties(fbx_obj, ma, settings)
@@ -2246,7 +2230,6 @@ def load(operator, context, filepath="",
          global_scale=1.0,
          bake_space_transform=False,
          use_custom_normals=True,
-         use_cycles=True,
          use_image_search=False,
          use_alpha_decals=False,
          decal_offset=0.0,
@@ -2310,8 +2293,6 @@ def load(operator, context, filepath="",
 
     cycles_material_wrap_map = {}
     image_cache = {}
-    if not use_cycles:
-        texture_cache = {}
 
     # Tables: (FBX_byte_id -> [FBX_data, None or Blender_datablock])
     fbx_table_nodes = {}
@@ -2379,7 +2360,7 @@ def load(operator, context, filepath="",
     settings = FBXImportSettings(
         operator.report, (axis_up, axis_forward), global_matrix, global_scale,
         bake_space_transform, global_matrix_inv, global_matrix_inv_transposed,
-        use_custom_normals, use_cycles, use_image_search,
+        use_custom_normals, use_image_search,
         use_alpha_decals, decal_offset,
         use_anim, anim_offset,
         use_custom_props, use_custom_props_enum_as_string,
@@ -2855,8 +2836,7 @@ def load(operator, context, filepath="",
                             continue
                         mat = fbx_item[1]
                         items.append((mat, lnk_prop))
-                        if settings.use_cycles:
-                            print("WARNING! Importing material's animation is not supported for Cycles materials...")
+                        print("WARNING! Importing material's animation is not supported for Nodal materials...")
                 for al_uuid, al_ctype in fbx_connection_map.get(acn_uuid, ()):
                     if al_ctype.props[0] != b'OO':
                         continue
@@ -2960,33 +2940,6 @@ def load(operator, context, filepath="",
                     (bool(elem_props_get_enum(fbx_props, b'WrapModeU', 0)),
                      bool(elem_props_get_enum(fbx_props, b'WrapModeV', 0))))
 
-        if not use_cycles:
-            # Simple function to make a new mtex and set defaults
-            def material_mtex_new(material, image, tex_map):
-                tex = texture_cache.get(image)
-                if tex is None:
-                    tex = bpy.data.textures.new(name=image.name, type='IMAGE')
-                    tex.image = image
-                    texture_cache[image] = tex
-
-                    # copy custom properties from image object to texture
-                    for key, value in image.items():
-                        tex[key] = value
-
-                    # delete custom properties on the image object
-                    for key in image.keys():
-                        del image[key]
-
-                mtex = material.texture_slots.add()
-                mtex.texture = tex
-                mtex.texture_coords = 'UV'
-                mtex.use_map_color_diffuse = False
-
-                # No rotation here...
-                mtex.offset[:] = tex_map[0]
-                mtex.scale[:] = tex_map[2]
-                return mtex
-
         for fbx_uuid, fbx_item in fbx_table_nodes.items():
             fbx_obj, blen_data = fbx_item
             if fbx_obj.id != b'Material':
@@ -2997,127 +2950,83 @@ def load(operator, context, filepath="",
                  image,
                  fbx_lnk_type) in connection_filter_reverse(fbx_uuid, b'Texture'):
 
-                if use_cycles:
-                    if fbx_lnk_type.props[0] == b'OP':
-                        lnk_type = fbx_lnk_type.props[3]
-
-                        ma_wrap = cycles_material_wrap_map[material]
+                if fbx_lnk_type.props[0] == b'OP':
+                    lnk_type = fbx_lnk_type.props[3]
 
-                        # tx/rot/scale
-                        tex_map = texture_mapping_get(fbx_lnk)
-                        if (tex_map[0] == (0.0, 0.0, 0.0) and
-                                tex_map[1] == (0.0, 0.0, 0.0) and
-                                tex_map[2] == (1.0, 1.0, 1.0) and
-                                tex_map[3] == (False, False)):
-                            use_mapping = False
-                        else:
-                            use_mapping = True
-                            tex_map_kw = {
-                                "translation": tex_map[0],
-                                "rotation": [-i for i in tex_map[1]],
-                                "scale": [((1.0 / i) if i != 0.0 else 1.0) for i in tex_map[2]],
-                                "clamp": tex_map[3],
-                                }
-
-                            """
-                            TODO for clamp:
-                                # awkward conversion UV clamping to minmax
-                                node_map.min = (0.0, 0.0, 0.0)
-                                node_map.max = (1.0, 1.0, 1.0)
-
-                                if clamp in {(False, False), (True, True)}:
-                                    node_map.use_min = node_map.use_max = clamp[0]
-                                else:
-                                    node_map.use_min = node_map.use_max = True
-                                    # use bool as index
-                                    node_map.min[not clamp[0]] = -1000000000.0
-                                    node_map.max[not clamp[0]] = 1000000000.0
-                            """
-
-                        if lnk_type in {b'DiffuseColor', b'3dsMax|maps|texmap_diffuse'}:
-                            ma_wrap.diffuse_image_set(image)
-                            if use_mapping:
-                                ma_wrap.diffuse_mapping_set(**tex_map_kw)
-                        elif lnk_type == b'SpecularColor':
-                            ma_wrap.specular_image_set(image)
-                            if use_mapping:
-                                ma_wrap.specular_mapping_set(**tex_map_kw)
-                        elif lnk_type in {b'ReflectionColor', b'3dsMax|maps|texmap_reflection'}:
-                            ma_wrap.reflect_image_set(image)
-                            if use_mapping:
-                                ma_wrap.reflect_mapping_set(**tex_map_kw)
-                        elif lnk_type == b'TransparentColor':  # alpha
-                            ma_wrap.alpha_image_set(image)
-                            if use_mapping:
-                                ma_wrap.alpha_mapping_set(**tex_map_kw)
-                            if use_alpha_decals:
-                                material_decals.add(material)
-                        elif lnk_type == b'DiffuseFactor':
-                            pass  # TODO
-                        elif lnk_type == b'ShininessExponent':
-                            ma_wrap.hardness_image_set(image)
-                         

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list