From 8a62fa9855124dbfa4001eccc073cb0ee65f9212 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Fri, 27 Mar 2020 12:31:30 +0100 Subject: GPencil: Cleanup of unused code a arguments --- source/blender/editors/gpencil/drawgpencil.c | 280 --------------------------- 1 file changed, 280 deletions(-) (limited to 'source/blender/editors/gpencil/drawgpencil.c') diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 7107aacad37..7b1e985fb7d 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -160,48 +160,6 @@ static void gp_calc_2d_stroke_fxy( } /* ----------- Volumetric Strokes --------------- */ -/* draw a 2D strokes in "volumetric" style */ -static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points, - int totpoints, - short thickness, - short UNUSED(dflag), - short sflag, - int offsx, - int offsy, - int winx, - int winy, - const float diff_mat[4][4], - const float ink[4]) -{ - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); - uint color = GPU_vertformat_attr_add( - format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); - - immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); - GPU_program_point_size(true); - immBegin(GPU_PRIM_POINTS, totpoints); - - const bGPDspoint *pt = points; - for (int i = 0; i < totpoints; i++, pt++) { - /* transform position to 2D */ - float co[2]; - float fpt[3]; - - mul_v3_m4v3(fpt, diff_mat, &pt->x); - gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co); - - gp_set_point_varying_color(pt, ink, color, false); - immAttr1f(size, pt->pressure * thickness); /* TODO: scale based on view transform */ - immVertex2f(pos, co[0], co[1]); - } - - immEnd(); - immUnbindProgram(); - GPU_program_point_size(false); -} - /* draw a 3D stroke in "volumetric" style */ static void gp_draw_stroke_volumetric_3d(const bGPDspoint *points, int totpoints, @@ -234,50 +192,6 @@ static void gp_draw_stroke_volumetric_3d(const bGPDspoint *points, /* ----- Existing Strokes Drawing (3D and Point) ------ */ -/* draw a given stroke - just a single dot (only one point) */ -static void gp_draw_stroke_point(const bGPDspoint *points, - short thickness, - short UNUSED(dflag), - short sflag, - int offsx, - int offsy, - int winx, - int winy, - const float diff_mat[4][4], - const float ink[4]) -{ - const bGPDspoint *pt = points; - - /* get final position using parent matrix */ - float fpt[3]; - mul_v3_m4v3(fpt, diff_mat, &pt->x); - - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - - if (sflag & GP_STROKE_3DSPACE) { - immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); - } - else { - immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); - - /* get 2D coordinates of point */ - float co[3] = {0.0f}; - gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co); - copy_v3_v3(fpt, co); - } - - gp_set_point_uniform_color(pt, ink); - /* set point thickness (since there's only one of these) */ - immUniform1f("size", (float)(thickness + 2) * pt->pressure); - - immBegin(GPU_PRIM_POINTS, 1); - immVertex3fv(pos, fpt); - immEnd(); - - immUnbindProgram(); -} - /* draw a given stroke in 3d (i.e. in 3d-space) */ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4], bool cyclic) { @@ -370,200 +284,6 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4 immUnbindProgram(); } -/* ----- Fancy 2D-Stroke Drawing ------ */ - -/* draw a given stroke in 2d */ -static void gp_draw_stroke_2d(const bGPDspoint *points, - int totpoints, - short thickness_s, - short dflag, - short sflag, - bool UNUSED(debug), - int offsx, - int offsy, - int winx, - int winy, - const float diff_mat[4][4], - const float ink[4]) -{ - /* otherwise thickness is twice that of the 3D view */ - float thickness = (float)thickness_s * 0.5f; - - /* strokes in Image Editor need a scale factor, since units there are not pixels! */ - float scalefac = 1.0f; - if ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) { - scalefac = 0.001f; - } - - /* TODO: fancy++ with the magic of shaders */ - - /* tessellation code - draw stroke as series of connected quads (triangle strips in fact) - * with connection edges rotated to minimize shrinking artifacts, and rounded endcaps. - */ - { - const bGPDspoint *pt1, *pt2; - float s0[2], s1[2]; /* segment 'center' points */ - float pm[2]; /* normal from previous segment. */ - int i; - float fpt[3]; - - GPUVertFormat *format = immVertexFormat(); - const struct { - uint pos, color; - } attr_id = { - .pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT), - .color = GPU_vertformat_attr_add( - format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT), - }; - - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GPU_PRIM_TRI_STRIP, totpoints * 2 + 4); - - /* get x and y coordinates from first point */ - mul_v3_m4v3(fpt, diff_mat, &points->x); - gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, s0); - - for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) { - float t0[2], t1[2]; /* tessellated coordinates */ - float m1[2], m2[2]; /* gradient and normal */ - float mt[2], sc[2]; /* gradient for thickness, point for end-cap */ - float pthick; /* thickness at segment point */ - - /* Get x and y coordinates from point2 - * (point1 has already been computed in previous iteration). */ - mul_v3_m4v3(fpt, diff_mat, &pt2->x); - gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, s1); - - /* calculate gradient and normal - 'angle'=(ny/nx) */ - m1[1] = s1[1] - s0[1]; - m1[0] = s1[0] - s0[0]; - normalize_v2(m1); - m2[1] = -m1[0]; - m2[0] = m1[1]; - - /* always use pressure from first point here */ - pthick = (pt1->pressure * thickness * scalefac); - - /* color of point */ - gp_set_point_varying_color(pt1, ink, attr_id.color, false); - - /* if the first segment, start of segment is segment's normal */ - if (i == 0) { - /* draw start cap first - * - make points slightly closer to center (about halfway across) - */ - mt[0] = m2[0] * pthick * 0.5f; - mt[1] = m2[1] * pthick * 0.5f; - sc[0] = s0[0] - (m1[0] * pthick * 0.75f); - sc[1] = s0[1] - (m1[1] * pthick * 0.75f); - - t0[0] = sc[0] - mt[0]; - t0[1] = sc[1] - mt[1]; - t1[0] = sc[0] + mt[0]; - t1[1] = sc[1] + mt[1]; - - /* First two points of cap. */ - immVertex2fv(attr_id.pos, t0); - immVertex2fv(attr_id.pos, t1); - - /* calculate points for start of segment */ - mt[0] = m2[0] * pthick; - mt[1] = m2[1] * pthick; - - t0[0] = s0[0] - mt[0]; - t0[1] = s0[1] - mt[1]; - t1[0] = s0[0] + mt[0]; - t1[1] = s0[1] + mt[1]; - - /* Last two points of start cap (and first two points of first segment). */ - immVertex2fv(attr_id.pos, t0); - immVertex2fv(attr_id.pos, t1); - } - /* if not the first segment, use bisector of angle between segments */ - else { - float mb[2]; /* bisector normal */ - float athick, dfac; /* actual thickness, difference between thicknesses */ - - /* calculate gradient of bisector (as average of normals) */ - mb[0] = (pm[0] + m2[0]) / 2; - mb[1] = (pm[1] + m2[1]) / 2; - normalize_v2(mb); - - /* calculate gradient to apply - * - as basis, use just pthick * bisector gradient - * - if cross-section not as thick as it should be, add extra padding to fix it - */ - mt[0] = mb[0] * pthick; - mt[1] = mb[1] * pthick; - athick = len_v2(mt); - dfac = pthick - (athick * 2); - - if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) { - mt[0] += (mb[0] * dfac); - mt[1] += (mb[1] * dfac); - } - - /* calculate points for start of segment */ - t0[0] = s0[0] - mt[0]; - t0[1] = s0[1] - mt[1]; - t1[0] = s0[0] + mt[0]; - t1[1] = s0[1] + mt[1]; - - /* Last two points of previous segment, and first two points of current segment. */ - immVertex2fv(attr_id.pos, t0); - immVertex2fv(attr_id.pos, t1); - } - - /* if last segment, also draw end of segment (defined as segment's normal) */ - if (i == totpoints - 2) { - /* for once, we use second point's pressure (otherwise it won't be drawn) */ - pthick = (pt2->pressure * thickness * scalefac); - - /* color of point */ - gp_set_point_varying_color(pt2, ink, attr_id.color, false); - - /* calculate points for end of segment */ - mt[0] = m2[0] * pthick; - mt[1] = m2[1] * pthick; - - t0[0] = s1[0] - mt[0]; - t0[1] = s1[1] - mt[1]; - t1[0] = s1[0] + mt[0]; - t1[1] = s1[1] + mt[1]; - - /* Last two points of last segment (and first two points of end cap). */ - immVertex2fv(attr_id.pos, t0); - immVertex2fv(attr_id.pos, t1); - - /* draw end cap as last step - * - make points slightly closer to center (about halfway across) - */ - mt[0] = m2[0] * pthick * 0.5f; - mt[1] = m2[1] * pthick * 0.5f; - sc[0] = s1[0] + (m1[0] * pthick * 0.75f); - sc[1] = s1[1] + (m1[1] * pthick * 0.75f); - - t0[0] = sc[0] - mt[0]; - t0[1] = sc[1] - mt[1]; - t1[0] = sc[0] + mt[0]; - t1[1] = sc[1] + mt[1]; - - /* Last two points of end cap. */ - immVertex2fv(attr_id.pos, t0); - immVertex2fv(attr_id.pos, t1); - } - - /* store computed point2 coordinates as point1 ones of next segment. */ - copy_v2_v2(s0, s1); - /* store stroke's 'natural' normal for next stroke to use */ - copy_v2_v2(pm, m2); - } - - immEnd(); - immUnbindProgram(); - } -} - /* ----- Strokes Drawing ------ */ /* Helper for doing all the checks on whether a stroke can be drawn */ -- cgit v1.2.3