[Bf-blender-cvs] [d1a3223] GPencil_Editing_Stage3: Fix: Delete tagged GPencil stroke points now adjusts timing info

Joshua Leung noreply at git.blender.org
Sat Dec 12 15:24:07 CET 2015


Commit: d1a3223c765a434012ee9fd6e9313389e7db894c
Author: Joshua Leung
Date:   Sun Dec 13 02:30:09 2015 +1300
Branches: GPencil_Editing_Stage3
https://developer.blender.org/rBd1a3223c765a434012ee9fd6e9313389e7db894c

Fix: Delete tagged GPencil stroke points now adjusts timing info

gp_stroke_delete_tagged_points() now adjusts timing data for stroke points
to ensure that all the timing info will be valid after creating the new
stroke segments (from splitting the original stroke).

Several other tools need to be modified to do this still (e.g. Copy and Duplicate)

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

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 ccae692..9c832eb 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -837,19 +837,41 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke
 		/* there are islands, so create a series of new strokes, adding them before the "next" stroke */
 		int idx;
 		
-		/* create each new stroke... */
+		/* Create each new stroke... */
 		for (idx = 0; idx < num_islands; idx++) {
 			tGPDeleteIsland *island = &islands[idx];
 			bGPDstroke *new_stroke  = MEM_dupallocN(gps);
 			
-			/* compute new buffer size (+ 1 needed as the endpoint index is "inclusive") */
+			/* Compute new buffer size (+ 1 needed as the endpoint index is "inclusive") */
 			new_stroke->totpoints = island->end_idx - island->start_idx + 1;
 			new_stroke->points    = MEM_callocN(sizeof(bGPDspoint) * new_stroke->totpoints, "gp delete stroke fragment");
 			
-			/* copy over the relevant points */
+			/* Copy over the relevant points */
 			memcpy(new_stroke->points, gps->points + island->start_idx, sizeof(bGPDspoint) * new_stroke->totpoints);
 			
-			/* add new stroke to the frame */
+			
+			/* Each island corresponds to a new stroke. We must adjust the 
+			 * timings of these new strokes:
+			 *
+			 * Each point's timing data is a delta from stroke's inittime, so as we erase some points from
+			 * the start of the stroke, we have to offset this inittime and all remaing points' delta values.
+			 * This way we get a new stroke with exactly the same timing as if user had started drawing from
+			 * the first non-removed point...
+			 */
+			{
+				bGPDspoint *pts;
+				float delta = gps->points[island->start_idx].time;
+				int j;
+				
+				new_stroke->inittime += (double)delta;
+				
+				pts = new_stroke->points;
+				for (j = 0; j < new_stroke->totpoints; j++, pts++) {
+					pts->time -= delta;
+				}
+			}
+			
+			/* Add new stroke to the frame */
 			if (next_stroke) {
 				BLI_insertlinkbefore(&gpf->strokes, next_stroke, new_stroke);
 			}




More information about the Bf-blender-cvs mailing list