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.
This commit is contained in:
Bastien Montagne 2017-10-10 12:32:50 +02:00
parent 0ec1bacc4d
commit e8f09a8e0b
Notes: blender-bot 2023-02-14 19:34:22 +01:00
Referenced by commit 9b5b8379: Fix for Fix (c): T52945: OBJ import - load_material_image - map_options not parsed correctly.
Referenced by commit 9b5b8379, Fix for Fix (c): T52945: OBJ import - load_material_image - map_options not parsed correctly.
Referenced by issue #52945, OBJ import - load_material_image - map_options not parsed correctly
1 changed files with 5 additions and 2 deletions

View File

@ -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: