glTF exporter: various baking fixes

This commit is contained in:
Julien Duroure 2022-02-11 19:37:58 +01:00
parent dd0aa51642
commit 0508df3751
3 changed files with 39 additions and 38 deletions

View File

@ -174,23 +174,26 @@ def gather_animation_channels(obj_uuid: int,
to_be_done = ['location', 'rotation_quaternion', 'scale']
to_be_done = [c for c in to_be_done if c not in done_paths]
for p in to_be_done:
channel = gather_animation_channel(
obj_uuid,
(),
export_settings,
None,
p,
start_frame,
end_frame,
force_range,
blender_action.name,
None,
False #If Object is not animated, don't keep animation for this channel
)
# In case of weight action, do nothing.
# If there is only weight --> TRS is already managed at first
if not (len(done_paths) == 1 and 'weights' in done_paths):
for p in to_be_done:
channel = gather_animation_channel(
obj_uuid,
(),
export_settings,
None,
p,
start_frame,
end_frame,
force_range,
blender_action.name,
None,
False #If Object is not animated, don't keep animation for this channel
)
if channel is not None:
channels.append(channel)
if channel is not None:
channels.append(channel)

View File

@ -148,16 +148,12 @@ def get_object_matrix(blender_obj_uuid: str,
data = {}
# If we bake (because export selection), we don't know exactly the frame range,
# TODO : bake_range_start & bake_range_end are no more needed here
# Because we bake, we don't know exactly the frame range,
# So using min / max of all actions
if export_settings['gltf_selected'] is True and export_settings['vtree'].tree_troncated is True:
start_frame = min([v[0] for v in [a.frame_range for a in bpy.data.actions]])
end_frame = max([v[1] for v in [a.frame_range for a in bpy.data.actions]])
else:
start_frame = bake_range_start
end_frame = bake_range_end
start_frame = min([v[0] for v in [a.frame_range for a in bpy.data.actions]])
end_frame = max([v[1] for v in [a.frame_range for a in bpy.data.actions]])
frame = start_frame
while frame <= end_frame:

View File

@ -69,21 +69,23 @@ def gather_animations( obj_uuid: int,
# Collect all 'actions' affecting this object. There is a direct mapping between blender actions and glTF animations
blender_actions = __get_blender_actions(blender_object, export_settings)
if export_settings['gltf_selected'] is True \
and not (blender_object.animation_data is not None and blender_object.animation_data.action is not None): #there is no animation
channels = __gather_channels_baked(obj_uuid, export_settings)
if channels is not None:
animation = gltf2_io.Animation(
channels=channels,
extensions=None, # as other animations
extras=None, # Because there is no animation to get extras from
name=blender_object.name, # Use object name as animation name
samplers=[]
)
if len([a for a in blender_actions if a[2] == "OBJECT"]) == 0:
# No TRS animation are found for this object.
# But we need to bake, in case we export selection
if export_settings['gltf_selected'] is True and blender_object.type != "ARMATURE":
channels = __gather_channels_baked(obj_uuid, export_settings)
if channels is not None:
animation = gltf2_io.Animation(
channels=channels,
extensions=None, # as other animations
extras=None, # Because there is no animation to get extras from
name=blender_object.name, # Use object name as animation name
samplers=[]
)
__link_samplers(animation, export_settings)
if animation is not None:
animations.append(animation)
__link_samplers(animation, export_settings)
if animation is not None:
animations.append(animation)
current_action = None
if blender_object.animation_data and blender_object.animation_data.action: