42#include "RNA_prototypes.hh"
55 const int array_index,
95 const int array_index,
112 fcu->
driver = MEM_new<ChannelDriver>(
"ChannelDriver");
134 const char dst_path[],
137 const char src_path[],
156 driver->
type = driver_type;
195 if (
ELEM(src_ptr->
type, RNA_Object, RNA_PoseBone) &&
196 (
STREQ(prop_name,
"location") ||
STREQ(prop_name,
"scale") ||
210 if (src_ptr->
type == RNA_PoseBone) {
215 if (
STREQ(prop_name,
"location")) {
216 if (src_index == 2) {
219 else if (src_index == 1) {
226 else if (
STREQ(prop_name,
"scale")) {
227 if (src_index == 2) {
230 else if (src_index == 1) {
241 if (src_index == 2) {
244 else if (src_index == 1) {
271 return (fcu !=
nullptr);
276 const char dst_path[],
279 const char src_path[],
298 "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
314 switch (mapping_type) {
321 int len = std::min(dst_len, src_len);
323 for (
int i = 0; i <
len; i++) {
344 for (
int i = 0; i <
len; i++) {
404 "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
411 if (array_index == -1) {
416 array_index_max = array_index;
420 if (array_index == array_index_max) {
421 array_index_max += 1;
425 for (; array_index < array_index_max; array_index++) {
450 const size_t expression_maxncpy =
sizeof(driver->
expression);
463 expression, expression_maxncpy,
"%s%s", dvar_prefix, (val) ?
"True" :
"False");
504 done_tot += (fcu !=
nullptr);
518 if (array_index >= 0) {
531 bool any_driver_removed =
false;
536 fcu_iter = fcu->
next;
541 any_driver_removed =
true;
543 return any_driver_removed;
580 "Could not find driver to copy, as RNA path is invalid for the given ID (ID = %s, "
617 "Could not paste driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
652 return (fcu !=
nullptr);
709 ListBaseT<DriverVar> tmp_list = {
nullptr,
nullptr};
730 for (dvar = driver->
variables.first(); dvar; dvar = dvarn) {
746 driver->
variables.last_ = tmp_list.last();
749 driver->
variables.first_ = tmp_list.first_;
750 driver->
variables.last_ = tmp_list.last();
776 target->
id = target_id;
784 for (
int i = 0; var->
name[i]; i++) {
785 if (!(i > 0 ? isalnum(var->
name[i]) : isalpha(var->
name[i]))) {
810 "Drive all components of this property using the target picked"},
814 "Single from Target",
815 "Drive this component of this property using the target picked"},
821 "Create drivers for each pair of corresponding elements"},
826 "Manually Create Later",
827 "Create drivers for all properties without assigning any targets yet"},
831 "Manually Create Later (Single)",
832 "Create driver for this property only and without assigning any targets yet"},
833 {0,
nullptr, 0,
nullptr,
nullptr},
885 bool driven, special;
899 C, &ptr, prop,
index,
nullptr,
nullptr, &driven, &special);
900 return (fcu ==
nullptr || fcu->
driver);
979 ot->name =
"Add Driver Menu";
980 ot->idname =
"ANIM_OT_driver_button_add_menu";
981 ot->description =
"Add driver(s) for the property(s) represented by the highlighted button";
997 "Method used to match target and driven properties");
1016 bool changed =
false;
1043 ot->
name =
"Add Driver";
1044 ot->
idname =
"ANIM_OT_driver_button_add";
1045 ot->
description =
"Add driver for the property under the cursor";
1062 bool changed =
false;
1092 ot->
name =
"Remove Driver";
1093 ot->
idname =
"ANIM_OT_driver_button_remove";
1095 "Remove the driver(s) for the connected property(s) represented by the highlighted button";
1105 RNA_def_boolean(ot->
srna,
"all",
true,
"All",
"Delete drivers for all elements of the array");
1128 ot->
name =
"Edit Driver";
1129 ot->
idname =
"ANIM_OT_driver_button_edit";
1131 "Edit the drivers for the connected property represented by the highlighted button";
1147 bool changed =
false;
1168 ot->
name =
"Copy Driver";
1169 ot->
idname =
"ANIM_OT_copy_driver_button";
1170 ot->
description =
"Copy the driver for the highlighted button";
1186 bool changed =
false;
1213 ot->
name =
"Paste Driver";
1214 ot->
idname =
"ANIM_OT_paste_driver_button";
1215 ot->
description =
"Paste the driver in the internal clipboard to the highlighted button";
Functions to modify FCurves.
#define STRNCPY_UTF8(dst, src)
Read Blender memory allocation and freeing.
#define UNUSED_FUNCTION(x)
bool all(VecOp< bool, D >) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
wmOperatorStatus popover_panel_invoke(bContext *C, const char *idname, bool keep_open, bool use_numselect, ReportList *reports)
void context_update_anim_flag(const bContext *C)
Button * context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
void ANIM_driver_vars_copybuf_free()
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
@ DVAR_TYPE_TRANSFORM_CHAN
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, eDriver_Types type)
Main Driver Management API calls.
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
FCurve * BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[])
void BKE_driver_invalidate_expression(struct ChannelDriver *driver, bool expr_changed, bool varname_changed)
PointerRNA RNA_id_pointer_create(ID *id)
std::optional< std::string > RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace)
bool ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short)
Main Driver Management API calls.
void ANIM_OT_driver_button_remove(wmOperatorType *ot)
const char * RNA_property_identifier(const PropertyRNA *prop)
bool ANIM_driver_vars_copy(ReportList *reports, FCurve *fcu)
FCurve * verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
static wmOperatorStatus add_driver_button_menu_exec(bContext *C, wmOperator *op)
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
void copy_fmodifiers(ListBaseT< FModifier > *dst, const ListBaseT< FModifier > *src)
struct ChannelDriver * fcurve_copy_driver(const struct ChannelDriver *driver)
void driver_free_variable_ex(struct ChannelDriver *driver, struct DriverVar *dvar)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
PropertyUnit RNA_property_unit(PropertyRNA *prop)
bool RNA_property_driver_editable(const PointerRNA *ptr, PropertyRNA *prop)
bool ANIM_driver_can_paste()
static wmOperatorStatus remove_driver_button_exec(bContext *C, wmOperator *op)
int ANIM_add_driver_with_target(ReportList *reports, ID *dst_id, const char dst_path[], int dst_index, ID *src_id, const char src_path[], int src_index, short flag, eDriver_Types driver_type, short mapping_type)
Main Driver Management API calls.
AnimData * BKE_animdata_ensure_id(ID *id)
bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short)
Main Driver Management API calls.
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
PropertyType RNA_property_type(PropertyRNA *prop)
AnimData * BKE_animdata_from_id(const ID *id)
static wmOperatorStatus add_driver_button_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *)
void BKE_fcurve_handles_recalc(FCurve &fcu)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
wmOperatorStatus WM_menu_invoke_ex(bContext *C, wmOperator *op, wm::OpCallContext opcontext)
bool RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
int BLI_str_rstrip_float_zero(char *str, char pad) ATTR_NONNULL(1)
FCurve * BKE_fcurve_copy(const FCurve *fcu)
static ListBaseT< DriverVar > driver_vars_copybuf
static wmOperatorStatus copy_driver_button_exec(bContext *C, wmOperator *op)
bool ANIM_remove_driver(ID *id, const char rna_path[], int array_index)
Main Driver Management API calls.
static wmOperatorStatus paste_driver_button_exec(bContext *C, wmOperator *op)
static FCurve * channeldriver_copypaste_buf
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
static int add_driver_with_target(ReportList *, ID *dst_id, const char dst_path[], int dst_index, ID *src_id, const char src_path[], int src_index, PointerRNA *dst_ptr, PropertyRNA *dst_prop, PointerRNA *src_ptr, PropertyRNA *src_prop, eDriver_Types driver_type)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static const EnumPropertyItem * driver_mapping_type_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void ANIM_OT_copy_driver_button(wmOperatorType *ot)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void BKE_fcurve_free(FCurve *fcu)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Main * CTX_data_main(const bContext *C)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
void ANIM_drivers_copybuf_free()
static wmOperatorStatus edit_driver_button_exec(bContext *C, wmOperator *op)
static wmOperatorStatus add_driver_button_none(bContext *C, wmOperator *op, short mapping_type)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
ID_Type GS(const char *name)
FCurve * alloc_driver_fcurve(const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
void DEG_relations_tag_update(Main *bmain)
@ CREATEDRIVER_WITH_DEFAULT_DVAR
static void UNUSED_FUNCTION ANIM_OT_driver_button_add_menu(wmOperatorType *ot)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
FCurve * BKE_fcurve_find_by_rna_context_ui(bContext *C, const PointerRNA *ptr, PropertyRNA *prop, int rnaindex, AnimData **r_animdata, bAction **r_action, bool *r_driven, bool *r_special)
void ANIM_copy_as_driver(ID *target_id, const char *target_path, const char *var_name)
FCurve * BKE_fcurve_find(ListBaseT< FCurve > *list, const char rna_path[], int array_index)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
const EnumPropertyItem prop_driver_create_mapping_types[]
void driver_change_variable_type(struct DriverVar *dvar, eDriverVar_Types type)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
void driver_variables_copy(ListBaseT< DriverVar > *dst_vars, const ListBaseT< DriverVar > *src_vars)
bool ANIM_driver_vars_can_paste()
void ANIM_OT_driver_button_edit(wmOperatorType *ot)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
void ANIM_OT_driver_button_add(wmOperatorType *ot)
@ FCURVE_EXTRAPOLATE_LINEAR
void ANIM_OT_paste_driver_button(wmOperatorType *ot)
eDriverFCurveCreationMode
@ DRIVER_FCURVE_LOOKUP_ONLY
@ DRIVER_FCURVE_KEYFRAMES
static bool add_driver_button_poll(bContext *C)
int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
@ CREATEDRIVER_MAPPING_NONE_ALL
@ CREATEDRIVER_MAPPING_NONE
@ CREATEDRIVER_MAPPING_N_N
@ CREATEDRIVER_MAPPING_1_1
@ CREATEDRIVER_MAPPING_1_N
FCurve * BKE_fcurve_create()
void driver_free_variable(ListBaseT< DriverVar > *variables, struct DriverVar *dvar)
struct DriverVar * driver_add_new_variable(struct ChannelDriver *driver)
ListBaseT< FCurve > drivers
ListBaseT< DriverVar > variables
eDriverTarget_TransformChannels transChan
eFCurve_Smoothing auto_smoothing
ListBaseT< FModifier > modifiers
bool has_owner_id() const
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports