Fix T58433: Limit Distance constraint distance not auto-computed.
Another case of a value that needs to be written back to non-COW copy.
This commit is contained in:
parent
18f0618677
commit
6a80a786f8
Notes:
blender-bot
2023-02-14 09:48:23 +01:00
Referenced by issue #58433, Limit distance constraint: reset distance does not work
|
@ -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);
|
||||
bConstraint *orig_con = constraint_find_original_for_update(cob, con);
|
||||
|
||||
if (orig_con != NULL) {
|
||||
bStretchToConstraint *orig_data = orig_con->data;
|
||||
if (orig_con != NULL) {
|
||||
bStretchToConstraint *orig_data = orig_con->data;
|
||||
|
||||
orig_data->orglength = data->orglength;
|
||||
|
||||
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) */
|
||||
|
|
Loading…
Reference in New Issue