Refactor: Anim: put default channel group names in one place
Previously they were split between two places, and were not fully consistent with each other. The inconsistency didn't result in user-facing inconsistency due to what was called when at a higher level, but this will ensure continued user-facing consistency as we make more changes to the keyframing code. Pull Request: https://projects.blender.org/blender/blender/pulls/122317
This commit is contained in:

committed by
Nathan Vegdahl

parent
8366ea8798
commit
b821e56165
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "BLI_array.hh"
|
||||
#include "BLI_bit_span.hh"
|
||||
#include "BLI_string_ref.hh"
|
||||
#include "BLI_vector.hh"
|
||||
#include "DNA_anim_types.h"
|
||||
#include "RNA_path.hh"
|
||||
@@ -73,6 +74,16 @@ class CombinedKeyingResult {
|
||||
void generate_reports(ReportList *reports);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the default channel group name for the given RNA pointer and property
|
||||
* path, or nullptr if it has no default.
|
||||
*
|
||||
* For example, for object location/rotation/scale this returns the standard
|
||||
* "Object Transforms" channel group name.
|
||||
*/
|
||||
const char *default_channel_group_for_path(const PointerRNA *animated_struct,
|
||||
const StringRef prop_rna_path);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Key-Framing Management
|
||||
* \{ */
|
||||
|
@@ -163,6 +163,29 @@ void CombinedKeyingResult::generate_reports(ReportList *reports)
|
||||
BKE_report(reports, RPT_ERROR, error_message.c_str());
|
||||
}
|
||||
|
||||
const char *default_channel_group_for_path(const PointerRNA *animated_struct,
|
||||
const StringRef prop_rna_path)
|
||||
{
|
||||
if (animated_struct->type == &RNA_PoseBone) {
|
||||
bPoseChannel *pose_channel = static_cast<bPoseChannel *>(animated_struct->data);
|
||||
return pose_channel->name;
|
||||
}
|
||||
|
||||
if (animated_struct->type == &RNA_Object) {
|
||||
if (prop_rna_path.find("location") != StringRef::not_found ||
|
||||
prop_rna_path.find("rotation") != StringRef::not_found ||
|
||||
prop_rna_path.find("scale") != StringRef::not_found)
|
||||
{
|
||||
/* NOTE: Keep this label in sync with the "ID" case in
|
||||
* keyingsets_utils.py :: get_transform_generators_base_info()
|
||||
*/
|
||||
return "Object Transforms";
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void update_autoflags_fcurve_direct(FCurve *fcu, PropertyRNA *prop)
|
||||
{
|
||||
/* Set additional flags for the F-Curve (i.e. only integer values). */
|
||||
@@ -925,14 +948,7 @@ CombinedKeyingResult insert_key_action(Main *bmain,
|
||||
BLI_assert(bmain != nullptr);
|
||||
BLI_assert(action != nullptr);
|
||||
|
||||
std::string group;
|
||||
if (ptr->type == &RNA_PoseBone) {
|
||||
bPoseChannel *pose_channel = static_cast<bPoseChannel *>(ptr->data);
|
||||
group = pose_channel->name;
|
||||
}
|
||||
else {
|
||||
group = "Object Transforms";
|
||||
}
|
||||
const char *group = default_channel_group_for_path(ptr, rna_path);
|
||||
|
||||
int property_array_index = 0;
|
||||
CombinedKeyingResult combined_result;
|
||||
@@ -946,7 +962,7 @@ CombinedKeyingResult insert_key_action(Main *bmain,
|
||||
ptr,
|
||||
prop,
|
||||
action,
|
||||
group.c_str(),
|
||||
group,
|
||||
rna_path.c_str(),
|
||||
property_array_index,
|
||||
frame,
|
||||
|
@@ -1025,28 +1025,7 @@ 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 char *group = nullptr;
|
||||
|
||||
/* Special exception for keyframing transforms:
|
||||
* Set "group" for this manually, instead of having them appearing at the bottom
|
||||
* (ungrouped) part of the channels list.
|
||||
* Leaving these ungrouped is not a nice user behavior in this case.
|
||||
*
|
||||
* TODO: Perhaps we can extend this behavior in future for other properties...
|
||||
*/
|
||||
if (ptr.type == &RNA_PoseBone) {
|
||||
bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr.data);
|
||||
group = pchan->name;
|
||||
}
|
||||
else if ((ptr.type == &RNA_Object) &&
|
||||
(strstr(identifier, "location") || strstr(identifier, "rotation") ||
|
||||
strstr(identifier, "scale")))
|
||||
{
|
||||
/* NOTE: Keep this label in sync with the "ID" case in
|
||||
* keyingsets_utils.py :: get_transform_generators_base_info()
|
||||
*/
|
||||
group = "Object Transforms";
|
||||
}
|
||||
const char *group = default_channel_group_for_path(&ptr, identifier);
|
||||
|
||||
if (all) {
|
||||
/* -1 indicates operating on the entire array (or the property itself otherwise) */
|
||||
|
Reference in New Issue
Block a user