Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2014-12-07 16:42:10 +0300
committerJoshua Leung <aligorith@gmail.com>2014-12-07 16:42:45 +0300
commitfe4d0c234eddd984b653c6530f26426871380504 (patch)
tree52d7313e811c2947d7c54db9146394a781fca9b7
parente67fd7a2cbf9723a0f800d9a14834ff6838f2b7f (diff)
Bugfix T42774: BSurface addon doesn't work on new builds
It turns out that several important modelling addons depend on the assumption that Grease Pencil data gets created on the active object instead of on scene level. This commit adds a toggle for setting whether new Grease Pencil data is created on scene or object level. These work as follows: * "Scene" = The behaviour originally introduced as part of the GPencil_EditStrokes changes. New strokes are added to the scene instead of the active object, making it easier to manage things when working with Grease Pencil in general. * "Object" = The previous behaviour (from 2.50 to 2.72), where new strokes are added to the active object. This is now being reintroduced to soften the transition for addons out there which have been doing this in a lazy/lax way so far. Now, what may be slightly confusing are the "fallback" measures in place: * "Scene" - To ensure that loading old files goes ok without needing a version patch, if the active object has GPencil data, that will be used in place of the scene's own GPencil data. * "Object" - If there was no active object at the time of creating strokes (for instance, if you delete the active object immediately before drawing), GPencil data gets attached to the current scene instead. Since some tweaks may still be needed here, I've decided to bump the subversion number so that we have a reference point when doing version patches.
-rw-r--r--release/scripts/startup/bl_ui/properties_grease_pencil_common.py16
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c58
-rw-r--r--source/blender/makesdna/DNA_scene_types.h11
-rw-r--r--source/blender/makesrna/intern/rna_scene.c15
5 files changed, 75 insertions, 27 deletions
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 5975931b83f..fc94b40f45c 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -68,6 +68,17 @@ class GreasePencilDrawingToolsPanel():
row = col.row(align=True)
row.prop(context.tool_settings, "use_grease_pencil_sessions", text="Continuous Drawing")
+
+ if context.space_data.type in ('VIEW_3D', 'CLIP_EDITOR'):
+ col.separator()
+ col.label("Data Source:")
+ row = col.row(align=True)
+ if context.space_data.type == 'VIEW_3D':
+ row.prop(context.tool_settings, "grease_pencil_source", expand=True)
+ elif context.space_data.type == 'CLIP_EDITOR':
+ row.prop(context.space_data, "grease_pencil_source", expand=True)
+
+
gpd = context.gpencil_data
if gpd:
col.separator()
@@ -328,8 +339,9 @@ class GreasePencilDataPanel():
gpd = context.gpencil_data
# Owner Selector
- # XXX: add this for 3D view too
- if context.space_data.type == 'CLIP_EDITOR':
+ if context.space_data.type == 'VIEW_3D':
+ layout.prop(context.tool_settings, "grease_pencil_source", expand=True)
+ elif context.space_data.type == 'CLIP_EDITOR':
layout.prop(context.space_data, "grease_pencil_source", expand=True)
# Grease Pencil data selector
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 4c333c8332b..8cd4e2584c6 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 272
-#define BLENDER_SUBVERSION 2
+#define BLENDER_SUBVERSION 3
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 270
#define BLENDER_MINSUBVERSION 5
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 6c7cd747a55..2cffea09b22 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -101,30 +101,44 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr
case SPACE_VIEW3D: /* 3D-View */
case SPACE_TIME: /* Timeline - XXX: this is a hack to get it to show GP keyframes for 3D view */
{
- /* default to using scene's data, unless it doesn't exist (and object's does instead) */
- /* XXX: this will require a toggle switch later to be more predictable */
- bool scene_ok = (scene != NULL);
- bool ob_ok = ((ob) && (ob->flag & SELECT) && (ob->gpd));
+ const char gpencil_src = (scene) ? scene->toolsettings->gpencil_src : GP_TOOL_SOURCE_SCENE;
- if (ob_ok || !scene_ok) {
- /* Object Case (not good for users):
- * - For existing files with object-level already,
- * or where user has explicitly assigned to object,
- * we can use the object as the host...
- *
- * - If there is no scene data provided (rare/impossible)
- * we will also be forced to use the object
- */
- if (ptr) RNA_id_pointer_create((ID *)ob, ptr);
- return &ob->gpd;
- }
+ if (gpencil_src == GP_TOOL_SOURCE_OBJECT) {
+ /* legacy behaviour for usage with old addons requiring object-linked to objects */
+
+ /* just in case no active/selected object... */
+ if (ob && (ob->flag & SELECT)) {
+ /* for now, as long as there's an object, default to using that in 3D-View */
+ if (ptr) RNA_id_pointer_create(&ob->id, ptr);
+ return &ob->gpd;
+ }
+ /* else: defaults to scene... */
+ }
else {
- /* Scene Case (default):
- * This is the new (as of 2014-Oct-13, for 2.73) default setting
- * which should work better for most users.
- */
- if (ptr) RNA_id_pointer_create((ID *)scene, ptr);
- return &scene->gpd;
+ /* prefer to use scene's data, unless it doesn't exist (and object's does instead) */
+ bool scene_ok = (scene != NULL);
+ bool ob_ok = ((ob) && (ob->flag & SELECT) && (ob->gpd));
+
+ if (ob_ok || !scene_ok) {
+ /* Object Case (not good for users):
+ * - For existing files with object-level already,
+ * or where user has explicitly assigned to object,
+ * we can use the object as the host...
+ *
+ * - If there is no scene data provided (rare/impossible)
+ * we will also be forced to use the object
+ */
+ if (ptr) RNA_id_pointer_create((ID *)ob, ptr);
+ return &ob->gpd;
+ }
+ else {
+ /* Scene Case (default):
+ * This is the new (as of 2014-Oct-13, for 2.73) default setting
+ * which should work better for most users.
+ */
+ if (ptr) RNA_id_pointer_create((ID *)scene, ptr);
+ return &scene->gpd;
+ }
}
break;
}
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 745b21618ca..27b5da90d55 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1093,9 +1093,10 @@ typedef struct ToolSettings {
short autoik_chainlen; /* runtime only */
/* Grease Pencil */
- char gpencil_flags;
+ char gpencil_flags; /* flags/options for how the tool works */
+ char gpencil_src; /* for main 3D view Grease Pencil, where data comes from */
- char pad[5];
+ char pad[4];
/* Image Paint (8 byttse aligned please!) */
struct ImagePaintSettings imapaint;
@@ -1769,6 +1770,12 @@ typedef enum ImagePaintMode {
/* toolsettings->gpencil_flags */
#define GP_TOOL_FLAG_PAINTSESSIONS_ON (1<<0)
+/* toolsettings->gpencil_src */
+typedef enum eGPencil_Source_3D {
+ GP_TOOL_SOURCE_SCENE = 0,
+ GP_TOOL_SOURCE_OBJECT = 1
+} eGPencil_Source_3d;
+
/* toolsettings->particle flag */
#define PE_KEEP_LENGTHS 1
#define PE_LOCK_FIRST 2
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index e65cf34bdad..52603625a9d 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1773,6 +1773,14 @@ static void rna_def_tool_settings(BlenderRNA *brna)
{WT_VGROUP_BONE_DEFORM_OFF, "OTHER_DEFORM", 0, "Other", "Vertex Groups assigned to non Deform Bones"},
{0, NULL, 0, NULL, NULL}
};
+
+ static 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 datablocks attached to the active object are used (required using pre 2.73 add-ons, e.g. BSurfaces)"},
+ {0, NULL, 0, NULL, NULL}
+ };
srna = RNA_def_struct(brna, "ToolSettings", NULL);
@@ -1965,6 +1973,13 @@ static void rna_def_tool_settings(BlenderRNA *brna)
"Allow drawing multiple strokes at a time with Grease Pencil");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* xxx: need toolbar to be redrawn... */
+ prop = RNA_def_property(srna, "grease_pencil_source", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_src");
+ RNA_def_property_enum_items(prop, gpencil_source_3d_items);
+ RNA_def_property_ui_text(prop, "Grease Pencil Source",
+ "Datablock where active Grease Pencil data is found from");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
/* Auto Keying */
prop = RNA_def_property(srna, "use_keyframe_insert_auto", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "autokey_mode", AUTOKEY_ON);