Refactor: convert rigid body "Bake to Keyframes" to current Action API

Convert the code for the rigid body "Bake to Keyframes" operator from the
legacy Actions API to the current API.

No functional changes.

This is part of #146586

Pull Request: https://projects.blender.org/blender/blender/pulls/147060
This commit is contained in:
Sybren A. Stüvel
2025-09-23 17:19:18 +02:00
parent 89d059c5d7
commit 2cabaeb4a7

View File

@@ -8,6 +8,7 @@ from bpy.props import (
EnumProperty,
IntProperty,
)
from bpy_extras import anim_utils
class CopyRigidbodySettings(Operator):
@@ -167,8 +168,13 @@ class BakeToKeyframes(Operator):
# clean up keyframes
for obj in objects:
action = obj.animation_data.action
for fcu in action.fcurves:
channelbag = anim_utils.action_get_channelbag_for_slot(
obj.animation_data.action,
obj.animation_data.action_slot,
)
if not channelbag:
continue
for fcu in channelbag.fcurves:
keyframe_points = fcu.keyframe_points
i = 1
# remove unneeded keyframes