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.
This commit is contained in:
Antonio Vazquez 2021-02-19 16:18:09 +01:00
parent 2b8c2438e4
commit 0d94695cc4
Notes: blender-bot 2023-02-14 08:10:10 +01:00
Referenced by issue #86105, Grease Pencil Time Offset Modifier does not work in 2.92
Referenced by issue #85958, Potential candidates for corrective releases
Referenced by issue #85745, Grease Pencil Modificador Time Offset Error
1 changed files with 12 additions and 2 deletions

View File

@ -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);
}
}
}