|
Blender V4.3
|
#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 } |
Variables | |
| static CLG_LogRef | LOG = {"bke.fcurve"} |
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 (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 DriverVarTypeInfo * | get_dvar_typeinfo (int type) |
| #define BEGIN_DVAR_TYPEDEF | ( | type | ) | { |
Definition at line 78 of file fcurve_driver.cc.
| #define END_DVAR_TYPEDEF } |
Definition at line 81 of file fcurve_driver.cc.
| anonymous enum |
| Enumerator | |
|---|---|
| VAR_INDEX_FRAME | |
| VAR_INDEX_CUSTOM | |
Definition at line 1107 of file fcurve_driver.cc.
| 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 1248 of file fcurve_driver.cc.
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 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().
| void BKE_driver_invalidate_expression | ( | struct ChannelDriver * | driver, |
| bool | expr_changed, | ||
| bool | varname_changed ) |
Reset cached compiled expression data.
Definition at line 1263 of file fcurve_driver.cc.
References BLI_expr_pylike_free(), DRIVER_FLAG_RECOMPILE, DRIVER_FLAG_RENAMEVAR, ChannelDriver::expr_simple, and ChannelDriver::flag.
Referenced by ANIM_driver_vars_paste(), 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 753 of file fcurve_driver.cc.
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(), quat_split_swing_and_twist(), quaternion_to_angles(), and zero_v4().
Referenced by dvar_eval_transChan(), and transform_evaluate().
| DriverVar * driver_add_new_variable | ( | struct ChannelDriver * | driver | ) |
Add a new driver variable.
Definition at line 1012 of file fcurve_driver.cc.
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, offsetof, STRNCPY_UTF8, 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 908 of file fcurve_driver.cc.
References DRIVER_TARGETS_LOOPER_END, DRIVER_TARGETS_USED_LOOPER_BEGIN, DTAR_FLAG_ID_OB_ONLY, ELEM, get_dvar_typeinfo(), ID_OB, DriverVar::num_targets, DriverVarTypeInfo::num_targets, DriverVarTypeInfo::target_flags, and DriverVar::type.
Referenced by add_driver_with_target(), ANIM_add_driver(), driver_add_new_variable(), and idriver_to_cdriver().
|
static |
Definition at line 1131 of file fcurve_driver.cc.
References BLI_expr_pylike_is_using_param(), and VAR_INDEX_FRAME.
Referenced by BKE_driver_expression_depends_on_time().
|
static |
Definition at line 380 of file fcurve_driver.cc.
References DRIVER_FLAG_INVALID, DRIVER_TARGETS_LOOPER_END, DRIVER_TARGETS_USED_LOOPER_BEGIN, DTAR_FLAG_INVALID, ChannelDriver::flag, GS, Object::id, ID_OB, and ID::name.
Referenced by dvar_eval_locDiff(), and dvar_eval_rotDiff().
|
static |
Definition at line 1183 of file fcurve_driver.cc.
References atomic_cas_ptr(), BLI_expr_pylike_free(), driver_compile_simple_expr_impl(), DRIVER_TYPE_PYTHON, ChannelDriver::expr_simple, and ChannelDriver::type.
Referenced by BKE_driver_has_simple_expression(), and driver_try_evaluate_simple_expr().
|
static |
Definition at line 1114 of file fcurve_driver.cc.
References BLI_array_alloca, BLI_expr_pylike_parse(), BLI_listbase_count(), ChannelDriver::expression, LISTBASE_FOREACH, VAR_INDEX_CUSTOM, VAR_INDEX_FRAME, and ChannelDriver::variables.
Referenced by driver_compile_simple_expr().
|
static |
Definition at line 1137 of file fcurve_driver.cc.
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, LISTBASE_FOREACH, LOG, 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 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().
| 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().
|
static |
Definition at line 102 of file fcurve_driver.cc.
References BLI_assert_unreachable, DriverTarget::context_property, PointerRNA::data, DTAR_CONTEXT_PROPERTY_ACTIVE_SCENE, DTAR_CONTEXT_PROPERTY_ACTIVE_VIEW_LAYER, Scene::id, PointerRNA::owner_id, RNA_id_pointer_create(), RNA_pointer_create(), DriverTargetContext::scene, PointerRNA::type, and DriverTargetContext::view_layer.
Referenced by driver_get_target_property().
| bool driver_get_target_property | ( | const DriverTargetContext * | driver_target_context, |
| DriverVar * | dvar, | ||
| DriverTarget * | dtar, | ||
| PointerRNA * | r_prop ) |
Definition at line 131 of file fcurve_driver.cc.
References driver_get_target_context_property(), DVAR_TYPE_CONTEXT_PROP, DriverTarget::id, RNA_id_pointer_create(), and DriverVar::type.
Referenced by blender::deg::DepsgraphNodeBuilder::build_driver_variables(), blender::deg::DepsgraphRelationBuilder::build_driver_variables(), driver_get_variable_property(), and dtar_get_prop_val().
| 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 ) |
Definition at line 281 of file fcurve_driver.cc.
References CLOG_ERROR, DRIVER_FLAG_INVALID, driver_get_target_property(), driver_target_context_from_animation_context(), DRIVER_VAR_PROPERTY_FALLBACK, DRIVER_VAR_PROPERTY_INVALID, DRIVER_VAR_PROPERTY_INVALID_INDEX, DRIVER_VAR_PROPERTY_SUCCESS, DTAR_FLAG_INVALID, dtar_try_use_fallback(), ELEM, ChannelDriver::flag, DriverTarget::flag, G, G_DEBUG, LOG, ID::name, PointerRNA::owner_id, PointerRNA_NULL, ptr, DriverTarget::rna_path, RNA_path_resolve_full(), RNA_property_array_check(), and RNA_property_array_length().
| float driver_get_variable_value | ( | const AnimationEvalContext * | anim_eval_context, |
| ChannelDriver * | driver, | ||
| DriverVar * | dvar ) |
Definition at line 1289 of file fcurve_driver.cc.
References DriverVar::curval, ELEM, get_dvar_typeinfo(), DriverVarTypeInfo::get_value, and DriverVar::type.
Referenced by driver_evaluate_simple_expr(), evaluate_driver_min_max(), and evaluate_driver_sum().
|
static |
Definition at line 89 of file fcurve_driver.cc.
References DEG_get_evaluated_scene(), DEG_get_evaluated_view_layer(), AnimationEvalContext::depsgraph, DriverTargetContext::scene, and DriverTargetContext::view_layer.
Referenced by driver_get_variable_property(), and dtar_get_prop_val().
|
static |
Definition at line 1208 of file fcurve_driver.cc.
References BLI_expr_pylike_is_valid(), driver_compile_simple_expr(), driver_evaluate_simple_expr(), and ChannelDriver::expr_simple.
Referenced by evaluate_driver_python().
| void driver_variable_name_validate | ( | struct DriverVar * | dvar | ) |
Validate driver variable name (after being renamed).
Definition at line 937 of file fcurve_driver.cc.
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, and DriverVar::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.
Definition at line 891 of file fcurve_driver.cc.
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 168 of file fcurve_driver.cc.
References CLOG_ERROR, DRIVER_FLAG_INVALID, driver_get_target_property(), driver_target_context_from_animation_context(), DTAR_FLAG_INVALID, dtar_try_use_fallback(), DriverTarget::fallback_value, ChannelDriver::flag, DriverTarget::flag, float, G, G_DEBUG, LOG, ID::name, PointerRNA::owner_id, PROP_BOOLEAN, PROP_ENUM, PROP_FLOAT, PROP_INT, 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_contextProp(), and dvar_eval_singleProp().
|
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().
|
static |
Definition at line 727 of file fcurve_driver.cc.
References dtar_get_prop_val(), and DriverVar::targets.
|
static |
Evaluate 'location difference' driver variable.
TODO: this needs to take into account space conversions.
Definition at line 483 of file fcurve_driver.cc.
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(), bPoseChannel::loc, Object::loc, LOG, mul_m4_v3(), ID::name, Object::pose, bPoseChannel::pose_head, bPoseChannel::pose_mat, and DriverVar::targets.
|
static |
Definition at line 420 of file fcurve_driver.cc.
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, DriverTarget::pchan_name, Object::pose, bPoseChannel::pose_mat, q1, safe_acosf(), and DriverVar::targets.
|
static |
Definition at line 411 of file fcurve_driver.cc.
References dtar_get_prop_val(), and DriverVar::targets.
|
static |
Evaluate 'transform channel' driver variable.
Definition at line 587 of file fcurve_driver.cc.
References BKE_constraint_mat_convertspace(), BKE_driver_target_matrix_to_rot_channels(), BKE_object_to_mat4(), BKE_pchan_to_mat4(), BKE_pose_channel_find_name(), BLI_assert, compatible_eul(), CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_WORLD, copy_m4_m4(), copy_v3_v3(), DRIVER_FLAG_INVALID, DTAR_FLAG_INVALID, DTAR_FLAG_LOCAL_CONSTS, DTAR_FLAG_LOCALSPACE, DTAR_ROTMODE_AUTO, DTAR_TRANSCHAN_ROTW, DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_SCALE_AVG, DTAR_TRANSCHAN_SCALEX, DTAR_TRANSCHAN_SCALEY, DTAR_TRANSCHAN_SCALEZ, ELEM, bPoseChannel::eul, ChannelDriver::flag, DriverTarget::flag, GS, DriverTarget::id, Object::id, ID_OB, len_v3(), mat4_to_volume_scale(), MAX_DTAR_TRANSCHAN_TYPES, mul_m4_m4m4(), ID::name, DriverTarget::pchan_name, Object::pose, bPoseChannel::pose_mat, Object::rot, ROT_MODE_EUL, DriverTarget::rotation_mode, bPoseChannel::rotmode, Object::rotmode, DriverVar::targets, and DriverTarget::transChan.
| float evaluate_driver | ( | PathResolvedRNA * | anim_rna, |
| ChannelDriver * | driver, | ||
| ChannelDriver * | driver_orig, | ||
| const AnimationEvalContext * | anim_eval_context ) |
Definition at line 1412 of file fcurve_driver.cc.
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 1347 of file fcurve_driver.cc.
References ChannelDriver::curval, driver_get_variable_value(), DRIVER_TYPE_MAX, LISTBASE_FOREACH, ChannelDriver::type, and ChannelDriver::variables.
Referenced by evaluate_driver().
|
static |
Definition at line 1383 of file fcurve_driver.cc.
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 1315 of file fcurve_driver.cc.
References BLI_listbase_is_single(), ChannelDriver::curval, driver_get_variable_value(), DRIVER_TYPE_AVERAGE, ListBase::first, float, LISTBASE_FOREACH, ChannelDriver::type, and ChannelDriver::variables.
Referenced by evaluate_driver().
| ChannelDriver * fcurve_copy_driver | ( | const ChannelDriver * | driver | ) |
Definition at line 1076 of file fcurve_driver.cc.
References BLI_listbase_clear(), driver_variables_copy(), ChannelDriver::expr_comp, ChannelDriver::expr_simple, MEM_dupallocN, and ChannelDriver::variables.
| void fcurve_free_driver | ( | struct FCurve * | fcu | ) |
This frees the driver itself.
Definition at line 1044 of file fcurve_driver.cc.
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, and ChannelDriver::variables.
Referenced by BKE_fcurve_free().
|
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().
|
static |
Definition at line 1229 of file fcurve_driver.cc.
Referenced by BKE_driver_expression_depends_on_time().
Definition at line 736 of file fcurve_driver.cc.
References safe_acosf(), and safe_asinf().
Referenced by BKE_driver_target_matrix_to_rot_channels().
|
static |
Definition at line 807 of file fcurve_driver.cc.
Referenced by get_dvar_typeinfo().
|
static |
Definition at line 58 of file fcurve_driver.cc.
Referenced by driver_evaluate_simple_expr(), driver_get_variable_property(), dtar_get_prop_val(), dvar_eval_locDiff(), and dvar_eval_rotDiff().