Compare commits

..

No commits in common. "c2e73b7e8be9a079964607137a715ea054b526c9" and "75d7f940aef2590086af4258fd9985f94c6ccafb" have entirely different histories.

9 changed files with 48 additions and 179 deletions

View File

@ -171,26 +171,8 @@ Blender side:
- [x] in theory, srgba, linearrgba , and hsva should be able to be represented visually
- [x] bevy_render::color::Color => bevy_color::color::Color
- [x] fix weird issue with hashmaps with enums as values
- [x] prevent attempting to add unexisting components to targets (ie when using the component search)
- [x] also for the bulk fix actions
- [x] selection of nested objects in collections IS NOT WORKING !!! AHH
- [ ] fix/ overhaul upgreadable components
- [x] add listing of upgradeable components for
- [x] meshes
- [x] materials
- [x] fix display of upgradeaeble components & co
- [x] add clear visual distinction between internal (selectable) & non selectable ones
- [x] do not make selection button available for external blueprints/collections
- [ ] perhaps do not show the other buttons & inputs either ? we cannot change the values of an external library file anyway
- [ ] prevent attempting to add unexisting components to targets (ie when using the component search)
- [ ] BLENVY_OT_item_select is missing handling for the other types (outside of object & collection)
- [ ] fix selection logic
- [ ] hidden objects/collections only semi respected at export
- this is because blueprints are external ?
- [ ] verify based on gltf settings
- [ ] add "Visibility::Hidden" component otherwise
https://devtalk.blender.org/t/how-to-get-render-visibility-for-object/23717
- [ ] inject_export_path_into_internal_blueprints should be called on every asset/blueprint scan !! Not just on export
- [ ] undo after a save removes any saved "serialized scene" data ? DIG into this
@ -199,9 +181,11 @@ Blender side:
- [ ] disabled components
- [ ] blueprint instances as children of blueprint instances
- [ ] blueprint instances as children of empties
- [x] update testing files
- [ ] hidden objects/collections not respected at export !!!?
- [ ] verify based on gltf settings
- [ ] add "hidden" component otherwise ?
https://devtalk.blender.org/t/how-to-get-render-visibility-for-object/23717
- [ ] add option to 'split out' meshes from blueprints ?
- [ ] ie considering meshletts etc , it would make sense to keep blueprints seperate from purely mesh gltfs
- [ ] persist exported materials path in blueprints so that it can be read from library file users
@ -211,16 +195,11 @@ Blender side:
Bevy Side:
- [x] deprecate BlueprintName & BlueprintPath & use BlueprintInfo instead
- [ ] make blueprint instances invisible until spawning is done to avoid "spawn flash"?
- [ ] should "blueprint spawned" only be triggered after all its sub blueprints have spawned ?
- [ ] simplify testing example:
- [x] remove use of rapier physics (or even the whole common boilerplate ?)
- [ ] remove/replace bevy editor pls with some native ui to display hierarchies
- [x] try out hot reloading
- [ ] add a way of overriding assets for collection instances
- [ ] add a way of visualizing per blueprint instances
- [ ] cleanup all the spurious debug messages
- [ ] fix animation handling
- [ ] simplify examples:
- [ ] a full fledged demo (including physics & co)
- [ ] other examples without interactions or physics
@ -229,5 +208,9 @@ Bevy Side:
- [ ] replace all references to the old 2 add-ons with those to Blenvy
- [ ] rename repo to "Blenvy"
- [ ] do a deprecation release of all bevy_gltf_xxx crates to point at the new Blenvy crate
- [ ] add a way of overriding assets for collection instances
- [ ] add a way of visualizing per blueprint instances
- [ ] cleanup all the spurious debug messages
- [ ] fix animation handling
clear && pytest -svv --blender-template ../../testing/bevy_example/art/testing_library.blend --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration_prepare.py && pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration.py

View File

@ -15,7 +15,7 @@ def draw_settings_ui(layout, auto_export_settings):
#op.export_format = 'GLTF_SEPARATE'
op.use_selection=True
op.will_save_settings=True
op.use_visible=True
op.use_visible=True # Export visible and hidden objects. See Object/Batch Export to skip.
op.use_renderable=True
op.use_active_collection = True
op.use_active_collection_with_nested=True

View File

