[Bf-extensions-cvs] [e8f09a8e] master: Fix T52945: OBJ import - load_material_image - map_options not parsed correctly.

Bastien Montagne noreply at git.blender.org
Tue Oct 10 12:35:39 CEST 2017


Commit: e8f09a8e0b28eb7eeb6bfc37d9957c3b680e6da5
Author: Bastien Montagne
Date:   Tue Oct 10 12:32:50 2017 +0200
Branches: master
https://developer.blender.org/rBAe8f09a8e0b28eb7eeb6bfc37d9957c3b680e6da5

Fix T52945: OBJ import - load_material_image - map_options not parsed correctly.

There were two issues - last set of option's tokens would not get added
correctly to map_options of current directive, and multiplification
factor of bumpmap was not correctly converted to float.

Thanks a bunch to @Tim Knip (timknip) for reporting the issue,
investigating it and proposing this patch.

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

M	io_scene_obj/import_obj.py

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

diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index c3390d4d..ce36f5ca 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -114,6 +114,8 @@ def create_materials(filepath, relpath,
                     map_options[curr_token[0]] = curr_token[1:]
                 curr_token[:] = []
             curr_token.append(token)
+        if curr_token:
+            map_options[curr_token[0]] = curr_token[1:]
 
         # Absolute path - c:\.. etc would work here
         image = obj_image_load(context_imagepath_map, line, DIR, use_image_search, relpath)
@@ -175,12 +177,13 @@ def create_materials(filepath, relpath,
 
         elif type == 'Bump':
             bump_mult = map_options.get(b'-bm')
+            bump_mult = float(bump_mult[0]) if len(bump_mult) > 1 else 1.0
 
             if use_cycles:
                 mat_wrap.normal_image_set(image)
                 mat_wrap.normal_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
                 if bump_mult:
-                    mat_wrap.normal_factor_set(bump_mult[0])
+                    mat_wrap.normal_factor_set(bump_mult)
 
             mtex = blender_material.texture_slots.add()
             mtex.use_map_color_diffuse = False
@@ -188,7 +191,7 @@ def create_materials(filepath, relpath,
             mtex.texture_coords = 'UV'
             mtex.use_map_normal = True
             if bump_mult:
-                mtex.normal_factor = bump_mult[0]
+                mtex.normal_factor = bump_mult
 
         elif type == 'D':
             if use_cycles:



More information about the Bf-extensions-cvs mailing list