diff options
author | Charlie Jolly <mistajolly@gmail.com> | 2018-12-05 21:48:27 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2018-12-07 14:45:48 +0300 |
commit | ad47b0236e32dc9a583a0d7209d8030bbb7c358e (patch) | |
tree | a68c61dc5bf051bfe14ab48276a7eba39d365c70 | |
parent | 942e9835a9acdc19164bf6b07796eace1548f3fd (diff) |
GP: Refactor coordinates to float
See: D4030
Differential Revision: https://developer.blender.org/D4036
-rw-r--r-- | source/blender/editors/gpencil/annotate_draw.c | 12 | ||||
-rw-r--r-- | source/blender/editors/gpencil/annotate_paint.c | 60 | ||||
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 18 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 12 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_fill.c | 12 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_intern.h | 9 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 111 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 18 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_select.c | 4 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 60 | ||||
-rw-r--r-- | source/blender/editors/include/ED_gpencil.h | 15 |
11 files changed, 147 insertions, 184 deletions
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index 1ef7e3883da..e6747856d1e 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -113,7 +113,7 @@ static void gp_draw_stroke_buffer( } GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const tGPspoint *pt = points; @@ -123,7 +123,7 @@ static void gp_draw_stroke_buffer( immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); immUniformColor3fvAlpha(ink, ink[3]); immBegin(GPU_PRIM_POINTS, 1); - immVertex2iv(pos, &pt->x); + immVertex2fv(pos, &pt->x); } else { float oldpressure = points[0].pressure; @@ -143,7 +143,7 @@ static void gp_draw_stroke_buffer( if (fabsf(pt->pressure - oldpressure) > 0.2f) { /* need to have 2 points to avoid immEnd assert error */ if (draw_points < 2) { - immVertex2iv(pos, &(pt - 1)->x); + immVertex2fv(pos, &(pt - 1)->x); } immEnd(); @@ -154,7 +154,7 @@ static void gp_draw_stroke_buffer( /* need to roll-back one point to ensure that there are no gaps in the stroke */ if (i != 0) { - immVertex2iv(pos, &(pt - 1)->x); + immVertex2fv(pos, &(pt - 1)->x); draw_points++; } @@ -162,12 +162,12 @@ static void gp_draw_stroke_buffer( } /* now the point we want */ - immVertex2iv(pos, &pt->x); + immVertex2fv(pos, &pt->x); draw_points++; } /* need to have 2 points to avoid immEnd assert error */ if (draw_points < 2) { - immVertex2iv(pos, &(pt - 1)->x); + immVertex2fv(pos, &(pt - 1)->x); } } diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 905bb362213..f03141c3513 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -141,8 +141,8 @@ typedef struct tGPsdata { short radius; /* radius of influence for eraser */ - int mval[2]; /* current mouse-position */ - int mvalo[2]; /* previous recorded mouse-position */ + float mval[2]; /* current mouse-position */ + float mvalo[2]; /* previous recorded mouse-position */ float pressure; /* current stylus pressure */ float opressure; /* previous stylus pressure */ @@ -242,10 +242,10 @@ static void gp_get_3d_reference(tGPsdata *p, float vec[3]) /* Stroke Editing ---------------------------- */ /* check if the current mouse position is suitable for adding a new point */ -static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) +static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2]) { - int dx = abs(mval[0] - pmval[0]); - int dy = abs(mval[1] - pmval[1]); + int dx = (int)fabsf(mval[0] - pmval[0]); + int dy = (int)fabsf(mval[1] - pmval[1]); /* if buffer is empty, just let this go through (i.e. so that dots will work) */ if (p->gpd->runtime.sbuffer_size == 0) @@ -270,13 +270,15 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) } /* convert screen-coordinates to buffer-coordinates */ -static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[3], float *depth) { bGPdata *gpd = p->gpd; /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) { - if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) { + int mval_i[2]; + round_v2i_v2fl(mval_i, mval); + if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval_i, out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ @@ -284,7 +286,6 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] else { float mval_prj[2]; float rvec[3], dvec[3]; - float mval_f[2] = {UNPACK2(mval)}; float zfac; /* Current method just converts each point in screen-coordinates to @@ -300,7 +301,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { - sub_v2_v2v2(mval_f, mval_prj, mval_f); + float mval_f[2]; + sub_v2_v2v2(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); sub_v3_v3v3(out, rvec, dvec); } @@ -331,7 +333,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] /* add current stroke-point to buffer (returns whether point was successfully added) */ static short gp_stroke_addpoint( - tGPsdata *p, const int mval[2], float pressure, double curtime) + tGPsdata *p, const float mval[2], float pressure, double curtime) { bGPdata *gpd = p->gpd; tGPspoint *pt; @@ -345,7 +347,7 @@ static short gp_stroke_addpoint( pt = (tGPspoint *)(gpd->runtime.sbuffer); /* store settings */ - copy_v2_v2_int(&pt->x, mval); + copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -360,7 +362,7 @@ static short gp_stroke_addpoint( pt = ((tGPspoint *)(gpd->runtime.sbuffer) + 1); /* store settings */ - copy_v2_v2_int(&pt->x, mval); + copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -381,7 +383,7 @@ static short gp_stroke_addpoint( pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size); /* store settings */ - copy_v2_v2_int(&pt->x, mval); + copy_v2_v2(&pt->x, mval); pt->pressure = pressure; pt->strength = 1.0f; /* unused for annotations, but initialise for easier conversions to GP Object */ @@ -402,7 +404,7 @@ static short gp_stroke_addpoint( pt = (tGPspoint *)(gpd->runtime.sbuffer); /* store settings */ - copy_v2_v2_int(&pt->x, mval); + copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -503,7 +505,7 @@ static void gp_stroke_simplify(tGPsdata *p) for (i = 0, j = 0; i < num_points; i++) { if (i - j == 3) { float co[2], pressure, time; - int mco[2]; + float mco[2]; /* initialize values */ co[0] = 0.0f; @@ -518,8 +520,8 @@ static void gp_stroke_simplify(tGPsdata *p) GP_SIMPLIFY_AVPOINT(j + 3, -0.25f); /* set values for adding */ - mco[0] = (int)co[0]; - mco[1] = (int)co[1]; + mco[0] = co[0]; + mco[1] = co[1]; /* ignore return values on this... assume to be ok for now */ gp_stroke_addpoint(p, mco, pressure, p->inittime + (double)time); @@ -643,17 +645,17 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) /* get an array of depths, far depths are blended */ if (gpencil_project_check(p)) { - int mval[2], mval_prev[2] = { 0 }; + int mval_i[2], mval_prev[2] = { 0 }; int interp_depth = 0; int found_depth = 0; depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_size, "depth_points"); for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size; i++, ptc++, pt++) { - copy_v2_v2_int(mval, &ptc->x); + round_v2i_v2fl(mval_i, &ptc->x); - if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) && - (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) && + (i && (ED_view3d_autodist_depth_seg(p->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { interp_depth = true; } @@ -661,7 +663,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) found_depth = true; } - copy_v2_v2_int(mval_prev, mval); + copy_v2_v2_int(mval_prev, mval_i); } if (found_depth == false) { @@ -766,10 +768,10 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) { RegionView3D *rv3d = p->ar->regiondata; - const int mval[2] = {x, y}; + const int mval_i[2] = {x, y}; float mval_3d[3]; - if (ED_view3d_autodist_simple(p->ar, mval, mval_3d, 0, NULL)) { + if (ED_view3d_autodist_simple(p->ar, mval_i, mval_3d, 0, NULL)) { const float depth_mval = view3d_point_depth(rv3d, mval_3d); const float depth_pt = view3d_point_depth(rv3d, &pt->x); @@ -786,13 +788,15 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons static void gp_stroke_eraser_dostroke( tGPsdata *p, bGPDframe *gpf, bGPDstroke *gps, - const int mval[2], const int mvalo[2], + const float mval[2], const float mvalo[2], const int radius, const rcti *rect) { bGPDspoint *pt1, *pt2; int pc1[2] = {0}; int pc2[2] = {0}; int i; + int mval_i[2]; + round_v2i_v2fl(mval_i, mval); if (gps->totpoints == 0) { /* just free stroke */ @@ -806,7 +810,7 @@ static void gp_stroke_eraser_dostroke( /* do boundbox check first */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { /* only check if point is inside */ - if (len_v2v2_int(mval, pc1) <= radius) { + if (len_v2v2_int(mval_i, pc1) <= radius) { /* free stroke */ gp_free_stroke(gpf, gps); } @@ -857,10 +861,10 @@ static void gp_stroke_eraser_dostroke( (gp_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false)) { /* Edge is affected - Check individual points now */ - if (len_v2v2_int(mval, pc1) <= radius) { + if (len_v2v2_int(mval_i, pc1) <= radius) { pt1->flag |= GP_SPOINT_TAG; } - if (len_v2v2_int(mval, pc2) <= radius) { + if (len_v2v2_int(mval_i, pc2) <= radius) { pt2->flag |= GP_SPOINT_TAG; } do_cull = true; diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index b447b867313..b44c9105e10 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -174,15 +174,15 @@ static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, f /* vertex 1 */ pt = &points[tmp_triangles[i][0]]; gp_set_tpoint_varying_color(pt, ink, color); - immVertex2iv(pos, &pt->x); + immVertex2fv(pos, &pt->x); /* vertex 2 */ pt = &points[tmp_triangles[i][1]]; gp_set_tpoint_varying_color(pt, ink, color); - immVertex2iv(pos, &pt->x); + immVertex2fv(pos, &pt->x); /* vertex 3 */ pt = &points[tmp_triangles[i][2]]; gp_set_tpoint_varying_color(pt, ink, color); - immVertex2iv(pos, &pt->x); + immVertex2fv(pos, &pt->x); } immEnd(); @@ -219,7 +219,7 @@ static void gp_draw_stroke_buffer( } GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); const tGPspoint *pt = points; @@ -230,7 +230,7 @@ static void gp_draw_stroke_buffer( immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR); immBegin(GPU_PRIM_POINTS, 1); gp_set_tpoint_varying_color(pt, ink, color); - immVertex2iv(pos, &pt->x); + immVertex2fv(pos, &pt->x); } else { float oldpressure = points[0].pressure; @@ -250,7 +250,7 @@ static void gp_draw_stroke_buffer( /* need to have 2 points to avoid immEnd assert error */ if (draw_points < 2) { gp_set_tpoint_varying_color(pt - 1, ink, color); - immVertex2iv(pos, &(pt - 1)->x); + immVertex2fv(pos, &(pt - 1)->x); } immEnd(); @@ -262,7 +262,7 @@ static void gp_draw_stroke_buffer( /* need to roll-back one point to ensure that there are no gaps in the stroke */ if (i != 0) { gp_set_tpoint_varying_color(pt - 1, ink, color); - immVertex2iv(pos, &(pt - 1)->x); + immVertex2fv(pos, &(pt - 1)->x); draw_points++; } @@ -271,13 +271,13 @@ static void gp_draw_stroke_buffer( /* now the point we want */ gp_set_tpoint_varying_color(pt, ink, color); - immVertex2iv(pos, &pt->x); + immVertex2fv(pos, &pt->x); draw_points++; } /* need to have 2 points to avoid immEnd assert error */ if (draw_points < 2) { gp_set_tpoint_varying_color(pt - 1, ink, color); - immVertex2iv(pos, &(pt - 1)->x); + immVertex2fv(pos, &(pt - 1)->x); } } diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 1e9538e86f8..9feea61c672 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -138,7 +138,7 @@ typedef struct tGP_BrushEditData { /* - position and pressure * - the *_prev variants are the previous values */ - int mval[2], mval_prev[2]; + float mval[2], mval_prev[2]; float pressure, pressure_prev; /* - effect vector (e.g. 2D/3D translation for grab brush) */ @@ -261,7 +261,9 @@ static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, c /* distance fading */ if (gp_brush->flag & GP_SCULPT_FLAG_USE_FALLOFF) { - float distance = (float)len_v2v2_int(gso->mval, co); + int mval_i[2]; + round_v2i_v2fl(mval_i, gso->mval); + float distance = (float)len_v2v2_int(mval_i, co); float fac; CLAMP(distance, 0.0f, (float)radius); @@ -594,7 +596,7 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso) float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); float mval_f[2]; - copy_v2fl_v2i(mval_f, gso->mval); + copy_v2_v2(mval_f, gso->mval); float mval_prj[2]; float dvec[3]; @@ -1435,7 +1437,9 @@ static bool gpsculpt_brush_do_stroke( /* do boundbox check first */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { /* only check if point is inside */ - if (len_v2v2_int(gso->mval, pc1) <= radius) { + int mval_i[2]; + round_v2i_v2fl(mval_i, gso->mval); + if (len_v2v2_int(mval_i, pc1) <= radius) { /* apply operation to this point */ changed = apply(gso, gps, 0, radius, pc1); } diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 98603f60bbb..6105a6b2523 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -748,19 +748,21 @@ static void gpencil_get_depth_array(tGPDfill *tgpf) int depth_margin = 0; /* get an array of depths, far depths are blended */ - int mval[2], mval_prev[2] = { 0 }; + int mval_prev[2] = { 0 }; int interp_depth = 0; int found_depth = 0; tgpf->depth_arr = MEM_mallocN(sizeof(float) * totpoints, "depth_points"); for (i = 0, ptc = tgpf->sbuffer; i < totpoints; i++, ptc++) { - copy_v2_v2_int(mval, &ptc->x); + + int mval_i[2]; + round_v2i_v2fl(mval_i, &ptc->x); if ((ED_view3d_autodist_depth( - tgpf->ar, mval, depth_margin, tgpf->depth_arr + i) == 0) && + tgpf->ar, mval_i, depth_margin, tgpf->depth_arr + i) == 0) && (i && (ED_view3d_autodist_depth_seg( - tgpf->ar, mval, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0))) + tgpf->ar, mval_i, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0))) { interp_depth = true; } @@ -768,7 +770,7 @@ static void gpencil_get_depth_array(tGPDfill *tgpf) found_depth = true; } - copy_v2_v2_int(mval_prev, mval); + copy_v2_v2_int(mval_prev, mval_i); } if (found_depth == false) { diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 6d05afa0e8d..50ae61209cc 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -196,7 +196,7 @@ typedef struct GP_SpaceConversion { } GP_SpaceConversion; bool gp_stroke_inside_circle( - const int mval[2], const int UNUSED(mvalo[2]), + const float mval[2], const float UNUSED(mvalo[2]), int rad, int x0, int y0, int x1, int y1); void gp_point_conversion_init(struct bContext *C, GP_SpaceConversion *r_gsc); @@ -228,13 +228,6 @@ void gp_stroke_convertcoords_tpoint( bGPDlayer *gpl, const struct tGPspoint *point2D, float *depth, float out[3]); -/* helper to convert 2d to 3d for primitive. See: D4030 */ -void gp_stroke_convertcoords_tpoint_primitive( - struct Scene *scene, struct ARegion *ar, - struct Object *ob, - bGPDlayer *gpl, const struct tPGPspoint *point2D, - float out[3]); - /* Poll Callbacks ------------------------------------ */ /* gpencil_utils.c */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 261d19ee4a8..be92f8ab74a 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -156,8 +156,8 @@ typedef struct tGPsdata { short radius; /* radius of influence for eraser */ - int mval[2]; /* current mouse-position */ - int mvalo[2]; /* previous recorded mouse-position */ + float mval[2]; /* current mouse-position */ + float mvalo[2]; /* previous recorded mouse-position */ float pressure; /* current stylus pressure */ float opressure; /* previous stylus pressure */ @@ -294,11 +294,11 @@ static void gp_get_3d_reference(tGPsdata *p, float vec[3]) /* Stroke Editing ---------------------------- */ /* check if the current mouse position is suitable for adding a new point */ -static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) +static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2]) { Brush *brush = p->brush; - int dx = abs(mval[0] - pmval[0]); - int dy = abs(mval[1] - pmval[1]); + int dx = (int)fabsf(mval[0] - pmval[0]); + int dy = (int)fabsf(mval[1] - pmval[1]); brush->gpencil_settings->flag &= ~GP_BRUSH_STABILIZE_MOUSE_TEMP; /* if buffer is empty, just let this go through (i.e. so that dots will work) */ @@ -314,7 +314,7 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) else { /* If the mouse is moving within the radius of the last move, * don't update the mouse position. This allows sharp turns. */ - copy_v2_v2_int(p->mval, p->mvalo); + copy_v2_v2(p->mval, p->mvalo); return false; } } @@ -363,7 +363,7 @@ static void gp_reproject_toplane(tGPsdata *p, bGPDstroke *gps) /* convert screen-coordinates to buffer-coordinates */ /* XXX this method needs a total overhaul! */ -static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[3], float *depth) { bGPdata *gpd = p->gpd; @@ -375,7 +375,10 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] *depth *= (1.0f - gpd->zdepth_offset); } - if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) { + int mval_i[2]; + round_v2i_v2fl(mval_i, mval); + + if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval_i, out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ @@ -390,7 +393,6 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] float mval_prj[2]; float rvec[3], dvec[3]; float mval_f[2]; - copy_v2fl_v2i(mval_f, mval); float zfac; /* Current method just converts each point in screen-coordinates to @@ -406,7 +408,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { - sub_v2_v2v2(mval_f, mval_prj, mval_f); + sub_v2_v2v2(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); sub_v3_v3v3(out, rvec, dvec); } @@ -418,8 +420,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] /* apply jitter to stroke */ static void gp_brush_jitter( - bGPdata *gpd, Brush *brush, tGPspoint *pt, const int mval[2], - const float pressure, int r_mval[2], RNG *rng) + bGPdata *gpd, Brush *brush, tGPspoint *pt, const float mval[2], + const float pressure, float r_mval[2], RNG *rng) { float tmp_pressure = pressure; if (brush->gpencil_settings->draw_jitter > 0.0f) { @@ -432,8 +434,8 @@ static void gp_brush_jitter( float mvec[2], svec[2]; /* mouse movement in ints -> floats */ if (gpd->runtime.sbuffer_size > 1) { - mvec[0] = (float)(mval[0] - (pt - 1)->x); - mvec[1] = (float)(mval[1] - (pt - 1)->y); + mvec[0] = (mval[0] - (pt - 1)->x); + mvec[1] = (mval[1] - (pt - 1)->y); normalize_v2(mvec); } else { @@ -457,7 +459,7 @@ static void gp_brush_jitter( } /* apply pressure change depending of the angle of the stroke to simulate a pen with shape */ -static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const int mval[2]) +static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const float mval[2]) { float mvec[2]; float sen = brush->gpencil_settings->draw_angle_factor; /* sensitivity */; @@ -469,8 +471,8 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const int /* Apply to first point (only if there are 2 points because before no data to do it ) */ if (gpd->runtime.sbuffer_size == 1) { - mvec[0] = (float)(mval[0] - (pt - 1)->x); - mvec[1] = (float)(mval[1] - (pt - 1)->y); + mvec[0] = (mval[0] - (pt - 1)->x); + mvec[1] = (mval[1] - (pt - 1)->y); normalize_v2(mvec); /* uses > 1.0f to get a smooth transition in first point */ @@ -482,8 +484,8 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const int /* apply from second point */ if (gpd->runtime.sbuffer_size >= 1) { - mvec[0] = (float)(mval[0] - (pt - 1)->x); - mvec[1] = (float)(mval[1] - (pt - 1)->y); + mvec[0] = (mval[0] - (pt - 1)->x); + mvec[1] = (mval[1] - (pt - 1)->y); normalize_v2(mvec); fac = 1.0f - fabs(dot_v2v2(v0, mvec)); /* 0.0 to 1.0 */ @@ -532,30 +534,30 @@ static void gp_smooth_buffer(tGPsdata *p, float inf, int idx) /* Compute smoothed coordinate by taking the ones nearby */ if (pta) { - copy_v2fl_v2i(a, &pta->x); + copy_v2_v2(a, &pta->x); madd_v2_v2fl(sco, a, average_fac); } if (ptb) { - copy_v2fl_v2i(b, &ptb->x); + copy_v2_v2(b, &ptb->x); madd_v2_v2fl(sco, b, average_fac); } if (ptc) { - copy_v2fl_v2i(c, &ptc->x); + copy_v2_v2(c, &ptc->x); madd_v2_v2fl(sco, c, average_fac); } if (ptd) { - copy_v2fl_v2i(d, &ptd->x); + copy_v2_v2(d, &ptd->x); madd_v2_v2fl(sco, d, average_fac); } /* Based on influence factor, blend between original and optimal smoothed coordinate */ interp_v2_v2v2(c, c, sco, inf); - round_v2i_v2fl(&ptc->x, c); + copy_v2_v2(&ptc->x, c); } /* add current stroke-point to buffer (returns whether point was successfully added) */ static short gp_stroke_addpoint( - tGPsdata *p, const int mval[2], float pressure, double curtime) + tGPsdata *p, const float mval[2], float pressure, double curtime) { bGPdata *gpd = p->gpd; Brush *brush = p->brush; @@ -577,7 +579,7 @@ static short gp_stroke_addpoint( pt = (tGPspoint *)(gpd->runtime.sbuffer); /* store settings */ - copy_v2_v2_int(&pt->x, mval); + copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -592,7 +594,7 @@ static short gp_stroke_addpoint( pt = ((tGPspoint *)(gpd->runtime.sbuffer) + 1); /* store settings */ - copy_v2_v2_int(&pt->x, mval); + copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -626,13 +628,13 @@ static short gp_stroke_addpoint( if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && (brush->gpencil_settings->draw_jitter > 0.0f)) { - int r_mval[2]; + float r_mval[2]; const float jitpress = (brush->gpencil_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) ? pressure : 1.0f; gp_brush_jitter(gpd, brush, pt, mval, jitpress, r_mval, p->rng); - copy_v2_v2_int(&pt->x, r_mval); + copy_v2_v2(&pt->x, r_mval); } else { - copy_v2_v2_int(&pt->x, mval); + copy_v2_v2(&pt->x, mval); } /* apply randomness to pressure */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && @@ -749,7 +751,7 @@ static short gp_stroke_addpoint( pt = (tGPspoint *)(gpd->runtime.sbuffer); /* store settings */ - copy_v2_v2_int(&pt->x, mval); + copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -1012,17 +1014,18 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) /* get an array of depths, far depths are blended */ if (gpencil_project_check(p)) { - int mval[2], mval_prev[2] = { 0 }; + int mval_i[2], mval_prev[2] = { 0 }; int interp_depth = 0; int found_depth = 0; depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_size, "depth_points"); for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size; i++, ptc++, pt++) { - copy_v2_v2_int(mval, &ptc->x); + + round_v2i_v2fl(mval_i, &ptc->x); - if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) && - (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) && + (i && (ED_view3d_autodist_depth_seg(p->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { interp_depth = true; } @@ -1030,7 +1033,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) found_depth = true; } - copy_v2_v2_int(mval_prev, mval); + copy_v2_v2_int(mval_prev, mval_i); } if (found_depth == false) { @@ -1204,7 +1207,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons RegionView3D *rv3d = p->ar->regiondata; bGPDlayer *gpl = p->gpl; - const int mval[2] = {x, y}; + const int mval_i[2] = {x, y}; float mval_3d[3]; float fpt[3]; @@ -1212,7 +1215,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons /* calculate difference matrix if parent object */ ED_gpencil_parent_location(p->depsgraph, obact, p->gpd, gpl, diff_mat); - if (ED_view3d_autodist_simple(p->ar, mval, mval_3d, 0, NULL)) { + if (ED_view3d_autodist_simple(p->ar, mval_i, mval_3d, 0, NULL)) { const float depth_mval = view3d_point_depth(rv3d, mval_3d); mul_v3_m4v3(fpt, diff_mat, &pt->x); @@ -1227,11 +1230,13 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons } /* apply a falloff effect to brush strength, based on distance */ -static float gp_stroke_eraser_calc_influence(tGPsdata *p, const int mval[2], const int radius, const int co[2]) +static float gp_stroke_eraser_calc_influence(tGPsdata *p, const float mval[2], const int radius, const int co[2]) { Brush *brush = p->brush; /* Linear Falloff... */ - float distance = (float)len_v2v2_int(mval, co); + int mval_i[2]; + round_v2i_v2fl(mval_i, mval); + float distance = (float)len_v2v2_int(mval_i, co); float fac; CLAMP(distance, 0.0f, (float)radius); @@ -1325,7 +1330,7 @@ static void gp_stroke_soft_refine(bGPDstroke *gps, const float cull_thresh) /* TODO: this could really do with some optimization (KD-Tree/BVH?) */ static void gp_stroke_eraser_dostroke(tGPsdata *p, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, - const int mval[2], const int mvalo[2], + const float mval[2], const float mvalo[2], const int radius, const rcti *rect) { Depsgraph *depsgraph = p->depsgraph; @@ -1337,6 +1342,8 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int pc2[2] = {0}; int i; float diff_mat[4][4]; + int mval_i[2]; + round_v2i_v2fl(mval_i, mval); /* calculate difference matrix */ ED_gpencil_parent_location(depsgraph, obact, p->gpd, gpl, diff_mat); @@ -1354,7 +1361,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, /* do boundbox check first */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { /* only check if point is inside */ - if (len_v2v2_int(mval, pc1) <= radius) { + if (len_v2v2_int(mval_i, pc1) <= radius) { /* free stroke */ gp_free_stroke(p->gpd, gpf, gps); } @@ -1377,7 +1384,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, /* do boundbox check first */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { /* only check if point is inside */ - if (len_v2v2_int(mval, pc1) <= radius) { + if (len_v2v2_int(mval_i, pc1) <= radius) { /* free stroke */ gp_free_stroke(p->gpd, gpf, gps); return; @@ -2450,10 +2457,10 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra if (GPENCIL_LAZY_MODE(p->brush, p->shift)) { float now_mouse[2]; float last_mouse[2]; - copy_v2fl_v2i(now_mouse, p->mval); - copy_v2fl_v2i(last_mouse, p->mvalo); + copy_v2_v2(now_mouse, p->mval); + copy_v2_v2(last_mouse, p->mvalo); interp_v2_v2v2(now_mouse, now_mouse, last_mouse, p->brush->smooth_stroke_factor); - round_v2i_v2fl(p->mval, now_mouse); + copy_v2_v2(p->mval, now_mouse); } /* try to add point */ @@ -2510,7 +2517,7 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra } /* handle draw event */ -static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent *event, Depsgraph *depsgraph, int x, int y) +static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent *event, Depsgraph *depsgraph, float x, float y) { tGPsdata *p = op->customdata; PointerRNA itemptr; @@ -2521,15 +2528,15 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent * add any x,y override position for fake events * NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... */ - p->mval[0] = event->mval[0] + 1 - x; - p->mval[1] = event->mval[1] + 1 - y; + p->mval[0] = event->mval[0] + 1.0f - x; + p->mval[1] = event->mval[1] + 1.0f - y; p->shift = event->shift; /* verify key status for straight lines */ if ((event->alt > 0) && (RNA_boolean_get(op->ptr, "disable_straight") == false)) { if (p->straight[0] == 0) { - int dx = abs(p->mval[0] - p->mvalo[0]); - int dy = abs(p->mval[1] - p->mvalo[1]); + int dx = (int)fabsf(p->mval[0] - p->mvalo[0]); + int dy = (int)fabsf(p->mval[1] - p->mvalo[1]); if ((dx > 0) || (dy > 0)) { /* check mouse direction to replace the other coordinate with previous values */ if (dx >= dy) { @@ -2919,7 +2926,7 @@ static void gpencil_add_missing_events(bContext *C, wmOperator *op, const wmEven } float factor = ((thickness * dot_factor) / scale) * samples; - copy_v2fl_v2i(a, p->mvalo); + copy_v2_v2(a, p->mvalo); b[0] = event->mval[0] + 1; b[1] = event->mval[1] + 1; diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index b67e68a2cd9..029db23499e 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -260,7 +260,7 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi /* ----------------------- */ /* create a rectangle */ -static void gp_primitive_rectangle(tGPDprimitive *tgpi, tPGPspoint *points2D) +static void gp_primitive_rectangle(tGPDprimitive *tgpi, tGPspoint *points2D) { BLI_assert(tgpi->tot_edges == 4); @@ -278,7 +278,7 @@ static void gp_primitive_rectangle(tGPDprimitive *tgpi, tPGPspoint *points2D) } /* create a line */ -static void gp_primitive_line(tGPDprimitive *tgpi, tPGPspoint *points2D) +static void gp_primitive_line(tGPDprimitive *tgpi, tGPspoint *points2D) { BLI_assert(tgpi->tot_edges == 2); @@ -290,7 +290,7 @@ static void gp_primitive_line(tGPDprimitive *tgpi, tPGPspoint *points2D) } /* create an arc */ -static void gp_primitive_arc(tGPDprimitive *tgpi, tPGPspoint *points2D) +static void gp_primitive_arc(tGPDprimitive *tgpi, tGPspoint *points2D) { const int totpoints = tgpi->tot_edges; const float step = M_PI_2 / (float)(totpoints - 1); @@ -313,7 +313,7 @@ static void gp_primitive_arc(tGPDprimitive *tgpi, tPGPspoint *points2D) length[1] = end[1] - start[1]; for (int i = 0; i < totpoints; i++) { - tPGPspoint *p2d = &points2D[i]; + tGPspoint *p2d = &points2D[i]; p2d->x = (start[0] + sinf(a) * length[0]); p2d->y = (end[1] - cosf(a) * length[1]); a += step; @@ -321,7 +321,7 @@ static void gp_primitive_arc(tGPDprimitive *tgpi, tPGPspoint *points2D) } /* create a circle */ -static void gp_primitive_circle(tGPDprimitive *tgpi, tPGPspoint *points2D) +static void gp_primitive_circle(tGPDprimitive *tgpi, tGPspoint *points2D) { const int totpoints = tgpi->tot_edges; const float step = (2.0f * M_PI) / (float)(totpoints); @@ -336,7 +336,7 @@ static void gp_primitive_circle(tGPDprimitive *tgpi, tPGPspoint *points2D) radius[1] = fabsf(((tgpi->bottom[1] - tgpi->top[1]) / 2.0f)); for (int i = 0; i < totpoints; i++) { - tPGPspoint *p2d = &points2D[i]; + tGPspoint *p2d = &points2D[i]; p2d->x = (center[0] + cosf(a) * radius[0]); p2d->y = (center[1] + sinf(a) * radius[1]); a += step; @@ -359,7 +359,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) gps->totpoints = tgpi->tot_edges; /* compute screen-space coordinates for points */ - tPGPspoint *points2D = MEM_callocN(sizeof(tPGPspoint) * tgpi->tot_edges, "gp primitive points2D"); + tGPspoint *points2D = MEM_callocN(sizeof(tGPspoint) * tgpi->tot_edges, "gp primitive points2D"); switch (tgpi->type) { case GP_STROKE_BOX: gp_primitive_rectangle(tgpi, points2D); @@ -384,10 +384,10 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* convert screen-coordinates to 3D coordinates */ for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; - tPGPspoint *p2d = &points2D[i]; + tGPspoint *p2d = &points2D[i]; /* convert screen-coordinates to 3D coordinates */ - gp_stroke_convertcoords_tpoint_primitive(tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, p2d, &pt->x); + gp_stroke_convertcoords_tpoint(tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, p2d, NULL, &pt->x); pt->pressure = 1.0f; pt->strength = tgpi->brush->gpencil_settings->draw_strength; diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 769f3d9db4b..cbe9d7e547a 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -905,8 +905,8 @@ static bool gp_stroke_do_circle_sel( if (((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) || ((!ELEM(V2D_IS_CLIPPED, x1, y1)) && BLI_rcti_isect_pt(rect, x1, y1))) { - int mval[2] = {mx, my}; - int mvalo[2] = {mx, my}; /* dummy - this isn't used... */ + float mval[2] = {(float)mx, (float)my}; + float mvalo[2] = {(float)mx, (float)my}; /* dummy - this isn't used... */ /* check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 1f1b779d4f8..7aabe546ce6 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -435,15 +435,14 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf( * \param x1, y1 The screen-space x and y coordinates of the end of the stroke segment */ bool gp_stroke_inside_circle( - const int mval[2], const int UNUSED(mvalo[2]), + const float mval[2], const float UNUSED(mvalo[2]), int rad, int x0, int y0, int x1, int y1) { /* simple within-radius check for now */ - const float mval_fl[2] = {mval[0], mval[1]}; const float screen_co_a[2] = {x0, y0}; const float screen_co_b[2] = {x1, y1}; - if (edge_inside_circle(mval_fl, rad, screen_co_a, screen_co_b)) { + if (edge_inside_circle(mval, rad, screen_co_a, screen_co_b)) { return true; } @@ -776,15 +775,17 @@ void gp_stroke_convertcoords_tpoint( float r_out[3]) { ToolSettings *ts = scene->toolsettings; - const int mval[2] = {point2D->x, point2D->y}; - if ((depth != NULL) && (ED_view3d_autodist_simple(ar, mval, r_out, 0, depth))) { + int mval_i[2]; + round_v2i_v2fl(mval_i, &point2D->x); + + if ((depth != NULL) && (ED_view3d_autodist_simple(ar, mval_i, r_out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ } else { - float mval_f[2] = {(float)point2D->x, (float)point2D->y}; + float mval_f[2] = {point2D->x, point2D->y}; float mval_prj[2]; float rvec[3], dvec[3]; float zfac; @@ -807,41 +808,6 @@ void gp_stroke_convertcoords_tpoint( } /** - * Convert primitive tPGPspoint (temporary 2D/screenspace point data used by GP primitive operators) - * to 3D coordinates. - * - * See: D4030 - */ -void gp_stroke_convertcoords_tpoint_primitive( - Scene *scene, ARegion *ar, - Object *ob, bGPDlayer *gpl, - const tPGPspoint *point2D, - float r_out[3]) -{ - ToolSettings *ts = scene->toolsettings; - - float mval_f[2] = { point2D->x, point2D->y }; - float mval_prj[2]; - float rvec[3], dvec[3]; - float zfac; - - /* Current method just converts each point in screen-coordinates to - * 3D-coordinates using the 3D-cursor as reference. - */ - ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, rvec); - zfac = ED_view3d_calc_zfac(ar->regiondata, rvec, NULL); - - if (ED_view3d_project_float_global(ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { - sub_v2_v2v2(mval_f, mval_prj, mval_f); - ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); - sub_v3_v3v3(r_out, rvec, dvec); - } - else { - zero_v3(r_out); - } -} - -/** * Get drawing reference point for conversion or projection of the stroke * \param[out] r_vec : Reference point found */ @@ -1476,7 +1442,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob) /* Cursor drawing */ /* check if cursor is in drawing region */ -static bool gp_check_cursor_region(bContext *C, int mval[2]) +static bool gp_check_cursor_region(bContext *C, int mval_i[2]) { ARegion *ar = CTX_wm_region(C); ScrArea *sa = CTX_wm_area(C); @@ -1496,7 +1462,7 @@ static bool gp_check_cursor_region(bContext *C, int mval[2]) return false; } else if (ar) { - return BLI_rcti_isect_pt_v(&ar->winrct, mval); + return BLI_rcti_isect_pt_v(&ar->winrct, mval_i); } else { return false; @@ -1558,7 +1524,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata) Brush *brush = NULL; Material *ma = NULL; MaterialGPencilStyle *gp_style = NULL; - int *last_mouse_position = customdata; + float *last_mouse_position = customdata; if ((gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE)) { gp_brush = &gset->brush[gset->weighttype]; @@ -1572,9 +1538,9 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata) float darkcolor[3]; float radius = 3.0f; - int mval[2] = {x, y}; + int mval_i[2] = {x, y}; /* check if cursor is in drawing region and has valid datablock */ - if ((!gp_check_cursor_region(C, mval)) || (gpd == NULL)) { + if ((!gp_check_cursor_region(C, mval_i)) || (gpd == NULL)) { return; } @@ -1708,7 +1674,7 @@ void ED_gpencil_toggle_brush_cursor(bContext *C, bool enable, void *customdata) { Scene *scene = CTX_data_scene(C); GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; - int *lastpost = customdata; + float *lastpost = customdata; if (gset->paintcursor && !enable) { /* clear cursor */ diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 62f8873d4bd..e4e047305c6 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -73,7 +73,7 @@ struct wmWindowManager; * Used as part of the 'stroke cache' used during drawing of new strokes */ typedef struct tGPspoint { - int x, y; /* x and y coordinates of cursor (in relative to area) */ + float x, y; /* x and y coordinates of cursor (in relative to area) */ float pressure; /* pressure of tablet at this point */ float strength; /* pressure of tablet at this point for alpha factor */ float time; /* Time relative to stroke start (used when converting to path) */ @@ -81,19 +81,6 @@ typedef struct tGPspoint { float uv_rot; /* uv rotation for dor mode */ } tGPspoint; -/* Temporary 'Stroke Point' data (2D / screen-space) - * - * Used for primitives. See: D4030 - */ -typedef struct tPGPspoint { - float x, y; /* x and y coordinates of cursor (in relative to area) */ - float pressure; /* pressure of tablet at this point */ - float strength; /* pressure of tablet at this point for alpha factor */ - float time; /* Time relative to stroke start (used when converting to path) */ - float uv_fac; /* factor of uv along the stroke */ - float uv_rot; /* uv rotation for dor mode */ -} tPGPspoint; - /* used to sort by zdepth gpencil objects in viewport */ /* TODO: this could be a system parameter in userprefs screen */ #define GP_CACHE_BLOCK_SIZE 16 |