[Bf-blender-cvs] [5f31282c469] functions: Merge branch 'master' into functions
Jacques Lucke
noreply at git.blender.org
Mon Sep 2 10:42:58 CEST 2019
Commit: 5f31282c4698b009552ed0bec02e39ecca13b263
Author: Jacques Lucke
Date: Mon Sep 2 09:59:03 2019 +0200
Branches: functions
https://developer.blender.org/rB5f31282c4698b009552ed0bec02e39ecca13b263
Merge branch 'master' into functions
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/fcurve.c
index 5d24d48e5f0,c4da2d2efc9..8b97bded0c0
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@@ -1746,41 -1757,52 +1759,87 @@@ static float dvar_eval_transChan(Channe
}
}
+/* evaluate 'function' driver variable */
+static float dvar_eval_function(ChannelDriver *UNUSED(driver), DriverVar *dvar)
+{
+ FnFunction fn = (FnFunction)get_driver_variable_function(dvar);
+ if (fn == NULL) {
+ return 0.0f;
+ }
+
+ FnTupleCallBody body = FN_tuple_call_get(fn);
+
+ FnTuple fn_in = FN_tuple_for_input(body);
+ FnTuple fn_out = FN_tuple_for_output(body);
+ FN_tuple_set_int32(fn_in, 0, (int64_t)dvar);
+
+ FN_tuple_call_invoke(body, fn_in, fn_out, __func__);
+ float result = FN_tuple_get_float(fn_out, 0);
+
+ FN_tuple_free(fn_in);
+ FN_tuple_free(fn_out);
+
+ return result;
+}
+
+struct bNodeTree;
+void *get_driver_variable_function(DriverVar *dvar)
+{
+ FnType float_ty = FN_type_get_float();
+ FnType int32_ty = FN_type_get_int32();
+ FnType inputs[] = {int32_ty, NULL};
+ FnType outputs[] = {float_ty, NULL};
+
+ struct bNodeTree *tree = (struct bNodeTree *)dvar->targets[0].id;
+ return FN_function_get_with_signature(tree, inputs, outputs);
+}
+
+ /* Convert a quaternion to pseudo-angles representing the weighted amount of rotation. */
+ static void quaternion_to_angles(float quat[4], int channel)
+ {
+ if (channel < 0) {
+ quat[0] = 2.0f * saacosf(quat[0]);
+
+ for (int i = 1; i < 4; i++) {
+ quat[i] = 2.0f * saasinf(quat[i]);
+ }
+ }
+ else if (channel == 0) {
+ quat[0] = 2.0f * saacosf(quat[0]);
+ }
+ else {
+ quat[channel] = 2.0f * saasinf(quat[channel]);
+ }
+ }
+
+ /* Compute channel values for a rotational Transform Channel driver variable. */
+ 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])
+ {
+ float *const quat = r_buf;
+ float *const eul = r_buf + 1;
+
+ zero_v4(r_buf);
+
+ if (rotation_mode == DTAR_ROTMODE_AUTO) {
+ mat4_to_eulO(eul, auto_order, mat);
+ }
+ else if (rotation_mode >= DTAR_ROTMODE_EULER_MIN && rotation_mode <= DTAR_ROTMODE_EULER_MAX) {
+ mat4_to_eulO(eul, rotation_mode, mat);
+ }
+ else if (rotation_mode == DTAR_ROTMODE_QUATERNION) {
+ mat4_to_quat(quat, mat);
+
+ /* For Transformation constraint convenience, convert to pseudo-angles. */
+ if (angles) {
+ quaternion_to_angles(quat, channel);
+ }
+ }
+ else {
+ BLI_assert(false);
+ }
+ }
+
/* ......... */
/* Table of Driver Variable Type Info Data */
@@@ -1794,15 -1816,15 +1853,15 @@@ static DriverVarTypeInfo dvar_types[MAX
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_ROT_DIFF) dvar_eval_rotDiff, /* eval callback */
2, /* number of targets used */
{"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */
-- {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY,
-- DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */
++ {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY}
++ /* flags */
END_DVAR_TYPEDEF,
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_LOC_DIFF) dvar_eval_locDiff, /* eval callback */
2, /* number of targets used */
{"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */
-- {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY,
-- DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */
++ {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY}
++ /* flags */
END_DVAR_TYPEDEF,
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_TRANSFORM_CHAN) dvar_eval_transChan, /* eval callback */
More information about the Bf-blender-cvs
mailing list