forked from bartvdbraak/blender
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.
This commit is contained in:
parent
e67fd7a2cb
commit
fe4d0c234e
@ -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
|
||||
|
@ -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
|
||||
|
@ -101,8 +101,21 @@ 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 */
|
||||
const char gpencil_src = (scene) ? scene->toolsettings->gpencil_src : GP_TOOL_SOURCE_SCENE;
|
||||
|
||||
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 {
|
||||
/* 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));
|
||||
|
||||
@ -126,6 +139,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr
|
||||
if (ptr) RNA_id_pointer_create((ID *)scene, ptr);
|
||||
return &scene->gpd;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_NODE: /* Nodes Editor */
|
||||
|
@ -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
|
||||
|
@ -1774,6 +1774,14 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
{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);
|
||||
RNA_def_struct_path_func(srna, "rna_ToolSettings_path");
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user