@ -209,7 +209,7 @@ def draw_component_ui(layout, object_or_collection, registry, selected_component
row = layout.row(align=True)
op = row.operator("blenvy.component_add", text="Add", icon="ADD")
op.component_type = selected_component
row.enabled = selected_component != '' and selected_component in list(registry.type_infos.keys())
row.enabled = selected_component != ''
layout.separator()
@ -343,13 +343,9 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
row = layout.row()
col = row.column()
selector_text = f"{target.name}({item_type_short})"
if target.library is None:
operator = col.operator("blenvy.select_item", text=selector_text, icon="FILE_BLEND")
operator.target_name = target.name
operator.item_type = item_type
else:
col.label(text=selector_text, icon="LIBRARY_DATA_DIRECT")
operator = col.operator("blenvy.select_item", text=f"{target.name}({item_type_short})")
operator.target_name = target.name
operator.item_type = item_type
col = row.column()
col.label(text=status)
@ -381,16 +377,18 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
def draw_invalid_items(self, layout, upgreadable_entries):
for entry in upgreadable_entries:
(status, custom_property, item, item_type) = entry
print("ENTRY", entry)
self.draw_invalid_or_unregistered(layout, status, custom_property, item, item_type)
def gather_invalid_item_data(self, item, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, item_type):
blenvy_custom_properties = ['components_meta', 'bevy_components', 'user_assets', 'generated_assets' ] # some of our own hard coded custom properties that should be ignored
upgreadable_entries = []
if "components_meta" in item or hasattr(item, "components_meta"): # FIXME; wrong way of determining
if "components_meta" in item:
components_metadata = item.components_meta.components
object_component_names = []
for index, component_meta in enumerate(components_metadata):
long_name = component_meta.long_name
if component_meta.invalid:
@ -411,12 +409,10 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
# Invalid (something is wrong)
# Unregistered (not in registry)
# Upgrade Needed (Old-style component)
status = None
if custom_property not in blenvy_custom_properties:
if custom_property not in object_component_names:
status = "Upgrade Needed"
else:
status = "Other issue"
if custom_property not in blenvy_custom_properties and custom_property not in object_component_names:
status = "Upgrade Needed"
if status is not None:
upgreadable_entries.append((status, custom_property, item, item_type))
@ -432,7 +428,8 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
layout = self.layout
registry = bpy.context.window_manager.components_registry
registry_has_type_infos = registry.has_type_infos()
type_infos = list(registry.type_infos.keys())
selected_object = context.selected_objects[0] if len(context.selected_objects) > 0 else None
selected_component = bpy.context.window_manager.blenvy.components.component_selector
row = layout.row()
row.label(text= "* Single item actions: Rename / Fix / Upgrade")#"Invalid/ unregistered components")
@ -452,12 +449,6 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
for collection in bpy.data.collections:
if len(collection.keys()) > 0:
upgreadable_entries += self.gather_invalid_item_data(collection, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, "COLLECTION")
for mesh in bpy.data.meshes:
if len(mesh.keys()) > 0:
upgreadable_entries += self.gather_invalid_item_data(mesh, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, "MESH")
for material in bpy.data.materials:
if len(material.keys()) > 0:
upgreadable_entries += self.gather_invalid_item_data(material, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, "MATERIAL")
if len(items_with_invalid_components) > 0:
self.draw_invalid_or_unregistered_header(layout, ["Item","Status", "Component", "Target"])
@ -493,7 +484,7 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel):
operator.original_name = original_name
operator.target_name = target_component_name
operator.target_items = json.dumps(items_with_original_components)
col.enabled = registry_has_type_infos and original_name != "" and original_name != target_component_name and original_name in type_infos and target_component_name in type_infos
col.enabled = registry_has_type_infos and original_name != "" and original_name != target_component_name
else:
if hasattr(layout,"progress") : # only for Blender > 4.0
col.progress(factor = components_rename_progress, text=f"updating {components_rename_progress * 100.0:.2f}%")

View File

@ -43,11 +43,14 @@ def process_map(registry, definition, update, nesting_long_names=[]):
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !
if is_value_value_type:
print("WRAPPPER, property group", definition["short_name"])
values_property_group_class = generate_wrapper_propertyGroup(f"{long_name}_values", original_long_name, definition_link, registry, update, nesting_long_names)
else:
(_, list_content_group_class) = process_component.process_component(registry, value_definition, update, {"nested": True, "long_name": original_long_name}, nesting_long_names)
values_property_group_class = list_content_group_class
print("COMPONENT, property group", definition["short_name"], values_property_group_class)
values_collection = CollectionProperty(type=values_property_group_class)
values_property_group_pointer = PointerProperty(type=values_property_group_class)

