[Bf-blender-cvs] [5f08a28304d] greasepencil-refactor: GPencil: Remove ol UV data from triangle struct

Antonio Vazquez noreply at git.blender.org
Wed Dec 11 10:35:59 CET 2019


Commit: 5f08a28304d58065bf4a9074a338a96223f756ae
Author: Antonio Vazquez
Date:   Wed Dec 11 10:29:33 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB5f08a28304d58065bf4a9074a338a96223f756ae

GPencil: Remove ol UV data from triangle struct

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

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/editors/gpencil/drawgpencil.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 066d2ee51af..534b2c66a5c 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2736,13 +2736,9 @@ void BKE_gpencil_triangulate_stroke_fill(bGPdata *gpd, bGPDstroke *gps)
     for (int i = 0; i < gps->tot_triangles; i++) {
       bGPDtriangle *stroke_triangle = &gps->triangles[i];
       memcpy(gps->triangles[i].verts, tmp_triangles[i], sizeof(uint[3]));
-      /* copy texture coordinates */
-      copy_v2_v2(stroke_triangle->uv[0], uv[tmp_triangles[i][0]]);
-      copy_v2_v2(stroke_triangle->uv[1], uv[tmp_triangles[i][1]]);
-      copy_v2_v2(stroke_triangle->uv[2], uv[tmp_triangles[i][2]]);
     }
 
-    /* Copy UVs to bGPDspoint. (might not be the right place for that) */
+    /* Copy UVs to bGPDspoint. */
     for (int i = 0; i < gps->totpoints; i++) {
       copy_v2_v2(gps->points[i].uv_fill, uv[i]);
     }
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 927b85a4385..fea053d1e1b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -318,14 +318,13 @@ static void gpencil_set_fill_point(GPUVertBuf *vbo,
                                    int idx,
                                    bGPDspoint *pt,
                                    const float fcolor[4],
-                                   const float uv[2],
                                    uint pos_id,
                                    uint color_id,
                                    uint text_id)
 {
   GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt->x);
   GPU_vertbuf_attr_set(vbo, color_id, idx, fcolor);
-  GPU_vertbuf_attr_set(vbo, text_id, idx, uv);
+  GPU_vertbuf_attr_set(vbo, text_id, idx, pt->uv_fill);
 }
 
 static void gpencil_vbo_ensure_size(GpencilBatchCacheElem *be, int totvertex)
@@ -628,7 +627,6 @@ void gpencil_get_fill_geom(struct GpencilBatchCacheElem *be,
                              be->vbo_len,
                              &gps->points[stroke_triangle->verts[j]],
                              color,
-                             stroke_triangle->uv[j],
                              be->pos_id,
                              be->color_id,
                              be->uvdata_id);
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 06e5f36637b..e029fec7056 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -322,14 +322,14 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
     else {
       gps->triangles = MEM_recallocN(gps->triangles, sizeof(*gps->triangles) * gps->tot_triangles);
     }
+    /* Copy UVs to bGPDspoint. */
+    for (int i = 0; i < gps->totpoints; i++) {
+      copy_v2_v2(gps->points[i].uv_fill, uv[i]);
+    }
 
     for (int i = 0; i < gps->tot_triangles; i++) {
       bGPDtriangle *stroke_triangle = &gps->triangles[i];
       memcpy(stroke_triangle->verts, tmp_triangles[i], sizeof(uint[3]));
-      /* copy texture coordinates */
-      copy_v2_v2(stroke_triangle->uv[0], uv[tmp_triangles[i][0]]);
-      copy_v2_v2(stroke_triangle->uv[1], uv[tmp_triangles[i][1]]);
-      copy_v2_v2(stroke_triangle->uv[2], uv[tmp_triangles[i][2]]);
     }
   }
   else {
@@ -354,7 +354,6 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
 
 /* add a new fill point and texture coordinates to vertex buffer */
 static void gp_add_filldata_tobuffer(const bGPDspoint *pt,
-                                     const float uv[2],
                                      uint pos,
                                      uint texcoord,
                                      short flag,
@@ -375,8 +374,8 @@ static void gp_add_filldata_tobuffer(const bGPDspoint *pt,
     fpt[2] = 0.0f; /* 2d always is z=0.0f */
   }
 
-  immAttr2f(texcoord, uv[0], uv[1]); /* texture coordinates */
-  immVertex3fv(pos, fpt);            /* position */
+  immAttr2f(texcoord, pt->uv_fill[0], pt->uv_fill[1]); /* texture coordinates */
+  immVertex3fv(pos, fpt);                              /* position */
 }
 
 #if 0 /* GPXX disabled, not used in annotations */
@@ -477,7 +476,6 @@ static void gp_draw_stroke_fill(bGPdata *gpd,
   for (int i = 0; i < gps->tot_triangles; i++, stroke_triangle++) {
     for (int j = 0; j < 3; j++) {
       gp_add_filldata_tobuffer(&gps->points[stroke_triangle->verts[j]],
-                               stroke_triangle->uv[j],
                                pos,
                                texcoord,
                                gps->flag,
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 80675d99d1b..5bbad05e90f 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -111,8 +111,6 @@ typedef enum eGPDspoint_Flag {
 typedef struct bGPDtriangle {
   /* indices for tessellated triangle used for GP Fill */
   unsigned int verts[3];
-  /* texture coordinates for verts */
-  float uv[3][2];
 } bGPDtriangle;
 
 /* ***************************************** */



More information about the Bf-blender-cvs mailing list