[Bf-blender-cvs] [81528822810] asset-greasepencil: GPencil: Fix empty preview image

Antonio Vazquez noreply at git.blender.org
Thu Jul 22 11:15:56 CEST 2021


Commit: 81528822810c5bcb02b8e2b8bbbbebc6836b685b
Author: Antonio Vazquez
Date:   Thu Jul 22 11:15:42 2021 +0200
Branches: asset-greasepencil
https://developer.blender.org/rB81528822810c5bcb02b8e2b8bbbbebc6836b685b

GPencil: Fix empty preview image

As the render preview uses a new scene, the active frame is set to 1, but grease pencil needs to have the current frame in the right place to display the strokes. Now the current frame number in the original frame is passes to scene creation function to set the same frame in the preview temporal scene.

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

M	source/blender/editors/render/render_preview.c

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

diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 17f4de578d7..b248d73411f 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -731,6 +731,8 @@ struct ObjectPreviewData {
   Object *object;
   /* Datablock copy. Can be NULL. */
   ID *datablock;
+  /* Current frame. */
+  int cfra;
   int sizex;
   int sizey;
 };
@@ -809,6 +811,7 @@ static void object_preview_render(IconPreview *preview, IconPreviewSize *preview
       /* Act on a copy. */
       .object = (Object *)preview->id_copy,
       .datablock = NULL,
+      .cfra = preview->scene->r.cfra,
       .sizex = preview_sized->sizex,
       .sizey = preview_sized->sizey,
   };
@@ -961,6 +964,9 @@ static Scene *gpencil_preview_scene_create(const struct ObjectPreviewData *previ
                                            Depsgraph **r_depsgraph)
 {
   Scene *scene = BKE_scene_add(preview_data->pr_main, "Object preview scene");
+  /* Grease pencil needs to set the scene to the current frame or the strokes
+   * will not be visible in the preview.  */
+  CFRA = preview_data->cfra;
   ViewLayer *view_layer = scene->view_layers.first;
   Depsgraph *depsgraph = DEG_graph_new(
       preview_data->pr_main, scene, view_layer, DAG_EVAL_VIEWPORT);
@@ -1016,6 +1022,7 @@ static void gpencil_preview_render(IconPreview *preview, IconPreviewSize *previe
       /* Act on a copy. */
       .object = NULL,
       .datablock = (ID *)preview->id_copy,
+      .cfra = preview->scene->r.cfra,
       .sizex = preview_sized->sizex,
       .sizey = preview_sized->sizey,
   };



More information about the Bf-blender-cvs mailing list