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
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-12-01 20:02:14 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-12-01 20:02:14 +0300
commit6a80a786f88c7b09c451e3c585224a392c3cd95c (patch)
tree8f1d3c769ff2095dc6a18f49e83e0d150d1663e9
parent18f06186778ea67583a362a611b1efa8c9da5fbd (diff)
Fix T58433: Limit Distance constraint distance not auto-computed.
Another case of a value that needs to be written back to non-COW copy.
-rw-r--r--source/blender/blenkernel/intern/constraint.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 8c31b830ff7..1a5b73afa12 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -110,6 +110,7 @@
static void damptrack_do_transform(float matrix[4][4], const float tarvec[3], int track_axis);
static bConstraint *constraint_find_original(Object *ob, bPoseChannel *pchan, bConstraint *con, Object **r_orig_ob);
+static bConstraint *constraint_find_original_for_update(bConstraintOb *cob, bConstraint *con);
/* -------------- Naming -------------- */
@@ -2819,9 +2820,19 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
dist = len_v3v3(cob->matrix[3], ct->matrix[3]);
/* set distance (flag is only set when user demands it) */
- if (data->dist == 0)
+ if (data->dist == 0) {
data->dist = dist;
+ /* Write the computed distance back to the master copy if in COW evaluation. */
+ bConstraint *orig_con = constraint_find_original_for_update(cob, con);
+
+ if (orig_con != NULL) {
+ bDistLimitConstraint *orig_data = orig_con->data;
+
+ orig_data->dist = data->dist;
+ }
+ }
+
/* check if we're which way to clamp from, and calculate interpolation factor (if needed) */
if (data->mode == LIMITDIST_OUTSIDE) {
/* if inside, then move to surface */
@@ -2973,17 +2984,12 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
data->orglength = dist;
/* Write the computed length back to the master copy if in COW evaluation. */
- if (DEG_is_active(cob->depsgraph)) {
- Object *orig_ob = NULL;
- bConstraint *orig_con = constraint_find_original(cob->ob, cob->pchan, con, &orig_ob);
-
- if (orig_con != NULL) {
- bStretchToConstraint *orig_data = orig_con->data;
+ bConstraint *orig_con = constraint_find_original_for_update(cob, con);
- orig_data->orglength = data->orglength;
+ if (orig_con != NULL) {
+ bStretchToConstraint *orig_data = orig_con->data;
- DEG_id_tag_update(&orig_ob->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_TRANSFORM);
- }
+ orig_data->orglength = data->orglength;
}
}
@@ -5140,6 +5146,23 @@ static bConstraint *constraint_find_original(Object *ob, bPoseChannel *pchan, bC
return NULL;
}
+static bConstraint *constraint_find_original_for_update(bConstraintOb *cob, bConstraint *con)
+{
+ /* Write the computed distance back to the master copy if in COW evaluation. */
+ if (!DEG_is_active(cob->depsgraph)) {
+ return NULL;
+ }
+
+ Object *orig_ob = NULL;
+ bConstraint *orig_con = constraint_find_original(cob->ob, cob->pchan, con, &orig_ob);
+
+ if (orig_con != NULL) {
+ DEG_id_tag_update(&orig_ob->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_TRANSFORM);
+ }
+
+ return orig_con;
+}
+
/* -------- Constraints and Proxies ------- */
/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */