Small optimisation: Only calculate the inverse_diff_mat once per stroke instead of for every point

(Later this calculation should be moved into the iteration macro instead, since
it only needs to be applied once per layer along with the diff_mat calculation)
This commit is contained in:
Joshua Leung 2016-08-29 13:50:53 +12:00
parent 299bb019b5
commit 44524f7519
1 changed files with 8 additions and 2 deletions

View File

@ -1907,7 +1907,15 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
if (gps->flag & GP_STROKE_SELECT) {
bGPDspoint *pt;
int i;
float inverse_diff_mat[4][4] = {0.0f};
/* Compute inverse matrix for unapplying parenting once instead of doing per-point */
/* TODO: add this bit to the iteration macro? */
if (gpl->parent) {
invert_m4_m4(inverse_diff_mat, diff_mat);
}
/* Adjust each point */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
float xy[2];
@ -1932,8 +1940,6 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* Unapply parent corrections */
if (gpl->parent) {
float inverse_diff_mat[4][4];
invert_m4_m4(inverse_diff_mat, diff_mat);
mul_m4_v3(inverse_diff_mat, &pt->x);
}
}