Import_3ds: Preserve object hierarchy #104790
@ -1054,7 +1054,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
|||||||
imported_objects.append(child)
|
imported_objects.append(child)
|
||||||
else:
|
else:
|
||||||
tracking = tracktype = None
|
tracking = tracktype = None
|
||||||
if child is not None and tracktype != 'TARGET' and tracking != 'AMBIENT':
|
if tracktype != 'TARGET' and tracking != 'AMBIENT':
|
||||||
object_dict[object_id] = child
|
object_dict[object_id] = child
|
||||||
object_list.append(child)
|
object_list.append(child)
|
||||||
object_parent.append(hierarchy)
|
object_parent.append(hierarchy)
|
||||||
@ -1272,14 +1272,12 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
|||||||
contextMeshMaterials, contextMesh_smooth, WORLD_MATRIX)
|
contextMeshMaterials, contextMesh_smooth, WORLD_MATRIX)
|
||||||
|
|
||||||
# Assign parents to objects
|
# Assign parents to objects
|
||||||
while None in object_list:
|
|
||||||
object_list.remove(None)
|
|
||||||
|
|
||||||
# check _if_ we need to assign first because doing so recalcs the depsgraph
|
# check _if_ we need to assign first because doing so recalcs the depsgraph
|
||||||
for ind, ob in enumerate(object_list):
|
for ind, ob in enumerate(object_list):
|
||||||
parent = object_parent[ind]
|
parent = object_parent[ind]
|
||||||
if parent == ROOT_OBJECT:
|
if parent == ROOT_OBJECT:
|
||||||
ob.parent = None
|
if ob is not None:
|
||||||
|
ob.parent = None
|
||||||
elif parent not in object_dict:
|
elif parent not in object_dict:
|
||||||
try:
|
try:
|
||||||
ob.parent = object_list[parent]
|
ob.parent = object_list[parent]
|
||||||
@ -1289,7 +1287,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
|||||||
try:
|
try:
|
||||||
ob.parent = object_dict.get(parent)
|
ob.parent = object_dict.get(parent)
|
||||||
except: # self to parent exception
|
except: # self to parent exception
|
||||||
ob.parent = None
|
object_list.remove(ob)
|
||||||
|
|
||||||
#pivot_list[ind] += pivot_list[parent] # Not sure this is correct, should parent space matrix be applied before combining?
|
#pivot_list[ind] += pivot_list[parent] # Not sure this is correct, should parent space matrix be applied before combining?
|
||||||
|
|
||||||
@ -1312,7 +1310,9 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
|||||||
|
|
||||||
# fix pivots
|
# fix pivots
|
||||||
for ind, ob in enumerate(object_list):
|
for ind, ob in enumerate(object_list):
|
||||||
if ob.type == 'MESH':
|
if ob is None: # remove None
|
||||||
|
object_list.pop(ind)
|
||||||
|
elif ob.type == 'MESH':
|
||||||
pivot = pivot_list[ind]
|
pivot = pivot_list[ind]
|
||||||
pivot_matrix = object_matrix.get(ob, mathutils.Matrix()) # unlikely to fail
|
pivot_matrix = object_matrix.get(ob, mathutils.Matrix()) # unlikely to fail
|
||||||
pivot_matrix = mathutils.Matrix.Translation(-1 * pivot)
|
pivot_matrix = mathutils.Matrix.Translation(-1 * pivot)
|
||||||
|
Loading…
Reference in New Issue
Block a user