forked from LeenkxTeam/LNXSDK
Update Export
This commit is contained in:
@ -29,6 +29,8 @@ import lnx.make_logic as make_logic
|
||||
import lnx.make_renderpath as make_renderpath
|
||||
import lnx.make_state as state
|
||||
import lnx.make_world as make_world
|
||||
import lnx.material.make_shader as make_shader
|
||||
import lnx.material.mat_state as mat_state
|
||||
import lnx.utils
|
||||
import lnx.utils_vs
|
||||
import lnx.write_data as write_data
|
||||
@ -45,6 +47,7 @@ if lnx.is_reload(__name__):
|
||||
make_renderpath = lnx.reload_module(make_renderpath)
|
||||
state = lnx.reload_module(state)
|
||||
make_world = lnx.reload_module(make_world)
|
||||
mat_state = lnx.reload_module(mat_state)
|
||||
lnx.utils = lnx.reload_module(lnx.utils)
|
||||
lnx.utils_vs = lnx.reload_module(lnx.utils_vs)
|
||||
write_data = lnx.reload_module(write_data)
|
||||
@ -238,6 +241,7 @@ def export_data_impl(fp, sdk_path):
|
||||
export_network = bpy.data.worlds['Lnx'].lnx_network != 'Disabled'
|
||||
|
||||
assets.reset()
|
||||
mat_state.material_cache.clear()
|
||||
|
||||
# Build node trees
|
||||
LeenkxExporter.import_traits = []
|
||||
@ -256,6 +260,13 @@ def export_data_impl(fp, sdk_path):
|
||||
if not os.path.exists(build_dir + '/compiled/Assets'):
|
||||
os.makedirs(build_dir + '/compiled/Assets')
|
||||
|
||||
ext = '.lz4' if LeenkxExporter.compress_enabled else '.lnx'
|
||||
scene_targets = []
|
||||
for scene in bpy.data.scenes:
|
||||
if scene.lnx_export:
|
||||
asset_path = build_dir + '/compiled/Assets/' + lnx.utils.safestr(scene.name + "_" + os.path.basename(scene.library.filepath).replace(".blend", "") if scene.library else scene.name) + ext
|
||||
scene_targets.append((scene.name, asset_path))
|
||||
|
||||
# Make all 'MESH' and 'EMPTY' objects visible to the depsgraph (we pass
|
||||
# this to the exporter further below) with a temporary "zoo" collection
|
||||
# in the current scene. We do this to ensure that (among other things)
|
||||
@ -276,22 +287,19 @@ def export_data_impl(fp, sdk_path):
|
||||
|
||||
build_cache = BuildExportCache()
|
||||
|
||||
for scene in bpy.data.scenes:
|
||||
if scene.lnx_export:
|
||||
# Reset shader comparison arrays to prevent cross-scene shader merging
|
||||
assets.reset_shader_cons()
|
||||
ext = '.lz4' if LeenkxExporter.compress_enabled else '.lnx'
|
||||
asset_path = build_dir + '/compiled/Assets/' + lnx.utils.safestr(scene.name + "_" + os.path.basename(scene.library.filepath).replace(".blend", "") if scene.library else scene.name) + ext
|
||||
LeenkxExporter.export_scene(bpy.context, asset_path, scene=scene, depsgraph=depsgraph, build_cache=build_cache)
|
||||
if LeenkxExporter.export_physics:
|
||||
physics_found = True
|
||||
if LeenkxExporter.export_navigation:
|
||||
navigation_found = True
|
||||
if LeenkxExporter.export_ui:
|
||||
ui_found = True
|
||||
if LeenkxExporter.export_network:
|
||||
network_found = True
|
||||
assets.add(asset_path)
|
||||
for scene_name, asset_path in scene_targets:
|
||||
# Reset shader comparison arrays to prevent cross-scene shader merging
|
||||
assets.reset_shader_cons()
|
||||
LeenkxExporter.export_scene(bpy.context, asset_path, scene=bpy.data.scenes[scene_name], depsgraph=depsgraph, build_cache=build_cache)
|
||||
if LeenkxExporter.export_physics:
|
||||
physics_found = True
|
||||
if LeenkxExporter.export_navigation:
|
||||
navigation_found = True
|
||||
if LeenkxExporter.export_ui:
|
||||
ui_found = True
|
||||
if LeenkxExporter.export_network:
|
||||
network_found = True
|
||||
assets.add(asset_path)
|
||||
|
||||
if physics_found is False: # Disable physics if no rigid body is exported
|
||||
export_physics = False
|
||||
|
||||
Reference in New Issue
Block a user