65 #define BEGIN_DVAR_TYPEDEF(type) {
68 #define END_DVAR_TYPEDEF }
114 "Driver Evaluation Error: cannot resolve target for %s -> %s",
130 "Driver Evaluation Error: array index is out of bounds for %s -> %s (%d)",
225 "Driver Evaluation Error: cannot resolve target for %s -> %s",
250 short valid_targets = 0;
269 return valid_targets;
294 "RotDiff DVar: not enough valid targets (n = %d) (a = %p, b = %p)",
305 for (
int i = 0; i < 2; i++) {
320 mat[i] = pchan->pose_mat;
328 float q1[4], q2[4], quat[4],
angle;
349 float loc1[3] = {0.0f, 0.0f, 0.0f};
350 float loc2[3] = {0.0f, 0.0f, 0.0f};
354 if (valid_targets < dvar->num_targets) {
357 "LocDiff DVar: not enough valid targets (n = %d) (a = %p, b = %p)",
455 float oldEul[3] = {0.0f, 0.0f, 0.0f};
456 bool use_eulers =
false;
481 if (pchan->rotmode > 0) {
483 rot_order = pchan->rotmode;
508 if (ob->rotmode > 0) {
510 rot_order = ob->rotmode;
568 mat, rot_order, dtar->rotation_mode, channel,
false, quat);
574 return quat[channel];
578 return mat[3][dtar->transChan];
585 quat[0] = 2.0f *
saacosf(quat[0]);
587 for (
int i = 1; i < 4; i++) {
588 quat[i] = 2.0f *
saasinf(quat[i]);
591 else if (channel == 0) {
592 quat[0] = 2.0f *
saacosf(quat[0]);
595 quat[channel] = 2.0f *
saasinf(quat[channel]);
600 float mat[4][4],
int auto_order,
int rotation_mode,
int channel,
bool angles,
float r_buf[4])
602 float *
const quat = r_buf;
603 float *
const eul = r_buf + 1;
624 float raw_quat[4], twist;
628 if (channel == axis + 1) {
638 quat[axis + 1] = twist;
661 {
"Object/Bone 1",
"Object/Bone 2"},
668 {
"Object/Bone 1",
"Object/Bone 2"},
711 if (dtar->rna_path) {
739 if (dtar->rna_path) {
770 dtar->idtype =
ID_OB;
779 const char special_char_blacklist[] = {
780 '~',
'`',
'!',
'@',
'#',
'$',
'%',
'^',
'&',
'*',
'+',
'=',
'-',
'/',
'\\',
781 '?',
':',
';',
'<',
'>',
'{',
'}',
'[',
']',
'|',
' ',
'.',
'\t',
'\n',
'\r',
793 if (dvar->
name[0] ==
'\0') {
803 else if (dvar->
name[0] ==
'_') {
810 if (strchr(dvar->
name,
' ')) {
813 if (strchr(dvar->
name,
'.')) {
818 for (
int i = 0; i <
sizeof(special_char_blacklist); i++) {
819 char *match = strchr(dvar->
name, special_char_blacklist[i]);
821 if (match == dvar->
name) {
824 else if (match !=
NULL) {
856 if (driver ==
NULL) {
920 if (driver ==
NULL) {
963 names[i++] = dvar->name;
1066 if (expression[0] ==
'\0') {
1070 if (strchr(expression,
'(') !=
NULL) {
1074 if (strstr(expression,
"frame") !=
NULL) {
1100 bool varname_changed)
1102 if (expr_changed || varname_changed) {
1112 if (varname_changed) {
1172 driver->
curval = tot ? (value / (
float)tot) : 0.0f;
1194 if (tmp_val > value) {
1200 if (tmp_val < value) {
1225 driver, driver_orig, &driver->
curval, anim_eval_context->
eval_time)) {
1250 switch (driver->
type) {
typedef float(TangentPoint)[2]
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float r_chanmat[4][4])
void BKE_constraint_mat_convertspace(struct Object *ob, struct bPoseChannel *pchan, struct bConstraintOb *cob, float mat[4][4], short from, short to, bool keep_scale)
#define DRIVER_TARGETS_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
General operations, lookup, etc. for blender objects.
void BKE_object_to_mat4(struct Object *ob, float r_mat[4][4])
#define BLI_array_alloca(arr, realsize)
@ EXPR_PYLIKE_DIV_BY_ZERO
eExprPyLike_EvalStatus BLI_expr_pylike_eval(struct ExprPyLike_Parsed *expr, const double *param_values, int param_values_len, double *r_result)
ExprPyLike_Parsed * BLI_expr_pylike_parse(const char *expression, const char **param_names, int param_names_len)
void BLI_expr_pylike_free(struct ExprPyLike_Parsed *expr)
bool BLI_expr_pylike_is_using_param(struct ExprPyLike_Parsed *expr, int index)
bool BLI_expr_pylike_is_valid(struct ExprPyLike_Parsed *expr)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void void void void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void void BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
ListBase BLI_listbase_from_link(struct Link *some_link)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float saacos(float fac)
MINLINE float saasinf(float f)
MINLINE float saacosf(float f)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
float mat4_to_volume_scale(const float M[4][4])
void invert_qt_normalized(float q[4])
void mat4_to_eulO(float eul[3], short order, const float mat[4][4])
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
void mat4_to_quat(float q[4], const float mat[4][4])
void compatible_eul(float eul[3], const float old[3])
float quat_split_swing_and_twist(const float q[4], int axis, float r_swing[4], float r_twist[4])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v4(float r[4])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
bool BLI_uniquename(struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_len)
#define BLI_MUTEX_INITIALIZER
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
pthread_mutex_t ThreadMutex
#define IN_RANGE_INCL(a, b, c)
#define BLT_I18NCONTEXT_ID_ACTION
#define CTX_DATA_(context, msgid)
bool BPY_string_is_keyword(const char *str)
float BPY_driver_exec(struct PathResolvedRNA *anim_rna, struct ChannelDriver *driver, struct ChannelDriver *driver_orig, const struct AnimationEvalContext *anim_eval_context)
void BPY_DECREF(void *pyob_ptr)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define MAX_DRIVER_TARGETS
@ MAX_DTAR_TRANSCHAN_TYPES
@ DTAR_TRANSCHAN_SCALE_AVG
@ DVAR_TYPE_TRANSFORM_CHAN
@ DTAR_ROTMODE_QUATERNION
@ DTAR_ROTMODE_SWING_TWIST_X
@ DTAR_ROTMODE_SWING_TWIST_Z
#define DVAR_ALL_INVALID_FLAGS
@ DVAR_FLAG_INVALID_START_CHAR
@ DVAR_FLAG_INVALID_EMPTY
@ DVAR_FLAG_INVALID_START_NUM
@ DVAR_FLAG_INVALID_HAS_SPACE
@ DVAR_FLAG_INVALID_HAS_DOT
@ DVAR_FLAG_INVALID_HAS_SPECIAL
@ DVAR_FLAG_INVALID_PY_KEYWORD
Object is a sort of wrapper for general info.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
ATOMIC_INLINE void * atomic_cas_ptr(void **v, void *old, void *_new)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
void driver_change_variable_type(DriverVar *dvar, int type)
static short driver_check_valid_targets(ChannelDriver *driver, DriverVar *dvar)
static void evaluate_driver_min_max(ChannelDriver *driver)
void fcurve_free_driver(FCurve *fcu)
static ExprPyLike_Parsed * driver_compile_simple_expr_impl(ChannelDriver *driver)
static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar)
bool driver_get_variable_property(ChannelDriver *driver, DriverTarget *dtar, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
bool BKE_driver_expression_depends_on_time(ChannelDriver *driver)
float evaluate_driver(PathResolvedRNA *anim_rna, ChannelDriver *driver, ChannelDriver *driver_orig, const AnimationEvalContext *anim_eval_context)
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])
static float dvar_eval_singleProp(ChannelDriver *driver, DriverVar *dvar)
static void evaluate_driver_python(PathResolvedRNA *anim_rna, ChannelDriver *driver, ChannelDriver *driver_orig, const AnimationEvalContext *anim_eval_context)
static bool python_driver_exression_depends_on_time(const char *expression)
void driver_free_variable(ListBase *variables, DriverVar *dvar)
static const DriverVarTypeInfo * get_dvar_typeinfo(int type)
static void evaluate_driver_sum(ChannelDriver *driver)
void driver_variable_unique_name(DriverVar *dvar)
struct DriverVarTypeInfo DriverVarTypeInfo
void driver_variable_name_validate(DriverVar *dvar)
void driver_variables_copy(ListBase *dst_vars, const ListBase *src_vars)
ChannelDriver * fcurve_copy_driver(const ChannelDriver *driver)
static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar)
static bool driver_compile_simple_expr(ChannelDriver *driver)
static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar)
DriverVar * driver_add_new_variable(ChannelDriver *driver)
static bool driver_check_simple_expr_depends_on_time(ExprPyLike_Parsed *expr)
static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar)
#define BEGIN_DVAR_TYPEDEF(type)
void driver_free_variable_ex(ChannelDriver *driver, DriverVar *dvar)
static bool driver_evaluate_simple_expr(ChannelDriver *driver, ExprPyLike_Parsed *expr, float *result, float time)
static bool driver_try_evaluate_simple_expr(ChannelDriver *driver, ChannelDriver *driver_orig, float *result, float time)
static void quaternion_to_angles(float quat[4], int channel)
static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES]
bool BKE_driver_has_simple_expression(ChannelDriver *driver)
void BKE_driver_invalidate_expression(ChannelDriver *driver, bool expr_changed, bool varname_changed)
float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
PropertyType RNA_property_type(PropertyRNA *prop)
const PointerRNA PointerRNA_NULL
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
bool RNA_path_resolve_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
bool RNA_path_resolve_property_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
struct ExprPyLike_Parsed * expr_simple
short target_flags[MAX_DRIVER_TARGETS]
float(* get_value)(ChannelDriver *driver, DriverVar *dvar)
const char * target_names[MAX_DRIVER_TARGETS]