Fix T53841: Can not import .obj or .fbx generated from Marvelous Designer
FBX part at least - note that we are actualy coping with totally invalid FBX file, strings there should always be in utf-8 encoding as per offcial FBX doc... But this error-handling does not hurt really. Based in D3012 by Philipp Oeser (@lichtwerk). To be backported to 2.79a.
This commit is contained in:
parent
808565a770
commit
29ae03c572
Notes:
blender-bot
2023-02-14 19:32:11 +01:00
Referenced by issue #53841, Can not import .obj or .fbx generated from Marvelous Designer Referenced by issue #53684, 2.79a release - addons
|
@ -21,7 +21,7 @@
|
|||
bl_info = {
|
||||
"name": "FBX format",
|
||||
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
|
||||
"version": (3, 8, 5),
|
||||
"version": (3, 8, 6),
|
||||
"blender": (2, 79, 1),
|
||||
"location": "File > Import-Export",
|
||||
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
|
||||
|
|
|
@ -82,7 +82,7 @@ def elem_find_first_string(elem, id_search):
|
|||
if fbx_item is not None and fbx_item.props: # Do not error on complete empty properties (see T45291).
|
||||
assert(len(fbx_item.props) == 1)
|
||||
assert(fbx_item.props_type[0] == data_types.STRING)
|
||||
return fbx_item.props[0].decode('utf-8')
|
||||
return fbx_item.props[0].decode('utf-8', 'replace')
|
||||
return None
|
||||
|
||||
|
||||
|
@ -124,14 +124,14 @@ def elem_name_ensure_class(elem, clss=...):
|
|||
elem_name, elem_class = elem_split_name_class(elem)
|
||||
if clss is not ...:
|
||||
assert(elem_class == clss)
|
||||
return elem_name.decode('utf-8')
|
||||
return elem_name.decode('utf-8', 'replace')
|
||||
|
||||
|
||||
def elem_name_ensure_classes(elem, clss=...):
|
||||
elem_name, elem_class = elem_split_name_class(elem)
|
||||
if clss is not ...:
|
||||
assert(elem_class in clss)
|
||||
return elem_name.decode('utf-8')
|
||||
return elem_name.decode('utf-8', 'replace')
|
||||
|
||||
|
||||
def elem_split_name_class_nodeattr(elem):
|
||||
|
@ -308,13 +308,13 @@ def blen_read_custom_properties(fbx_obj, blen_obj, settings):
|
|||
# Special case for 3DS Max user properties:
|
||||
assert(fbx_prop.props[1] == b'KString')
|
||||
assert(fbx_prop.props_type[4] == data_types.STRING)
|
||||
items = fbx_prop.props[4].decode('utf-8')
|
||||
items = fbx_prop.props[4].decode('utf-8', 'replace')
|
||||
for item in items.split('\r\n'):
|
||||
if item:
|
||||
prop_name, prop_value = item.split('=', 1)
|
||||
blen_obj[prop_name.strip()] = prop_value.strip()
|
||||
else:
|
||||
prop_name = fbx_prop.props[0].decode('utf-8')
|
||||
prop_name = fbx_prop.props[0].decode('utf-8', 'replace')
|
||||
prop_type = fbx_prop.props[1]
|
||||
if prop_type in {b'Vector', b'Vector3D', b'Color', b'ColorRGB'}:
|
||||
assert(fbx_prop.props_type[4:7] == bytes((data_types.FLOAT64,)) * 3)
|
||||
|
@ -330,7 +330,7 @@ def blen_read_custom_properties(fbx_obj, blen_obj, settings):
|
|||
blen_obj[prop_name] = fbx_prop.props[4]
|
||||
elif prop_type == b'KString':
|
||||
assert(fbx_prop.props_type[4] == data_types.STRING)
|
||||
blen_obj[prop_name] = fbx_prop.props[4].decode('utf-8')
|
||||
blen_obj[prop_name] = fbx_prop.props[4].decode('utf-8', 'replace')
|
||||
elif prop_type in {b'Number', b'double', b'Double'}:
|
||||
assert(fbx_prop.props_type[4] == data_types.FLOAT64)
|
||||
blen_obj[prop_name] = fbx_prop.props[4]
|
||||
|
@ -344,13 +344,13 @@ def blen_read_custom_properties(fbx_obj, blen_obj, settings):
|
|||
assert(fbx_prop.props_type[4:6] == bytes((data_types.INT32, data_types.STRING)))
|
||||
val = fbx_prop.props[4]
|
||||
if settings.use_custom_props_enum_as_string and fbx_prop.props[5]:
|
||||
enum_items = fbx_prop.props[5].decode('utf-8').split('~')
|
||||
enum_items = fbx_prop.props[5].decode('utf-8', 'replace').split('~')
|
||||
assert(val >= 0 and val < len(enum_items))
|
||||
blen_obj[prop_name] = enum_items[val]
|
||||
else:
|
||||
blen_obj[prop_name] = val
|
||||
else:
|
||||
print ("WARNING: User property type '%s' is not supported" % prop_type.decode('utf-8'))
|
||||
print ("WARNING: User property type '%s' is not supported" % prop_type.decode('utf-8', 'replace'))
|
||||
|
||||
|
||||
def blen_read_object_transform_do(transform_data):
|
||||
|
|
Loading…
Reference in New Issue