[Bf-blender-cvs] [866d7a1dbd3] asset-greasepencil: GPencil: Add missing preview handling

Antonio Vazquez noreply at git.blender.org
Thu Jul 8 20:56:46 CEST 2021


Commit: 866d7a1dbd387356d9c20fa061a0bb36de74db43
Author: Antonio Vazquez
Date:   Thu Jul 8 20:56:42 2021 +0200
Branches: asset-greasepencil
https://developer.blender.org/rB866d7a1dbd387356d9c20fa061a0bb36de74db43

GPencil: Add missing preview handling

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

M	source/blender/blenkernel/intern/gpencil.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index a90875604c5..8420ee89674 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -77,7 +77,7 @@ static CLG_LogRef LOG = {"bke.gpencil"};
 static void greasepencil_copy_data(Main *UNUSED(bmain),
                                    ID *id_dst,
                                    const ID *id_src,
-                                   const int UNUSED(flag))
+                                   const int flag)
 {
   bGPdata *gpd_dst = (bGPdata *)id_dst;
   const bGPdata *gpd_src = (const bGPdata *)id_src;
@@ -123,6 +123,13 @@ static void greasepencil_copy_data(Main *UNUSED(bmain),
 
     BLI_addtail(&gpd_dst->layers, gpl_dst);
   }
+
+  if (flag & LIB_ID_COPY_NO_PREVIEW) {
+    gpd_dst->preview = NULL;
+  }
+  else {
+    BKE_previewimg_id_copy(&gpd_dst->id, &gpd_src->id);
+  }
 }
 
 static void greasepencil_free_data(ID *id)
@@ -190,6 +197,8 @@ static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id
         }
       }
     }
+
+    BKE_previewimg_blend_write(writer, gpd->preview);
   }
 }
 
@@ -204,6 +213,10 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd)
   BLO_read_data_address(reader, &gpd->adt);
   BKE_animdata_blend_read_data(reader, gpd->adt);
 
+  /* Preview. */
+  BLO_read_data_address(reader, &gpd->preview);
+  BKE_previewimg_blend_read(reader, gpd->preview);
+
   /* Ensure full objectmode for linked grease pencil. */
   if (gpd->id.lib != NULL) {
     gpd->flag &= ~GP_DATA_STROKE_PAINTMODE;



More information about the Bf-blender-cvs mailing list