fix export with a 'zoo collection'

Add a temporary collection to the scene that links all the foreign objects meshes and collections with meshes to the current scene, have the dependency graph see it and then destroy it.
This commit is contained in:
N8n5h 2019-11-30 22:45:43 -03:00
parent c97c5ff36b
commit b1a25548a9
2 changed files with 13 additions and 3 deletions

View file

@ -1763,7 +1763,7 @@ class ArmoryExporter:
for o in self.meshArray.items():
self.export_mesh(o, scene)
def execute(self, context, filepath, scene=None):
def execute(self, context, filepath, scene=None, depsgraph=None):
global current_output
profile_time = time.time()
@ -1799,7 +1799,7 @@ class ArmoryExporter:
# for i in range(0, len(self.scene.view_layers)):
# if self.scene.view_layers[i] == True:
# self.active_layers.append(i)
self.depsgraph = context.evaluated_depsgraph_get()
self.depsgraph = context.evaluated_depsgraph_get() if depsgraph == None else depsgraph
self.preprocess()
# scene_objects = []

View file

@ -103,11 +103,21 @@ def export_data(fp, sdk_path):
ArmoryExporter.optimize_enabled = state.is_publish and wrd.arm_optimize_data
if not os.path.exists(build_dir + '/compiled/Assets'):
os.makedirs(build_dir + '/compiled/Assets')
# have a "zoo" collection in the current scene
export_coll = bpy.data.collections.new("export_coll")
bpy.context.scene.collection.children.link(export_coll)
for scene in bpy.data.scenes:
if scene == bpy.context.scene: continue
for o in scene.collection.all_objects:
if o.type == "MESH" or o.type == "EMPTY": export_coll.objects.link(o)
depsgraph = bpy.context.evaluated_depsgraph_get()
bpy.data.collections.remove(export_coll) # destroy "zoo" collection
for scene in bpy.data.scenes:
if scene.arm_export:
ext = '.lz4' if ArmoryExporter.compress_enabled else '.arm'
asset_path = build_dir + '/compiled/Assets/' + arm.utils.safestr(scene.name) + ext
exporter.execute(bpy.context, asset_path, scene=scene)
exporter.execute(bpy.context, asset_path, scene=scene, depsgraph=depsgraph)
if ArmoryExporter.export_physics:
physics_found = True
if ArmoryExporter.export_navigation: