GPencil: Add inverse diff matrix to iterator macro

GPencil: Cleanup inverse mat code

This calculation is done in the macro, so don't need do it again in loop.
This commit is contained in:
Antonioya 2019-07-25 12:10:47 +02:00
parent d3ca0bf6f8
commit fd730fce0c
2 changed files with 3 additions and 7 deletions

View File

@ -3401,12 +3401,6 @@ 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];
/* Compute inverse matrix for unapplying parenting once instead of doing per-point */
/* TODO: add this bit to the iteration macro? */
invert_m4_m4(inverse_diff_mat, gpstroke_iter.diff_mat);
/* Adjust each point */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
float xy[2];
@ -3493,7 +3487,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* Unapply parent corrections */
if (!ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP)) {
mul_m4_v3(inverse_diff_mat, &pt->x);
mul_m4_v3(gpstroke_iter.inverse_diff_mat, &pt->x);
}
}
}

View File

@ -583,6 +583,7 @@ typedef enum ACTCONT_TYPES {
struct GP_EditableStrokes_Iter {
float diff_mat[4][4];
float inverse_diff_mat[4][4];
};
/**
@ -607,6 +608,7 @@ struct GP_EditableStrokes_Iter {
for (bGPDframe *gpf_ = init_gpf_; gpf_; gpf_ = gpf_->next) { \
if ((gpf_ == gpl->actframe) || ((gpf_->flag & GP_FRAME_SELECT) && is_multiedit_)) { \
ED_gpencil_parent_location(depsgraph_, obact_, gpd_, gpl, gpstroke_iter.diff_mat); \
invert_m4_m4(gpstroke_iter.inverse_diff_mat, gpstroke_iter.diff_mat); \
/* loop over strokes */ \
for (bGPDstroke *gps = gpf_->strokes.first; gps; gps = gps->next) { \
/* skip strokes that are invalid for current view */ \