Blender  V3.3
Classes | Variables
fcurve_driver.c File Reference
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
#include "BLI_alloca.h"
#include "BLI_expr_pylike_eval.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string_utils.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_action.h"
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_constraint.h"
#include "BKE_fcurve_driver.h"
#include "BKE_global.h"
#include "BKE_object.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "atomic_ops.h"
#include "CLG_log.h"

Go to the source code of this file.

Classes

struct  DriverVarTypeInfo
 

Functions

Driver Target Utilities
static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar)
 
bool driver_get_variable_property (ChannelDriver *driver, DriverTarget *dtar, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
 
static short driver_check_valid_targets (ChannelDriver *driver, DriverVar *dvar)
 
Driver Variable Utilities
static float dvar_eval_singleProp (ChannelDriver *driver, DriverVar *dvar)
 
static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar)
 
static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar)
 
static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
 
static void quaternion_to_angles (float quat[4], int channel)
 
void BKE_driver_target_matrix_to_rot_channels (float mat[4][4], int auto_order, int rotation_mode, int channel, bool angles, float r_buf[4])
 
Driver API
void driver_free_variable (ListBase *variables, DriverVar *dvar)
 
void driver_free_variable_ex (ChannelDriver *driver, DriverVar *dvar)
 
void driver_variables_copy (ListBase *dst_vars, const ListBase *src_vars)
 
void driver_change_variable_type (DriverVar *dvar, int type)
 
void driver_variable_name_validate (DriverVar *dvar)
 
void driver_variable_unique_name (DriverVar *dvar)
 
DriverVardriver_add_new_variable (ChannelDriver *driver)
 
void fcurve_free_driver (FCurve *fcu)
 
ChannelDriverfcurve_copy_driver (const ChannelDriver *driver)
 
Driver Evaluation
float driver_get_variable_value (ChannelDriver *driver, DriverVar *dvar)
 
static void evaluate_driver_sum (ChannelDriver *driver)
 
static void evaluate_driver_min_max (ChannelDriver *driver)
 
static void evaluate_driver_python (PathResolvedRNA *anim_rna, ChannelDriver *driver, ChannelDriver *driver_orig, const AnimationEvalContext *anim_eval_context)
 
float evaluate_driver (PathResolvedRNA *anim_rna, ChannelDriver *driver, ChannelDriver *driver_orig, const AnimationEvalContext *anim_eval_context)
 

Variables

static CLG_LogRef LOG = {"bke.fcurve"}
 

Driver Variables

#define BEGIN_DVAR_TYPEDEF(type)   {
 
#define END_DVAR_TYPEDEF   }
 
typedef struct DriverVarTypeInfo DriverVarTypeInfo
 

Driver Expression Evaluation

enum  { VAR_INDEX_FRAME = 0 , VAR_INDEX_CUSTOM }
 
static ExprPyLike_Parseddriver_compile_simple_expr_impl (ChannelDriver *driver)
 
static bool driver_check_simple_expr_depends_on_time (ExprPyLike_Parsed *expr)
 
static bool driver_evaluate_simple_expr (ChannelDriver *driver, ExprPyLike_Parsed *expr, float *result, float time)
 
static bool driver_compile_simple_expr (ChannelDriver *driver)
 
static bool driver_try_evaluate_simple_expr (ChannelDriver *driver, ChannelDriver *driver_orig, float *result, float time)
 
bool BKE_driver_has_simple_expression (ChannelDriver *driver)
 
static bool python_driver_exression_depends_on_time (const char *expression)
 
bool BKE_driver_expression_depends_on_time (ChannelDriver *driver)
 
void BKE_driver_invalidate_expression (ChannelDriver *driver, bool expr_changed, bool varname_changed)
 

Driver Variable Type Info

static DriverVarTypeInfo dvar_types [MAX_DVAR_TYPES]
 
static const DriverVarTypeInfoget_dvar_typeinfo (int type)
 

Macro Definition Documentation

◆ BEGIN_DVAR_TYPEDEF

#define BEGIN_DVAR_TYPEDEF (   type)    {

Definition at line 65 of file fcurve_driver.c.

◆ END_DVAR_TYPEDEF

#define END_DVAR_TYPEDEF   }

Definition at line 68 of file fcurve_driver.c.

