Compare commits

..

1 Commits

Author SHA1 Message Date
Mark Moissette
dca49bd696
Merge b92081d06e into 9b50d77790 2024-07-23 21:42:29 +00:00
6 changed files with 17 additions and 62 deletions

View File

@ -222,10 +222,6 @@ Blender side:
- [ ] materials fixes & upgrades
- [x] materials do not get exported again if the files are missing, until you change a material
- [x] materials do not get exported when a material is added ?
- [x] add_material_info_to_objects is now called AFTER the blueprint export, making it useless, needs change !
- [ ] materials_path custom property should be ignored both in the list of fixable component AND on export
- [ ] if we want to add material_infos & others as normal components they should not be editable, so we need another attribute, and adapt the UI for that
- [ ] if material library is toggled, then changes to materials should not change the blueprints that are using them ?
- [ ] material assets seem to be added to list regardless of whether material exports are enabled or not
- [ ] review & upgrade overall logic of material libraries, their names & output path

View File

@ -101,24 +101,23 @@ def auto_export(changes_per_scene, changes_per_collection, changes_per_material,
# backup current selections
old_selections = bpy.context.selected_objects
# deal with materials
if export_materials_library:
print("export MATERIALS")
export_materials(materials_to_export, settings, blueprints_data)
# export any level/world scenes
# first export any level/world scenes
if len(level_scenes_to_export) > 0:
print("export LEVELS")
print("export MAIN scenes")
for scene_name in level_scenes_to_export:
print(" exporting scene:", scene_name)
export_level_scene(bpy.data.scenes[scene_name], settings, blueprints_data)
# now deal with blueprints/collections
do_export_blueprints = not change_detection or changed_export_parameters or len(blueprints_to_export) > 0
if do_export_blueprints:
print("export BLUEPRINTS")
do_export_library_scene = not change_detection or changed_export_parameters or len(blueprints_to_export) > 0
if do_export_library_scene:
print("export LIBRARY")
export_blueprints(blueprints_to_export, settings, blueprints_data)
# then deal with materials
if export_materials_library:
export_materials(materials_to_export, settings, blueprints_data)#blueprints_data.blueprint_names, settings.library_scenes, settings)
# reset current scene from backup
bpy.context.window.scene = old_current_scene

View File

@ -15,7 +15,6 @@ from ..common.export_gltf import (generate_gltf_export_settings)
#
def clear_material_info(collection_names, library_scenes):
pass
for scene in library_scenes:
root_collection = scene.collection
for cur_collection in traverse_tree(root_collection):

View File

@ -171,10 +171,6 @@ def add_metadata_to_components_without_metadata(item):
continue
upsert_component_in_item(item, component_name, registry)
# adds a component to an item (including metadata) WITHOUT a component definition
def add_component_to_item_without_registry():
pass
# adds a component to an item (including metadata) using the provided component definition & optional value
def add_component_to_item(item, component_definition, value=None):
warnings = []

View File

@ -19,42 +19,15 @@ class BLENVY_OT_component_add(Operator):
description="component type to add",
) # type: ignore
component_value: StringProperty(
name="component_value",
description="value of the newly added component"
) # type: ignore
target_item_name: StringProperty(
name="target item name",
description="name of the object/collection/mesh/material to add the component to",
) # type: ignore
target_item_type: EnumProperty(
name="target item type",
description="type of the object/collection/mesh/material to add the component to",
items=(
('OBJECT', "Object", ""),
('COLLECTION', "Collection", ""),
('MESH', "Mesh", ""),
('MATERIAL', "Material", ""),
),
default="OBJECT"
) # type: ignore
def execute(self, context):
if self.target_item_name == "" or self.target_item_type == "":
target_item = get_selected_item(context)
print("adding component ", self.component_type, "to target '"+target_item.name+"'")
else:
target_item = get_item_by_type(self.target_item_type, self.target_item_name)
print("adding component ", self.component_type, "to target '"+target_item.name+"'")
target = get_selected_item(context)
print("adding component ", self.component_type, "to target '"+target.name+"'")
has_component_type = self.component_type != ""
if has_component_type and target_item is not None:
if has_component_type and target is not None:
type_infos = context.window_manager.components_registry.type_infos
component_definition = type_infos[self.component_type]
component_value = self.component_value if self.component_value != "" else None
add_component_to_item(target_item, component_definition, value=component_value)
add_component_to_item(target, component_definition)
return {'FINISHED'}

View File

@ -2,7 +2,6 @@ import os
import posixpath
import bpy
from pathlib import Path
from ..core.helpers_collections import (traverse_tree)
def find_materials_not_on_disk(materials, materials_path_full, extension):
@ -66,18 +65,11 @@ def add_material_info_to_objects(materials_per_object, settings):
current_project_name = Path(bpy.context.blend_data.filepath).stem
materials_library_name = f"{current_project_name}_materials"
materials_exported_path = posixpath.join(materials_path, f"{materials_library_name}{export_gltf_extension}")
#print("ADDING MAERIAL INFOS")
for object in materials_per_object.keys():
material = materials_per_object[object]
# problem with using actual components: you NEED the type registry/component infos, so if there is none , or it is not loaded yet, it does not work
# for a few components we could hardcode this
component_value = f'(name: "{material.name}", path: "{materials_exported_path}")'
#bpy.ops.blenvy.component_add(target_item_name=object.name, target_item_type="OBJECT", component_type="blenvy::blueprints::materials::MaterialInfo", component_value=component_value)
# TODO: switch to using actual components ?
materials_exported_path = posixpath.join(materials_path, f"{materials_library_name}{export_gltf_extension}")
object['MaterialInfo'] = component_value
print("adding materialInfo to object", object, "material info", component_value)
object['MaterialInfo'] = f'(name: "{material.name}", path: "{materials_exported_path}")'
# get all the materials of all objects in a given scene