From 588837cf354a41efe646922f55ba3599966789ea Mon Sep 17 00:00:00 2001 From: bangbangsheshotmedown Date: Sat, 9 Aug 2025 21:01:53 +0200 Subject: [PATCH] Reset armature before processing actions --- blender-4.1/iqm_export.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/blender-4.1/iqm_export.py b/blender-4.1/iqm_export.py index 119ccdf..d8edcea 100644 --- a/blender-4.1/iqm_export.py +++ b/blender-4.1/iqm_export.py @@ -735,9 +735,33 @@ def collectBones(context, armature, scale): worklist.append(child) print('Collected %d bones' % len(worklist)) return bones - + +def clearArmaturePose(armature, clear_object=False): + """Reset every pose-bone to identity (rest) so sampling starts clean.""" + for pb in armature.pose.bones: + pb.location = mathutils.Vector((0.0, 0.0, 0.0)) + if pb.rotation_mode == 'QUATERNION': + pb.rotation_quaternion = mathutils.Quaternion((1.0, 0.0, 0.0, 0.0)) + else: + pb.rotation_euler = mathutils.Euler((0.0, 0.0, 0.0), pb.rotation_mode) + pb.scale = mathutils.Vector((1.0, 1.0, 1.0)) + pb.matrix_basis = mathutils.Matrix.Identity(4) + + if clear_object: + armature.location = mathutils.Vector((0.0, 0.0, 0.0)) + if armature.rotation_mode == 'QUATERNION': + armature.rotation_quaternion = mathutils.Quaternion((1.0, 0.0, 0.0, 0.0)) + else: + armature.rotation_euler = mathutils.Euler((0.0, 0.0, 0.0), armature.rotation_mode) + armature.scale = Vector((1.0, 1.0, 1.0)) def collectAnim(context, armature, scale, bones, action, startframe = None, endframe = None): + scene = context.scene + depsgraph = context.evaluated_depsgraph_get() + + clearArmaturePose(armature, clear_object=False) + depsgraph.update() + if startframe is None or endframe is None: startframe, endframe = action.frame_range startframe = int(startframe) @@ -1161,3 +1185,4 @@ def unregister(): if __name__ == "__main__": register() +