Typedef Documentation

◆ DriverVarTypeInfo

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_INDEX_FRAME 
VAR_INDEX_CUSTOM 

Definition at line 946 of file fcurve_driver.c.

Function Documentation

◆ BKE_driver_expression_depends_on_time()

bool BKE_driver_expression_depends_on_time ( struct ChannelDriver driver)

◆ BKE_driver_has_simple_expression()

bool BKE_driver_has_simple_expression ( struct ChannelDriver driver)

Check if the expression in the driver conforms to the simple subset.

Definition at line 1057 of file fcurve_driver.c.

References BLI_expr_pylike_is_valid(), driver_compile_simple_expr(), and ChannelDriver::expr_simple.

Referenced by BKE_driver_expression_depends_on_time(), and graph_draw_driver_settings_panel().

◆ BKE_driver_invalidate_expression()

void BKE_driver_invalidate_expression ( struct ChannelDriver driver,
bool  expr_changed,
bool  varname_changed 
)

◆ BKE_driver_target_matrix_to_rot_channels()

void BKE_driver_target_matrix_to_rot_channels ( float  mat[4][4],
int  auto_order,
int  rotation_mode,
int  channel,
bool  angles,
float  r_buf[4] 
)

◆ driver_add_new_variable()

DriverVar* driver_add_new_variable ( struct ChannelDriver driver)

◆ driver_change_variable_type()

void driver_change_variable_type ( struct DriverVar dvar,
int  type 
)

◆ driver_check_simple_expr_depends_on_time()

static bool driver_check_simple_expr_depends_on_time ( ExprPyLike_Parsed expr)
static

◆ driver_check_valid_targets()

static short driver_check_valid_targets ( ChannelDriver driver,
DriverVar dvar 
)
static

◆ driver_compile_simple_expr()

static bool driver_compile_simple_expr ( ChannelDriver driver)
static

◆ driver_compile_simple_expr_impl()

static ExprPyLike_Parsed* driver_compile_simple_expr_impl ( ChannelDriver driver)
static

◆ driver_evaluate_simple_expr()

static bool driver_evaluate_simple_expr ( ChannelDriver driver,
ExprPyLike_Parsed expr,
float result,
float  time 
)
static

◆ driver_free_variable()

void driver_free_variable ( struct ListBase variables,
struct DriverVar dvar 
)

Perform actual freeing driver variable and remove it from the given list.

Definition at line 697 of file fcurve_driver.c.

References BLI_freelinkN(), DRIVER_TARGETS_LOOPER_BEGIN, DRIVER_TARGETS_LOOPER_END, MEM_freeN, and NULL.

Referenced by ANIM_driver_vars_copybuf_free(), and driver_free_variable_ex().

◆ driver_free_variable_ex()

void driver_free_variable_ex ( struct ChannelDriver driver,
struct DriverVar dvar 
)

Free the driver variable and do extra updates.

Definition at line 721 of file fcurve_driver.c.

References BKE_driver_invalidate_expression(), driver_free_variable(), and ChannelDriver::variables.

Referenced by driver_delete_var_cb(), and fcurve_free_driver().

◆ driver_get_variable_property()

bool driver_get_variable_property ( struct ChannelDriver driver,
struct DriverTarget dtar,
struct PointerRNA r_ptr,
struct PropertyRNA **  r_prop,
int *  r_index 
)

◆ driver_get_variable_value()

float driver_get_variable_value ( struct ChannelDriver driver,
struct DriverVar dvar 
)

Evaluate a Driver Variable to get a value that contributes to the final.

Definition at line 1124 of file fcurve_driver.c.

References DriverVar::curval, ELEM, get_dvar_typeinfo(), DriverVarTypeInfo::get_value, NULL, and DriverVar::type.

Referenced by BPY_driver_exec(), driver_evaluate_simple_expr(), evaluate_driver_min_max(), and evaluate_driver_sum().

◆ driver_try_evaluate_simple_expr()

static bool driver_try_evaluate_simple_expr ( ChannelDriver driver,
ChannelDriver driver_orig,
float result,
float  time 
)
static

◆ driver_variable_name_validate()

void driver_variable_name_validate ( struct DriverVar dvar)

◆ driver_variable_unique_name()

