Cleanup: Rename function `gpencil_point_to_parent_space`

gpencil_point_to_parent_space -> gpencil_point_to_world_space

The old name was not clear because it looked it was moving into
the object space, but really is doing the opposite.
This commit is contained in:
Antonio Vazquez 2022-10-02 13:38:25 +02:00
parent 8f1d3e14d9
commit 9d30adb7eb
10 changed files with 48 additions and 48 deletions

View File

@ -5460,7 +5460,7 @@ static bool gpencil_test_lasso(bGPDstroke *gps,
const struct GP_SelectLassoUserData *data = user_data;
bGPDspoint pt2;
int x0, y0;
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy(gsc, gps, &pt2, &x0, &y0);
/* test if in lasso */
return ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(&data->rect, x0, y0) &&

View File

@ -429,7 +429,7 @@ static void gpencil_load_array_strokes(tGPDfill *tgpf)
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
bGPDspoint pt2;
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy_fl(
&tgpf->gsc, gps, &pt2, &stroke->points2d[i][0], &stroke->points2d[i][1]);
}
@ -597,11 +597,11 @@ static void gpencil_cut_extensions(tGPDfill *tgpf)
/* First stroke. */
bGPDspoint *pt = &gps_a->points[0];
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy_fl(&tgpf->gsc, gps_a, &pt2, &a1xy[0], &a1xy[1]);
pt = &gps_a->points[1];
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy_fl(&tgpf->gsc, gps_a, &pt2, &a2xy[0], &a2xy[1]);
bGPDspoint *extreme_a = &gps_a->points[1];
@ -624,11 +624,11 @@ static void gpencil_cut_extensions(tGPDfill *tgpf)
}
pt = &gps_b->points[0];
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy_fl(&tgpf->gsc, gps_b, &pt2, &b1xy[0], &b1xy[1]);
pt = &gps_b->points[1];
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy_fl(&tgpf->gsc, gps_b, &pt2, &b2xy[0], &b2xy[1]);
bGPDspoint *extreme_b = &gps_b->points[1];

View File

@ -276,15 +276,15 @@ void gpencil_point_to_xy_fl(const GP_SpaceConversion *gsc,
float *r_y);
/**
* Convert point to parent space
* Convert point to world space
*
* \param pt: Original point
* \param diff_mat: Matrix with the difference between original parent matrix
* \param diff_mat: Matrix with the transformation
* \param[out] r_pt: Pointer to new point after apply matrix
*/
void gpencil_point_to_parent_space(const bGPDspoint *pt,
const float diff_mat[4][4],
bGPDspoint *r_pt);
void gpencil_point_to_world_space(const bGPDspoint *pt,
const float diff_mat[4][4],
bGPDspoint *r_pt);
/**
* Change points position relative to parent object
*/

View File

