gpencil object data and scene data #42895

Closed
opened 2014-12-14 14:53:57 +01:00 by Cezary Kopias · 7 comments

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

  • change gpencil mode to 'object'
  • draw some gpencil object data
  • change gpencil mode to 'scene'
  • draw some gpencil scene data
  • you still will be painting on gpencil object data layer
  • 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
**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** - change gpencil mode to 'object' - draw some gpencil object data - change gpencil mode to 'scene' - draw some gpencil scene data - you still will be painting on gpencil object data layer - 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
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @kopias

Added subscriber: @kopias
Julian Eisel self-assigned this 2014-12-14 23:14:30 +01:00
Member

Added subscriber: @JoshuaLeung

Added subscriber: @JoshuaLeung
Member

@JoshuaLeung, spent quite some time on this today, to see what causes it and how to solve it. Turned out that blender/blender@fe4d0c234e 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.

@JoshuaLeung, spent quite some time on this today, to see what causes it and how to solve it. Turned out that blender/blender@fe4d0c234e 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.
Member

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.

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.
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Member

Closed by commit blender/blender@071ec918f4.

Closed by commit blender/blender@071ec918f4.
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#42895
No description provided.