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 /source/blender/editors/gpencil/gpencil_utils.c | |
parent | 942e9835a9acdc19164bf6b07796eace1548f3fd (diff) |
GP: Refactor coordinates to float
See: D4030
Differential Revision: https://developer.blender.org/D4036
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_utils.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 60 |
1 files changed, 13 insertions, 47 deletions
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 */ |