diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2020-10-20 23:36:51 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2020-10-20 23:36:51 +0300 |
commit | 33eae7da675d532bbb9c12b129c0e30228f5f000 (patch) | |
tree | 153bcf72924302de330134fddd24950a050c91d7 /io_scene_gltf2 | |
parent | f713ed806347b3f352f6eed042d2de7ef4f7e8e8 (diff) |
glTF exporter: filtering of exported nodes
This partially solves bugs on "use_selected" option.
Not perfect yet (for example on collection or linked collection), but better than nothing for now
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-x | io_scene_gltf2/__init__.py | 2 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py | 32 |
2 files changed, 27 insertions, 7 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 6b4a88d0..03180b3f 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -15,7 +15,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": (1, 4, 37), + "version": (1, 4, 38), 'blender': (2, 91, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py index 30058309..35c2df00 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py @@ -49,25 +49,45 @@ def gather_node(blender_object, library, blender_scene, dupli_object_parent, exp @cached def __gather_node(blender_object, library, blender_scene, dupli_object_parent, export_settings): + children = __gather_children(blender_object, blender_scene, export_settings) + + camera = None + mesh = None + skin = None + weights = None + # If blender_scene is None, we are coming from animation export # Check to know if object is exported is already done, so we don't check # again if object is instanced in scene : this check was already done when exporting object itself if not __filter_node(blender_object, blender_scene, export_settings): - return None + if children: + # This node should be filtered out, but has un-filtered children present. + # So, export this node, excluding its camera, mesh, skin, and weights. + # The transformations and animations on this node will have visible effects on children. + pass + else: + # This node is filtered out, and has no un-filtered children or descendants. + return None + else: + # This node is being fully exported. + camera = __gather_camera(blender_object, export_settings) + mesh = __gather_mesh(blender_object, library, export_settings) + skin = __gather_skin(blender_object, export_settings) + weights = __gather_weights(blender_object, export_settings) node = gltf2_io.Node( - camera=__gather_camera(blender_object, export_settings), - children=__gather_children(blender_object, blender_scene, export_settings), + camera=camera, + children=children, extensions=__gather_extensions(blender_object, export_settings), extras=__gather_extras(blender_object, export_settings), matrix=__gather_matrix(blender_object, export_settings), - mesh=__gather_mesh(blender_object, library, export_settings), + mesh=mesh, name=__gather_name(blender_object, export_settings), rotation=None, scale=None, - skin=__gather_skin(blender_object, export_settings), + skin=skin, translation=None, - weights=__gather_weights(blender_object, export_settings) + weights=weights ) # If node mesh is skined, transforms should be ignored at import, so no need to set them here |