@@ -1581,6 +1581,7 @@ def collect_object(
1581
1581
selected_only = False ,
1582
1582
apply_modifiers = False ,
1583
1583
export_animations = False ,
1584
+ export_metadata = False ,
1584
1585
):
1585
1586
1586
1587
n = Node ('Actor' )
@@ -1597,7 +1598,12 @@ def collect_object(
1597
1598
child_nodes = []
1598
1599
1599
1600
for child in bl_obj .children :
1600
- new_obj = collect_object (child , selected_only = selected_only , apply_modifiers = apply_modifiers , export_animations = export_animations )
1601
+ new_obj = collect_object (child ,
1602
+ selected_only = selected_only ,
1603
+ apply_modifiers = apply_modifiers ,
1604
+ export_animations = export_animations ,
1605
+ export_metadata = export_metadata ,
1606
+ )
1601
1607
if new_obj :
1602
1608
child_nodes .append (new_obj )
1603
1609
@@ -1640,20 +1646,22 @@ def collect_object(
1640
1646
selected_only = False , # if is instancer, maybe all child want to be instanced
1641
1647
apply_modifiers = False , # if is instancer, applying modifiers may end in a lot of meshes
1642
1648
export_animations = False , # TODO: test how would animation work mixed with instancing
1643
- )
1649
+ export_metadata = False ,
1650
+ )
1644
1651
child_nodes .append (new_obj )
1645
1652
#dups.append((dup.instance_object.original, dup.matrix_world.copy()))
1646
1653
dup_idx += 1
1647
1654
1648
- collect_object_custom_data (bl_obj , n , apply_modifiers , obj_mat , depsgraph )
1655
+ collect_object_custom_data (bl_obj , n , apply_modifiers , obj_mat , depsgraph , export_metadata )
1649
1656
1650
1657
# todo: maybe make some assumptions? like if obj is probe or reflection, don't add to animated objects list
1651
1658
1652
1659
if export_animations :
1653
1660
datasmith_context ["anim_objects" ].append ((bl_obj , n ["name" ], obj_mat ))
1654
1661
1662
+ if export_metadata :
1663
+ collect_object_metadata (n ["name" ], "Actor" , bl_obj )
1655
1664
1656
- collect_object_metadata (n ["name" ], "Actor" , bl_obj )
1657
1665
# just to make children appear last
1658
1666
n .push (transform )
1659
1667
@@ -1668,7 +1676,7 @@ def collect_object(
1668
1676
return n
1669
1677
1670
1678
1671
- def collect_object_custom_data (bl_obj , n , apply_modifiers , obj_mat , depsgraph ):
1679
+ def collect_object_custom_data (bl_obj , n , apply_modifiers , obj_mat , depsgraph , export_metadata = False ):
1672
1680
# I think that these should be ordered by how common they are
1673
1681
if bl_obj .type == 'EMPTY' :
1674
1682
pass
@@ -1701,7 +1709,8 @@ def collect_object_custom_data(bl_obj, n, apply_modifiers, obj_mat, depsgraph):
1701
1709
meshes .append (umesh )
1702
1710
fill_umesh (umesh , bl_mesh )
1703
1711
1704
- collect_object_metadata (n ["name" ], "StaticMesh" , bl_mesh )
1712
+ if export_metadata :
1713
+ collect_object_metadata (n ["name" ], "StaticMesh" , bl_mesh )
1705
1714
1706
1715
material_list = datasmith_context ["materials" ]
1707
1716
if len (bl_obj .material_slots ) == 0 :
@@ -2183,12 +2192,14 @@ def collect_and_save(context, args, save_path):
2183
2192
frame_start = context .scene .frame_start
2184
2193
frame_end = context .scene .frame_end
2185
2194
2195
+ write_metadata = args ["write_metadata" ]
2186
2196
2187
2197
for obj in root_objects :
2188
2198
uobj = collect_object (obj ,
2189
2199
selected_only = selected_only ,
2190
2200
apply_modifiers = apply_modifiers ,
2191
2201
export_animations = export_animations ,
2202
+ export_metadata = write_metadata ,
2192
2203
)
2193
2204
if uobj :
2194
2205
objects .append (uobj )
0 commit comments