[Bf-blender-cvs] [99d13d1c65a] greasepencil-object: Cleanup: Remove the redundant GP_TOOL_SOURCE_OBJECT stuff

Joshua Leung noreply at git.blender.org
Sat Nov 4 05:47:48 CET 2017


Commit: 99d13d1c65a3a640863e050a171a35a119a10e2b
Author: Joshua Leung
Date:   Mon Oct 30 00:44:56 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB99d13d1c65a3a640863e050a171a35a119a10e2b

Cleanup: Remove the redundant GP_TOOL_SOURCE_OBJECT stuff

Since we only have GP objects in the 3D view now, this is the only
setting that should be used. Therefore, there's no need to set this
setting or check if for any reasons anymore.

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

M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/gpencil/gpencil_data.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/object/object_add.c
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 03ad060f95e..6064f3d05eb 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -434,14 +434,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 
 				ob = BKE_object_add(main, scene, sl, OB_GPENCIL, "GP_Scene");
 				zero_v3(ob->loc);
+				
+				// FIXME: function above actually initialises a new db already, which we throw away...
 				ob->data = scene->gpd;
 				scene->gpd = NULL;
 
 				/* set cache as dirty */
 				BKE_gpencil_batch_cache_dirty(ob->data);
 			}
-			/* set default mode as object */
-			scene->toolsettings->gpencil_src = GP_TOOL_SOURCE_OBJECT;
 		}
 		
 		/* Handle object-linked grease pencil datablocks */
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index c1619ae22a7..99d747c4563 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1643,17 +1643,15 @@ static int gp_convert_scene_to_object_poll(bContext *C)
 static int gp_convert_scene_to_object_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Scene *scene = CTX_data_scene(C);
-	ToolSettings *ts = CTX_data_tool_settings(C);
 	bGPdata *gpd = scene->gpd;
 	float loc[3] = { 0.0f, 0.0f, 0.0f };
 
 	Object *ob = ED_add_gpencil_object(C, scene, loc); /* always in origin */
+	
+	// FIXME: This loses the datablock created above...
 	ob->data = gpd;
 	scene->gpd = NULL;
 
-	/* set grease pencil mode to object */
-	ts->gpencil_src = GP_TOOL_SOURCE_OBJECT;
-
 	/* notifiers */
 	BKE_gpencil_batch_cache_dirty(gpd);
 	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 67da2408991..01ffc24fc9b 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1445,9 +1445,6 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
 					p->scene->gp_object = obact;
 				}
 			}
