[Bf-blender-cvs] [dbf4ddbe167] greasepencil-refactor: GPencil: Move opacity factor to stroke from runtime

Antonio Vazquez noreply at git.blender.org
Sun Jan 19 16:40:52 CET 2020


Commit: dbf4ddbe167eca0db52fa31ea53493578a3da1ff
Author: Antonio Vazquez
Date:   Sun Jan 19 16:35:54 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBdbf4ddbe167eca0db52fa31ea53493578a3da1ff

GPencil: Move opacity factor to stroke from runtime

If the modifier is applied, need to be in the stroke.

Note: Maybe we need to active this value in some sculpt brush to define the opacity of the Fill, because when you apply the modiifer, you can only replace the value using the modifier again. Other solution would be a reset opacity operator.

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

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/intern/draw_cache_impl_gpencil.c
M	source/blender/editors/gpencil/annotate_paint.c
M	source/blender/editors/gpencil/gpencil_primitive.c
M	source/blender/editors/space_view3d/view3d_gizmo_ruler.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
M	source/blender/makesdna/DNA_gpencil_types.h

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index a71735bea65..931f7448886 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -498,6 +498,7 @@ bGPDstroke *BKE_gpencil_stroke_add(bGPDframe *gpf, int mat_idx, int totpoints, s
   bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
 
   gps->thickness = thickness;
+  gps->fill_opacity_fac = 1.0f;
   gps->gradient_f = 1.0f;
   gps->gradient_s[0] = 1.0f;
   gps->gradient_s[1] = 1.0f;
@@ -3298,6 +3299,7 @@ static void gpencil_convert_spline(Main *bmain,
   /* Create Stroke. */
   bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "bGPDstroke");
   gps->thickness = 1.0f;
+  gps->fill_opacity_fac = 1.0f;
   gps->gradient_f = 1.0f;
   gps->uv_scale = 1.0f;
 
@@ -3810,9 +3812,6 @@ void BKE_gpencil_frame_original_pointers_update(const struct bGPDframe *gpf_orig
       if (gps_eval != NULL) {
         gps_eval->runtime.gps_orig = gps_orig;
 
-        /* Reset fill opacity. */
-        gps_eval->runtime.fill_opacity_fac = 1.0f;
-
         /* Assign original point pointer. */
         for (int i = 0; i < gps_orig->totpoints; i++) {
           bGPDspoint *pt_eval = &gps_eval->points[i];
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 39e7a6fa87a..a86cf71ff7a 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4464,6 +4464,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 
           LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
             LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+              /* Set initial opacity for fill color. */
+              gps->fill_opacity_fac = 1.0f;
 
               /* Calc geometry data because in old versions this data was not saved. */
               BKE_gpencil_stroke_geometry_update(gps);
diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index 3158af5eab5..312bb2cd9b6 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -277,7 +277,7 @@ static void gpencil_buffer_add_point(gpStrokeVert *verts,
   /* Encode fill opacity defined by opacity modifier in vertex color alpha. If
    * no opacity modifier, the value will be always 1.0f. The opacity factor can be any
    * value between 0.0f and 2.0f */
-  col->fcol[3] = (((int)(col->fcol[3] * 10000.0f)) * 10.0f) + gps->runtime.fill_opacity_fac;
+  col->fcol[3] = (((int)(col->fcol[3] * 10000.0f)) * 10.0f) + gps->fill_opacity_fac;
 
   vert->strength = (round_cap0) ? pt->strength : -pt->strength;
   vert->u_stroke = pt->uv_fac;
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 9cc10fa1f04..8fcbd2b51c0 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -599,6 +599,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
   /* copy appropriate settings for stroke */
   gps->totpoints = totelem;
   gps->thickness = gpl->thickness;
+  gps->fill_opacity_fac = 1.0f;
   gps->gradient_f = 1.0f;
   gps->gradient_s[0] = 1.0f;
   gps->gradient_s[1] = 1.0f;
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index cd48a3dc736..052ba55460f 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -359,6 +359,7 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
   /* create new temp stroke */
   bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "Temp bGPDstroke");
   gps->thickness = 2.0f;
+  gps->fill_opacity_fac = 1.0f;
   gps->gradient_f = 1.0f;
   gps->gradient_s[0] = 1.0f;
   gps->gradient_s[1] = 1.0f;
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index 604e73d34d1..97451edb148 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -479,6 +479,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup)
     gps->flag = GP_STROKE_3DSPACE;
     gps->thickness = 3;
     gps->gradient_f = 1.0f;
+    gps->fill_opacity_fac = 1.0f;
     gps->gradient_s[0] = 1.0f;
     gps->gradient_s[1] = 1.0f;
     gps->uv_scale = 1.0f;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
index 423e04110b9..e1aeec94574 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
@@ -116,7 +116,7 @@ static void deformStroke(GpencilModifierData *md,
 
   /* Fill using opacity factor. */
   if (mmd->modify_color != GP_MODIFY_COLOR_STROKE) {
-    gps->runtime.fill_opacity_fac = mmd->factor;
+    gps->fill_opacity_fac = mmd->factor;
   }
 }
 
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 442a905c814..8d07749bcec 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -182,8 +182,7 @@ typedef struct bGPDstroke_Runtime {
   int stroke_start;
   /** Triangle offset in the ibo where this fill starts. */
   int fill_start;
-  /** Factor of opacity for Fill color (used by opacity modifier). */
-  float fill_opacity_fac;
+  int _pad[1];
 
   /** Original stroke (used to dereference evaluated data) */
   struct bGPDstroke *gps_orig;
@@ -225,7 +224,9 @@ typedef struct bGPDstroke {
   float gradient_f;
   /** factor xy of shape for dots gradients */
   float gradient_s[2];
-  char _pad_3[4];
+
+  /** Factor of opacity for Fill color (used by opacity modifier). */
+  float fill_opacity_fac;
 
   /** UV rotation */
   float uv_rotation;



More information about the Bf-blender-cvs mailing list