[Bf-blender-cvs] [65ec429d11] master: GP Interpolate Sequence: Tool settings for controlling the shape of interpolation

Joshua Leung noreply at git.blender.org
Wed Jan 18 07:43:21 CET 2017


Commit: 65ec429d1176404fcedd0dc29c03476972ab303f
Author: Joshua Leung
Date:   Wed Jan 18 19:00:17 2017 +1300
Branches: master
https://developer.blender.org/rB65ec429d1176404fcedd0dc29c03476972ab303f

GP Interpolate Sequence: Tool settings for controlling the shape of interpolation

This commit introduces the ability to use the Robert Penner easing equations
or a Custom Curve to control the way that the "Interpolate Sequence" operator
interpolates between keyframes. Previously, it was only possible to get linear
interpolation between the gp frames.

Workflow:
1) Place current frame between a pair of GP keyframes
2) Open the "Interpolate" panel in the Toolshelf
3) Choose the interpolation type (under "Sequence Options")
4) Adjust settings (e.g. if you're using "Custom Curve", use the curvemap widget
   to define the way that the interpolation proceeds)
5) Click "Sequence" to interpolate
6) Play back/scrub the animation to see if you've got the result you want
7) If you need to make some tweaks, undo, or delete the generated keyframes,
   then repeat the process again from step 4 until you've got the desired result.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/gpencil/gpencil_interpolate.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index c43f56acb3..1f06b202ad 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -244,8 +244,8 @@ class GreasePencilStrokeEditPanel:
             layout.separator()
             layout.operator("gpencil.reproject")
 
+
 class GreasePencilInterpolatePanel:
-    # subclass must set
     bl_space_type = 'VIEW_3D'
     bl_label = "Interpolate..."
     bl_category = "Grease Pencil"
@@ -273,6 +273,23 @@ class GreasePencilInterpolatePanel:
         col.prop(settings, "interpolate_all_layers")
         col.prop(settings, "interpolate_selected_only")
 
+        col = layout.column(align=True)
+        col.label(text="Sequence Options:")
+        col.prop(settings, "type")
+        if settings.type == 'CUSTOM':
+            box = layout.box()
+            # TODO: Options for loading/saving curve presets?
+            box.template_curve_mapping(settings, "interpolation_curve", brush=True)
+        elif settings.type != 'LINEAR':
+            col.prop(settings, "easing")
+
+            if settings.type == 'BACK':
+                layout.prop(settings, "back")
+            elif setting.type == 'ELASTIC':
+                sub = layout.column(align=True)
+                sub.prop(settings, "amplitude")
+                sub.prop(settings, "period")
+
 
 class GreasePencilBrushPanel:
     # subclass must set
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 3eb76a3b0f..60e86d7544 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -22,6 +22,7 @@ from bpy.types import Menu, Panel, UIList
 from bl_ui.properties_grease_pencil_common import (
         GreasePencilDrawingToolsPanel,
         GreasePencilStrokeEditPanel,
+        GreasePencilInterpolatePanel,
         GreasePencilStrokeSculptPanel,
         GreasePencilBrushPanel,
         GreasePencilBrushCurvesPanel
@@ -1963,6 +1964,11 @@ class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
     bl_space_type = 'VIEW_3D'
 
 
+# Grease Pencil stroke interpolation tools
+class VIEW3D_PT_tools_grease_pencil_interpolate(GreasePencilInterpolatePanel, Panel):
+    bl_space_type = 'VIEW_3D'
+
+
 # Grease Pencil stroke sculpting tools
 class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel):
     bl_space_type = 'VIEW_3D'
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 39a97b08df..69d3b4db54 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -287,13 +287,16 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
 		ts->imapaint.paintcursor = NULL;
 		id_us_plus((ID *)ts->imapaint.stencil);
 		ts->particle.paintcursor = NULL;
+		
 		/* duplicate Grease Pencil Drawing Brushes */
 		BLI_listbase_clear(&ts->gp_brushes);
 		for (bGPDbrush *brush = sce->toolsettings->gp_brushes.first; brush; brush = brush->next) {
 			bGPDbrush *newbrush = BKE_gpencil_brush_duplicate(brush);
 			BLI_addtail(&ts->gp_brushes, newbrush);
 		}
-
+		
+		/* duplicate Grease Pencil interpolation curve */
+		ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo);
 	}
 	
 	/* make a private copy of the avicodecdata */
@@ -440,12 +443,17 @@ void BKE_scene_free(Scene *sce)
 			BKE_paint_free(&sce->toolsettings->uvsculpt->paint);
 			MEM_freeN(sce->toolsettings->uvsculpt);
 		}
+		BKE_paint_free(&sce->toolsettings->imapaint.paint);
+		
 		/* free Grease Pencil Drawing Brushes */
 		BKE_gpencil_free_brushes(&sce->toolsettings->gp_brushes);
 		BLI_freelistN(&sce->toolsettings->gp_brushes);
-
-		BKE_paint_free(&sce->toolsettings->imapaint.paint);
-
+		
+		/* free Grease Pencil interpolation curve */
+		if (sce->toolsettings->gp_interpolate.custom_ipo) {
+			curvemapping_free(sce->toolsettings->gp_interpolate.custom_ipo);
+		}
+		
 		MEM_freeN(sce->toolsettings);
 		sce->toolsettings = NULL;
 	}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a63b9ed7d1..61f1965734 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5932,6 +5932,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
 			sce->toolsettings->wpaint->wpaint_prev = NULL;
 			sce->toolsettings->wpaint->tot = 0;
 		}