@ -167,20 +167,20 @@ static bool gpencil_stroke_need_flip(Depsgraph *depsgraph,
/* Line from start of strokes. */
pt = &gps_from->points[0];
gpencil_point_to_parent_space(pt, diff_mat, &pt_dummy_ps);
gpencil_point_to_world_space(pt, diff_mat, &pt_dummy_ps);
gpencil_point_to_xy_fl(gsc, gps_from, &pt_dummy_ps, &v_from_start[0], &v_from_start[1]);
pt = &gps_to->points[0];
gpencil_point_to_parent_space(pt, diff_mat, &pt_dummy_ps);
gpencil_point_to_world_space(pt, diff_mat, &pt_dummy_ps);
gpencil_point_to_xy_fl(gsc, gps_from, &pt_dummy_ps, &v_to_start[0], &v_to_start[1]);
/* Line from end of strokes. */
pt = &gps_from->points[gps_from->totpoints - 1];
gpencil_point_to_parent_space(pt, diff_mat, &pt_dummy_ps);
gpencil_point_to_world_space(pt, diff_mat, &pt_dummy_ps);
gpencil_point_to_xy_fl(gsc, gps_from, &pt_dummy_ps, &v_from_end[0], &v_from_end[1]);
pt = &gps_to->points[gps_to->totpoints - 1];
gpencil_point_to_parent_space(pt, diff_mat, &pt_dummy_ps);
gpencil_point_to_world_space(pt, diff_mat, &pt_dummy_ps);
gpencil_point_to_xy_fl(gsc, gps_from, &pt_dummy_ps, &v_to_end[0], &v_to_end[1]);
const bool isect_lines = (isect_seg_seg_v2(v_from_start, v_to_start, v_from_end, v_to_end) ==

View File

@ -1551,7 +1551,7 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p,
/* only process if it hasn't been masked out... */
if (!(p->flags & GP_PAINTFLAG_SELECTMASK) || (gps->points->flag & GP_SPOINT_SELECT)) {
bGPDspoint pt_temp;
gpencil_point_to_parent_space(gps->points, p->diff_mat, &pt_temp);
gpencil_point_to_world_space(gps->points, p->diff_mat, &pt_temp);
gpencil_point_to_xy(&p->gsc, gps, &pt_temp, &pc1[0], &pc1[1]);
/* Do bound-box check first. */
if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) {
@ -1575,7 +1575,7 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p,
/* get points to work with */
pt1 = gps->points + i;
bGPDspoint npt;
gpencil_point_to_parent_space(pt1, p->diff_mat, &npt);
gpencil_point_to_world_space(pt1, p->diff_mat, &npt);
gpencil_point_to_xy(&p->gsc, gps, &npt, &pc1[0], &pc1[1]);
/* Do bound-box check first. */
@ -1633,14 +1633,14 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p,
}
bGPDspoint npt;
gpencil_point_to_parent_space(pt1, p->diff_mat, &npt);
gpencil_point_to_world_space(pt1, p->diff_mat, &npt);
gpencil_point_to_xy(&p->gsc, gps, &npt, &pc1[0], &pc1[1]);
gpencil_point_to_parent_space(pt2, p->diff_mat, &npt);
gpencil_point_to_world_space(pt2, p->diff_mat, &npt);
gpencil_point_to_xy(&p->gsc, gps, &npt, &pc2[0], &pc2[1]);
if (pt0) {
gpencil_point_to_parent_space(pt0, p->diff_mat, &npt);
gpencil_point_to_world_space(pt0, p->diff_mat, &npt);
gpencil_point_to_xy(&p->gsc, gps, &npt, &pc0[0], &pc0[1]);
}
else {

View File

@ -1462,7 +1462,7 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso,
bGPDspoint pt_temp;
pt = &gps->points[0];
if ((is_masking && (pt->flag & GP_SPOINT_SELECT) != 0) || (!is_masking)) {
gpencil_point_to_parent_space(gps->points, diff_mat, &pt_temp);
gpencil_point_to_world_space(gps->points, diff_mat, &pt_temp);
gpencil_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]);
pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
@ -1499,10 +1499,10 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso,
}
}
bGPDspoint npt;
gpencil_point_to_parent_space(pt1, diff_mat, &npt);
gpencil_point_to_world_space(pt1, diff_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]);
gpencil_point_to_parent_space(pt2, diff_mat, &npt);
gpencil_point_to_world_space(pt2, diff_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc2[0], &pc2[1]);
/* Check that point segment of the bound-box of the selection stroke. */
@ -1803,7 +1803,7 @@ static bool get_automasking_strokes_list(tGP_BrushEditData *gso)
bGPDspoint npt;
if (gps->totpoints == 1) {
gpencil_point_to_parent_space(gps->points, bound_mat, &npt);
gpencil_point_to_world_space(gps->points, bound_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]);
/* Only check if point is inside. */
@ -1821,7 +1821,7 @@ static bool get_automasking_strokes_list(tGP_BrushEditData *gso)
pt2 = gps->points + i + 1;
/* Check first point. */
gpencil_point_to_parent_space(pt1, bound_mat, &npt);
gpencil_point_to_world_space(pt1, bound_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]);
if (len_v2v2_int(mval_i, pc1) <= radius) {
BLI_ghash_insert(gso->automasking_strokes, gps, gps);
@ -1830,7 +1830,7 @@ static bool get_automasking_strokes_list(tGP_BrushEditData *gso)
}
/* Check second point. */
gpencil_point_to_parent_space(pt2, bound_mat, &npt);
gpencil_point_to_world_space(pt2, bound_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc2[0], &pc2[1]);
if (len_v2v2_int(mval_i, pc2) <= radius) {
BLI_ghash_insert(gso->automasking_strokes, gps, gps);

View File

@ -1497,7 +1497,7 @@ static bool gpencil_stroke_do_circle_sel(bGPdata *gpd,
pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
bGPDspoint pt_temp;
gpencil_point_to_parent_space(pt, diff_mat, &pt_temp);
gpencil_point_to_world_space(pt, diff_mat, &pt_temp);
gpencil_point_to_xy(gsc, gps, &pt_temp, &x0, &y0);
/* do boundbox check first */
@ -2477,7 +2477,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
int xy[2];
bGPDspoint pt2;
gpencil_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
gpencil_point_to_world_space(pt, gpstroke_iter.diff_mat, &pt2);
gpencil_point_to_xy(&gsc, gps_active, &pt2, &xy[0], &xy[1]);
/* do boundbox check first */

View File

@ -612,9 +612,9 @@ void gpencil_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
}
}
void gpencil_point_to_parent_space(const bGPDspoint *pt,
const float diff_mat[4][4],
bGPDspoint *r_pt)
void gpencil_point_to_world_space(const bGPDspoint *pt,
const float diff_mat[4][4],
bGPDspoint *r_pt)
{
mul_v3_m4v3(&r_pt->x, diff_mat, &pt->x);
}
@ -937,7 +937,7 @@ void ED_gpencil_project_stroke_to_view(bContext *C, bGPDlayer *gpl, bGPDstroke *
float xy[2];
bGPDspoint pt2;
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy_fl(&gsc, gps, &pt2, &xy[0], &xy[1]);
/* Planar - All on same plane parallel to the viewplane */
@ -1083,7 +1083,7 @@ void ED_gpencil_stroke_reproject(Depsgraph *depsgraph,
* artifacts in the final points. */
bGPDspoint pt2;
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy_fl(gsc, gps_active, &pt2, &xy[0], &xy[1]);
/* Project stroke in one axis */
@ -2943,7 +2943,7 @@ void ED_gpencil_projected_2d_bound_box(const GP_SpaceConversion *gsc,
for (int i = 0; i < 8; i++) {
bGPDspoint pt_dummy, pt_dummy_ps;
copy_v3_v3(&pt_dummy.x, bb.vec[i]);
gpencil_point_to_parent_space(&pt_dummy, diff_mat, &pt_dummy_ps);
gpencil_point_to_world_space(&pt_dummy, diff_mat, &pt_dummy_ps);
gpencil_point_to_xy_fl(gsc, gps, &pt_dummy_ps, &bounds[i][0], &bounds[i][1]);
}
@ -3007,7 +3007,7 @@ bool ED_gpencil_stroke_point_is_inside(const bGPDstroke *gps,
int i;
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
bGPDspoint pt2;
gpencil_point_to_parent_space(pt, diff_mat, &pt2);
gpencil_point_to_world_space(pt, diff_mat, &pt2);
gpencil_point_to_xy(gsc, gps, &pt2, &mcoords[i][0], &mcoords[i][1]);
}
@ -3033,9 +3033,9 @@ void ED_gpencil_stroke_extremes_to2d(const GP_SpaceConversion *gsc,
{
bGPDspoint pt_dummy_ps;
gpencil_point_to_parent_space(&gps->points[0], diff_mat, &pt_dummy_ps);
gpencil_point_to_world_space(&gps->points[0], diff_mat, &pt_dummy_ps);
gpencil_point_to_xy_fl(gsc, gps, &pt_dummy_ps, &r_ctrl1[0], &r_ctrl1[1]);
gpencil_point_to_parent_space(&gps->points[gps->totpoints - 1], diff_mat, &pt_dummy_ps);
gpencil_point_to_world_space(&gps->points[gps->totpoints - 1], diff_mat, &pt_dummy_ps);
gpencil_point_to_xy_fl(gsc, gps, &pt_dummy_ps, &r_ctrl2[0], &r_ctrl2[1]);
}
@ -3063,11 +3063,11 @@ bGPDstroke *ED_gpencil_stroke_nearest_to_ends(bContext *C,
float pt2d_start[2], pt2d_end[2];
bGPDspoint *pt = &gps->points[0];
gpencil_point_to_parent_space(pt, diff_mat, &pt_parent);
gpencil_point_to_world_space(pt, diff_mat, &pt_parent);
gpencil_point_to_xy_fl(gsc, gps, &pt_parent, &pt2d_start[0], &pt2d_start[1]);
pt = &gps->points[gps->totpoints - 1];
gpencil_point_to_parent_space(pt, diff_mat, &pt_parent);
gpencil_point_to_world_space(pt, diff_mat, &pt_parent);
gpencil_point_to_xy_fl(gsc, gps, &pt_parent, &pt2d_end[0], &pt2d_end[1]);
/* Loop all strokes of the active frame. */
@ -3093,11 +3093,11 @@ bGPDstroke *ED_gpencil_stroke_nearest_to_ends(bContext *C,
float pt2d_target_start[2], pt2d_target_end[2];
pt = &gps_target->points[0];
gpencil_point_to_parent_space(pt, diff_mat, &pt_parent);
gpencil_point_to_world_space(pt, diff_mat, &pt_parent);
gpencil_point_to_xy_fl(gsc, gps, &pt_parent, &pt2d_target_start[0], &pt2d_target_start[1]);
pt = &gps_target->points[gps_target->totpoints - 1];
gpencil_point_to_parent_space(pt, diff_mat, &pt_parent);
gpencil_point_to_world_space(pt, diff_mat, &pt_parent);
gpencil_point_to_xy_fl(gsc, gps, &pt_parent, &pt2d_target_end[0], &pt2d_target_end[1]);
/* If the distance to the original stroke extremes is too big, the stroke must not be joined.
@ -3121,7 +3121,7 @@ bGPDstroke *ED_gpencil_stroke_nearest_to_ends(bContext *C,
for (i = 0, pt = gps_target->points; i < gps_target->totpoints; i++, pt++) {
/* Convert point to 2D. */
float pt2d[2];
gpencil_point_to_parent_space(pt, diff_mat, &pt_parent);
gpencil_point_to_world_space(pt, diff_mat, &pt_parent);
gpencil_point_to_xy_fl(gsc, gps, &pt_parent, &pt2d[0], &pt2d[1]);
/* Check with Start point. */

View File

@ -846,7 +846,7 @@ static bool gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
if (gps->totpoints == 1) {
bGPDspoint pt_temp;
pt = &gps->points[0];
gpencil_point_to_parent_space(gps->points, diff_mat, &pt_temp);
gpencil_point_to_world_space(gps->points, diff_mat, &pt_temp);
gpencil_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]);
pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
@ -884,10 +884,10 @@ static bool gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
}
bGPDspoint npt;
gpencil_point_to_parent_space(pt1, diff_mat, &npt);
gpencil_point_to_world_space(pt1, diff_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]);
gpencil_point_to_parent_space(pt2, diff_mat, &npt);
gpencil_point_to_world_space(pt2, diff_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc2[0], &pc2[1]);
/* Check that point segment of the bound-box of the selection stroke. */

View File

@ -413,7 +413,7 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso,
if (gps->totpoints == 1) {
bGPDspoint pt_temp;
pt = &gps->points[0];
gpencil_point_to_parent_space(gps->points, diff_mat, &pt_temp);
gpencil_point_to_world_space(gps->points, diff_mat, &pt_temp);
gpencil_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]);
pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
@ -440,10 +440,10 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso,
pt2 = gps->points + i + 1;
bGPDspoint npt;
gpencil_point_to_parent_space(pt1, diff_mat, &npt);
gpencil_point_to_world_space(pt1, diff_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc1[0], &pc1[1]);
gpencil_point_to_parent_space(pt2, diff_mat, &npt);
gpencil_point_to_world_space(pt2, diff_mat, &npt);
gpencil_point_to_xy(gsc, gps, &npt, &pc2[0], &pc2[1]);
/* Check that point segment of the bound-box of the selection stroke */