Cleanup: replace gpencil tri vars w/ array
This commit is contained in:
@@ -441,9 +441,7 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
|
|||||||
|
|
||||||
for (int i = 0; i < gps->tot_triangles; i++) {
|
for (int i = 0; i < gps->tot_triangles; i++) {
|
||||||
bGPDtriangle *stroke_triangle = &gps->triangles[i];
|
bGPDtriangle *stroke_triangle = &gps->triangles[i];
|
||||||
stroke_triangle->v1 = tmp_triangles[i][0];
|
memcpy(stroke_triangle->verts, tmp_triangles[i], sizeof(uint[3]));
|
||||||
stroke_triangle->v2 = tmp_triangles[i][1];
|
|
||||||
stroke_triangle->v3 = tmp_triangles[i][2];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -490,38 +488,24 @@ static void gp_draw_stroke_fill(
|
|||||||
/* Draw all triangles for filling the polygon (cache must be calculated before) */
|
/* Draw all triangles for filling the polygon (cache must be calculated before) */
|
||||||
BLI_assert(gps->tot_triangles >= 1);
|
BLI_assert(gps->tot_triangles >= 1);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
for (i = 0, stroke_triangle = gps->triangles; i < gps->tot_triangles; i++, stroke_triangle++) {
|
if (gps->flag & GP_STROKE_3DSPACE) {
|
||||||
if (gps->flag & GP_STROKE_3DSPACE) {
|
for (i = 0, stroke_triangle = gps->triangles; i < gps->tot_triangles; i++, stroke_triangle++) {
|
||||||
/* vertex 1 */
|
for (int j = 0; j < 3; j++) {
|
||||||
pt = &gps->points[stroke_triangle->v1];
|
pt = &gps->points[stroke_triangle->verts[j]];
|
||||||
mul_v3_m4v3(fpt, diff_mat, &pt->x);
|
mul_v3_m4v3(fpt, diff_mat, &pt->x);
|
||||||
glVertex3fv(fpt);
|
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);
|
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
float co[2];
|
else {
|
||||||
/* vertex 1 */
|
for (i = 0, stroke_triangle = gps->triangles; i < gps->tot_triangles; i++, stroke_triangle++) {
|
||||||
pt = &gps->points[stroke_triangle->v1];
|
for (int j = 0; j < 3; j++) {
|
||||||
mul_v3_m4v3(fpt, diff_mat, &pt->x);
|
float co[2];
|
||||||
gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
|
pt = &gps->points[stroke_triangle->verts[j]];
|
||||||
glVertex2fv(co);
|
mul_v3_m4v3(fpt, diff_mat, &pt->x);
|
||||||
/* vertex 2 */
|
gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
|
||||||
pt = &gps->points[stroke_triangle->v2];
|
glVertex2fv(co);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|||||||
@@ -60,11 +60,13 @@ typedef enum eGPDspoint_Flag {
|
|||||||
} eGPSPoint_Flag;
|
} eGPSPoint_Flag;
|
||||||
|
|
||||||
/* Grease-Pencil Annotations - 'Triangle'
|
/* Grease-Pencil Annotations - 'Triangle'
|
||||||
* -> A triangle contains the index of three vertices for filling the stroke
|
* A triangle contains the index of three vertices for filling the stroke
|
||||||
* This is only used if high quality fill is enabled
|
* This is only used if high quality fill is enabled.
|
||||||
|
* (not saved to blend file).
|
||||||
*/
|
*/
|
||||||
typedef struct bGPDtriangle {
|
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;
|
} bGPDtriangle;
|
||||||
|
|
||||||
/* GP brush (used for new strokes) */
|
/* GP brush (used for new strokes) */
|
||||||
|
|||||||
@@ -959,19 +959,19 @@ static void rna_def_gpencil_triangle(BlenderRNA *brna)
|
|||||||
|
|
||||||
/* point v1 */
|
/* point v1 */
|
||||||
prop = RNA_def_property(srna, "v1", PROP_INT, PROP_NONE);
|
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_ui_text(prop, "v1", "First triangle vertex index");
|
||||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
|
||||||
/* point v2 */
|
/* point v2 */
|
||||||
prop = RNA_def_property(srna, "v2", PROP_INT, PROP_NONE);
|
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_ui_text(prop, "v2", "Second triangle vertex index");
|
||||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
|
||||||
/* point v3 */
|
/* point v3 */
|
||||||
prop = RNA_def_property(srna, "v3", PROP_INT, PROP_NONE);
|
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_ui_text(prop, "v3", "Third triangle vertex index");
|
||||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user