From 8f1d3e14d9b472c00c1e537cc1e6e20b279d08e1 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Sun, 2 Oct 2022 13:34:39 +0200 Subject: Cleanup: Rename functions gpencil_apply_parent->gpencil_world_to_object_space gpencil_apply_parent_point->gpencil_world_to_object_space_point The old name was not descriptive enough. --- source/blender/editors/gpencil/gpencil_edit.c | 4 +-- source/blender/editors/gpencil/gpencil_fill.c | 2 +- source/blender/editors/gpencil/gpencil_intern.h | 16 ++++++------ source/blender/editors/gpencil/gpencil_paint.c | 4 +-- source/blender/editors/gpencil/gpencil_primitive.c | 2 +- source/blender/editors/gpencil/gpencil_utils.c | 29 +++++++++------------- 6 files changed, 26 insertions(+), 31 deletions(-) diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 3aa83262505..2615f70a21a 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2914,7 +2914,7 @@ static int gpencil_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) /* return data */ copy_v3_v3(&pt->x, fpt); - gpencil_apply_parent_point(depsgraph, obact, gpl, pt); + gpencil_world_to_object_space_point(depsgraph, obact, gpl, pt); changed = true; } @@ -3015,7 +3015,7 @@ static int gpencil_snap_to_cursor(bContext *C, wmOperator *op) for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) { copy_v3_v3(&pt->x, cursor_global); - gpencil_apply_parent_point(depsgraph, obact, gpl, pt); + gpencil_world_to_object_space_point(depsgraph, obact, gpl, pt); changed = true; } diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 3f49ced16da..e288c6c4aca 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -2228,7 +2228,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) /* if parented change position relative to parent object */ for (int a = 0; a < tgpf->sbuffer_used; a++) { pt = &gps->points[a]; - gpencil_apply_parent_point(tgpf->depsgraph, tgpf->ob, tgpf->gpl, pt); + gpencil_world_to_object_space_point(tgpf->depsgraph, tgpf->ob, tgpf->gpl, pt); } /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 4d62f834d86..3b797e7e4c8 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -291,20 +291,20 @@ void gpencil_point_to_parent_space(const bGPDspoint *pt, /** * Change position relative to parent object */ -void gpencil_apply_parent(struct Depsgraph *depsgraph, - struct Object *obact, - bGPDlayer *gpl, - bGPDstroke *gps); +void gpencil_world_to_object_space(struct Depsgraph *depsgraph, + struct Object *obact, + bGPDlayer *gpl, + bGPDstroke *gps); /** * Change point position relative to parent object */ /** * Change point position relative to parent object */ -void gpencil_apply_parent_point(struct Depsgraph *depsgraph, - struct Object *obact, - bGPDlayer *gpl, - bGPDspoint *pt); +void gpencil_world_to_object_space_point(struct Depsgraph *depsgraph, + struct Object *obact, + bGPDlayer *gpl, + bGPDspoint *pt); /** * generic based on gpencil_point_to_xy_fl diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index e1eeda5437a..9a067dc018f 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1137,7 +1137,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) pt = gps->points; for (int i = 0; i < gps->totpoints; i++, pt++) { /* if parented change position relative to parent object */ - gpencil_apply_parent_point(depsgraph, obact, gpl, pt); + gpencil_world_to_object_space_point(depsgraph, obact, gpl, pt); } /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ @@ -1302,7 +1302,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* reproject to plane (only in 3d space) */ gpencil_reproject_toplane(p, gps); /* change position relative to parent object */ - gpencil_apply_parent(depsgraph, obact, gpl, gps); + gpencil_world_to_object_space(depsgraph, obact, gpl, gps); /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ if ((!is_depth) && (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || is_camera)) { ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index b13cab8be6d..67774b97c10 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -1073,7 +1073,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* if parented change position relative to parent object */ for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; - gpencil_apply_parent_point(tgpi->depsgraph, tgpi->ob, tgpi->gpl, pt); + gpencil_world_to_object_space_point(tgpi->depsgraph, tgpi->ob, tgpi->gpl, pt); } /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index c972d7c680f..9af143e590d 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -616,13 +616,13 @@ void gpencil_point_to_parent_space(const bGPDspoint *pt, const float diff_mat[4][4], bGPDspoint *r_pt) { - float fpt[3]; - - mul_v3_m4v3(fpt, diff_mat, &pt->x); - copy_v3_v3(&r_pt->x, fpt); + mul_v3_m4v3(&r_pt->x, diff_mat, &pt->x); } -void gpencil_apply_parent(Depsgraph *depsgraph, Object *obact, bGPDlayer *gpl, bGPDstroke *gps) +void gpencil_world_to_object_space(Depsgraph *depsgraph, + Object *obact, + bGPDlayer *gpl, + bGPDstroke *gps) { bGPDspoint *pt; int i; @@ -630,34 +630,29 @@ void gpencil_apply_parent(Depsgraph *depsgraph, Object *obact, bGPDlayer *gpl, b /* undo matrix */ float diff_mat[4][4]; float inverse_diff_mat[4][4]; - float fpt[3]; BKE_gpencil_layer_transform_matrix_get(depsgraph, obact, gpl, diff_mat); invert_m4_m4(inverse_diff_mat, diff_mat); for (i = 0; i < gps->totpoints; i++) { pt = &gps->points[i]; - mul_v3_m4v3(fpt, inverse_diff_mat, &pt->x); - copy_v3_v3(&pt->x, fpt); + mul_m4_v3(inverse_diff_mat, &pt->x); } } -void gpencil_apply_parent_point(Depsgraph *depsgraph, - Object *obact, - bGPDlayer *gpl, - bGPDspoint *pt) +void gpencil_world_to_object_space_point(Depsgraph *depsgraph, + Object *obact, + bGPDlayer *gpl, + bGPDspoint *pt) { /* undo matrix */ float diff_mat[4][4]; float inverse_diff_mat[4][4]; - float fpt[3]; BKE_gpencil_layer_transform_matrix_get(depsgraph, obact, gpl, diff_mat); invert_m4_m4(inverse_diff_mat, diff_mat); - mul_v3_m4v3(fpt, inverse_diff_mat, &pt->x); - - copy_v3_v3(&pt->x, fpt); + mul_m4_v3(inverse_diff_mat, &pt->x); } void gpencil_point_to_xy( @@ -1122,7 +1117,7 @@ void ED_gpencil_stroke_reproject(Depsgraph *depsgraph, copy_v3_v3(&pt->x, &pt2.x); /* apply parent again */ - gpencil_apply_parent_point(depsgraph, gsc->ob, gpl, pt); + gpencil_world_to_object_space_point(depsgraph, gsc->ob, gpl, pt); } /* Project screen-space back to 3D space (from current perspective) * so that all points have been treated the same way. */ -- cgit v1.2.3