Skip to content

Commit 27263e4

Browse files
committed
add flag to enable exporting metadata
1 parent d4db22a commit 27263e4

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
Features marked with `*` require the UE4 plugin to work.
44

5+
## [Unreleased]
6+
### Fixed
7+
* Export metadata is now a flag, off by default, to help in case other addons store info there.
8+
9+
510
## [1.0.3] 2020-08-19
611
### Added
712
+ Texture node now supports box projection.

__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ class ExportDatasmith(bpy.types.Operator, ExportHelper):
7676
"Improves material nodes support, but at a reduced quality",
7777
default=False,
7878
)
79+
write_metadata: BoolProperty(
80+
name="Write metadata",
81+
description="Writes custom properties of objects and meshes as metadata."
82+
"It may be useful to disable this when using certain addons",
83+
default=True,
84+
)
7985
use_logging: BoolProperty(
8086
name="Enable logging",
8187
description="Enable logging to Window > System console",

export_datasmith.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,7 @@ def collect_object(
15811581
selected_only=False,
15821582
apply_modifiers=False,
15831583
export_animations=False,
1584+
export_metadata=False,
15841585
):
15851586

15861587
n = Node('Actor')
@@ -1597,7 +1598,12 @@ def collect_object(
15971598
child_nodes = []
15981599

15991600
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+
)
16011607
if new_obj:
16021608
child_nodes.append(new_obj)
16031609

@@ -1640,20 +1646,22 @@ def collect_object(
16401646
selected_only=False, # if is instancer, maybe all child want to be instanced
16411647
apply_modifiers=False, # if is instancer, applying modifiers may end in a lot of meshes
16421648
export_animations=False, # TODO: test how would animation work mixed with instancing
1643-
)
1649+
export_metadata=False,
1650+
)
16441651
child_nodes.append(new_obj)
16451652
#dups.append((dup.instance_object.original, dup.matrix_world.copy()))
16461653
dup_idx += 1
16471654

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)
16491656

16501657
# todo: maybe make some assumptions? like if obj is probe or reflection, don't add to animated objects list
16511658

16521659
if export_animations:
16531660
datasmith_context["anim_objects"].append((bl_obj, n["name"], obj_mat))
16541661

1662+
if export_metadata:
1663+
collect_object_metadata(n["name"], "Actor", bl_obj)
16551664

1656-
collect_object_metadata(n["name"], "Actor", bl_obj)
16571665
# just to make children appear last
16581666
n.push(transform)
16591667

@@ -1668,7 +1676,7 @@ def collect_object(
16681676
return n
16691677

16701678

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):
16721680
# I think that these should be ordered by how common they are
16731681
if bl_obj.type == 'EMPTY':
16741682
pass
@@ -1701,7 +1709,8 @@ def collect_object_custom_data(bl_obj, n, apply_modifiers, obj_mat, depsgraph):
17011709
meshes.append(umesh)
17021710
fill_umesh(umesh, bl_mesh)
17031711

1704-
collect_object_metadata(n["name"], "StaticMesh", bl_mesh)
1712+
if export_metadata:
1713+
collect_object_metadata(n["name"], "StaticMesh", bl_mesh)
17051714

17061715
material_list = datasmith_context["materials"]
17071716
if len(bl_obj.material_slots) == 0:
@@ -2183,12 +2192,14 @@ def collect_and_save(context, args, save_path):
21832192
frame_start = context.scene.frame_start
21842193
frame_end = context.scene.frame_end
21852194

2195+
write_metadata = args["write_metadata"]
21862196

21872197
for obj in root_objects:
21882198
uobj = collect_object(obj,
21892199
selected_only=selected_only,
21902200
apply_modifiers=apply_modifiers,
21912201
export_animations=export_animations,
2202+
export_metadata=write_metadata,
21922203
)
21932204
if uobj:
21942205
objects.append(uobj)

testing/test_datasmith_export.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
custom_args["minimal_export"] = False
5656
custom_args["use_logging"] = True
5757
custom_args["use_profiling"] = False
58+
custom_args["write_metadata"] = False
5859

5960
if "-benchmark" in sys.argv:
6061
custom_args["use_logging"] = False

0 commit comments

Comments
 (0)