Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-02-05 16:07:34 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-02-05 16:10:41 +0300
commit2782ce8a938fabbe1f4ba40f062cbdd7cdea5219 (patch)
tree490309fa66d83105f40f388a80659715d212d4d1 /io_scene_obj
parentde73210a2ebaca137f5f9d98011e8d66899fc441 (diff)
Fix T61179: Import OBJ groups bug.
Regression/side effect from rBA9448cef00d1b3, while we do want to get one Blender object per 'o' line (object declaration) in OBJ file, we do want to 'reuse' same objects when same OBJ groups ('g' lines) are used inside of a same object, in case we split OBJ groups into objects... Thanks to Jacques Lucke (@JacquesLucke) for initial investigation.
Diffstat (limited to 'io_scene_obj')
-rw-r--r--io_scene_obj/__init__.py2
-rw-r--r--io_scene_obj/import_obj.py41
2 files changed, 24 insertions, 19 deletions
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 7286f251..126e818e 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "Wavefront OBJ format",
"author": "Campbell Barton, Bastien Montagne",
- "version": (3, 5, 5),
+ "version": (3, 5, 6),
"blender": (2, 80, 0),
"location": "File > Import-Export",
"description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index ddb2658f..e7f9770c 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -454,8 +454,10 @@ def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
# if the key is a tuple, join it to make a string
if not key:
return filename # assume its a string. make sure this is true if the splitting code is changed
- else:
+ elif isinstance(key, bytes):
return key.decode('utf-8', 'replace')
+ else:
+ return "_".join(k.decode('utf-8', 'replace') for k in key)
# Return a key that makes the faces unique.
face_split_dict = {}
@@ -468,10 +470,10 @@ def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
face_vert_tex_indices,
context_material,
context_smooth_group,
- context_object,
+ context_object_key,
face_invalid_blenpoly,
) = face
- key = context_object
+ key = context_object_key
if oldkey != key:
# Check the key has changed.
@@ -532,7 +534,7 @@ def create_mesh(new_objects,
edges = []
tot_loops = 0
- context_object = None
+ context_object_key = None
# reverse loop through face indices
for f_idx in range(len(faces) - 1, -1, -1):
@@ -541,7 +543,7 @@ def create_mesh(new_objects,
face_vert_tex_indices,
context_material,
context_smooth_group,
- context_object,
+ context_object_key,
face_invalid_blenpoly,
) = faces[f_idx]
@@ -591,7 +593,7 @@ def create_mesh(new_objects,
] if face_vert_tex_indices else [],
context_material,
context_smooth_group,
- context_object,
+ context_object_key,
[],
)
for ngon in ngon_face_indices]
@@ -880,7 +882,7 @@ def load(context,
data.append(tuple(vec[:vec_len]))
return ret_context_multi_line
- def create_face(context_material, context_smooth_group, context_object):
+ def create_face(context_material, context_smooth_group, context_object_key):
face_vert_loc_indices = []
face_vert_nor_indices = []
face_vert_tex_indices = []
@@ -890,7 +892,7 @@ def load(context,
face_vert_tex_indices,
context_material,
context_smooth_group,
- context_object,
+ context_object_key,
[], # If non-empty, that face is a Blender-invalid ngon (holes...), need a mutable object for that...
)
@@ -918,7 +920,8 @@ def load(context,
# Context variables
context_material = None
context_smooth_group = None
- context_object = None
+ context_object_key = None
+ context_object_obpart = None
context_vgroup = None
objects_names = set()
@@ -1003,7 +1006,7 @@ def load(context,
if not context_multi_line:
line_split = line_split[1:]
# Instantiate a face
- face = create_face(context_material, context_smooth_group, context_object)
+ face = create_face(context_material, context_smooth_group, context_object_key)
(face_vert_loc_indices, face_vert_nor_indices, face_vert_tex_indices,
_1, _2, _3, face_invalid_blenpoly) = face
faces.append(face)
@@ -1077,7 +1080,7 @@ def load(context,
if not context_multi_line:
line_split = line_split[1:]
# Instantiate a face
- face = create_face(context_material, context_smooth_group, context_object)
+ face = create_face(context_material, context_smooth_group, context_object_key)
face_vert_loc_indices = face[0]
# XXX A bit hackish, we use special 'value' of face_vert_nor_indices (a single True item) to tag this
# as a polyline, and not a regular face...
@@ -1102,14 +1105,16 @@ def load(context,
elif line_start == b'o':
if use_split_objects:
- context_object = unique_name(objects_names, line_value(line_split))
- # unique_obects[context_object]= None
+ context_object_key = unique_name(objects_names, line_value(line_split))
+ context_object_obpart = context_object_key
+ # unique_objects[context_object_key]= None
elif line_start == b'g':
if use_split_groups:
- context_object = unique_name(objects_names, line_value(line_split))
- # print 'context_object', context_object
- # unique_obects[context_object]= None
+ grppart = line_value(line_split)
+ context_object_key = (context_object_obpart, grppart) if context_object_obpart else grppart
+ # print 'context_object_key', context_object_key
+ # unique_objects[context_object_key]= None
elif use_groups_as_vgroups:
context_vgroup = line_value(line.split())
if context_vgroup and context_vgroup != b'(null)':
@@ -1170,8 +1175,8 @@ def load(context,
context_nurbs[b'deg'] = [int(i) for i in line.split()[1:]]
elif line_start == b'end':
# Add the nurbs curve
- if context_object:
- context_nurbs[b'name'] = context_object
+ if context_object_key:
+ context_nurbs[b'name'] = context_object_key
nurbs.append(context_nurbs)
context_nurbs = {}
context_parm = b''