Refactor: split animrig::action_fcurve_ensure() into two components
Split the majority of `animrig::action_fcurve_ensure()` into a new function `action_channelbag_ensure()`. This ensures that the Action has a layer, keyframe strip, action slot, and channelbag for the given ID. `animrig::action_fcurve_ensure()` now just calls into that function, and then ensures that there is an F-Curve in that channelbag. No functional changes. Pull Request: https://projects.blender.org/blender/blender/pulls/134864
This commit is contained in:
@@ -1625,6 +1625,20 @@ animrig::Channelbag *channelbag_for_action_slot(Action &action, slot_handle_t sl
|
||||
Span<FCurve *> fcurves_for_action_slot(Action &action, slot_handle_t slot_handle);
|
||||
Span<const FCurve *> fcurves_for_action_slot(const Action &action, slot_handle_t slot_handle);
|
||||
|
||||
/**
|
||||
* Find or create a Channelbag on the given action, for the given ID.
|
||||
*
|
||||
* This function also ensures that there is a layer and a keyframe strip for the
|
||||
* channelbag to exist on.
|
||||
*
|
||||
* \param action: MUST already be assigned to the animated ID.
|
||||
*
|
||||
* \param animated_id: The ID that is animated by this Action. It is used to
|
||||
* create and assign an appropriate slot if needed when creating the fcurve, and
|
||||
* set the fcurve color properly
|
||||
*/
|
||||
Channelbag *action_channelbag_ensure(bAction &dna_action, ID &animated_id);
|
||||
|
||||
/**
|
||||
* Find or create an F-Curve on the given action that matches the given fcurve
|
||||
* descriptor.
|
||||
|
||||
@@ -2633,10 +2633,7 @@ FCurve *action_fcurve_ensure_ex(Main *bmain,
|
||||
return action_fcurve_ensure(bmain, *act, *ptr->owner_id, fcurve_descriptor);
|
||||
}
|
||||
|
||||
FCurve *action_fcurve_ensure(Main *bmain,
|
||||
bAction &dna_action,
|
||||
ID &animated_id,
|
||||
FCurveDescriptor fcurve_descriptor)
|
||||
Channelbag *action_channelbag_ensure(bAction &dna_action, ID &animated_id)
|
||||
{
|
||||
Action &action = dna_action.wrap();
|
||||
|
||||
@@ -2659,7 +2656,21 @@ FCurve *action_fcurve_ensure(Main *bmain,
|
||||
assert_baklava_phase_1_invariants(action);
|
||||
StripKeyframeData &strip_data = action.layer(0)->strip(0)->data<StripKeyframeData>(action);
|
||||
|
||||
return &strip_data.channelbag_for_slot_ensure(*slot).fcurve_ensure(bmain, fcurve_descriptor);
|
||||
return &strip_data.channelbag_for_slot_ensure(*slot);
|
||||
}
|
||||
|
||||
FCurve *action_fcurve_ensure(Main *bmain,
|
||||
bAction &dna_action,
|
||||
ID &animated_id,
|
||||
FCurveDescriptor fcurve_descriptor)
|
||||
{
|
||||
Channelbag *channelbag = action_channelbag_ensure(dna_action, animated_id);
|
||||
BLI_assert(channelbag);
|
||||
if (!channelbag) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &channelbag->fcurve_ensure(bmain, fcurve_descriptor);
|
||||
}
|
||||
|
||||
FCurve *action_fcurve_ensure_legacy(Main *bmain,
|
||||
|
||||
Reference in New Issue
Block a user