Grease Pencil Apply Armature Modifier Issue #62715

Closed
opened 2019-03-18 16:43:28 +01:00 by David · 7 comments

System Information
Operating system: macOS Mojave
Graphics card: NVIDIA GeForce GTX 675MX 1024 MB
Processor: 3.2 GHz Intel Core i5

Blender Version
Broken: (example: 2.80, 9099305771ec-x86_64, master, 2019-03-17, as found on the splash screen)

Short description of error
I've added an armature modifier to a grease pencil object.
When I try to apply the modifier the grease pencil object snaps back to its original position.

Every other modifier (lattice, hook, thickness) work perfectly fine when the modifier is applied.
It appears as though the Armature Modifier Apply option is not connecting with the Grease Pencil Data.

Here is a video demonstrating the current results:
https://www.levelpixellevel.com/greasepencilarmatureapply.html

I've attached a file with an example
grease_pencil_apply_armature.blend

Exact steps for others to reproduce the error
Make a simple grease pencil stroke.
Attach it via armature modifier to a simple armature.
Move the armature in pose mode to a new location.
Hit apply on the armature modifier.
Grease pencil object goes back to the original location.

**System Information** Operating system: macOS Mojave Graphics card: NVIDIA GeForce GTX 675MX 1024 MB Processor: 3.2 GHz Intel Core i5 **Blender Version** Broken: (example: 2.80, 9099305771ec-x86_64, master, 2019-03-17, as found on the splash screen) **Short description of error** I've added an armature modifier to a grease pencil object. When I try to apply the modifier the grease pencil object snaps back to its original position. Every other modifier (lattice, hook, thickness) work perfectly fine when the modifier is applied. It appears as though the Armature Modifier Apply option is not connecting with the Grease Pencil Data. Here is a video demonstrating the current results: https://www.levelpixellevel.com/greasepencilarmatureapply.html I've attached a file with an example [grease_pencil_apply_armature.blend](https://archive.blender.org/developer/F6844831/grease_pencil_apply_armature.blend) **Exact steps for others to reproduce the error** Make a simple grease pencil stroke. Attach it via armature modifier to a simple armature. Move the armature in pose mode to a new location. Hit apply on the armature modifier. Grease pencil object goes back to the original location.
Author

Added subscriber: @LevelPixelLevel

Added subscriber: @LevelPixelLevel
Antonio Vazquez self-assigned this 2019-03-18 17:41:37 +01:00

Added subscriber: @Sergey

Added subscriber: @Sergey

@Sergey I don't know why it's not working the armature deform here.

If you look at MOD_gpencilarmature.c in function bakeModifier() you will see the apply is using the same logic used in viewport (also other modifiers like Hook use the same logic). Ihave done a debug and the function is executed, but the deformed point is equal to original point. It looks the armature is not deformed.

Maybe there are something wrong in the loop around BKE_scene_graph_update_for_newframe() or the armatures need something else/different.

Could you help me here?

@Sergey I don't know why it's not working the armature deform here. If you look at **MOD_gpencilarmature.c** in function **bakeModifier()** you will see the apply is using the same logic used in viewport (also other modifiers like Hook use the same logic). Ihave done a debug and the function is executed, but the deformed point is equal to original point. It looks the armature is not deformed. Maybe there are something wrong in the loop around *BKE_scene_graph_update_for_newframe()* or the armatures need something else/different. Could you help me here?

@antoniov, dependency graph operates in an evaluated domain, with all IDs being copied and decoupled from the original ones. The bakeModifier() does proper way of updating dependency graph for the new frame, but then it attempts to use original object to deform vertices.
That could work in some cases, because generally transformation matrices are copied back to original, but you should not rely on that.
Proper solution is to do all evaluation and deformation in the evaluated domain, and them copy things back (or, at least, pass all the evaluated datablocks to deformation and pass original data to be deformed).

Anyway, code worth 1000s words: P939: Fix #62715

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
index 11e648e355d..39738c663e0 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
@@ -119,8 +119,10 @@ static void bakeModifier(
         Main *bmain, Depsgraph *depsgraph,
         GpencilModifierData *md, Object *ob)
 {
-	ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md;
 	Scene *scene = DEG_get_evaluated_scene(depsgraph);
+	Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+	ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md;
+	GpencilModifierData *md_eval = BKE_gpencil_modifiers_findByName(object_eval, md->name);
 	bGPdata *gpd = ob->data;
 	int oldframe = (int)DEG_get_ctime(depsgraph);
 
@@ -137,7 +139,7 @@ static void bakeModifier(
 
 			/* compute armature effects on this frame */
 			for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
-				deformStroke(md, depsgraph, ob, gpl, gps);
+				deformStroke(md_eval, depsgraph, object_eval, gpl, gps);
 			}
 		}
 	}

The reason it was failing is because md points to an original armature, which doesn't have runtime data needed for deformation. That dtaa is to come from evaluated armature.

@antoniov, dependency graph operates in an evaluated domain, with all IDs being copied and decoupled from the original ones. The `bakeModifier()` does proper way of updating dependency graph for the new frame, but then it attempts to use original object to deform vertices. That could work in some cases, because generally transformation matrices are copied back to original, but you should not rely on that. Proper solution is to do all evaluation and deformation in the evaluated domain, and them copy things back (or, at least, pass all the evaluated datablocks to deformation and pass original data to be deformed). Anyway, code worth 1000s words: [P939: Fix #62715](https://archive.blender.org/developer/P939.txt) ``` diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c index 11e648e355d..39738c663e0 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c @@ -119,8 +119,10 @@ static void bakeModifier( Main *bmain, Depsgraph *depsgraph, GpencilModifierData *md, Object *ob) { - ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; Scene *scene = DEG_get_evaluated_scene(depsgraph); + Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); + ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; + GpencilModifierData *md_eval = BKE_gpencil_modifiers_findByName(object_eval, md->name); bGPdata *gpd = ob->data; int oldframe = (int)DEG_get_ctime(depsgraph); @@ -137,7 +139,7 @@ static void bakeModifier( /* compute armature effects on this frame */ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { - deformStroke(md, depsgraph, ob, gpl, gps); + deformStroke(md_eval, depsgraph, object_eval, gpl, gps); } } } ``` The reason it was failing is because md points to an original armature, which doesn't have runtime data needed for deformation. That dtaa is to come from evaluated armature.

This issue was referenced by 08fe29e52f

This issue was referenced by 08fe29e52f161398682570eff45d8de391b73df8

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

@antoniov and @Sergey thank you for fixing this so quickly!

@antoniov and @Sergey thank you for fixing this so quickly!
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#62715
No description provided.