Blender  V3.3
Functions | Variables
drivers.c File Reference
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_texture_types.h"
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_fcurve_driver.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "ED_keyframing.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "WM_api.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_path.h"
#include "RNA_prototypes.h"
#include "anim_intern.h"

Go to the source code of this file.

Functions

FCurveverify_driver_fcurve (ID *id, const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
 
struct FCurvealloc_driver_fcurve (const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
 
static int add_driver_with_target (ReportList *UNUSED(reports), 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, short flag, int driver_type)
 
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, int driver_type, short mapping_type)
 Main Driver Management API calls. More...
 
int ANIM_add_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type)
 Main Driver Management API calls. More...
 
bool ANIM_remove_driver (ReportList *UNUSED(reports), ID *id, const char rna_path[], int array_index, short UNUSED(flag))
 
void ANIM_drivers_copybuf_free (void)
 
bool ANIM_driver_can_paste (void)
 
bool ANIM_copy_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag))
 
bool ANIM_paste_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag))
 
void ANIM_driver_vars_copybuf_free (void)
 
bool ANIM_driver_vars_can_paste (void)
 
bool ANIM_driver_vars_copy (ReportList *reports, FCurve *fcu)
 
bool ANIM_driver_vars_paste (ReportList *reports, FCurve *fcu, bool replace)
 
void ANIM_copy_as_driver (struct ID *target_id, const char *target_path, const char *var_name)
 
static const EnumPropertyItemdriver_mapping_type_itemf (bContext *C, PointerRNA *UNUSED(owner_ptr), PropertyRNA *UNUSED(owner_prop), bool *r_free)
 
static bool add_driver_button_poll (bContext *C)
 
static int add_driver_button_none (bContext *C, wmOperator *op, short mapping_type)
 
static int add_driver_button_menu_exec (bContext *C, wmOperator *op)
 
static int add_driver_button_menu_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 
static void UNUSED_FUNCTION() ANIM_OT_driver_button_add_menu (wmOperatorType *ot)
 
static int add_driver_button_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 
void ANIM_OT_driver_button_add (wmOperatorType *ot)
 
static int remove_driver_button_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_driver_button_remove (wmOperatorType *ot)
 
static int edit_driver_button_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_driver_button_edit (wmOperatorType *ot)
 
static int copy_driver_button_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_copy_driver_button (wmOperatorType *ot)
 
static int paste_driver_button_exec (bContext *C, wmOperator *op)
 
void ANIM_OT_paste_driver_button (wmOperatorType *ot)
 

Variables

static FCurvechanneldriver_copypaste_buf = NULL
 
static ListBase driver_vars_copybuf = {NULL, NULL}
 
EnumPropertyItem prop_driver_create_mapping_types []
 

Function Documentation

◆ add_driver_button_invoke()

static int add_driver_button_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ add_driver_button_menu_exec()

static int add_driver_button_menu_exec ( bContext C,
wmOperator op 
)
static

◆ add_driver_button_menu_invoke()

static int add_driver_button_menu_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ add_driver_button_none()

static int add_driver_button_none ( bContext C,
wmOperator op,
short  mapping_type 
)
static

◆ add_driver_button_poll()

static bool add_driver_button_poll ( bContext C)
static

◆ add_driver_with_target()

static int add_driver_with_target ( ReportList UNUSEDreports,
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,
short  flag,
int  driver_type 
)
static

◆ alloc_driver_fcurve()

struct FCurve* alloc_driver_fcurve ( const char  rna_path[],
const int  array_index,
eDriverFCurveCreationMode  creation_mode 
)

◆ ANIM_add_driver()

int ANIM_add_driver ( struct ReportList reports,
struct ID id,
const char  rna_path[],
int  array_index,
short  flag,
int  type 
)

◆ ANIM_add_driver_with_target()

int ANIM_add_driver_with_target ( struct ReportList reports,
struct ID dst_id,
const char  dst_path[],
int  dst_index,
struct ID src_id,
const char  src_path[],
int  src_index,
short  flag,
int  driver_type,
short  mapping_type 
)

Main Driver Management API calls.

Add a new driver for the specified property on the given ID block, and make it be driven by the specified target.

This is intended to be used in conjunction with a modal "eyedropper" for picking the variable that is going to be used to drive this one.

Parameters
flageCreateDriverFlags
driver_typeeDriver_Types
mapping_typeeCreateDriver_MappingTypes

Definition at line 281 of file drivers.c.

References add_driver_with_target(), ANIM_add_driver(), BKE_reportf(), CREATEDRIVER_MAPPING_1_1, CREATEDRIVER_MAPPING_1_N, CREATEDRIVER_MAPPING_N_N, CREATEDRIVER_MAPPING_NONE, CREATEDRIVER_WITH_DEFAULT_DVAR, FCurve::flag, len, MIN2, ID::name, ptr, RNA_id_pointer_create(), RNA_path_resolve_property(), RNA_property_array_check(), RNA_property_array_length(), and RPT_ERROR.

Referenced by driverdropper_sample().

◆ ANIM_copy_as_driver()

void ANIM_copy_as_driver ( struct ID target_id,
const char *  target_path,
const char *  var_name 
)

◆ ANIM_copy_driver()

bool ANIM_copy_driver ( ReportList reports,
ID id,
const char  rna_path[],
int  array_index,
short   UNUSEDflag 
)

◆ ANIM_driver_can_paste()

bool ANIM_driver_can_paste ( void  )

