From 712f007c7179e77ebc68d0057fc56513161be004 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Tue, 4 Oct 2022 09:19:40 +0200 Subject: glTF exporter: tweak UI for export nested collections --- io_scene_gltf2/__init__.py | 25 +++++++++++++--------- .../blender/exp/gltf2_blender_export_keys.py | 2 +- .../blender/exp/gltf2_blender_gather_tree.py | 8 +++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index a0e2b58e..534b6392 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -4,7 +4,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (3, 4, 26), + "version": (3, 4, 27), 'blender': (3, 3, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -320,12 +320,12 @@ class ExportGLTF2_Base: ) use_active_collection_with_nested: BoolProperty( - name='Active Collection and nested Collections', - description='Export objects in the active collection and nested collections only', - default=False + name='Include Nested Collections', + description='Include active collection and nested collections', + default=True ) - use_active_collection_without_nested: BoolProperty( + use_active_collection: BoolProperty( name='Active Collection', description='Export objects in the active collection only', default=False @@ -528,7 +528,7 @@ class ExportGLTF2_Base: 'use_visible', 'use_renderable', 'use_active_collection_with_nested', - 'use_active_collection_without_nested' + 'use_active_collection', 'use_mesh_edges', 'use_mesh_vertices', 'use_active_scene', @@ -592,8 +592,12 @@ class ExportGLTF2_Base: export_settings['gltf_visible'] = self.use_visible export_settings['gltf_renderable'] = self.use_renderable - export_settings['gltf_active_collection_with_nested'] = self.use_active_collection_with_nested - export_settings['gltf_active_collection_without_nested'] = self.use_active_collection_without_nested + + export_settings['gltf_active_collection'] = self.use_active_collection + if self.use_active_collection: + export_settings['gltf_active_collection_with_nested'] = self.use_active_collection_with_nested + else: + export_settings['gltf_active_collection_with_nested'] = False export_settings['gltf_active_scene'] = self.use_active_scene export_settings['gltf_selected'] = self.use_selection @@ -735,8 +739,9 @@ class GLTF_PT_export_include(bpy.types.Panel): col.prop(operator, 'use_selection') col.prop(operator, 'use_visible') col.prop(operator, 'use_renderable') - col.prop(operator, 'use_active_collection_without_nested') - col.prop(operator, 'use_active_collection_with_nested') + col.prop(operator, 'use_active_collection') + if operator.use_active_collection: + col.prop(operator, 'use_active_collection_with_nested') col.prop(operator, 'use_active_scene') col = layout.column(heading = "Data", align = True) diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py b/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py index bcf2c1fc..31a84ad9 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py @@ -18,7 +18,7 @@ SELECTED = 'gltf_selected' VISIBLE = 'gltf_visible' RENDERABLE = 'gltf_renderable' ACTIVE_COLLECTION_WITH_NESTED = 'gltf_active_collection_with_nested' -ACTIVE_COLLECTION_WITHOUT_NESTED = 'gltf_active_collection_without_nested' +ACTIVE_COLLECTION = 'gltf_active_collection' SKINS = 'gltf_skins' DEF_BONES_ONLY = 'gltf_def_bones' FORCE_SAMPLING = 'gltf_force_sampling' diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py index dc25b417..d341028c 100644 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py @@ -392,13 +392,13 @@ class VExportTree: if all([c.hide_render for c in self.nodes[uuid].blender_object.users_collection]): return False - if self.export_settings[gltf2_blender_export_keys.ACTIVE_COLLECTION_WITH_NESTED]: - found = any(x == self.nodes[uuid].blender_object for x in bpy.context.collection.all_objects) + if self.export_settings[gltf2_blender_export_keys.ACTIVE_COLLECTION] and not self.export_settings[gltf2_blender_export_keys.ACTIVE_COLLECTION_WITH_NESTED]: + found = any(x == self.nodes[uuid].blender_object for x in bpy.context.collection.objects) if not found: return False - if self.export_settings[gltf2_blender_export_keys.ACTIVE_COLLECTION_WITHOUT_NESTED]: - found = any(x == self.nodes[uuid].blender_object for x in bpy.context.collection.objects) + if self.export_settings[gltf2_blender_export_keys.ACTIVE_COLLECTION] and self.export_settings[gltf2_blender_export_keys.ACTIVE_COLLECTION_WITH_NESTED]: + found = any(x == self.nodes[uuid].blender_object for x in bpy.context.collection.all_objects) if not found: return False -- cgit v1.2.3