Blender
V3.3
|
#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 |
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_Parsed * | driver_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 DriverVarTypeInfo * | get_dvar_typeinfo (int type) |
Definition at line 65 of file fcurve_driver.c.
#define END_DVAR_TYPEDEF } |
Definition at line 68 of file fcurve_driver.c.
typedef struct DriverVarTypeInfo DriverVarTypeInfo |
anonymous enum |
Enumerator | |
---|---|
VAR_INDEX_FRAME | |
VAR_INDEX_CUSTOM |
Definition at line 946 of file fcurve_driver.c.
bool BKE_driver_expression_depends_on_time | ( | struct ChannelDriver * | driver | ) |
Check if the expression in the driver may depend on the current frame.
Definition at line 1083 of file fcurve_driver.c.
References BKE_driver_has_simple_expression(), driver_check_simple_expr_depends_on_time(), DRIVER_TYPE_PYTHON, ChannelDriver::expr_simple, ChannelDriver::expression, python_driver_exression_depends_on_time(), and ChannelDriver::type.
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().
void BKE_driver_invalidate_expression | ( | struct ChannelDriver * | driver, |
bool | expr_changed, | ||
bool | varname_changed | ||
) |
Reset cached compiled expression data.
Definition at line 1098 of file fcurve_driver.c.
References BLI_expr_pylike_free(), DRIVER_FLAG_RECOMPILE, DRIVER_FLAG_RENAMEVAR, ChannelDriver::expr_simple, ChannelDriver::flag, and NULL.
Referenced by driver_add_new_variable(), driver_free_variable_ex(), ui_but_anim_expression_create(), and ui_but_anim_expression_set().
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] | ||
) |
Compute channel values for a rotational Transform Channel driver variable.
Definition at line 599 of file fcurve_driver.c.
References BLI_assert, DTAR_ROTMODE_AUTO, DTAR_ROTMODE_EULER_MAX, DTAR_ROTMODE_EULER_MIN, DTAR_ROTMODE_QUATERNION, DTAR_ROTMODE_SWING_TWIST_X, DTAR_ROTMODE_SWING_TWIST_Z, mat4_to_eulO(), mat4_to_quat(), NULL, quat_split_swing_and_twist(), quaternion_to_angles(), and zero_v4().
Referenced by transform_evaluate().
DriverVar* driver_add_new_variable | ( | struct ChannelDriver * | driver | ) |
Add a new driver variable.
Definition at line 851 of file fcurve_driver.c.
References BKE_driver_invalidate_expression(), BLI_addtail(), BLI_uniquename(), BLT_I18NCONTEXT_ID_ACTION, CTX_DATA_, driver_change_variable_type(), DVAR_TYPE_SINGLE_PROP, MEM_callocN, DriverVar::name, NULL, and ChannelDriver::variables.
Referenced by add_driver_with_target(), ANIM_add_driver(), ANIM_copy_as_driver(), driver_add_var_cb(), and idriver_to_cdriver().
Change the type of driver variable.
Definition at line 747 of file fcurve_driver.c.
References DRIVER_TARGETS_LOOPER_END, DRIVER_TARGETS_USED_LOOPER_BEGIN, DTAR_FLAG_ID_OB_ONLY, ELEM, get_dvar_typeinfo(), ID_OB, NULL, DriverVarTypeInfo::num_targets, DriverVar::num_targets, DriverVarTypeInfo::target_flags, type, and DriverVar::type.
Referenced by add_driver_with_target(), ANIM_add_driver(), driver_add_new_variable(), and idriver_to_cdriver().
|
static |
Definition at line 969 of file fcurve_driver.c.
References BLI_expr_pylike_is_using_param(), and VAR_INDEX_FRAME.
Referenced by BKE_driver_expression_depends_on_time().
|
static |
Definition at line 248 of file fcurve_driver.c.
References DRIVER_FLAG_INVALID, DRIVER_TARGETS_LOOPER_END, DRIVER_TARGETS_USED_LOOPER_BEGIN, DTAR_FLAG_INVALID, ChannelDriver::flag, GS, Object::id, ID_OB, if(), ID::name, and NULL.
Referenced by dvar_eval_locDiff(), and dvar_eval_rotDiff().
|
static |
Definition at line 1020 of file fcurve_driver.c.
References atomic_cas_ptr(), BLI_expr_pylike_free(), driver_compile_simple_expr_impl(), DRIVER_TYPE_PYTHON, ChannelDriver::expr_simple, NULL, and ChannelDriver::type.
Referenced by BKE_driver_has_simple_expression(), and driver_try_evaluate_simple_expr().
|
static |
Definition at line 953 of file fcurve_driver.c.
References BLI_array_alloca, BLI_expr_pylike_parse(), BLI_listbase_count(), ChannelDriver::expression, LISTBASE_FOREACH, names, names_len, VAR_INDEX_CUSTOM, VAR_INDEX_FRAME, and ChannelDriver::variables.
Referenced by driver_compile_simple_expr().
|
static |
Definition at line 975 of file fcurve_driver.c.
References BLI_array_alloca, BLI_expr_pylike_eval(), BLI_listbase_count(), CLOG_ERROR, DRIVER_FLAG_INVALID, driver_get_variable_value(), EXPR_PYLIKE_DIV_BY_ZERO, EXPR_PYLIKE_MATH_ERROR, EXPR_PYLIKE_SUCCESS, ChannelDriver::expression, ChannelDriver::flag, float(), CCL_NAMESPACE_BEGIN::isfinite(), LISTBASE_FOREACH, LOG, result, time, VAR_INDEX_CUSTOM, VAR_INDEX_FRAME, and ChannelDriver::variables.
Referenced by driver_try_evaluate_simple_expr().
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().
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().
bool driver_get_variable_property | ( | struct ChannelDriver * | driver, |
struct DriverTarget * | dtar, | ||
struct PointerRNA * | r_ptr, | ||
struct PropertyRNA ** | r_prop, | ||
int * | r_index | ||
) |
Same as 'dtar_get_prop_val'. but get the RNA property.
Definition at line 180 of file fcurve_driver.c.
References CLOG_ERROR, DRIVER_FLAG_INVALID, DTAR_FLAG_INVALID, ELEM, DriverTarget::flag, ChannelDriver::flag, G, G_DEBUG, id, DriverTarget::id, LOG, ID::name, NULL, PointerRNA_NULL, ptr, RNA_id_pointer_create(), DriverTarget::rna_path, and RNA_path_resolve_full().
Referenced by pyrna_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().
|
static |
Definition at line 1045 of file fcurve_driver.c.
References BLI_expr_pylike_is_valid(), driver_compile_simple_expr(), driver_evaluate_simple_expr(), ChannelDriver::expr_simple, result, and time.
Referenced by evaluate_driver_python().
Validate driver variable name (after being renamed).
Definition at line 776 of file fcurve_driver.c.
References BPY_string_is_keyword(), DVAR_ALL_INVALID_FLAGS, DVAR_FLAG_INVALID_EMPTY, DVAR_FLAG_INVALID_HAS_DOT, DVAR_FLAG_INVALID_HAS_SPACE, DVAR_FLAG_INVALID_HAS_SPECIAL, DVAR_FLAG_INVALID_NAME, DVAR_FLAG_INVALID_PY_KEYWORD, DVAR_FLAG_INVALID_START_CHAR, DVAR_FLAG_INVALID_START_NUM, DriverVar::flag, IN_RANGE_INCL, DriverVar::name, and NULL.
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.
Definition at line 730 of file fcurve_driver.c.
References BLI_assert, BLI_duplicatelist(), BLI_listbase_is_empty(), DRIVER_TARGETS_LOOPER_BEGIN, DRIVER_TARGETS_LOOPER_END, LISTBASE_FOREACH, and MEM_dupallocN.
Referenced by fcurve_copy_driver().
|
static |
Helper function to obtain a value using RNA from the specified source (for evaluating drivers).
Definition at line 80 of file fcurve_driver.c.
References CLOG_ERROR, DRIVER_FLAG_INVALID, DTAR_FLAG_INVALID, ELEM, DriverTarget::flag, ChannelDriver::flag, float(), G, G_DEBUG, id, DriverTarget::id, LOG, ID::name, NULL, PROP_BOOLEAN, PROP_ENUM, PROP_FLOAT, PROP_INT, ptr, RNA_id_pointer_create(), DriverTarget::rna_path, RNA_path_resolve_property_full(), RNA_property_array_check(), RNA_property_array_length(), RNA_property_boolean_get(), RNA_property_boolean_get_index(), RNA_property_enum_get(), RNA_property_float_get(), RNA_property_float_get_index(), RNA_property_int_get(), RNA_property_int_get_index(), and RNA_property_type().
Referenced by dvar_eval_singleProp().
|
static |
Evaluate 'location difference' driver variable.
TODO: this needs to take into account space conversions.
Definition at line 347 of file fcurve_driver.c.
References BKE_constraint_mat_convertspace(), BKE_pose_channel_find_name(), BLI_assert, CLOG_WARN, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_WORLD, copy_m4_m4(), copy_v3_v3(), driver_check_valid_targets(), DRIVER_TARGETS_LOOPER_END, DRIVER_TARGETS_USED_LOOPER_BEGIN, DTAR_FLAG_LOCAL_CONSTS, DTAR_FLAG_LOCALSPACE, G, G_DEBUG, GS, DriverTarget::id, Object::id, ID_OB, len_v3v3(), Object::loc, LOG, mul_m4_v3(), ID::name, NULL, Object::obmat, Object::pose, and DriverVar::targets.
|
static |
Definition at line 286 of file fcurve_driver.c.
References angle(), BKE_pose_channel_find_name(), BLI_assert, CLOG_WARN, driver_check_valid_targets(), fabsf, float(), G, G_DEBUG, GS, DriverTarget::id, Object::id, ID_OB, invert_qt_normalized(), LOG, M_PI, mat4_to_quat(), mul_qt_qtqt(), ID::name, NULL, Object::obmat, DriverTarget::pchan_name, Object::pose, q1, saacos(), and DriverVar::targets.
|
static |
Definition at line 279 of file fcurve_driver.c.
References dtar_get_prop_val(), and DriverVar::targets.
|
static |
Evaluate 'transform channel' driver variable.
Definition at line 449 of file fcurve_driver.c.
References DriverTarget::id, and DriverVar::targets.
float evaluate_driver | ( | PathResolvedRNA * | anim_rna, |
ChannelDriver * | driver, | ||
ChannelDriver * | driver_orig, | ||
const AnimationEvalContext * | anim_eval_context | ||
) |
Definition at line 1240 of file fcurve_driver.c.
References ChannelDriver::curval, DRIVER_FLAG_INVALID, DRIVER_TYPE_AVERAGE, DRIVER_TYPE_MAX, DRIVER_TYPE_MIN, DRIVER_TYPE_PYTHON, DRIVER_TYPE_SUM, evaluate_driver_min_max(), evaluate_driver_python(), evaluate_driver_sum(), ChannelDriver::flag, and ChannelDriver::type.
|
static |
Definition at line 1179 of file fcurve_driver.c.
References ChannelDriver::curval, driver_get_variable_value(), DRIVER_TYPE_MAX, ListBase::first, DriverVar::next, DriverVar::prev, ChannelDriver::type, and ChannelDriver::variables.
Referenced by evaluate_driver().
|
static |
Definition at line 1215 of file fcurve_driver.c.
References BLI_mutex_lock(), BLI_mutex_unlock(), BPY_driver_exec(), ChannelDriver::curval, DRIVER_FLAG_INVALID, driver_try_evaluate_simple_expr(), AnimationEvalContext::eval_time, ChannelDriver::expression, ChannelDriver::flag, and UNUSED_VARS.
Referenced by evaluate_driver().
|
static |
Definition at line 1148 of file fcurve_driver.c.
References BLI_listbase_is_single(), ChannelDriver::curval, driver_get_variable_value(), DRIVER_TYPE_AVERAGE, ListBase::first, float(), DriverVar::next, ChannelDriver::type, and ChannelDriver::variables.
Referenced by evaluate_driver().
ChannelDriver* fcurve_copy_driver | ( | const ChannelDriver * | driver | ) |
Definition at line 915 of file fcurve_driver.c.
References BLI_listbase_clear(), driver_variables_copy(), ChannelDriver::expr_comp, ChannelDriver::expr_simple, MEM_dupallocN, NULL, and ChannelDriver::variables.
This frees the driver itself.
Definition at line 883 of file fcurve_driver.c.
References BLI_expr_pylike_free(), BPY_DECREF(), FCurve::driver, driver_free_variable_ex(), ELEM, ChannelDriver::expr_comp, ChannelDriver::expr_simple, ListBase::first, MEM_freeN, DriverVar::next, NULL, and ChannelDriver::variables.
Referenced by BKE_fcurve_free().
|
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().
|
static |
Definition at line 1064 of file fcurve_driver.c.
References NULL.
Referenced by BKE_driver_expression_depends_on_time().
Definition at line 582 of file fcurve_driver.c.
References saacosf(), and saasinf().
Referenced by BKE_driver_target_matrix_to_rot_channels().
|
static |
Definition at line 652 of file fcurve_driver.c.
Referenced by get_dvar_typeinfo().
|
static |
Definition at line 47 of file fcurve_driver.c.
Referenced by driver_evaluate_simple_expr(), driver_get_variable_property(), dtar_get_prop_val(), dvar_eval_locDiff(), and dvar_eval_rotDiff().