feat(blenvy): now iterating over main scenes instead of manually filtering scenes out

for blueprints & assets
This commit is contained in:
kaosat.dev 2024-05-19 11:22:34 +02:00
parent c2a847934b
commit 70bdd489a1
2 changed files with 18 additions and 19 deletions

View File

@ -199,16 +199,16 @@ class OT_test_bevy_assets(Operator):
bl_options = {"UNDO"}
def execute(self, context):
blenvy = context.window_manager.blenvy
blueprints_registry = context.window_manager.blueprints_registry
blueprints_registry.add_blueprints_data()
blueprints_data = blueprints_registry.blueprints_data
settings = {"blueprints_path": "blueprints", "export_gltf_extension": ".glb"}
settings = SimpleNamespace(**settings)
for scene in bpy.data.scenes:
if scene.name != "Library":
assets_hierarchy = get_main_scene_assets_tree(scene, blueprints_data, settings)
scene["assets"] = json.dumps(assets_hierarchy)
write_ron_assets_file(scene.name, assets_hierarchy, internal_only=False)
for scene in blenvy.main_scenes:
assets_hierarchy = get_main_scene_assets_tree(scene, blueprints_data, settings)
scene["assets"] = json.dumps(assets_hierarchy)
write_ron_assets_file(scene.name, assets_hierarchy, internal_only=False)
return {'FINISHED'}

View File

@ -68,6 +68,7 @@ class Blenvy_assets(bpy.types.Panel):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation.
blenvy = context.window_manager.blenvy
layout.operator(operator="bevyassets.test")
@ -84,18 +85,16 @@ class Blenvy_assets(bpy.types.Panel):
settings = SimpleNamespace(**settings)
if panel:
for scene in bpy.data.scenes:
if scene.name != "Library": # FIXME: hack for testing
#get_main_scene_assets_tree(scene, blueprints_data, settings)
user_assets = get_user_assets(scene)
row = panel.row()
scene_assets_panel = draw_assets(layout=row, name=scene.name, title=f"{scene.name} Assets", asset_registry=asset_registry, user_assets=user_assets, target_type="SCENE", target_name=scene.name)
"""if scene.name in blueprints_data.blueprint_instances_per_main_scene:
for blueprint_name in blueprints_data.blueprint_instances_per_main_scene[scene.name].keys():
blueprint = blueprints_data.blueprints_per_name[blueprint_name]
blueprint_assets = get_user_assets(blueprint.collection)
if scene_assets_panel:
row = scene_assets_panel.row()
draw_assets(layout=row, name=blueprint.name, title=f"{blueprint.name} Assets", asset_registry=asset_registry, assets=blueprint_assets, target_type="BLUEPRINT", target_name=blueprint.name)
for scene in blenvy.main_scenes:
#get_main_scene_assets_tree(scene, blueprints_data, settings)
user_assets = get_user_assets(scene)
row = panel.row()
scene_assets_panel = draw_assets(layout=row, name=scene.name, title=f"{scene.name} Assets", asset_registry=asset_registry, user_assets=user_assets, target_type="SCENE", target_name=scene.name)
"""if scene.name in blueprints_data.blueprint_instances_per_main_scene:
for blueprint_name in blueprints_data.blueprint_instances_per_main_scene[scene.name].keys():
blueprint = blueprints_data.blueprints_per_name[blueprint_name]
blueprint_assets = get_user_assets(blueprint.collection)
if scene_assets_panel:
row = scene_assets_panel.row()
draw_assets(layout=row, name=blueprint.name, title=f"{blueprint.name} Assets", asset_registry=asset_registry, assets=blueprint_assets, target_type="BLUEPRINT", target_name=blueprint.name)
"""