Refactor: combine insert_keyframe() and insert_key_rna() into a single function #122053

Merged
Nathan Vegdahl merged 49 commits from nathanvegdahl/blender:combine_keying_functions into main 2024-06-11 16:43:08 +02:00
6 changed files with 11 additions and 8 deletions
Showing only changes of commit cec3c29874 - Show all commits

View File

@ -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,

View File

@ -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,

View File

@ -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". */

View File

@ -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

might just be me but I find it easier to read if such things are outside the function arguments.

might just be me but I find it easier to read if such things are outside the function arguments.
CombinedKeyingResult result = insert_keyframes(bmain,
&id_rna_pointer,

View File

@ -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,

View File

@ -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,