[Bf-blender-cvs] [930ae8e3c42] master: GPencil: Lock rotation of textures

Antonioya noreply at git.blender.org
Thu May 9 19:53:49 CEST 2019


Commit: 930ae8e3c422f6c875ae933480dc4a4a9b2c2c51
Author: Antonioya
Date:   Thu May 9 19:53:25 2019 +0200
Branches: master
https://developer.blender.org/rB930ae8e3c422f6c875ae933480dc4a4a9b2c2c51

GPencil: Lock rotation of textures

By default the texture is locked and only the box is aligned when Follow Drawing Path is enabled.

Before, when the Follow was disabled, the texture was always aligned to top and it was not affected by object rotation. Now, the texture always is rotated with object rotation.

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

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 7dabbcf4c41..60b9f323e90 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -133,7 +133,8 @@ static void gpencil_vbo_ensure_size(GpencilBatchCacheElem *be, int totvertex)
 void DRW_gpencil_get_point_geom(GpencilBatchCacheElem *be,
                                 bGPDstroke *gps,
                                 short thickness,
-                                const float ink[4])
+                                const float ink[4],
+                                const bool follow)
 {
   int totvertex = gps->totpoints;
   if (be->vbo == NULL) {
@@ -177,26 +178,34 @@ void DRW_gpencil_get_point_geom(GpencilBatchCacheElem *be,
     /* use previous point to determine stroke direction */
     bGPDspoint *pt2 = NULL;
     float fpt[3];
-    if (i == 0) {
-      if (gps->totpoints > 1) {
-        /* extrapolate a point before first point */
-        pt2 = &gps->points[1];
-        interp_v3_v3v3(fpt, &pt2->x, &pt->x, 1.5f);
-        GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
+    if (!follow) {
+      /* add small offset to get a vector */
+      copy_v3_v3(fpt, &pt->x);
+      fpt[0] += 0.00001f;
+      fpt[1] += 0.00001f;
+      GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
+    }
+    else {
+      if (i == 0) {
+        if (gps->totpoints > 1) {
+          /* extrapolate a point before first point */
+          pt2 = &gps->points[1];
+          interp_v3_v3v3(fpt, &pt2->x, &pt->x, 1.5f);
+          GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
+        }
+        else {
+          /* add small offset to get a vector */
+          copy_v3_v3(fpt, &pt->x);
+          fpt[0] += 0.00001f;
+          fpt[1] += 0.00001f;
+          GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
+        }
       }
       else {
-        /* add small offset to get a vector */
-        copy_v3_v3(fpt, &pt->x);
-        fpt[0] += 0.00001f;
-        fpt[1] += 0.00001f;
-        GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
+        pt2 = &gps->points[i - 1];
+        GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, &pt2->x);
       }
     }
-    else {
-      pt2 = &gps->points[i - 1];
-      GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, &pt2->x);
-    }
-
     be->vbo_len++;
   }
 }
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 4b6c913785d..c23b4c254e4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -870,6 +870,7 @@ static void gpencil_add_stroke_vertexdata(GpencilBatchCache *cache,
   float ink[4];
   short sthickness;
   MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
+  const bool follow = ((gp_style) && (gp_style->flag & GP_STYLE_COLOR_LOCK_DOTS)) ? 0 : 1;
 
   /* set color using base color, tint color and opacity */
   if (cache->is_dirty) {
@@ -919,7 +920,7 @@ static void gpencil_add_stroke_vertexdata(GpencilBatchCache *cache,
     else {
       /* create vertex data */
       const int old_len = cache->b_point.vbo_len;
-      DRW_gpencil_get_point_geom(&cache->b_point, gps, sthickness, ink);
+      DRW_gpencil_get_point_geom(&cache->b_point, gps, sthickness, ink, follow);
 
       /* add to list of groups */
       if (old_len < cache->b_point.vbo_len) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 2ac1dc3211c..23c39a56dab 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -437,7 +437,8 @@ void DRW_gpencil_multisample_ensure(struct GPENCIL_Data *vedata, int rect_w, int
 void DRW_gpencil_get_point_geom(struct GpencilBatchCacheElem *be,
                                 struct bGPDstroke *gps,
                                 short thickness,
-                                const float ink[4]);
+                                const float ink[4],
+                                const bool follow);
 void DRW_gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be,
                                  struct bGPDstroke *gps,
                                  short thickness,
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
index a64a7ecb9be..af767245f63 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
@@ -70,9 +70,11 @@ float getAngle(vec2 pt0, vec2 pt1)
     return 0.0;
   }
 
+  /* disable, but keep for future follow modes 	
   if (use_follow_path == FALSE) {
     return 0.0;
   }
+  */
 
   /* default horizontal line (x-axis) in screen space */
   vec2 v0 = vec2(1.0, 0.0);



More information about the Bf-blender-cvs mailing list