[Bf-blender-cvs] [0d94695cc45] master: Fix T85745: Render grease pencil with time offset modifier fails

Antonio Vazquez noreply at git.blender.org
Fri Feb 19 16:18:45 CET 2021


Commit: 0d94695cc458b1f7666104314b57b174f0ee93d1
Author: Antonio Vazquez
Date:   Fri Feb 19 16:18:09 2021 +0100
Branches: master
https://developer.blender.org/rB0d94695cc458b1f7666104314b57b174f0ee93d1

Fix T85745: Render grease pencil with time offset modifier fails

The problem was introduced fixing task T85035. 

As the frame was set again when render, if there was a time modifier, the frame was not remaped to the right frame number.

===================================================================

M	source/blender/draw/engines/gpencil/gpencil_engine.c

===================================================================

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 4f8f1f7a456..5eaeeca8bab 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -23,6 +23,7 @@
 #include "DRW_render.h"
 
 #include "BKE_gpencil.h"
+#include "BKE_gpencil_modifier.h"
 #include "BKE_lib_id.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
@@ -621,11 +622,20 @@ void GPENCIL_cache_populate(void *ved, Object *ob)
     bool do_onion = (!pd->is_render) ? pd->do_onion : (gpd->onion_flag & GP_ONION_GHOST_ALWAYS);
     gpd->runtime.playing = (short)pd->playing;
 
-    /* When render in background the active frame could not be properly set due thread priority
+    /* When render in background the active frame could not be properly set due thread priority,
      * better set again. This is not required in viewport. */
     if (txl->render_depth_tx) {
+      const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
+      const DRWContextState *draw_ctx = DRW_context_state_get();
+
       LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
-        gpl->actframe = BKE_gpencil_layer_frame_get(gpl, pd->cfra, GP_GETFRAME_USE_PREV);
+        /* If there is a time modifier, need remap the time before. */
+        if (time_remap) {
+          gpl->actframe = BKE_gpencil_frame_retime_get(draw_ctx->depsgraph, pd->scene, ob, gpl);
+        }
+        else {
+          gpl->actframe = BKE_gpencil_layer_frame_get(gpl, pd->cfra, GP_GETFRAME_USE_PREV);
+        }
       }
     }



More information about the Bf-blender-cvs mailing list