Reverted to old "is action for armature" functionality

The current Blender 4.4 functionality is still very wishy washy (not able to inspect channel bags), and the solution that was created was broken.

In addition, newly created actions will be given an appropriately named slot instead of it being a "Legacy Slot".
This commit is contained in:
Colin Basnett
2025-08-03 01:40:38 -07:00
parent 921efe97aa
commit f4b20e4e0f
2 changed files with 14 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ from collections import Counter
from typing import List, Iterable, Dict, Tuple, cast as typing_cast from typing import List, Iterable, Dict, Tuple, cast as typing_cast
import bpy import bpy
import re
from bpy.props import StringProperty from bpy.props import StringProperty
from bpy.types import Context, Action, Object, AnimData, TimelineMarker, Operator, Armature from bpy.types import Context, Action, Object, AnimData, TimelineMarker, Operator, Armature
from bpy_extras.io_utils import ExportHelper from bpy_extras.io_utils import ExportHelper
@@ -16,7 +17,6 @@ from .ui import PSA_UL_export_sequences
from ..builder import build_psa, PsaBuildSequence, PsaBuildOptions from ..builder import build_psa, PsaBuildSequence, PsaBuildOptions
from ..writer import write_psa from ..writer import write_psa
from ...shared.helpers import populate_bone_collection_list, get_nla_strips_in_frame_range, PsxBoneCollection from ...shared.helpers import populate_bone_collection_list, get_nla_strips_in_frame_range, PsxBoneCollection
from ...shared.semver import SemanticVersion
from ...shared.ui import draw_bone_filter_mode from ...shared.ui import draw_bone_filter_mode
@@ -41,16 +41,9 @@ def is_action_for_object(obj: Object, action: Action):
if obj is None or obj.animation_data is None or obj.type != 'ARMATURE': if obj is None or obj.animation_data is None or obj.type != 'ARMATURE':
return False return False
version = SemanticVersion(bpy.app.version)
def is_action_for_object_legacy(action: Action, obj: Object):
"""
This is the legacy behavior before slotted actions were introduced in Blender 4.4.
It would simply check if it had any f-curves that corresponded to any bones in the armature.
"""
import re
armature_data = typing_cast(Armature, obj.data) armature_data = typing_cast(Armature, obj.data)
bone_names = set([x.name for x in armature_data.bones]) bone_names = set([x.name for x in armature_data.bones])
for fcurve in action.fcurves: for fcurve in action.fcurves:
match = re.match(r'pose\.bones\[\"([^\"]+)\"](\[\"([^\"]+)\"])?', fcurve.data_path) match = re.match(r'pose\.bones\[\"([^\"]+)\"](\[\"([^\"]+)\"])?', fcurve.data_path)
if not match: if not match:
@@ -58,14 +51,9 @@ def is_action_for_object(obj: Object, action: Action):
bone_name = match.group(1) bone_name = match.group(1)
if bone_name in bone_names: if bone_name in bone_names:
return True return True
return False return False
if version < SemanticVersion((4, 4, 0)):
return is_action_for_object_legacy(action, obj)
# If the object is a part of the slot's user list, then it is a valid action for the object.
return any(obj in slot.users() for slot in action.slots)
def update_actions_and_timeline_markers(context: Context, armature_objects: Iterable[Object]): def update_actions_and_timeline_markers(context: Context, armature_objects: Iterable[Object]):
pg = getattr(context.scene, 'psa_export') pg = getattr(context.scene, 'psa_export')

View File

@@ -252,6 +252,7 @@ def import_psa(context: Context, psa_reader: PsaReader, armature_object: Object,
action = bpy.data.actions[action_name] action = bpy.data.actions[action_name]
else: else:
action = bpy.data.actions.new(name=action_name) action = bpy.data.actions.new(name=action_name)
action.slots.new('OBJECT', armature_object.name)
# Calculate the target FPS. # Calculate the target FPS.
match options.fps_source: match options.fps_source: