diff options
author | Joshua Leung <aligorith@gmail.com> | 2014-12-07 16:42:10 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2014-12-07 16:42:45 +0300 |
commit | fe4d0c234eddd984b653c6530f26426871380504 (patch) | |
tree | 52d7313e811c2947d7c54db9146394a781fca9b7 /source/blender/editors/gpencil | |
parent | e67fd7a2cbf9723a0f800d9a14834ff6838f2b7f (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.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 58 |
1 files changed, 36 insertions, 22 deletions
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; } |