Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/constraint.c76
-rw-r--r--source/blender/editors/object/object_constraint.c5
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c15
4 files changed, 65 insertions, 36 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index fc1b4d82c20..9411f937f08 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2634,7 +2634,7 @@ static void actcon_get_tarmat(struct Depsgraph *depsgraph,
{
bActionConstraint *data = con->data;
- if (VALID_CONS_TARGET(ct)) {
+ if (VALID_CONS_TARGET(ct) || data->flag & ACTCON_USE_EVAL_TIME) {
float tempmat[4][4], vec[3];
float s, t;
short axis;
@@ -2642,42 +2642,48 @@ static void actcon_get_tarmat(struct Depsgraph *depsgraph,
/* initialize return matrix */
unit_m4(ct->matrix);
- /* get the transform matrix of the target */
- constraint_target_to_mat4(ct->tar,
- ct->subtarget,
- tempmat,
- CONSTRAINT_SPACE_WORLD,
- ct->space,
- con->flag,
- con->headtail);
+ /* Skip targets if we're using local float property to set action time */
+ if (data->flag & ACTCON_USE_EVAL_TIME) {
+ s = data->eval_time;
+ } else {
+ /* get the transform matrix of the target */
+ constraint_target_to_mat4(ct->tar,
+ ct->subtarget,
+ tempmat,
+ CONSTRAINT_SPACE_WORLD,
+ ct->space,
+ con->flag,
+ con->headtail);
+
+ /* determine where in transform range target is */
+ /* data->type is mapped as follows for backwards compatibility:
+ * 00,01,02 - rotation (it used to be like this)
+ * 10,11,12 - scaling
+ * 20,21,22 - location
+ */
+ if (data->type < 10) {
+ /* extract rotation (is in whatever space target should be in) */
+ mat4_to_eul(vec, tempmat);
+ mul_v3_fl(vec, RAD2DEGF(1.0f)); /* rad -> deg */
+ axis = data->type;
+ }
+ else if (data->type < 20) {
+ /* extract scaling (is in whatever space target should be in) */
+ mat4_to_size(vec, tempmat);
+ axis = data->type - 10;
+ }
+ else {
+ /* extract location */
+ copy_v3_v3(vec, tempmat[3]);
+ axis = data->type - 20;
+ }
- /* determine where in transform range target is */
- /* data->type is mapped as follows for backwards compatibility:
- * 00,01,02 - rotation (it used to be like this)
- * 10,11,12 - scaling
- * 20,21,22 - location
- */
- if (data->type < 10) {
- /* extract rotation (is in whatever space target should be in) */
- mat4_to_eul(vec, tempmat);
- mul_v3_fl(vec, RAD2DEGF(1.0f)); /* rad -> deg */
- axis = data->type;
- }
- else if (data->type < 20) {
- /* extract scaling (is in whatever space target should be in) */
- mat4_to_size(vec, tempmat);
- axis = data->type - 10;
- }
- else {
- /* extract location */
- copy_v3_v3(vec, tempmat[3]);
- axis = data->type - 20;
- }
+ BLI_assert((unsigned int)axis < 3);
- BLI_assert((unsigned int)axis < 3);
+ /* Target defines the animation */
+ s = (vec[axis] - data->min) / (data->max - data->min);
+ }
- /* Target defines the animation */
- s = (vec[axis] - data->min) / (data->max - data->min);
CLAMP(s, 0, 1);
t = (s * (data->end - data->start)) + data->start;
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(depsgraph,
@@ -2734,7 +2740,7 @@ static void actcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
bActionConstraint *data = con->data;
bConstraintTarget *ct = targets->first;
- if (VALID_CONS_TARGET(ct)) {
+ if (VALID_CONS_TARGET(ct) || data->flag & ACTCON_USE_EVAL_TIME) {
switch (data->mix_mode) {
case ACTCON_MIX_BEFORE:
mul_m4_m4m4_aligned_scale(cob->matrix, ct->matrix, cob->matrix);
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index b062ae0c698..af04c4a3263 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -387,6 +387,11 @@ static void test_constraint(
data->act = NULL;
con->flag |= CONSTRAINT_DISABLE;
}
+
+ /* Skip target checking if we're not using it */
+ if (data->flag & ACTCON_USE_EVAL_TIME) {
+ check_targets = false;
+ }
}
else if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
bFollowPathConstraint *data = con->data;
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index cddc78d7640..92ee3f062a6 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -337,7 +337,8 @@ typedef struct bActionConstraint {
float max;
int flag;
char mix_mode;
- char _pad[7];
+ char _pad[3];
+ float eval_time; /* Only used when flag ACTCON_USE_EVAL_TIME is set. */
struct bAction *act;
/** MAX_ID_NAME-2. */
char subtarget[64];
@@ -860,6 +861,8 @@ typedef enum eSameVolume_Mode {
typedef enum eActionConstraint_Flags {
/* Bones use "object" part of target action, instead of "same bone name" part */
ACTCON_BONE_USE_OBJECT_ACTION = (1 << 0),
+ /* Ignore the transform of 'tar' and use 'eval_time' instead: */
+ ACTCON_USE_EVAL_TIME = (1 << 1),
} eActionConstraint_Flags;
/* bActionConstraint.mix_mode */
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index d9dd35c4280..653056e4dc1 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -1790,6 +1790,21 @@ static void rna_def_constraint_action(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_ActionConstraint_minmax_range");
+ prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "eval_time");
+ RNA_def_property_range(prop, 0.f, 1.f);
+ RNA_def_property_ui_text(
+ prop, "Evaluation Time", "Interpolates between Action Start and End frames");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "use_eval_time", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", ACTCON_USE_EVAL_TIME);
+ RNA_def_property_ui_text(prop,
+ "Use Evaluation Time",
+ "Interpolate between Action Start and End frames, with the Evaluation "
+ "Time slider instead of the Target object/bone");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
RNA_define_lib_overridable(false);
}