View File

@ -93,8 +93,7 @@ class ComponentsSettings(PropertyGroup):
component_selector: StringProperty(
search=add_component_to_ui_list,
description="component selector: only components present in the registry are accepted"
search=add_component_to_ui_list
)# type: ignore

View File

@ -4,49 +4,12 @@ from bpy.props import StringProperty, EnumProperty
from bpy_types import Operator
from blenvy.core.helpers_collections import (set_active_collection)
import json
def select_area(context, area_name):
for area in context.screen.areas:
#if area.type == 'PROPERTIES' and context.object is not None and context.object.type not in ('LIGHT_PROBE', 'CAMERA', 'LIGHT', 'SPEAKER'):
# Set it the active space
print("SELECT AREA", area_name)
try:
area.spaces.active.context = area_name #'MATERIAL' # 'VIEW_LAYER', 'SCENE' etc.
except Exception as error:
print(f"failed to switch to area {area_name}: {error}")
break # OPTIONAL
def get_collection_scene(collection):
for scene in bpy.data.scenes:
if scene.user_of_id(collection):
return scene
return None
def get_object_by_name(name):
object = bpy.data.objects.get(name, None)
return object
def get_object_scene(object):
object = bpy.data.objects.get(object.name, None)
if object is not None:
scenes_of_object = list(object.users_scene)
if len(scenes_of_object) > 0:
return scenes_of_object[0]
return None
def get_mesh_object(mesh):
for object in bpy.data.objects:
if isinstance(object.data, bpy.types.Mesh) and mesh.name == object.data.name:
return object
def get_material_object(material):
for object in bpy.data.objects:
if isinstance(object.data, bpy.types.Mesh) and material.name in object.data.materials:
return object
class BLENVY_OT_item_select(Operator):
"""Select object by name"""
bl_idname = "blenvy.select_item"
@ -70,121 +33,52 @@ class BLENVY_OT_item_select(Operator):
description="target to select's name ",
) # type: ignore
@classmethod
def register(cls):
bpy.types.WindowManager.blenvy_item_selected_ids = StringProperty(default="{}")
@classmethod
def unregister(cls):
del bpy.types.WindowManager.blenvy_item_selected_ids
def execute(self, context):
if self.target_name:
if self.item_type == 'OBJECT':
if self.item_type == "OBJECT":
object = bpy.data.objects[self.target_name]
scenes_of_object = list(object.users_scene)
if len(scenes_of_object) > 0:
bpy.ops.object.select_all(action='DESELECT')
bpy.context.window.scene = scenes_of_object[0]
object.select_set(True)
context.window_manager.blenvy_item_selected_ids = json.dumps({"name": object.name, "type": self.item_type})
bpy.context.view_layer.objects.active = object
select_area(context=context, area_name="OBJECT")
elif self.item_type == 'COLLECTION':
elif self.item_type == "COLLECTION":
collection = bpy.data.collections[self.target_name]
scene_of_collection = get_collection_scene(collection)
if scene_of_collection is not None:
bpy.ops.object.select_all(action='DESELECT')
bpy.context.window.scene = scene_of_collection
#bpy.context.view_layer.objects.active = None
#
context.window_manager.blenvy_item_selected_ids = json.dumps({"name": collection.name, "type": self.item_type})
bpy.context.view_layer.objects.active = None
set_active_collection(bpy.context.window.scene, collection.name)
select_area(context=context, area_name="COLLECTION")
elif self.item_type == 'MESH':
mesh = bpy.data.meshes[self.target_name]
mesh_object = get_mesh_object(mesh)
scene_of_item = get_object_scene(mesh_object)
if scene_of_item is not None:
bpy.ops.object.select_all(action='DESELECT')
bpy.context.window.scene = scene_of_item
mesh_object.select_set(True)
bpy.context.view_layer.objects.active = mesh_object
context.window_manager.blenvy_item_selected_ids = json.dumps({"name": mesh.name, "type": self.item_type})
select_area(context=context, area_name="DATA")
elif self.item_type == 'MATERIAL':
# find object that uses material
material = bpy.data.materials[self.target_name]
material_object = get_material_object(material)
scene_of_item = get_object_scene(material_object)
select_area(context=context, area_name="MATERIAL")
print("scene_of_item", scene_of_item)
if scene_of_item is not None:
bpy.ops.object.select_all(action='DESELECT')
bpy.context.window.scene = scene_of_item
#material_object.select_set(True)
bpy.context.view_layer.objects.active = material_object
context.window_manager.blenvy_item_selected_ids = json.dumps({"name": material.name, "type": self.item_type})
select_area(context=context, area_name="MATERIAL")
return {'FINISHED'}
def get_selected_item(context):
selection = None
#print("original context", context)
def get_outliner_area():
if bpy.context.area.type!='OUTLINER':
for area in bpy.context.screen.areas:
if area.type == 'OUTLINER':
return area
return None
#print("original context", context)
area = get_outliner_area()
if area is not None:
region = next(region for region in area.regions if region.type == "WINDOW")
try:
selection_overrides = json.loads(context.window_manager.blenvy_item_selected_ids)
#print("selection_overrides", selection_overrides)
if selection_overrides["type"] == "OBJECT":
selection = bpy.data.objects[selection_overrides["name"]]
elif selection_overrides["type"] == "COLLECTION":
selection = bpy.data.collections[selection_overrides["name"]]
if selection_overrides["type"] == "MESH":
selection = bpy.data.meshes[selection_overrides["name"]]
elif selection_overrides["type"] == "MATERIAL":
selection = bpy.data.materials[selection_overrides["name"]]
#print("SELECTION", selection)
#context.window_manager.blenvy_item_selected_ids = "{}"
except: pass
with bpy.context.temp_override(area=area, region=region):
#print("overriden context", bpy.context)
for obj in bpy.context.selected_ids:
pass#print(f"Selected: {obj.name} - {type(obj)}")
selection = bpy.context.selected_ids[len(bpy.context.selected_ids) - 1] if len(bpy.context.selected_ids)>0 else None #next(iter(bpy.context.selected_ids), None)
"""if selection is not None:
print("selection", f"Selected: {selection.name} - {type(selection)}")"""
if selection is None:
area = get_outliner_area()
if area is not None:
region = next(region for region in area.regions if region.type == "WINDOW")
with bpy.context.temp_override(area=area, region=region):
#print("overriden context", bpy.context)
for obj in bpy.context.selected_ids:
print(f"Selected: {obj.name} - {type(obj)}")
number_of_selections = len(bpy.context.selected_ids)
selection = bpy.context.selected_ids[number_of_selections - 1] if number_of_selections > 0 else None #next(iter(bpy.context.selected_ids), None)
if selection is None:
number_of_selections = len(context.selected_objects)
selection = context.selected_objects[number_of_selections - 1] if number_of_selections > 0 else None
#print("SELECTIONS", context.selected_objects)
return selection

