Skip to content

Commit

Permalink
feat(gltf_auto_export): cleaned up folder & modules structure, moved …
Browse files Browse the repository at this point in the history
…a few files around for coherence
  • Loading branch information
kaosat-dev committed Feb 4, 2024
1 parent 0ffa3fe commit 212bc59
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 55 deletions.
2 changes: 1 addition & 1 deletion tools/gltf_auto_export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .auto_export.tracker import AutoExportTracker
from .auto_export.preferences import (AutoExportGltfAddonPreferences)

from .internals import (SceneLink,
from .auto_export.internals import (SceneLink,
SceneLinks,
CollectionToExport,
CollectionsToExport,
Expand Down
8 changes: 4 additions & 4 deletions tools/gltf_auto_export/auto_export/auto_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from .export_main_scenes import export_main_scene
from .export_blueprints import check_if_blueprint_on_disk, check_if_blueprints_exist, export_blueprints_from_collections

from ..helpers_scenes import (get_scenes, )
from ..helpers_collections import (get_collections_in_library, get_exportable_collections, get_collections_per_scene, find_collection_ascendant_target_collection)
from ..export_materials import cleanup_materials, export_materials
from ..bevy_scene_components import upsert_scene_components
from ..helpers.helpers_scenes import (get_scenes, )
from ..helpers.helpers_collections import (get_collections_in_library, get_exportable_collections, get_collections_per_scene, find_collection_ascendant_target_collection)
from ..modules.export_materials import cleanup_materials, export_materials
from ..modules.bevy_scene_components import upsert_scene_components


"""Main function"""
Expand Down
4 changes: 2 additions & 2 deletions tools/gltf_auto_export/auto_export/export_blueprints.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import bpy

from ..generate_and_export import generate_and_export
from ..helpers.generate_and_export import generate_and_export
from .export_gltf import (generate_gltf_export_preferences)
from ..helpers_scenes import clear_hollow_scene, copy_hollowed_collection_into
from ..helpers.helpers_scenes import clear_hollow_scene, copy_hollowed_collection_into

# export collections: all the collections that have an instance in the main scene AND any marked collections, even if they do not have instances
def export_collections(collections, folder_path, library_scene, addon_prefs, gltf_export_preferences, blueprint_hierarchy, library_collections):
Expand Down
6 changes: 3 additions & 3 deletions tools/gltf_auto_export/auto_export/export_main_scenes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import bpy

from ..generate_and_export import generate_and_export
from ..helpers.generate_and_export import generate_and_export
from .export_gltf import (generate_gltf_export_preferences, export_gltf)
from ..bevy_dynamic import is_object_dynamic, is_object_static
from ..helpers_scenes import clear_hollow_scene, copy_hollowed_collection_into
from ..modules.bevy_dynamic import is_object_dynamic, is_object_static
from ..helpers.helpers_scenes import clear_hollow_scene, copy_hollowed_collection_into


# export all main scenes
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tools/gltf_auto_export/auto_export/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from bpy_extras.io_utils import ExportHelper
from bpy.props import (IntProperty, StringProperty)
from .preferences import (AutoExportGltfAddonPreferences, AutoExportGltfPreferenceNames)
from ..helpers_scenes import (get_scenes)
from ..helpers_collections import (get_exportable_collections)
from ..helpers.helpers_scenes import (get_scenes)
from ..helpers.helpers_collections import (get_exportable_collections)
from .auto_export import auto_export

class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
Expand Down
2 changes: 1 addition & 1 deletion tools/gltf_auto_export/auto_export/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
CollectionProperty
)

from ..internals import (CUSTOM_PG_sceneName)
from .internals import (CUSTOM_PG_sceneName)

AutoExportGltfPreferenceNames = [
'auto_export',
Expand Down
2 changes: 1 addition & 1 deletion tools/gltf_auto_export/auto_export/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from bpy.types import (PropertyGroup)
from bpy.props import (PointerProperty)

from ..internals import CollectionsToExport
from .internals import CollectionsToExport

class AutoExportTracker(PropertyGroup):

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import bpy
from .auto_export.export_gltf import export_gltf
from ..auto_export.export_gltf import export_gltf
from .helpers_collections import (set_active_collection)

"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
import bpy
from .helpers_collections import (set_active_collection)
from .auto_export.object_makers import (make_empty)

# generate a copy of a scene that replaces collection instances with empties
# copy original names before creating a new scene, & reset them
def generate_hollow_scene(original_root_collection, library_collections, addon_prefs, name="__temp_scene", filter=None):
collection_instances_combine_mode = getattr(addon_prefs, "collection_instances_combine_mode")

temp_scene = bpy.data.scenes.new(name=name)
copy_root_collection = temp_scene.collection

# we set our active scene to be this one : this is needed otherwise the stand-in empties get generated in the wrong scene
bpy.context.window.scene = temp_scene
set_active_collection(bpy.context.scene, copy_root_collection.name)

"""found = find_layer_collection_recursive(copy_root_collection, bpy.context.view_layer.layer_collection)
if found:
# once it's found, set the active layer collection to the one we found
bpy.context.view_layer.active_layer_collection = found"""

# TODO also add the handling for "template" flags, so that instead of creating empties we link the data from the sub collection INTO the parent collection
# copies the contents of a collection into another one while replacing blueprint instances with empties
# if we have combine_mode set to "Inject", we take all the custom attributed of the nested (1 level only ! unless we use 'deepMerge') custom attributes and copy them to this level

results = copy_hollowed_collection_into(
original_root_collection,
copy_root_collection,
filter=filter,
collection_instances_combine_mode=collection_instances_combine_mode,
library_collections=library_collections
)

return (temp_scene, results.root_objects, results.special_properties)

from .object_makers import (make_empty)

# copies the contents of a collection into another one while replacing library instances with empties
def copy_hollowed_collection_into(source_collection, destination_collection, parent_empty=None, filter=None, collection_instances_combine_mode=None, library_collections=[]):
Expand Down
File renamed without changes.
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from .auto_export.object_makers import make_empty
from ..helpers.object_makers import make_empty

def upsert_scene_components(scene, world, main_scene_names):
#should only be run in one of the main scenes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import bpy
from pathlib import Path

from .generate_and_export import generate_and_export
from ..helpers.generate_and_export import generate_and_export

from .helpers_collections import (set_active_collection, traverse_tree)
from .auto_export.export_gltf import (export_gltf, generate_gltf_export_preferences)
from .auto_export.object_makers import make_cube
from ..helpers.helpers_collections import (set_active_collection, traverse_tree)
from ..auto_export.export_gltf import (export_gltf, generate_gltf_export_preferences)
from ..helpers.object_makers import make_cube

# get materials per object, and injects the materialInfo component
def get_materials(object):
Expand Down
4 changes: 2 additions & 2 deletions tools/gltf_auto_export/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from ..auto_export import auto_export

from ..auto_export.preferences import (AutoExportGltfAddonPreferences, AutoExportGltfPreferenceNames)
from ..helpers_scenes import (get_scenes)
from ..helpers_collections import (get_exportable_collections)
from ..helpers.helpers_scenes import (get_scenes)
from ..helpers.helpers_collections import (get_exportable_collections)
######################################################
## ui logic & co

Expand Down

0 comments on commit 212bc59

Please sign in to comment.