Maniphest T94600

Constraint Shrinkwrap does not applies, it reset all changes
Closed, Resolved

Assigned To
Philipp Oeser (lichtwerk)
Authored By
Wovchik (microcoder)
Jan 3 2022, 1:31 PM
Tags
  • BF Blender
  • Animation & Rigging
  • Dependency Graph
Subscribers
Philipp Oeser (lichtwerk)
Sergey Sharybin (sergey)
Sybren A. Stüvel (sybren)
Wovchik (microcoder)

Description

System Information
Operating system: Linux-5.15.12-1-MANJARO-x86_64-with-glibc2.33 64 Bits
Graphics card: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2) Intel Open Source Technology Center 4.5 (Core Profile) Mesa 21.3.3

Blender Version
Broken: version: 3.1.0 Alpha, branch: makepkg (modified), commit date: 2021-12-31 20:32, hash: rB6844304dda49
Worked: (newest version of Blender that worked as expected)

Short description of error

Constraint (not modifier) Shrinkwrap does not applies, after click Apply it reset all changes:

Exact steps for others to reproduce the error

Open test file

Revisions and Commits

rB Blender
D13765
D13765

Related Objects

Mentioned In
T93479: 3.0 Potential candidates for corrective releases
Mentioned Here
rBddc19819f33a: Fix T60971: Apply visual transform not working
P2696 T94600_snippet
D5007: Fix T60971 apply visual transform not working

Event Timeline

Wovchik (microcoder) created this task.Jan 3 2022, 1:31 PM
Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Jan 3 2022, 4:33 PM
Philipp Oeser (lichtwerk) added projects: Animation & Rigging, Dependency Graph.
Philipp Oeser (lichtwerk) added subscribers: Sergey Sharybin (sergey), Sybren A. Stüvel (sybren), Philipp Oeser (lichtwerk).

Can confirm, Apply visual transform on the other hand seems to behave better.

I am trying to follow D5007: Fix T60971 apply visual transform not working / rBddc19819f33a: Fix T60971: Apply visual transform not working, but its kinda for me hard to read the comments in relation to what was committed, so what is really necessary in the combo of BKE_constraints_make_evalob & BKE_constraints_solve. I assume this should always be fed with evaluated objects, and if I do the following, we indeed get proper results:

1
2
3diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
4index d284c32b1df..62e1c806dcd 100644
5--- a/source/blender/blenkernel/intern/constraint.c
6+++ b/source/blender/blenkernel/intern/constraint.c
7@@ -5679,8 +5679,10 @@ bool BKE_constraint_apply_for_object(Depsgraph *depsgraph,
8 bConstraint *new_con = BKE_constraint_duplicate_ex(con, 0, !ID_IS_LINKED(ob));
9 ListBase single_con = {new_con, new_con};
10
11+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
12+
13 bConstraintOb *cob = BKE_constraints_make_evalob(
14- depsgraph, scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
15+ depsgraph, scene, ob_eval, NULL, CONSTRAINT_OBTYPE_OBJECT);
16 /* Undo the effect of the current constraint stack evaluation. */
17 mul_m4_m4m4(cob->matrix, ob->constinv, cob->matrix);
18

context: quote from D5007:

It is unreliable to use BKE_object_where_is_calc on original object: it might depend on constraints which needs final geometry which does not exist in an original domain.

However if I look at other places with the combo of BKE_constraints_make_evalob & BKE_constraints_solve, these dont necessarily get evaluated objects/pchans either, so my understanding might be limited here...

@Sergey Sharybin (sergey): could you share your wisdom?
CC @Sybren A. Stüvel (sybren)

Wovchik (microcoder) added a comment.Jan 4 2022, 9:35 PM

Hmm... Interested... if the object Cube join to Sphere (CTRL+J) then the constraint apply correctly! it means that somewhere it is already implemented in the code, it remains to find and refer to this method

Sergey Sharybin (sergey) added a comment.Jan 5 2022, 3:44 PM

@Philipp Oeser (lichtwerk) The other usages of BKE_constraints_make_evalobhappen from inside evaluation, so they are intended to operate on exact data they are given (which happened to be evaluated).

Not really sure why BKE_constraint_apply_for_object needs to access evaluated object (the matrices and such are copied from evaluated to original in the BKE_object_sync_to_original). Would be really nice to know what is it missing there to have proper behavior without requesting evaluated object.

Philipp Oeser (lichtwerk) added a comment.Jan 5 2022, 3:56 PM
In T94600#1282908, @Wovchik (microcoder) wrote:

Hmm... Interested... if the object Cube join to Sphere (CTRL+J) then the constraint apply correctly! it means that somewhere it is already implemented in the code, it remains to find and refer to this method

Like I said, Object > Apply > Visual Transform is also fine

In T94600#1283298, @Sergey Sharybin (sergey) wrote:

@Philipp Oeser (lichtwerk) The other usages of BKE_constraints_make_evalobhappen from inside evaluation, so they are intended to operate on exact data they are given (which happened to be evaluated).

Not really sure why BKE_constraint_apply_for_object needs to access evaluated object (the matrices and such are copied from evaluated to original in the BKE_object_sync_to_original). Would be really nice to know what is it missing there to have proper behavior without requesting evaluated object.

Will see if I can continue digging in a bit...

Sergey Sharybin (sergey) added a comment.Jan 5 2022, 4:27 PM

@Philipp Oeser (lichtwerk), actually, constraint might need an evaluated state of target's geometry (so object matrices is not enough for correct behavior). So your proposed patch is actually correct :)

Philipp Oeser (lichtwerk) added a comment.Jan 5 2022, 5:11 PM

Since the example file does not actually have anything acting on its geometry, should I investigate further why there is something wrong with the matrices? Create a Diff? Commit straight?

Philipp Oeser (lichtwerk) claimed this task.Jan 5 2022, 5:52 PM

Doing some more digging

Philipp Oeser (lichtwerk) closed this task as Resolved by committing rB1b1e9471625d: Fix T94600: Apply single shrinkwrap constraint fails.Jan 10 2022, 12:04 PM
Philipp Oeser (lichtwerk) added a commit: rB1b1e9471625d: Fix T94600: Apply single shrinkwrap constraint fails.
Philipp Oeser (lichtwerk) added a commit: rB15e4d0f25d75: Fix T94600: Apply single shrinkwrap constraint fails.Jan 11 2022, 10:39 AM