Constraint Shrinkwrap does not applies, it reset all changes #94600

Closed
opened 2022-01-03 13:31:15 +01:00 by Vladimir · 13 comments

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: 6844304dda
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:

Screenshot_20220103_152303.png

Exact steps for others to reproduce the error

Open test file shrinkwrap.blend

**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: `6844304dda` 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: ![Screenshot_20220103_152303.png](https://archive.blender.org/developer/F12786657/Screenshot_20220103_152303.png) **Exact steps for others to reproduce the error** Open test file [shrinkwrap.blend](https://archive.blender.org/developer/F12786659/shrinkwrap.blend)
Author

Added subscriber: @Wovchick

Added subscriber: @Wovchick
Member

Added subscribers: @Sergey, @dr.sybren, @lichtwerk

Added subscribers: @Sergey, @dr.sybren, @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

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

I am trying to follow D5007: Fix #60971 apply visual transform not working / ddc19819f3, 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:

P2696: T94600_snippet



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

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: could you share your wisdom?
CC @dr.sybren

Can confirm, Apply visual transform on the other hand seems to behave better. I am trying to follow [D5007: Fix #60971 apply visual transform not working](https://archive.blender.org/developer/D5007) / ddc19819f3, 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: [P2696: T94600_snippet](https://archive.blender.org/developer/P2696.txt) ``` diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index d284c32b1df..62e1c806dcd 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -5679,8 +5679,10 @@ bool BKE_constraint_apply_for_object(Depsgraph *depsgraph, bConstraint *new_con = BKE_constraint_duplicate_ex(con, 0, !ID_IS_LINKED(ob)); ListBase single_con = {new_con, new_con}; + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); + bConstraintOb *cob = BKE_constraints_make_evalob( - depsgraph, scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + depsgraph, scene, ob_eval, NULL, CONSTRAINT_OBTYPE_OBJECT); /* Undo the effect of the current constraint stack evaluation. */ mul_m4_m4m4(cob->matrix, ob->constinv, cob->matrix); ``` context: quote from [D5007](https://archive.blender.org/developer/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: could you share your wisdom? CC @dr.sybren

This issue was referenced by 15e4d0f25d

This issue was referenced by 15e4d0f25d75b54d26101d9a3a65272f77241ec8

This issue was referenced by 1b1e947162

This issue was referenced by 1b1e9471625d195d418c995375a1cc6a0833031a
Author

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

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

@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.

@lichtwerk The other usages of `BKE_constraints_make_evalob`happen 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.
Member

In #94600#1282908, @Wovchick 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 #94600#1283298, @Sergey wrote:
@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...

> In #94600#1282908, @Wovchick 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 #94600#1283298, @Sergey wrote: > @lichtwerk The other usages of `BKE_constraints_make_evalob`happen 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...

@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 :)

@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 :)
Member

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?

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 self-assigned this 2022-01-05 17:52:22 +01:00
Member

Doing some more digging

Doing some more digging
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#94600
No description provided.