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

View File

@ -68,6 +68,7 @@ class Blenvy_assets(bpy.types.Panel):
layout = self.layout layout = self.layout
layout.use_property_split = True layout.use_property_split = True
layout.use_property_decorate = False # No animation. layout.use_property_decorate = False # No animation.
blenvy = context.window_manager.blenvy
layout.operator(operator="bevyassets.test") layout.operator(operator="bevyassets.test")
@ -84,10 +85,8 @@ class Blenvy_assets(bpy.types.Panel):
settings = SimpleNamespace(**settings) settings = SimpleNamespace(**settings)
if panel: if panel:
for scene in bpy.data.scenes: for scene in blenvy.main_scenes:
if scene.name != "Library": # FIXME: hack for testing
#get_main_scene_assets_tree(scene, blueprints_data, settings) #get_main_scene_assets_tree(scene, blueprints_data, settings)
user_assets = get_user_assets(scene) user_assets = get_user_assets(scene)
row = panel.row() 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) 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)