[Bf-blender-cvs] [44524f7] master: Small optimisation: Only calculate the inverse_diff_mat once per stroke instead of for every point

Joshua Leung noreply at git.blender.org
Mon Aug 29 04:52:50 CEST 2016


Commit: 44524f751954598038f957403d4fdc9d814ff31c
Author: Joshua Leung
Date:   Mon Aug 29 13:50:53 2016 +1200
Branches: master
https://developer.blender.org/rB44524f751954598038f957403d4fdc9d814ff31c

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)

===================================================================

M	source/blender/editors/gpencil/gpencil_edit.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index d9b6c80..d308d3a 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -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);
 				}
 			}




More information about the Bf-blender-cvs mailing list