glTF exporter: remove proxy management

This commit is contained in:
Julien Duroure 2022-02-06 16:51:03 +01:00
parent 713854cc2b
commit 6da09c309d
6 changed files with 12 additions and 22 deletions

View File

@ -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": (3, 2, 1),
"version": (3, 2, 2),
'blender': (3, 1, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -51,9 +51,8 @@ def __gather_scene(blender_scene, export_settings):
nodes=[]
)
for _blender_object in [obj for obj in blender_scene.objects if obj.proxy is None]:
if _blender_object.parent is None:
blender_object = _blender_object.proxy if _blender_object.proxy else _blender_object
for blender_object in blender_scene.objects:
if blender_object.parent is None:
node = gltf2_blender_gather_nodes.gather_node(
blender_object,
blender_object.library.name if blender_object.library else None,
@ -70,17 +69,14 @@ def __gather_animations(blender_scene, export_settings):
animations = []
merged_tracks = {}
for _blender_object in blender_scene.objects:
blender_object = _blender_object.proxy if _blender_object.proxy else _blender_object
for blender_object in blender_scene.objects:
# First check if this object is exported or not. Do not export animation of not exported object
obj_node = gltf2_blender_gather_nodes.gather_node(blender_object,
blender_object.library.name if blender_object.library else None,
blender_scene, None, export_settings)
if obj_node is not None:
# Check was done on armature, but use here the _proxy object, because this is where the animation is
animations_, merged_tracks = gltf2_blender_gather_animations.gather_animations(_blender_object, merged_tracks, len(animations), export_settings)
animations_, merged_tracks = gltf2_blender_gather_animations.gather_animations(blender_object, merged_tracks, len(animations), export_settings)
animations += animations_
if export_settings['gltf_nla_strips'] is False:

View File

@ -86,13 +86,11 @@ def __gather_node(channels: typing.Tuple[bpy.types.FCurve],
if isinstance(blender_bone, bpy.types.PoseBone):
if export_settings["gltf_def_bones"] is False:
obj = blender_object.proxy if blender_object.proxy else blender_object
return gltf2_blender_gather_joints.gather_joint(obj, blender_bone, export_settings)
return gltf2_blender_gather_joints.gather_joint(blender_object, blender_bone, export_settings)
else:
bones, _, _ = gltf2_blender_gather_skins.get_bone_tree(None, blender_object)
if blender_bone.name in [b.name for b in bones]:
obj = blender_object.proxy if blender_object.proxy else blender_object
return gltf2_blender_gather_joints.gather_joint(obj, blender_bone, export_settings)
return gltf2_blender_gather_joints.gather_joint(blender_object, blender_bone, export_settings)
return gltf2_blender_gather_nodes.gather_node(blender_object,
blender_object.library.name if blender_object.library else None,

View File

@ -112,8 +112,7 @@ def gather_animation_channels(blender_action: bpy.types.Action,
# Retrieve channels for drivers, if needed
obj_driver = blender_object.proxy if blender_object.proxy else blender_object
drivers_to_manage = gltf2_blender_gather_drivers.get_sk_drivers(obj_driver)
drivers_to_manage = gltf2_blender_gather_drivers.get_sk_drivers(blender_object)
for obj, fcurves in drivers_to_manage:
channel = __gather_animation_channel(
fcurves,

View File

@ -174,8 +174,7 @@ def get_bone_matrix(blender_object_if_armature: typing.Optional[bpy.types.Object
# If some drivers must be evaluated, do it here, to avoid to have to change frame by frame later
obj_driver = blender_object_if_armature.proxy if blender_object_if_armature.proxy else blender_object_if_armature
drivers_to_manage = get_sk_drivers(obj_driver)
drivers_to_manage = get_sk_drivers(blender_object_if_armature)
for dr_obj, dr_fcurves in drivers_to_manage:
vals = get_sk_driver_values(dr_obj, frame, dr_fcurves)

View File

@ -166,15 +166,13 @@ def __gather_children(blender_object, blender_scene, export_settings):
children = []
only_bone_children = True # True by default, will be set to False if needed
# standard children
for _child_object in blender_object.children:
if _child_object.parent_bone:
for child_object in blender_object.children:
if child_object.parent_bone:
# this is handled further down,
# as the object should be a child of the specific bone,
# not the Armature object
continue
child_object = _child_object.proxy if _child_object.proxy else _child_object
node = gather_node(child_object,
child_object.library.name if child_object.library else None,
blender_scene, None, export_settings)
@ -187,7 +185,7 @@ def __gather_children(blender_object, blender_scene, export_settings):
if dupli_object.parent is not None:
continue
if dupli_object.type == "ARMATURE":
continue # There is probably a proxy
continue # There is probably a proxy (no more existing)
node = gather_node(dupli_object,
dupli_object.library.name if dupli_object.library else None,
blender_scene, blender_object.name, export_settings)