+		
 		/* relink grease pencil drawing brushes */
 		link_list(fd, &sce->toolsettings->gp_brushes);
 		for (bGPDbrush *brush = sce->toolsettings->gp_brushes.first; brush; brush = brush->next) {
@@ -5948,6 +5949,12 @@ static void direct_link_scene(FileData *fd, Scene *sce)
 				direct_link_curvemapping(fd, brush->cur_jitter);
 			}
 		}
+		
+		/* relink grease pencil interpolation curves */
+		sce->toolsettings->gp_interpolate.custom_ipo = newdataadr(fd, sce->toolsettings->gp_interpolate.custom_ipo);
+		if (sce->toolsettings->gp_interpolate.custom_ipo) {
+			direct_link_curvemapping(fd, sce->toolsettings->gp_interpolate.custom_ipo);
+		}
 	}
 
 	if (sce->ed) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index ad1999c0bc..7b8b95f000 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2691,6 +2691,10 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
 				write_curvemapping(wd, brush->cur_jitter);
 			}
 		}
+		/* write grease-pencil custom ipo curve to file */
+		if (tos->gp_interpolate.custom_ipo) {
+			write_curvemapping(wd, tos->gp_interpolate.custom_ipo);
+		}
 		
 
 		write_paint(wd, &tos->imapaint.paint);
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index ca51149353..287a6f214c 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -38,19 +38,22 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_math.h"
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
+#include "BLI_easing.h"
+#include "BLI_math.h"
 
 #include "BLT_translation.h"
 
+#include "DNA_color_types.h"
+#include "DNA_gpencil_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
-#include "DNA_gpencil_types.h"
 
+#include "BKE_colortools.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
@@ -681,6 +684,209 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot)
 
 /* ****************** Interpolate Sequence *********************** */
 
+/* Helper: Perform easing equation calculations for GP interpolation operator */
+static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_settings, float time)
+{
+	const float begin  = 0.0f;
+	const float change = 1.0f;
+	const float duration = 1.0f;
+	
+	const float back = ipo_settings->back;
+	const float amplitude = ipo_settings->amplitude;
+	const float period = ipo_settings->period;
+	
+	eBezTriple_Easing easing = ipo_settings->easing;
+	float result = time;
+	
+	switch (ipo_settings->type) {
+		case GP_IPO_BACK:
+			switch (easing) {
+				case BEZT_IPO_EASE_IN:
+					result = BLI_easing_back_ease_in(time, begin, change, duration, back);
+					break;
+				case BEZT_IPO_EASE_OUT:
+					result = BLI_easing_back_ease_out(time, begin, change, duration, back);
+					break;
+				case BEZT_IPO_EASE_IN_OUT:
+					result = BLI_easing_back_ease_in_out(time, begin, change, duration, back);
+					break;
+					
+				default: /* default/auto: same as ease out */
+					result = BLI_easing_back_ease_out(time, begin, change, duration, back);
+					break;
+			}
+			break;
+
+		case GP_IPO_BOUNCE:
+			switch (easing) {
+				case BEZT_IPO_EASE_IN:
+					result = BLI_easing_bounce_ease_in(time, begin, change, duration);
+					break;
+				case BEZT_IPO_EASE_OUT:
+					result = BLI_easing_bounce_ease_out(time, begin, change, duration);
+					break;
+				case BEZT_IPO_EASE_IN_OUT:
+					result = BLI_easing_bounce_ease_in_out(time, begin, change, duration);
+					break;
+					
+				default: /* default/auto: same as ease out */
+					result = BLI_easing_bounce_ease_out(time, begin, change, duration);
+					break;
+			}
+			break;
+			
+		case BEZT_IPO_CIRC:
+			switch (easing) {
+				case BEZT_IPO_EASE_IN:
+					result = BLI_easing_circ_ease_in(time, begin, change, duration);
+					break;
+				case BEZT_IPO_EASE_OUT:
+					result = BLI_easing_circ_ease_out(time, begin, change, duration);
+					break;
+				case BEZT_IPO_EASE_IN_OUT:
+					result = BLI_easing_circ_ease_in_out(time, begin, change, duration);
+					break;
+					
+				default: /* default/auto: same as ease in */
+					result = BLI_easing_circ_ease_in(time, begin, change, duration);
+					break;
+			}
+			break;
+
+		case BEZT_IPO_CUBIC:
+			switch (easing) {
+				case BEZT_IPO_EASE_IN:
+					result = BLI_easing_cubic_ease_in(time, begin, change, duration);
+					break;
+				case BEZT_IPO_EASE_OUT:
+					result = BLI_easing_cubic_ease_out(time, begin, change, duration);
+					break;
+				case BEZT_IPO_EASE_IN_OUT:
+					result = BLI_easing_cubic_ease_in_out(time, begin, change, duration);
+					break;
+					
+				default: /* default/auto: same as ease in */
+					result = BLI_easing_cubic_ease_in(time, begin, change, duration);
+					break;
+			}
+			break;
+		
+		case GP_IPO_ELASTIC:
+			switch (easing) {
+				case BEZT_IPO_EASE_IN:
+					result = BLI_easing_elastic_ease_in(time, begin, change, duration, amplitude, period);
+					break;
+				case BEZT_IPO_EASE_OUT:
+					result = BLI_easing_elastic_ease_out(time, begin, change, duration, amplitude, period);
+					break;
+				case BEZT_IPO_EASE_IN_OUT:
+					result = BLI_easing_elastic_ease_in_out(time, begin, change, duration, amplitude, period);
+					break;
+					
+				default: /* default/auto: same as ease out */
+					result = BLI_easing_elastic_ease_out(time, begin

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list