feat(Blenvy): continued overhaul of auto export, slowly adding back tests too
This commit is contained in:
parent
382f37be74
commit
008f6b3a88
|
@ -83,4 +83,6 @@ General issues:
|
||||||
- "parents" can only be blueprints
|
- "parents" can only be blueprints
|
||||||
- they normally need/have unique export paths (otherwise, user error, perhaps show it ?)
|
- they normally need/have unique export paths (otherwise, user error, perhaps show it ?)
|
||||||
- perhaps a simple hashing of the parent's path would be enought
|
- perhaps a simple hashing of the parent's path would be enought
|
||||||
- addon-prefs => settings
|
- [ ] addon-prefs => settings
|
||||||
|
|
||||||
|
- [ ] generate_gltf_export_preferences => should not use add-on prefs at all ? since we are not overriding gltf settings that way anymore ?
|
|
@ -46,7 +46,7 @@ def generate_gltf_export_preferences(addon_prefs):
|
||||||
for key in addon_prefs.__annotations__.keys():
|
for key in addon_prefs.__annotations__.keys():
|
||||||
if str(key) not in AutoExportGltfPreferenceNames:
|
if str(key) not in AutoExportGltfPreferenceNames:
|
||||||
#print("overriding setting", key, "value", getattr(addon_prefs,key))
|
#print("overriding setting", key, "value", getattr(addon_prefs,key))
|
||||||
gltf_export_preferences[key] = getattr(addon_prefs, key)
|
pass#gltf_export_preferences[key] = getattr(addon_prefs, key)
|
||||||
|
|
||||||
|
|
||||||
standard_gltf_exporter_settings = get_standard_exporter_settings()
|
standard_gltf_exporter_settings = get_standard_exporter_settings()
|
||||||
|
@ -74,4 +74,4 @@ def export_gltf (path, export_settings):
|
||||||
settings = {**export_settings, "filepath": path}
|
settings = {**export_settings, "filepath": path}
|
||||||
# print("export settings",settings)
|
# print("export settings",settings)
|
||||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
#bpy.ops.export_scene.gltf(**settings)
|
bpy.ops.export_scene.gltf(**settings)
|
||||||
|
|
|
@ -30,7 +30,6 @@ def export_main_scene(scene, blend_file_path, addon_prefs, blueprints_data):
|
||||||
gltf_output_path = os.path.join(levels_path_full, scene.name)
|
gltf_output_path = os.path.join(levels_path_full, scene.name)
|
||||||
|
|
||||||
#inject_blueprints_list_into_main_scene(scene, blueprints_data, addon_prefs)
|
#inject_blueprints_list_into_main_scene(scene, blueprints_data, addon_prefs)
|
||||||
return
|
|
||||||
if export_separate_dynamic_and_static_objects:
|
if export_separate_dynamic_and_static_objects:
|
||||||
#print("SPLIT STATIC AND DYNAMIC")
|
#print("SPLIT STATIC AND DYNAMIC")
|
||||||
# first export static objects
|
# first export static objects
|
||||||
|
|
|
@ -7,6 +7,7 @@ from .settings_diff import get_setting_changes
|
||||||
|
|
||||||
# prepare export by gather the changes to the scenes & settings
|
# prepare export by gather the changes to the scenes & settings
|
||||||
def prepare_and_export():
|
def prepare_and_export():
|
||||||
|
print("prepare and export")
|
||||||
blenvy = bpy.context.window_manager.blenvy
|
blenvy = bpy.context.window_manager.blenvy
|
||||||
bpy.context.window_manager.auto_export_tracker.disable_change_detection()
|
bpy.context.window_manager.auto_export_tracker.disable_change_detection()
|
||||||
auto_export_settings = blenvy.auto_export
|
auto_export_settings = blenvy.auto_export
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from ...settings import are_settings_identical, load_settings
|
from ...settings import are_settings_identical, load_settings, upsert_settings
|
||||||
|
|
||||||
# which settings are specific to auto_export # TODO: can we infer this ?
|
# which settings are specific to auto_export # TODO: can we infer this ?
|
||||||
auto_export_parameter_names = [
|
auto_export_parameter_names = [
|
||||||
|
@ -27,10 +27,19 @@ def get_setting_changes():
|
||||||
|
|
||||||
previous_export_settings = load_settings(".blenvy_export_settings_previous")
|
previous_export_settings = load_settings(".blenvy_export_settings_previous")
|
||||||
current_export_settings = load_settings(".blenvy_export_settings")
|
current_export_settings = load_settings(".blenvy_export_settings")
|
||||||
auto_export_settings_changed = not are_settings_identical(previous_export_settings, current_export_settings)
|
export_settings_changed = not are_settings_identical(previous_export_settings, current_export_settings)
|
||||||
|
|
||||||
|
# if there were no setting before, it is new, we need export
|
||||||
|
if previous_gltf_settings is None:
|
||||||
|
pass
|
||||||
|
if previous_export_settings is None:
|
||||||
|
pass
|
||||||
|
|
||||||
return {}
|
# write the new settings to the old settings
|
||||||
|
upsert_settings(".blenvy_gltf_settings_previous", current_gltf_settings)
|
||||||
|
upsert_settings(".blenvy_export_settings_previous", current_gltf_settings)
|
||||||
|
|
||||||
|
return gltf_settings_changed or export_settings_changed
|
||||||
|
|
||||||
def did_export_settings_change(self):
|
def did_export_settings_change(self):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -72,9 +72,19 @@ class AutoExportSettings(PropertyGroup):
|
||||||
default=True
|
default=True
|
||||||
) # type: ignore
|
) # type: ignore
|
||||||
|
|
||||||
|
dry_run: EnumProperty(
|
||||||
|
name="dry run",
|
||||||
|
description="debug/ develop helper to enable everything but the actual exporting of files",
|
||||||
|
items=(
|
||||||
|
("NO_EXPORT", "No export", "do not actually export gltf files"),
|
||||||
|
("NO_PREPARE", "No prepare", "do not actually export gltf files AND do not prepare the exports either (ie no creating fake scenes etc)"),
|
||||||
|
)
|
||||||
|
) # type: ignore
|
||||||
|
|
||||||
# special property for gltf settings
|
# special property for gltf settings
|
||||||
gltf_settings_backup: StringProperty(
|
gltf_settings_backup: StringProperty(
|
||||||
name="gltf settings backup",
|
name="gltf settings backup",
|
||||||
description="backup for existing gltf settings so that we can restore them"
|
description="backup for existing gltf settings so that we can restore them"
|
||||||
) # type: ignore
|
) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
[pytest]
|
||||||
|
blender-template = ../../testing/bevy_example/art/testing.blend
|
||||||
|
addopts = -svv
|
||||||
|
testpaths =
|
||||||
|
tests
|
||||||
|
|
||||||
|
# dependencies:
|
||||||
|
# pytest_blender
|
||||||
|
# pixelmatch
|
|
@ -9,6 +9,8 @@ import filecmp
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from pixelmatch.contrib.PIL import pixelmatch
|
from pixelmatch.contrib.PIL import pixelmatch
|
||||||
|
|
||||||
|
from blenvy.gltf_auto_export.auto_export.prepare_and_export import prepare_and_export
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def setup_data(request):
|
def setup_data(request):
|
||||||
print("\nSetting up resources...")
|
print("\nSetting up resources...")
|
||||||
|
@ -98,9 +100,17 @@ def test_export_complex(setup_data):
|
||||||
# move the main cube
|
# move the main cube
|
||||||
bpy.data.objects["Cube"].location = [1, 0, 0]
|
bpy.data.objects["Cube"].location = [1, 0, 0]
|
||||||
# move the cube in the library
|
# move the cube in the library
|
||||||
bpy.data.objects["Blueprint1_mesh"].location = [1, 2, 1]
|
# TODO: add back bpy.data.objects["Blueprint1_mesh"].location = [1, 2, 1]
|
||||||
|
|
||||||
auto_export_operator(
|
registry = bpy.context.window_manager.components_registry
|
||||||
|
blenvy = bpy.context.window_manager.blenvy
|
||||||
|
main_scene = blenvy.main_scenes.add()
|
||||||
|
main_scene.name = "World"
|
||||||
|
blenvy.auto_export.auto_export = True
|
||||||
|
|
||||||
|
prepare_and_export()
|
||||||
|
|
||||||
|
"""auto_export_operator(
|
||||||
auto_export=True,
|
auto_export=True,
|
||||||
direct_mode=True,
|
direct_mode=True,
|
||||||
project_root_path = os.path.abspath(root_path),
|
project_root_path = os.path.abspath(root_path),
|
||||||
|
@ -111,7 +121,7 @@ def test_export_complex(setup_data):
|
||||||
export_scene_settings=True,
|
export_scene_settings=True,
|
||||||
export_blueprints=True,
|
export_blueprints=True,
|
||||||
export_materials_library=True
|
export_materials_library=True
|
||||||
)
|
)"""
|
||||||
# blueprint1 => has an instance, got changed, should export
|
# blueprint1 => has an instance, got changed, should export
|
||||||
# blueprint2 => has NO instance, but marked as asset, should export
|
# blueprint2 => has NO instance, but marked as asset, should export
|
||||||
# blueprint3 => has NO instance, not marked as asset, used inside blueprint 4: should export
|
# blueprint3 => has NO instance, not marked as asset, used inside blueprint 4: should export
|
||||||
|
|
Loading…
Reference in New Issue