Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-10-20 01:28:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-20 01:28:12 +0300
commitcb957fd8e0e2e0d0dbbebc3e7e3fcc5bfa8b51a8 (patch)
tree0c0ac2c123dc23a00d8ea1b44a3de894225fba37 /source/blender
parent465b6333ccb5b56ced54ca342c60086c60ab21db (diff)
Cleanup: replace gpencil tri vars w/ array
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c52
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h8
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c6
3 files changed, 26 insertions, 40 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index c08ed0db400..bba7137c3ee 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -441,9 +441,7 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
for (int i = 0; i < gps->tot_triangles; i++) {
bGPDtriangle *stroke_triangle = &gps->triangles[i];
- stroke_triangle->v1 = tmp_triangles[i][0];
- stroke_triangle->v2 = tmp_triangles[i][1];
- stroke_triangle->v3 = tmp_triangles[i][2];
+ memcpy(stroke_triangle->verts, tmp_triangles[i], sizeof(uint[3]));
}
}
else {
@@ -490,38 +488,24 @@ static void gp_draw_stroke_fill(
/* Draw all triangles for filling the polygon (cache must be calculated before) */
BLI_assert(gps->tot_triangles >= 1);
glBegin(GL_TRIANGLES);
- for (i = 0, stroke_triangle = gps->triangles; i < gps->tot_triangles; i++, stroke_triangle++) {
- if (gps->flag & GP_STROKE_3DSPACE) {
- /* vertex 1 */
- pt = &gps->points[stroke_triangle->v1];
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
- glVertex3fv(fpt);
- /* vertex 2 */
- pt = &gps->points[stroke_triangle->v2];
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
- glVertex3fv(fpt);
- /* vertex 3 */
- pt = &gps->points[stroke_triangle->v3];
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
- glVertex3fv(fpt);
+ if (gps->flag & GP_STROKE_3DSPACE) {
+ for (i = 0, stroke_triangle = gps->triangles; i < gps->tot_triangles; i++, stroke_triangle++) {
+ for (int j = 0; j < 3; j++) {
+ pt = &gps->points[stroke_triangle->verts[j]];
+ mul_v3_m4v3(fpt, diff_mat, &pt->x);
+ glVertex3fv(fpt);
+ }
}
- else {
- float co[2];
- /* vertex 1 */
- pt = &gps->points[stroke_triangle->v1];
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
- gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
- glVertex2fv(co);
- /* vertex 2 */
- pt = &gps->points[stroke_triangle->v2];
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
- gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
- glVertex2fv(co);
- /* vertex 3 */
- pt = &gps->points[stroke_triangle->v3];
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
- gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
- glVertex2fv(co);
+ }
+ else {
+ for (i = 0, stroke_triangle = gps->triangles; i < gps->tot_triangles; i++, stroke_triangle++) {
+ for (int j = 0; j < 3; j++) {
+ float co[2];
+ pt = &gps->points[stroke_triangle->verts[j]];
+ mul_v3_m4v3(fpt, diff_mat, &pt->x);
+ gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
+ glVertex2fv(co);
+ }
}
}
glEnd();
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 0364d855f69..a62538d1032 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -60,11 +60,13 @@ typedef enum eGPDspoint_Flag {
} eGPSPoint_Flag;
/* Grease-Pencil Annotations - 'Triangle'
- * -> A triangle contains the index of three vertices for filling the stroke
- * This is only used if high quality fill is enabled
+ * A triangle contains the index of three vertices for filling the stroke
+ * This is only used if high quality fill is enabled.
+ * (not saved to blend file).
*/
typedef struct bGPDtriangle {
- int v1, v2, v3; /* indices for tesselated triangle used for GP Fill */
+ /* indices for tesselated triangle used for GP Fill */
+ unsigned int verts[3];
} bGPDtriangle;
/* GP brush (used for new strokes) */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index a2733b91427..b15f6dbccfa 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -959,19 +959,19 @@ static void rna_def_gpencil_triangle(BlenderRNA *brna)
/* point v1 */
prop = RNA_def_property(srna, "v1", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "v1");
+ RNA_def_property_int_sdna(prop, NULL, "verts[0]");
RNA_def_property_ui_text(prop, "v1", "First triangle vertex index");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
/* point v2 */
prop = RNA_def_property(srna, "v2", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "v2");
+ RNA_def_property_int_sdna(prop, NULL, "verts[1]");
RNA_def_property_ui_text(prop, "v2", "Second triangle vertex index");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
/* point v3 */
prop = RNA_def_property(srna, "v3", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "v3");
+ RNA_def_property_int_sdna(prop, NULL, "verts[2]");
RNA_def_property_ui_text(prop, "v3", "Third triangle vertex index");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}