void driver_variable_unique_name ( struct DriverVar dvar)

Ensure the driver variable's name is unique.

Assumes the driver variable has already been assigned to the driver, so that the prev/next pointers can be used to find the other variables.

Definition at line 845 of file fcurve_driver.c.

References BLI_listbase_from_link(), BLI_uniquename(), and DriverVar::name.

◆ driver_variables_copy()

void driver_variables_copy ( ListBase dst_vars,
const ListBase src_vars 
)

◆ dtar_get_prop_val()

static float dtar_get_prop_val ( ChannelDriver driver,
DriverTarget dtar 
)
static

◆ dvar_eval_locDiff()

static float dvar_eval_locDiff ( ChannelDriver driver,
DriverVar dvar 
)
static

◆ dvar_eval_rotDiff()

static float dvar_eval_rotDiff ( ChannelDriver driver,
DriverVar dvar 
)
static

◆ dvar_eval_singleProp()

static float dvar_eval_singleProp ( ChannelDriver driver,
DriverVar dvar 
)
static

Definition at line 279 of file fcurve_driver.c.

References dtar_get_prop_val(), and DriverVar::targets.

◆ dvar_eval_transChan()

static float dvar_eval_transChan ( ChannelDriver driver,
DriverVar dvar 
)
static

Evaluate 'transform channel' driver variable.

Definition at line 449 of file fcurve_driver.c.

References DriverTarget::id, and DriverVar::targets.

◆ evaluate_driver()

float evaluate_driver ( PathResolvedRNA anim_rna,
ChannelDriver driver,
ChannelDriver driver_orig,
const AnimationEvalContext anim_eval_context 
)

◆ evaluate_driver_min_max()

static void evaluate_driver_min_max ( ChannelDriver driver)
static

◆ evaluate_driver_python()

static void evaluate_driver_python ( PathResolvedRNA anim_rna,
ChannelDriver driver,
ChannelDriver driver_orig,
const AnimationEvalContext anim_eval_context 
)
static

◆ evaluate_driver_sum()

static void evaluate_driver_sum ( ChannelDriver driver)
static

◆ fcurve_copy_driver()

ChannelDriver* fcurve_copy_driver ( const ChannelDriver driver)

◆ fcurve_free_driver()

void fcurve_free_driver ( struct FCurve fcu)

◆ get_dvar_typeinfo()

static const DriverVarTypeInfo* get_dvar_typeinfo ( int  type)
static

Definition at line 681 of file fcurve_driver.c.

References dvar_types, MAX_DVAR_TYPES, NULL, and type.

Referenced by driver_change_variable_type(), and driver_get_variable_value().

◆ python_driver_exression_depends_on_time()

static bool python_driver_exression_depends_on_time ( const char *  expression)
static

Definition at line 1064 of file fcurve_driver.c.

References NULL.

Referenced by BKE_driver_expression_depends_on_time().

◆ quaternion_to_angles()

static void quaternion_to_angles ( float  quat[4],
int  channel 
)
static

Definition at line 582 of file fcurve_driver.c.

References saacosf(), and saasinf().

Referenced by BKE_driver_target_matrix_to_rot_channels().

Variable Documentation

◆ dvar_types

DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES]
static
Initial value:
= {
1,
{"Property"},
{0}
2,
{"Object/Bone 1", "Object/Bone 2"},
2,
{"Object/Bone 1", "Object/Bone 2"},
1,
{"Object/Bone"},
}
@ DVAR_TYPE_LOC_DIFF
@ DVAR_TYPE_TRANSFORM_CHAN
@ DVAR_TYPE_ROT_DIFF
@ DVAR_TYPE_SINGLE_PROP
@ DTAR_FLAG_ID_OB_ONLY
@ DTAR_FLAG_STRUCT_REF
static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar)
static float dvar_eval_singleProp(ChannelDriver *driver, DriverVar *dvar)
static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar)
#define END_DVAR_TYPEDEF
Definition: fcurve_driver.c:68
static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar)
#define BEGIN_DVAR_TYPEDEF(type)
Definition: fcurve_driver.c:65

Definition at line 652 of file fcurve_driver.c.

Referenced by get_dvar_typeinfo().

◆ LOG

CLG_LogRef LOG = {"bke.fcurve"}
static