-			
-			/* set grease pencil mode to object */
-			ts->gpencil_src = GP_TOOL_SOURCE_OBJECT;
 			break;
 		}
 		case SPACE_NODE:
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 306178bb165..1039dc07d7f 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1197,11 +1197,10 @@ void ED_gp_project_stroke_to_plane(Object *ob, RegionView3D *rv3d, bGPDstroke *g
 	/* normal vector for a plane locked to axis */
 	zero_v3(plane_normal);
 	plane_normal[axis] = 1.0f;
+	
 	/* if object, apply object rotation */
-	if (type & GP_TOOL_SOURCE_OBJECT) {
-		if (ob && ob->type == OB_GPENCIL) {
-			mul_mat3_m4_v3(ob->obmat, plane_normal);
-		}
+	if (ob && (ob->type == OB_GPENCIL)) {
+		mul_mat3_m4_v3(ob->obmat, plane_normal);
 	}
 
 	/* Reproject the points in the plane */
@@ -1239,11 +1238,10 @@ void ED_gp_project_point_to_plane(Object *ob, RegionView3D *rv3d, const float or
 	/* normal vector for a plane locked to axis */
 	zero_v3(plane_normal);
 	plane_normal[axis] = 1.0f;
+	
 	/* if object, apply object rotation */
-	if (type & GP_TOOL_SOURCE_OBJECT) {
-		if (ob && ob->type == OB_GPENCIL) {
-			mul_mat3_m4_v3(ob->obmat, plane_normal);
-		}
+	if (ob && (ob->type == OB_GPENCIL)) {
+		mul_mat3_m4_v3(ob->obmat, plane_normal);
 	}
 
 	/* Reproject the points in the plane */
@@ -1261,37 +1259,36 @@ void ED_gp_project_point_to_plane(Object *ob, RegionView3D *rv3d, const float or
 }
 
 /* get drawing reference for conversion or projection of the stroke */
-void ED_gp_get_drawing_reference(ToolSettings *ts, View3D *v3d, Scene *scene, Object *ob, bGPDlayer *gpl, char align_flag, float vec[3])
+// FIXME: Remove ts arg
+void ED_gp_get_drawing_reference(ToolSettings *UNUSED(ts), View3D *v3d, Scene *scene, Object *ob, bGPDlayer *gpl, char align_flag, float vec[3])
 {
 	const float *fp = ED_view3d_cursor3d_get(scene, v3d);
 
 	/* if using a gpencil object at cursor mode, can use the location of the object */
-	if ((ts->gpencil_src & GP_TOOL_SOURCE_OBJECT) && (align_flag & GP_PROJECT_VIEWSPACE)) {
-		if (ob) {
-			if (ob->type == OB_GPENCIL) {
-				/* use last stroke position for layer */
-				if (gpl && gpl->flag & GP_LAYER_USE_LOCATION) {
-					if (gpl->actframe) {
-						bGPDframe *gpf = gpl->actframe;
-						if (gpf->strokes.last) {
-							bGPDstroke *gps = gpf->strokes.last;
-							if (gps->totpoints > 0) {
-								copy_v3_v3(vec, &gps->points[gps->totpoints - 1].x);
-								mul_m4_v3(ob->obmat, vec);
-								return;
-							}
+	if (align_flag & GP_PROJECT_VIEWSPACE) {
+		if (ob && (ob->type == OB_GPENCIL)) {
+			/* use last stroke position for layer */
+			if (gpl && gpl->flag & GP_LAYER_USE_LOCATION) {
+				if (gpl->actframe) {
+					bGPDframe *gpf = gpl->actframe;
+					if (gpf->strokes.last) {
+						bGPDstroke *gps = gpf->strokes.last;
+						if (gps->totpoints > 0) {
+							copy_v3_v3(vec, &gps->points[gps->totpoints - 1].x);
+							mul_m4_v3(ob->obmat, vec);
+							return;
 						}
 					}
 				}
-				/* use cursor */
-				if (align_flag & GP_PROJECT_CURSOR) {
-					/* use 3D-cursor */
-					copy_v3_v3(vec, fp);
-				}
-				else {
-					/* use object location */
-					copy_v3_v3(vec, ob->obmat[3]);
-				}
+			}
+			/* use cursor */
+			if (align_flag & GP_PROJECT_CURSOR) {
+				/* use 3D-cursor */
+				copy_v3_v3(vec, fp);
+			}
+			else {
+				/* use object location */
+				copy_v3_v3(vec, ob->obmat[3]);
 			}
 		}
 	}
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 406658b0d4d..e2eba401481 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1010,11 +1010,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
 
 	ob = ED_object_add_type(C, OB_GPENCIL, NULL, loc, rot, false, layer);
 	BKE_object_obdata_size_init(ob, GP_OBGPENCIL_DEFAULT_SIZE);
-
-	/* set grease pencil mode to object */
-	ToolSettings *ts = CTX_data_tool_settings(C);
-	ts->gpencil_src = GP_TOOL_SOURCE_OBJECT;
-	
+		
 	/* if type is monkey, create a 2D Suzanne */
 	// TODO: create with offset to cursor?
 	switch (type) {
@@ -1045,7 +1041,7 @@ void OBJECT_OT_gpencil_add(wmOperatorType *ot)
 {
 
 	/* identifiers */
-	ot->name = "Add Gpencil";
+	ot->name = "Add GPencil";
 	ot->description = "Add a grease pencil object to the scene";
 	ot->idname = "OBJECT_OT_gpencil_add";
 
@@ -2343,7 +2339,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, SceneLayer
 					ID_NEW_REMAP_US2(obn->data)
 					else {
 						obn->data = ID_NEW_SET(obn->data, BKE_gpencil_copy(bmain, obn->data));
-						didit = 1
+						didit = 1;
 					}
 					id_us_min(id);
 				}
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index b1912e6e6c2..2bed5123a28 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -965,7 +965,6 @@ static void outliner_item_activate(
 		}
 		else if (ELEM(te->idcode, ID_GD)) {
 			/* set grease pencil to object mode */
-			scene->toolsettings->gpencil_src = GP_TOOL_SOURCE_OBJECT;
 			WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
 		}
 		else {  // rest of types
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index c21fa677367..8437480e4f5 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1469,7 +1469,7 @@ typedef struct ToolSettings {
 
 	/* Grease Pencil */
 	char gpencil_flags;		/* flags/options for how the tool works */
-	char gpencil_src;		/* for main 3D view Grease Pencil, where data comes from */
+	char gpencil_src;		/* for main 3D view Grease Pencil, where data comes from */ /* DEPRECATED */
 
 	char gpencil_v3d_align; /* stroke placement settings: 3D View */
 	char gpencil_v2d_align; /*                          : General 2D Editor */
@@ -2235,12 +2235,6 @@ typedef enum eGPencil_SimplifyFlags {
 	GP_TOOL_FLAG_DISABLE_FAST_DRAWING = (1 << 9),
 } eGPencil_SimplifyFlags;
 
-/* toolsettings->gpencil_src */
-typedef enum eGPencil_Source_3D {
-	GP_TOOL_SOURCE_SCENE    = 0,
-	GP_TOOL_SOURCE_OBJECT   = 1
-} eGPencil_Source_3d;
-
 /* toolsettings->gpencil_*_align - Stroke Placement mode flags */
 typedef enum eGPencil_Placement_Flags {
 	/* New strokes are added in viewport/data space (i.e. not screen space) */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index a6b9f96475d..eb969f32efc 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2563,16 +2563,6 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
 		{0, NULL, 0, NULL, NULL}
 	};
 	
-	static const EnumPropertyItem gpencil_source_3d_items[] = {
-		{GP_TOOL_SOURCE_SCENE, "SCENE", 0, "Scene",
-		 "Grease Pencil data attached to the current scene is used, "
-		 "unless the active object already has Grease Pencil data (i.e. for old files)"},
-		{GP_TOOL_SOURCE_OBJECT, "OBJECT", 0, "Object",
-		 "Grease Pencil data-blocks attached to the active object are used "
-		 "(required when using pre 2.73 add-ons, e.g. BSurfaces)"},
-		{0, NULL, 0, NULL, NULL}
-	};
-	
 	static const EnumPropertyItem gpencil_stroke_placement_items[] = {
 		{GP_PROJECT_VIEWSPACE, "ORIGIN", ICON_OBJECT_ORIGIN, "Origin", "Draw stroke at Object origin"},
 		{GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR, "CURSOR", ICON_CURSOR, "3D Cursor", "Draw stroke at 3D cursor location" },
@@ -2813,13 +2803,6 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
 		"When draw new strokes, the new stroke is drawn below of all strokes in the layer");
 	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 
-	prop = RNA_def_property(srna, "grease_pencil_source", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_bitflag_sdna(prop, NULL, "g

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list