View File

@ -81,8 +81,7 @@ def test_export_complex(setup_data):
}
gltf_settings = {
"export_animations": True,
"export_optimize_animation_size": False,
"export_apply":True
"export_optimize_animation_size": False
}
# store settings for the auto_export part
@ -121,12 +120,12 @@ def test_export_complex(setup_data):
user_asset.name = "yoho_audio"
user_asset.path = "audio/fake.mp3"
# we have to cheat, since we cannot rely on the data injected when saving the library file (since we are not saving it as part of the tests)
bpy.data.collections["External_blueprint"]["export_path"] = "blueprints/External_blueprint.glb"
bpy.data.collections["External_blueprint2"]["export_path"] = "blueprints/External_blueprint2.glb"
bpy.data.collections["External_blueprint3"]["export_path"] = "blueprints/External_blueprint3.glb"
# we have to cheat, since we cannot rely on the data injected when saving the library file
#bpy.data.collections["External_blueprint"]["export_path"] = "blueprints/External_blueprint.glb"
#bpy.data.collections["External_blueprint2"]["export_path"] = "blueprints/External_blueprint2.glb"
#bpy.data.collections["External_blueprint3"]["export_path"] = "blueprints/External_blueprint3.glb"
# do the actual exporting
prepare_and_export()
# blueprint1 => has an instance, got changed, should export