Blender V4.3
fcurve_driver.cc File Reference
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_alloca.h"
#include "BLI_expr_pylike_eval.h"
#include "BLI_listbase.h"
#include "BLI_math_base_safe.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_string_utf8.h"
#include "BLI_string_utils.hh"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_action.hh"
#include "BKE_animsys.h"
#include "BKE_armature.hh"
#include "BKE_constraint.h"
#include "BKE_fcurve_driver.h"
#include "BKE_global.hh"
#include "BKE_object.hh"
#include "RNA_access.hh"
#include "RNA_path.hh"
#include "RNA_prototypes.hh"
#include "atomic_ops.h"
#include "CLG_log.h"
#include "DEG_depsgraph_query.hh"
#include <cstring>

Go to the source code of this file.

Classes

struct  DriverVarTypeInfo
 

Macros

Driver Variables
#define BEGIN_DVAR_TYPEDEF(type)   {
 
#define END_DVAR_TYPEDEF   }
 

Functions

Driver Target Utilities
static DriverTargetContext driver_target_context_from_animation_context (const AnimationEvalContext *anim_eval_context)
 
static bool driver_get_target_context_property (const DriverTargetContext *driver_target_context, DriverTarget *dtar, PointerRNA *r_property_ptr)
 
bool driver_get_target_property (const DriverTargetContext *driver_target_context, DriverVar *dvar, DriverTarget *dtar, PointerRNA *r_prop)
 
static bool dtar_try_use_fallback (DriverTarget *dtar)
 
static float dtar_get_prop_val (const AnimationEvalContext *anim_eval_context, ChannelDriver *driver, DriverVar *dvar, DriverTarget *dtar)
 
eDriverVariablePropertyResult driver_get_variable_property (const AnimationEvalContext *anim_eval_context, ChannelDriver *driver, DriverVar *dvar, DriverTarget *dtar, const bool allow_no_index, 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 (const AnimationEvalContext *anim_eval_context, ChannelDriver *driver, DriverVar *dvar)
 
static float dvar_eval_rotDiff (const AnimationEvalContext *, ChannelDriver *driver, DriverVar *dvar)
 
static float dvar_eval_locDiff (const AnimationEvalContext *, ChannelDriver *driver, DriverVar *dvar)
 
static float dvar_eval_transChan (const AnimationEvalContext *, ChannelDriver *driver, DriverVar *dvar)
 
static float dvar_eval_contextProp (const AnimationEvalContext *anim_eval_context, 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 (const AnimationEvalContext *anim_eval_context, ChannelDriver *driver, DriverVar *dvar)
 
static void evaluate_driver_sum (const AnimationEvalContext *anim_eval_context, ChannelDriver *driver)
 
static void evaluate_driver_min_max (const AnimationEvalContext *anim_eval_context, 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 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 (const ExprPyLike_Parsed *expr)
 
static bool driver_evaluate_simple_expr (const AnimationEvalContext *anim_eval_context, ChannelDriver *driver, ExprPyLike_Parsed *expr, float *result, float time)
 
static bool driver_compile_simple_expr (ChannelDriver *driver)
 
static bool driver_try_evaluate_simple_expr (const AnimationEvalContext *anim_eval_context, 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 78 of file fcurve_driver.cc.

◆ END_DVAR_TYPEDEF

#define END_DVAR_TYPEDEF   }

Definition at line 81 of file fcurve_driver.cc.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_INDEX_FRAME 
VAR_INDEX_CUSTOM 

Definition at line 1107 of file fcurve_driver.cc.

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 1222 of file fcurve_driver.cc.

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()

◆ driver_change_variable_type()

◆ driver_check_simple_expr_depends_on_time()

static bool driver_check_simple_expr_depends_on_time ( const ExprPyLike_Parsed * expr)
static

◆ driver_check_valid_targets()

static short driver_check_valid_targets ( ChannelDriver * driver,
DriverVar * dvar )
static

◆ driver_compile_simple_expr()

◆ driver_compile_simple_expr_impl()

◆ driver_evaluate_simple_expr()

◆ 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 858 of file fcurve_driver.cc.

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

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 882 of file fcurve_driver.cc.

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

Referenced by ANIM_driver_vars_paste(), driver_delete_var_cb(), and fcurve_free_driver().

◆ driver_get_target_context_property()

◆ driver_get_target_property()

◆ driver_get_variable_property()

◆ driver_get_variable_value()

float driver_get_variable_value ( const AnimationEvalContext * anim_eval_context,
ChannelDriver * driver,
DriverVar * dvar )

◆ driver_target_context_from_animation_context()

static DriverTargetContext driver_target_context_from_animation_context ( const AnimationEvalContext * anim_eval_context)
static

◆ driver_try_evaluate_simple_expr()

static bool driver_try_evaluate_simple_expr ( const AnimationEvalContext * anim_eval_context,
ChannelDriver * driver,
ChannelDriver * driver_orig,
float * result,
float time )
static

◆ driver_variable_name_validate()

◆ 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 1006 of file fcurve_driver.cc.

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

◆ driver_variables_copy()

void driver_variables_copy ( ListBase * dst_vars,
const ListBase * src_vars )

◆ dtar_get_prop_val()

◆ dtar_try_use_fallback()

static bool dtar_try_use_fallback ( DriverTarget * dtar)
static

Checks if the fallback value can be used, and if so, sets dtar flags to signal its usage. The caller is expected to immediately return the fallback value if this returns true.

Definition at line 153 of file fcurve_driver.cc.

References DTAR_FLAG_FALLBACK_USED, DTAR_OPTION_USE_FALLBACK, DriverTarget::flag, and DriverTarget::options.

Referenced by driver_get_variable_property(), and dtar_get_prop_val().

◆ dvar_eval_contextProp()

static float dvar_eval_contextProp ( const AnimationEvalContext * anim_eval_context,
ChannelDriver * driver,
DriverVar * dvar )
static

Definition at line 727 of file fcurve_driver.cc.

References dtar_get_prop_val(), and DriverVar::targets.

◆ dvar_eval_locDiff()

◆ dvar_eval_rotDiff()

◆ dvar_eval_singleProp()

static float dvar_eval_singleProp ( const AnimationEvalContext * anim_eval_context,
ChannelDriver * driver,
DriverVar * dvar )
static

Definition at line 411 of file fcurve_driver.cc.

References dtar_get_prop_val(), and DriverVar::targets.

◆ dvar_eval_transChan()

◆ evaluate_driver()

◆ evaluate_driver_min_max()

static void evaluate_driver_min_max ( const AnimationEvalContext * anim_eval_context,
ChannelDriver * driver )
static

◆ evaluate_driver_python()

◆ evaluate_driver_sum()

static void evaluate_driver_sum ( const AnimationEvalContext * anim_eval_context,
ChannelDriver * driver )
static

◆ fcurve_copy_driver()

◆ fcurve_free_driver()

◆ get_dvar_typeinfo()

static const DriverVarTypeInfo * get_dvar_typeinfo ( int type)
static

Definition at line 842 of file fcurve_driver.cc.

References dvar_types, and MAX_DVAR_TYPES.

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 1229 of file fcurve_driver.cc.

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 736 of file fcurve_driver.cc.

References safe_acosf(), and safe_asinf().

Referenced by BKE_driver_target_matrix_to_rot_channels().

Variable Documentation

◆ dvar_types

DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES]
static

Definition at line 807 of file fcurve_driver.cc.

Referenced by get_dvar_typeinfo().

◆ LOG