Page MenuHome

gpencil object data and scene data
Closed, ResolvedPublic

Description

System Information
Win7x64 GTX660M

Blender Version
Broken: 2.73 testbuild1
Worked: (optional)

Short description of error
cant paint on gpencil scene data

Exact steps for others to reproduce the error

  1. change gpencil mode to 'object'
  2. draw some gpencil object data
  3. change gpencil mode to 'scene'
  4. draw some gpencil scene data
  5. you still will be painting on gpencil object data layer
  6. and this code will fail:

import bpy

if bpy.context.scene.tool_settings.grease_pencil_source == 'SCENE':

gp_active_layer = bpy.context.scene.grease_pencil.layers.active

Event Timeline

Czarek Kopias (kopias) raised the priority of this task from to Needs Triage by Developer.
Czarek Kopias (kopias) updated the task description. (Show Details)
Czarek Kopias (kopias) set Type to Bug.
Julian Eisel (Severin) lowered the priority of this task from Needs Triage by Developer to Normal.

@Joshua Leung (aligorith), spent quite some time on this today, to see what causes it and how to solve it. Turned out that rBfe4d0c234eddd984 caused this. The logic added to gpencil_edit.c fails if source is Object first and then Scene (because ob->gpd is created, so it will from now on always return &ob->gpd if this object is selected). I came up with this:

switch (sa->spacetype) {
    case SPACE_VIEW3D: /* 3D-View */
    case SPACE_TIME: /* Timeline - XXX: this is a hack to get it to show GP keyframes for 3D view */
      {
        BLI_assert(scene && ELEM(scene->toolsettings->gpencil_src,
                                 GP_TOOL_SOURCE_SCENE, GP_TOOL_SOURCE_OBJECT));

        if (scene->toolsettings->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 {
            if (ptr) RNA_id_pointer_create(&scene->id, ptr);
            return &scene->gpd;
        }
        break;
    }
...

It looks like this makes a version bump unnecessary.
I also realized that if you select an Object with gpencil data the scene strokes aren't displayed anymore, which i'm not sure about... I would expect them to be always visible, you can still hide them.

I'm very aware of what causes it; indeed, I explicitly mentioned this in the commit log.

The problem though is that if we do this, anyone loading an old file with Grease Pencil data is going to go: "where did my stuff go?!", since the "scene first" behaviour is the sensible default going forward. From past examples, I'm pretty sure we'd get more repeat bug reports coming in about "missing" stuff than we'd get about slightly confusing behaviour that only a few might start hitting once they start toggling around.