Returns whether there is a driver in the copy/paste buffer to paste.

Definition at line 580 of file drivers.c.

References channeldriver_copypaste_buf, and NULL.

Referenced by ui_popup_context_menu_for_button().

◆ ANIM_driver_vars_can_paste()

bool ANIM_driver_vars_can_paste ( void  )

Checks if there are driver variables in the copy/paste buffer.

Definition at line 708 of file drivers.c.

References BLI_listbase_is_empty(), and driver_vars_copybuf.

◆ ANIM_driver_vars_copy()

bool ANIM_driver_vars_copy ( struct ReportList reports,
struct FCurve fcu 
)

◆ ANIM_driver_vars_copybuf_free()

void ANIM_driver_vars_copybuf_free ( void  )

Clear copy-paste buffer for driver variable sets.

Note
This function frees any MEM_calloc'ed copy/paste buffer data.

Definition at line 692 of file drivers.c.

References BLI_listbase_clear(), driver_free_variable(), driver_vars_copybuf, ListBase::first, and DriverVar::next.

Referenced by ANIM_copy_as_driver(), ANIM_driver_vars_copy(), and WM_exit_ex().

◆ ANIM_driver_vars_paste()

bool ANIM_driver_vars_paste ( struct ReportList reports,
struct FCurve fcu,
bool  replace 
)

Paste the variables in the buffer to the given FCurve.

Definition at line 737 of file drivers.c.

References FCurve::driver, and NULL.

Referenced by graph_driver_vars_paste_exec().

◆ ANIM_drivers_copybuf_free()

void ANIM_drivers_copybuf_free ( void  )

Clear copy-paste buffer for drivers.

Note
This function frees any MEM_calloc'ed copy/paste buffer data.

Definition at line 571 of file drivers.c.

References BKE_fcurve_free(), channeldriver_copypaste_buf, and NULL.

Referenced by ANIM_copy_as_driver(), ANIM_copy_driver(), and WM_exit_ex().

◆ ANIM_OT_copy_driver_button()

void ANIM_OT_copy_driver_button ( wmOperatorType ot)

◆ ANIM_OT_driver_button_add()

void ANIM_OT_driver_button_add ( wmOperatorType ot)

◆ ANIM_OT_driver_button_add_menu()

static void UNUSED_FUNCTION() ANIM_OT_driver_button_add_menu ( wmOperatorType ot)
static

◆ ANIM_OT_driver_button_edit()

void ANIM_OT_driver_button_edit ( wmOperatorType ot)

◆ ANIM_OT_driver_button_remove()

void ANIM_OT_driver_button_remove ( wmOperatorType ot)

◆ ANIM_OT_paste_driver_button()

void ANIM_OT_paste_driver_button ( wmOperatorType ot)

◆ ANIM_paste_driver()

bool ANIM_paste_driver ( ReportList reports,
ID id,
const char  rna_path[],
int  array_index,
short   UNUSEDflag 
)

◆ ANIM_remove_driver()

bool ANIM_remove_driver ( ReportList UNUSEDreports,
ID id,
const char  rna_path[],
int  array_index,
short   UNUSEDflag 
)

◆ copy_driver_button_exec()

static int copy_driver_button_exec ( bContext C,
wmOperator op 
)
static

◆ driver_mapping_type_itemf()

static const EnumPropertyItem* driver_mapping_type_itemf ( bContext C,
PointerRNA UNUSEDowner_ptr,
PropertyRNA UNUSEDowner_prop,
bool r_free 
)
static

◆ edit_driver_button_exec()

static int edit_driver_button_exec ( bContext C,
wmOperator op 
)
static

◆ paste_driver_button_exec()

static int paste_driver_button_exec ( bContext C,
wmOperator op 
)
static

◆ remove_driver_button_exec()

static int remove_driver_button_exec ( bContext C,
wmOperator op 
)
static

◆ verify_driver_fcurve()

FCurve* verify_driver_fcurve ( struct ID id,
const char  rna_path[],
int  array_index,
eDriverFCurveCreationMode  creation_mode 
)

Get (or add relevant data to be able to do so) F-Curve from the driver stack, for the given Animation Data block. This assumes that all the destinations are valid.

Note
This low-level function shouldn't be used directly for most tools, although there are special cases where this approach is preferable.

Definition at line 50 of file drivers.c.

References alloc_driver_fcurve(), BKE_animdata_ensure_id(), BKE_animdata_from_id(), BKE_fcurve_find(), BLI_addtail(), DRIVER_FCURVE_LOOKUP_ONLY, AnimData::drivers, ELEM, and NULL.

Referenced by add_driver_with_target(), ANIM_add_driver(), ANIM_copy_driver(), ANIM_paste_driver(), ANIM_remove_driver(), and ui_but_anim_expression_create().

Variable Documentation

◆ channeldriver_copypaste_buf

FCurve* channeldriver_copypaste_buf = NULL
static

◆ driver_vars_copybuf

ListBase driver_vars_copybuf = {NULL, NULL}
static

◆ prop_driver_create_mapping_types

EnumPropertyItem prop_driver_create_mapping_types[]

Mapping Types enum for operators.

Note
Used by ANIM_OT_driver_button_add and UI_OT_eyedropper_driver.

Definition at line 835 of file drivers.c.

Referenced by ANIM_OT_driver_button_add_menu(), driver_mapping_type_itemf(), and UI_OT_eyedropper_driver().