Refactor: combine insert_keyframe() and insert_key_rna() into a single function #122053
@ -799,7 +799,6 @@ CombinedKeyingResult insert_key_action(Main *bmain,
|
||||
property_array_index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const SingleKeyingResult keying_result = insert_keyframe_fcurve_value(bmain,
|
||||
ptr,
|
||||
prop,
|
||||
|
@ -331,10 +331,10 @@ bool autokeyframe_property(bContext *C,
|
||||
|
||||
const std::string path = fcu ? fcu->rna_path :
|
||||
RNA_path_from_ID_to_property(ptr, prop).value_or("");
|
||||
const std::optional<std::string> group = (fcu && fcu->grp) ? fcu->grp->name : nullptr;
|
||||
/* NOTE: `rnaindex == -1` is a magic number, meaning either "operate on
|
||||
* all elements" or "not an array property". */
|
||||
const std::optional<int> array_index = rnaindex < 0 ? std::nullopt : std::optional(rnaindex);
|
||||
const std::optional<std::string> group = (fcu && fcu->grp) ? fcu->grp->name : nullptr;
|
||||
|
||||
CombinedKeyingResult result = insert_keyframes(bmain,
|
||||
ptr,
|
||||
|
@ -1026,7 +1026,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
|
||||
/* standard properties */
|
||||
if (const std::optional<std::string> path = RNA_path_from_ID_to_property(&ptr, prop)) {
|
||||
const char *identifier = RNA_property_identifier(prop);
|
||||
const std::optional<std::string> group = default_channel_group_for_path(&ptr, identifier);
|
||||
const std::optional<blender::StringRefNull> group = default_channel_group_for_path(
|
||||
&ptr, identifier);
|
||||
|
||||
/* NOTE: `index == -1` is a magic number, meaning either "operate on all
|
||||
* elements" or "not an array property". */
|
||||
|
@ -1082,9 +1082,10 @@ static int insert_key_to_keying_set_path(bContext *C,
|
||||
CombinedKeyingResult combined_result;
|
||||
for (; array_index < array_length; array_index++) {
|
||||
if (mode == ModifyKeyMode::INSERT) {
|
||||
const std::optional<blender::StringRefNull> group = groupname ? std::optional(groupname) :
|
||||
std::nullopt;
|
||||
const std::optional<int> index = array_index >= 0 ? std::optional(array_index) :
|
||||
std::nullopt;
|
||||
const std::optional<std::string> group = groupname ? std::optional(groupname) : std::nullopt;
|
||||
PointerRNA id_rna_pointer = RNA_id_pointer_create(keyingset_path->id);
|
||||
nathanvegdahl marked this conversation as resolved
Outdated
|
||||
CombinedKeyingResult result = insert_keyframes(bmain,
|
||||
&id_rna_pointer,
|
||||
|
@ -849,8 +849,9 @@ static void insert_fcurve_key(bAnimContext *ac,
|
||||
* so it's easier for now to just read the F-Curve directly.
|
||||
* (TODO: add the full-blown PointerRNA relative parsing case here...)
|
||||
*/
|
||||
const std::optional<std::string> channel_group = fcu->grp ? std::optional(fcu->grp->name) :
|
||||
std::nullopt;
|
||||
const std::optional<blender::StringRefNull> channel_group = fcu->grp ?
|
||||
std::optional(fcu->grp->name) :
|
||||
std::nullopt;
|
||||
if (ale->id && !ale->owner) {
|
||||
PointerRNA id_rna_pointer = RNA_id_pointer_create(ale->id);
|
||||
CombinedKeyingResult result = insert_keyframes(ac->bmain,
|
||||
|
@ -205,8 +205,9 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
|
||||
* If this is set, then it's a driver. If we don't check for this, we'd end
|
||||
* up adding the keyframes on a new F-Curve in the action data instead.
|
||||
*/
|
||||
const std::optional<std::string> channel_group = fcu->grp ? std::optional(fcu->grp->name) :
|
||||
std::nullopt;
|
||||
const std::optional<blender::StringRefNull> channel_group = fcu->grp ? std::optional(
|
||||
fcu->grp->name) :
|
||||
std::nullopt;
|
||||
if (ale->id && !ale->owner && !fcu->driver) {
|
||||
PointerRNA id_rna_pointer = RNA_id_pointer_create(ale->id);
|
||||
CombinedKeyingResult result = insert_keyframes(ac->bmain,
|
||||
|
Loading…
Reference in New Issue
Block a user
might just be me but I find it easier to read if such things are outside the function arguments.