Cleanup: make format
Pull Request: https://projects.blender.org/blender/blender/pulls/130226
This commit is contained in:
+16
-8
@@ -70,6 +70,8 @@ def gather_actions_animations(export_settings):
|
||||
# For example, cache will get frame 1/4/7/10 if step is 3, with an action starting at frame 1
|
||||
# If all backing is enabled, and scene start at 0, we will get frame 0/3/6/9 => Cache will fail
|
||||
# Set the reference frame from the first action retrieve, and align all actions to this frame
|
||||
|
||||
|
||||
def _align_frame_start(reference_frame_start, frame, export_settings):
|
||||
|
||||
if reference_frame_start is None:
|
||||
@@ -78,7 +80,8 @@ def _align_frame_start(reference_frame_start, frame, export_settings):
|
||||
if export_settings['gltf_frame_step'] == 1:
|
||||
return frame
|
||||
|
||||
return reference_frame_start + export_settings['gltf_frame_step'] * ceil((frame - reference_frame_start) / export_settings['gltf_frame_step'])
|
||||
return reference_frame_start + export_settings['gltf_frame_step'] * \
|
||||
ceil((frame - reference_frame_start) / export_settings['gltf_frame_step'])
|
||||
|
||||
|
||||
def prepare_actions_range(export_settings):
|
||||
@@ -131,7 +134,8 @@ def prepare_actions_range(export_settings):
|
||||
start_frame = max(bpy.context.scene.frame_start, start_frame)
|
||||
end_frame = min(bpy.context.scene.frame_end, end_frame)
|
||||
|
||||
export_settings['ranges'][obj_uuid][blender_action.name]['start'] = _align_frame_start(start_frame_reference, start_frame, export_settings)
|
||||
export_settings['ranges'][obj_uuid][blender_action.name]['start'] = _align_frame_start(
|
||||
start_frame_reference, start_frame, export_settings)
|
||||
export_settings['ranges'][obj_uuid][blender_action.name]['end'] = end_frame
|
||||
|
||||
if start_frame_reference is None:
|
||||
@@ -140,7 +144,8 @@ def prepare_actions_range(export_settings):
|
||||
# Recheck all actions to align to this frame
|
||||
for obj_uuid_tmp in export_settings['ranges'].keys():
|
||||
for action_name_tmp in export_settings['ranges'][obj_uuid_tmp].keys():
|
||||
export_settings['ranges'][obj_uuid_tmp][action_name_tmp]['start'] = _align_frame_start(start_frame_reference, export_settings['ranges'][obj_uuid_tmp][action_name_tmp]['start'], export_settings)
|
||||
export_settings['ranges'][obj_uuid_tmp][action_name_tmp]['start'] = _align_frame_start(
|
||||
start_frame_reference, export_settings['ranges'][obj_uuid_tmp][action_name_tmp]['start'], export_settings)
|
||||
|
||||
if export_settings['gltf_negative_frames'] == "SLIDE":
|
||||
if track is not None:
|
||||
@@ -178,7 +183,8 @@ def prepare_actions_range(export_settings):
|
||||
|
||||
if type_ == "SHAPEKEY" and export_settings['gltf_bake_animation']:
|
||||
export_settings['ranges'][obj_uuid][obj_uuid] = {}
|
||||
export_settings['ranges'][obj_uuid][obj_uuid]['start'] = _align_frame_start(start_frame_reference, bpy.context.scene.frame_start, export_settings)
|
||||
export_settings['ranges'][obj_uuid][obj_uuid]['start'] = _align_frame_start(
|
||||
start_frame_reference, bpy.context.scene.frame_start, export_settings)
|
||||
export_settings['ranges'][obj_uuid][obj_uuid]['end'] = bpy.context.scene.frame_end
|
||||
|
||||
# For baking drivers
|
||||
@@ -188,7 +194,8 @@ def prepare_actions_range(export_settings):
|
||||
if obj_dr not in export_settings['ranges']:
|
||||
export_settings['ranges'][obj_dr] = {}
|
||||
export_settings['ranges'][obj_dr][obj_uuid + "_" + blender_action.name] = {}
|
||||
export_settings['ranges'][obj_dr][obj_uuid + "_" + blender_action.name]['start'] = _align_frame_start(start_frame_reference, start_frame, export_settings)
|
||||
export_settings['ranges'][obj_dr][obj_uuid + "_" + blender_action.name]['start'] = _align_frame_start(
|
||||
start_frame_reference, start_frame, export_settings)
|
||||
export_settings['ranges'][obj_dr][obj_uuid + "_" + blender_action.name]['end'] = end_frame
|
||||
|
||||
if len(blender_actions) == 0 and export_settings['gltf_bake_animation']:
|
||||
@@ -196,7 +203,8 @@ def prepare_actions_range(export_settings):
|
||||
# In case of baking animation, we will use scene frame range
|
||||
# Will be calculated later if max range. Can be set here if scene frame range
|
||||
export_settings['ranges'][obj_uuid][obj_uuid] = {}
|
||||
export_settings['ranges'][obj_uuid][obj_uuid]['start'] = _align_frame_start(start_frame_reference, bpy.context.scene.frame_start, export_settings)
|
||||
export_settings['ranges'][obj_uuid][obj_uuid]['start'] = _align_frame_start(
|
||||
start_frame_reference, bpy.context.scene.frame_start, export_settings)
|
||||
export_settings['ranges'][obj_uuid][obj_uuid]['end'] = bpy.context.scene.frame_end
|
||||
|
||||
# For baking drivers
|
||||
@@ -206,8 +214,8 @@ def prepare_actions_range(export_settings):
|
||||
if obj_dr not in export_settings['ranges']:
|
||||
export_settings['ranges'][obj_dr] = {}
|
||||
export_settings['ranges'][obj_dr][obj_uuid + "_" + obj_uuid] = {}
|
||||
export_settings['ranges'][obj_dr][obj_uuid + "_" +
|
||||
obj_uuid]['start'] = _align_frame_start(start_frame_reference, bpy.context.scene.frame_start, export_settings)
|
||||
export_settings['ranges'][obj_dr][obj_uuid + "_" + obj_uuid]['start'] = _align_frame_start(
|
||||
start_frame_reference, bpy.context.scene.frame_start, export_settings)
|
||||
export_settings['ranges'][obj_dr][obj_uuid + "_" + obj_uuid]['end'] = bpy.context.scene.frame_end
|
||||
|
||||
if (export_settings['gltf_negative_frames'] == "SLIDE"
|
||||
|
||||
@@ -107,7 +107,8 @@ def __gather_extras(blender_mesh: bpy.types.Mesh,
|
||||
extras = generate_extras(blender_mesh) or {}
|
||||
|
||||
# Not for GN Instances
|
||||
if export_settings['gltf_morph'] and blender_mesh.shape_keys and ((blender_mesh.is_evaluated is True and blender_mesh.get('gltf2_mesh_applied') is not None) or blender_mesh.is_evaluated is False):
|
||||
if export_settings['gltf_morph'] and blender_mesh.shape_keys and ((blender_mesh.is_evaluated is True and blender_mesh.get(
|
||||
'gltf2_mesh_applied') is not None) or blender_mesh.is_evaluated is False):
|
||||
morph_max = len(blender_mesh.shape_keys.key_blocks) - 1
|
||||
if morph_max > 0:
|
||||
extras['targetNames'] = [k.name for k in get_sk_exported(blender_mesh.shape_keys.key_blocks)]
|
||||
|
||||
+2
-1
@@ -151,7 +151,8 @@ class PrimitiveCreator:
|
||||
# We need to check if we are in a GN Instance, because for GN instances, it seems that shape keys are preserved,
|
||||
# even if we apply modifiers
|
||||
# (For classic objects, shape keys are not preserved if we apply modifiers)
|
||||
if self.blender_mesh.shape_keys and self.export_settings['gltf_morph'] and ((self.blender_mesh.is_evaluated is True and self.blender_mesh.get('gltf2_mesh_applied') is not None) or self.blender_mesh.is_evaluated is False):
|
||||
if self.blender_mesh.shape_keys and self.export_settings['gltf_morph'] and (
|
||||
(self.blender_mesh.is_evaluated is True and self.blender_mesh.get('gltf2_mesh_applied') is not None) or self.blender_mesh.is_evaluated is False):
|
||||
self.key_blocks = get_sk_exported(self.blender_mesh.shape_keys.key_blocks)
|
||||
|
||||
# Fetch vert positions and bone data (joint,weights)
|
||||
|
||||
+2
-1
@@ -432,7 +432,8 @@ class ExportImage:
|
||||
|
||||
# We don't manage UDIM packed image, so this could not happen to be here
|
||||
# Lets display an error
|
||||
export_settings['log'].error("UDIM packed images are not supported for export. Please unpack them before exporting.")
|
||||
export_settings['log'].error(
|
||||
"UDIM packed images are not supported for export. Please unpack them before exporting.")
|
||||
|
||||
|
||||
def _encode_temp_image(tmp_image: bpy.types.Image, file_format: str, export_settings) -> bytes:
|
||||
|
||||
Reference in New Issue
Block a user