[Bf-blender-cvs] [bdb33d3] GPencil_EditStrokes: Initial/backend support for animating settings of Grease Pencil datablocks

Joshua Leung noreply at git.blender.org
Wed Nov 26 13:31:48 CET 2014


Commit: bdb33d3c6e891d03b697666725bdf5b75662cfb8
Author: Joshua Leung
Date:   Thu Nov 27 01:27:52 2014 +1300
Branches: GPencil_EditStrokes
https://developer.blender.org/rBbdb33d3c6e891d03b697666725bdf5b75662cfb8

Initial/backend support for animating settings of Grease Pencil datablocks

This commit makes it possible to insert keyframes for the line thickness,
opacity, colour, and even volumetric/non-volumetric options. It is useful
to be able to do this in order to control the thickness of lines when the
camera is placed quite close.

Notes:
* Currently, apart from the keyframe status indicator colours applied to the
  buttons, these keyframes are not shown anywhere. Support for this will be
  added to the animation editors shortly, but for those who need this functionality,
  it's better that it works in some way first :)
* No support for drivers exists yet. This may still get supported a bit later...

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

M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 08b4436..5bf4588 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -100,6 +100,7 @@ bool id_type_can_have_animdata(ID *id)
 		case ID_SCE:
 		case ID_MC:
 		case ID_MSK:
+		case ID_GD:
 		{
 			return 1;
 		}
@@ -1031,6 +1032,9 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u
 
 	/* line styles */
 	ANIMDATA_IDS_CB(mainptr->linestyle.first);
+	
+	/* grease pencil */
+	ANIMDATA_IDS_CB(mainptr->gpencil.first);
 }
 
 /* Fix all RNA-Paths throughout the database (directly access the Global.main version)
@@ -1119,6 +1123,9 @@ void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const cha
 	/* linestyles */
 	RENAMEFIX_ANIM_IDS(mainptr->linestyle.first);
 	
+	/* grease pencil */
+	RENAMEFIX_ANIM_IDS(mainptr->gpencil.first);
+	
 	/* scenes */
 	RENAMEFIX_ANIM_NODETREE_IDS(mainptr->scene.first, Scene);
 }
@@ -2680,6 +2687,9 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
 	/* linestyles */
 	EVAL_ANIM_IDS(main->linestyle.first, ADT_RECALC_ANIM);
 	
+	/* grease pencil */
+	EVAL_ANIM_IDS(main->gpencil.first, ADT_RECALC_ANIM);
+	
 	/* objects */
 	/* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets
 	 * this tagged by Depsgraph on framechange. This optimization means that objects
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 2b60a6a..dd21555 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -45,6 +45,7 @@
 #include "DNA_gpencil_types.h"
 #include "DNA_userdef_types.h"
 
+#include "BKE_animsys.h"
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
 #include "BKE_library.h"
@@ -115,6 +116,12 @@ void BKE_gpencil_free(bGPdata *gpd)
 {
 	/* free layers */
 	free_gpencil_layers(&gpd->layers);
+	
+	/* free animation data */
+	if (gpd->adt) {
+		BKE_free_animdata(&gpd->id);
+		gpd->adt = NULL;
+	}
 }
 
 /* -------- Container Creation ---------- */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 0786567..3fb047e 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -33,6 +33,9 @@
 #include "DNA_listBase.h"
 #include "DNA_ID.h"
 
+struct AnimData;
+
+
 /* Grease-Pencil Annotations - 'Stroke Point'
  *	-> Coordinates may either be 2d or 3d depending on settings at the time
  * 	-> Coordinates of point on stroke, in proportions of window size
@@ -154,7 +157,8 @@ typedef enum eGPDlayer_Flag {
 
 /* Grease-Pencil Annotations - 'DataBlock' */
 typedef struct bGPdata {
-	ID id;					/* Grease Pencil data is */
+	ID id;					/* Grease Pencil data is a datablock */
+	struct AnimData *adt;   /* animation data - for animating draw settings */
 	
 	/* saved Grease-Pencil data */
 	ListBase layers;		/* bGPDlayers */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index edb5727..ace4f75 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -55,6 +55,16 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
 	WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
 }
 
+static char *rna_GPencilLayer_path(PointerRNA *ptr)
+{
+	bGPDlayer *gpl = (bGPDlayer *)ptr->data;
+	char name_esc[sizeof(gpl->info) * 2];
+	
+	BLI_strescape(name_esc, gpl->info, sizeof(name_esc));
+	
+	return BLI_sprintfN("layers[\"%s\"]", name_esc);
+}
+
 static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
 {
 	bGPDlayer *gpl = (bGPDlayer *)ptr->data;
@@ -602,6 +612,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	srna = RNA_def_struct(brna, "GPencilLayer", NULL);
 	RNA_def_struct_sdna(srna, "bGPDlayer");
 	RNA_def_struct_ui_text(srna, "Grease Pencil Layer", "Collection of related sketches");
+	RNA_def_struct_path_func(srna, "rna_GPencilLayer_path");
 	
 	/* Name */
 	prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
@@ -827,6 +838,9 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Layers", "");
 	rna_def_gpencil_layers_api(brna, prop);
 	
+	/* Animation Data */
+	rna_def_animdata_common(srna);
+	
 	/* Flags */
 	prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");




More information about the Bf-blender-cvs mailing list