WIP: Animation: Select Grouped operator #104758

Draft
RedMser wants to merge 9 commits from RedMser/blender:animation-select-grouped into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 66 additions and 6 deletions
Showing only changes of commit ead2243a63 - Show all commits

View File

@ -1951,7 +1951,7 @@ static const EnumPropertyItem actkeys_prop_select_grouped_types[] = {
"MODIFIERS",
0,
"Modifiers",
"All keyframes on each channel that has the same modifiers"},
"All keyframes on each channel that have all of the same types of modifiers"},
{ACTKEYS_SELECT_GROUP_DATABLOCK,
"DATABLOCK",
0,
@ -1997,6 +1997,33 @@ static short select_grouped_active_channel_type_strict(KeyframeEditData *ked,
return 0;
}
/* ACTKEYS_SELECT_GROUP_MODIFIERS */
static int convert_modifiers_to_bitmask(ListBase modifiers)
{
int bitmask = 0;
FModifier *modifier;
for (modifier = modifiers.first; modifier; modifier = modifier->next) {
bitmask |= 1 << modifier->type;
}
return bitmask;
}
static short select_grouped_modifiers(KeyframeEditData *ked, struct BezTriple *bezt)
{
if (BLI_gset_haskey(ked->data,
POINTER_FROM_INT(convert_modifiers_to_bitmask(ked->fcu->modifiers)))) {
return KEYFRAME_OK_ALL;
}
return 0;
}
static short select_grouped_active_modifiers(KeyframeEditData *ked, struct BezTriple *bezt)
{
BLI_gset_add(ked->data, POINTER_FROM_INT(convert_modifiers_to_bitmask(ked->fcu->modifiers)));
return 0;
}
/* ACTKEYS_SELECT_GROUP_DATABLOCK */
static short select_grouped_datablock(KeyframeEditData *ked, struct BezTriple *bezt)
@ -2151,8 +2178,11 @@ static KeyframeEditFunc select_grouped_get_filter_callback(ListBase *anim_data,
break;
}
case ACTKEYS_SELECT_GROUP_MODIFIERS: {
/* TODO(redmser): Modifier types. */
BLI_assert(0);
if (ale == NULL) {
return select_grouped_modifiers;
}
ANIM_fcurve_keyframes_loop(ked, fcu, ok_cb, select_grouped_active_modifiers, NULL);
break;
}
case ACTKEYS_SELECT_GROUP_DATABLOCK: {

View File

@ -2073,7 +2073,7 @@ static const EnumPropertyItem graphkeys_prop_select_grouped_types[] = {
"MODIFIERS",
0,
"Modifiers",
"All keyframes on each channel that has the same modifiers"},
"All keyframes on each channel that have all of the same types of modifiers"},
{GRAPHKEYS_SELECT_GROUP_DATABLOCK,
"DATABLOCK",
0,
@ -2119,6 +2119,33 @@ static short select_grouped_active_channel_type_strict(KeyframeEditData *ked,
return 0;
}
/* GRAPHKEYS_SELECT_GROUP_MODIFIERS */
static int convert_modifiers_to_bitmask(ListBase modifiers)
{
int bitmask = 0;
FModifier *modifier;
for (modifier = modifiers.first; modifier; modifier = modifier->next) {
bitmask |= 1 << modifier->type;
}
return bitmask;
}
static short select_grouped_modifiers(KeyframeEditData *ked, struct BezTriple *bezt)
{
if (BLI_gset_haskey(ked->data,
POINTER_FROM_INT(convert_modifiers_to_bitmask(ked->fcu->modifiers)))) {
return KEYFRAME_OK_ALL;
}
return 0;
}
static short select_grouped_active_modifiers(KeyframeEditData *ked, struct BezTriple *bezt)
{
BLI_gset_add(ked->data, POINTER_FROM_INT(convert_modifiers_to_bitmask(ked->fcu->modifiers)));
return 0;
}
/* GRAPHKEYS_SELECT_GROUP_DATABLOCK */
static short select_grouped_datablock(KeyframeEditData *ked, struct BezTriple *bezt)
@ -2314,8 +2341,11 @@ static KeyframeEditFunc select_grouped_get_filter_callback(ListBase *anim_data,
break;
}
case GRAPHKEYS_SELECT_GROUP_MODIFIERS: {
/* TODO(redmser): Modifier types. */
BLI_assert(0);
if (ale == NULL) {
return select_grouped_modifiers;
}
ANIM_fcurve_keyframes_loop(ked, fcu, ok_cb, select_grouped_active_modifiers, NULL);
break;
}
case GRAPHKEYS_SELECT_GROUP_DATABLOCK: {