Commit: faf93e0cc6ccbcbfaf4f5d1f0aeb33639d653dce
Author: Joshua Leung
Date:   Sun Oct 29 04:22:25 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rBfaf93e0cc6ccbcbfaf4f5d1f0aeb33639d653dce

Fix some missed ob->gpd references

===================================================================

M       source/blender/blenkernel/intern/object.c
M       source/blender/blenloader/intern/versioning_280.c
M       source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M       source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M       source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M       source/blender/draw/engines/gpencil/gpencil_engine.c
M       source/blender/editors/animation/anim_filter.c
M       source/blender/editors/gpencil/gpencil_utils.c
M       source/blender/editors/object/object_add.c
M       source/blender/editors/space_outliner/outliner_tree.c
M       source/blender/makesrna/intern/rna_modifier.c

===================================================================

diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index 36fc4c67a18..f16fe6edb9f 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1267,7 +1267,8 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object 
*ob_dst, const Object *ob_
        BLI_listbase_clear(&ob_dst->pc_ids);
 
        /* grease pencil: clean derived data */
-       BKE_gpencil_free_derived_frames(ob_dst->gpd);
+       if (ob_dst->type == OB_GPENCIL)
+               BKE_gpencil_free_derived_frames(ob_dst->data);
 
        ob_dst->mpath = NULL;
 
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index 03ad060f95e..f296ac684f5 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -445,6 +445,7 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *main)
                }
                
                /* Handle object-linked grease pencil datablocks */
+               printf("version patching objects\n");
                for (Object *ob = main->object.first; ob; ob = ob->id.next) {
                        if (ob->gpd) {
                                if (ob->type == OB_GPENCIL) {
@@ -466,11 +467,13 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *main)
                                         * We cannot create new objects for 
these, as we don't have a scene & scene layer
                                         * to put them into from here...
                                         */
-                                       printf("WARNING: Old Grease Pencil data 
('%s') still exists on Object '%s'\n",
-                                              ob->gpd->id.name+2, 
ob->id.name+2);
+                                       //printf("WARNING: Old Grease Pencil 
data ('%s') still exists on Object '%s'\n",
+                                       //       ob->gpd->id.name+2, 
ob->id.name+2);
+                                       printf("Convert GP object\n");
                                }
                        }
                }
+               printf("done\n");
 
                /* Convert grease pencil palettes to blender palettes */
                if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", 
"Palette", "*palette")) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 65a93bc8775..1558645b255 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -1027,7 +1027,7 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene 
*scene, Object *ob)
                case OB_GPENCIL:
                {
                        /* GPencil evaluation operations. */
-                       bGPdata *gpd = ob->gpd; /* FIXME */
+                       bGPdata *gpd = (bGPdata *)obdata;
                        ID *gpd_id = &gpd->id; /* No COW for now, as GP uses 
its own cache system. See gpencil_engine.c */
                        
                        op_node = add_operation_node(gpd_id, 
DEG_NODE_TYPE_GEOMETRY, NULL,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 4d92ad75af5..78953a5a0e1 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1719,6 +1719,11 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main 
*bmain, Scene *scene, Obje
                {
                        break;
                }
+               
+               case OB_GPENCIL: /* Grease Pencil */
+               {
+                       break;
+               }
        }
 
        /* ShapeKeys */
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index c2b02fc75ee..4df3eb49b5d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -791,7 +791,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data 
*e_data, void *vedata, T
        GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
        bGPDbrush *brush = BKE_gpencil_brush_getactive(ts);
-       bGPdata *gpd = ob->gpd;
+       bGPdata *gpd = ob->data;
        float obscale = (ob->size[0] + ob->size[1] + ob->size[2]) / 3.0f;
 
        bGPDpaletteref *palslot = BKE_gpencil_paletteslot_get_active(gpd);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 3ab915ad282..44ccc7fef93 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -270,11 +270,15 @@ static void GPENCIL_cache_init(void *vedata)
                        }
                }
                /* detect if painting session */
-               if ((obact) && (obact->gpd) && (obact->gpd->flag & 
GP_DATA_STROKE_PAINTMODE) &&
+               bGPdata *obact_gpd = NULL;
+               if ((obact) && (obact->type == OB_GPENCIL) && (obact->data))
+                       obact_gpd = ob->data;
+               
+               if ((obact_gpd) && (obact_gpd->flag & GP_DATA_STROKE_PAINTMODE) 
&&
                    (stl->storage->playing == 0) &&
                    ((ts->gpencil_simplify & GP_TOOL_FLAG_DISABLE_FAST_DRAWING) 
== 0))
                {
-                       if (((obact->gpd->sbuffer_sflag & GP_STROKE_ERASER) == 
0) && (obact->gpd->sbuffer_size > 0)) {
+                       if (((obact_gpd->sbuffer_sflag & GP_STROKE_ERASER) == 
0) && (obact_gpd->sbuffer_size > 0)) {
                                stl->g_data->session_flag = 
GP_DRW_PAINT_PAINTING;
                        }
                        else {
diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index d7cb48bc67b..e4fef755db4 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1710,7 +1710,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, 
ListBase *anim_data, voi
                /* Objects in the scene */
                for (base = sl->object_bases.first; base; base = base->next) {
                        /* Only consider this object if it has got some GP data 
(saving on all the other tests) */
-                       if (base->object && base->object->gpd) {
+                       if (base->object && (base->object->type == OB_GPENCIL)) 
{
                                Object *ob = base->object;
                                
                                /* firstly, check if object can be included, by 
the following factors:
@@ -1747,7 +1747,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, 
ListBase *anim_data, voi
                                
                                /* finally, include this object's grease pencil 
datablock */
                                /* XXX: Should we store these under expanders 
per item? */
-                               items += 
animdata_filter_gpencil_data(anim_data, ads, ob->gpd, filter_mode);
+                               items += 
animdata_filter_gpencil_data(anim_data, ads, ob->data, filter_mode);
                        }
                }
        }
diff --git a/source/blender/editors/gpencil/gpencil_utils.c 
b/source/blender/editors/gpencil/gpencil_utils.c
index 91bae38737b..b93d470742c 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -952,7 +952,7 @@ void ED_gpencil_parent_location(Object *obact, bGPdata 
*gpd, bGPDlayer *gpl, flo
        if (obparent == NULL) {
                if (obact != NULL) {
                        /* the gpd can be scene, but a gpobject can be active, 
so need check gpd */
-                       if ((obact->type == OB_GPENCIL) && (obact->gpd == gpd)) 
{
+                       if ((obact->type == OB_GPENCIL) && (obact->data == 
gpd)) {
                                copy_m4_m4(diff_mat, obact->obmat);
                                return;
                        }
diff --git a/source/blender/editors/object/object_add.c 
b/source/blender/editors/object/object_add.c
index 630f5a15134..b0736104635 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2232,8 +2232,9 @@ static Base *object_add_duplicate_internal(Main *bmain, 
Scene *scene, SceneLayer
                        }
                }
                /* duplicate grease pencil data for OB_GPENCIL */
+               // XXX: Review this (aligorith)
                if ((dupflag != 0) && (obn->type == OB_GPENCIL)) {
-                       obn->gpd = BKE_gpencil_data_duplicate(bmain, obn->gpd, 
false);
+                       obn->data = BKE_gpencil_data_duplicate(bmain, 
obn->data, false);
                }
 
                id = obn->data;
diff --git a/source/blender/editors/space_outliner/outliner_tree.c 
b/source/blender/editors/space_outliner/outliner_tree.c
index ebbf64676dd..a2dbae4968c 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -447,7 +447,7 @@ static void outliner_add_object_contents(SpaceOops *soops, 
TreeElement *te, Tree
        if (ob->proxy && !ID_IS_LINKED_DATABLOCK(ob))
                outliner_add_element(soops, &te->subtree, ob->proxy, te, 
TSE_PROXY, 0);
                
-       outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0); /* FIXME: 
Kept for now to make it easier to identify these objects for fixing */
+       //outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0); /* 
FIXME: Kept for now to make it easier to identify these objects for fixing */
        
        outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0);
        
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index f9c0e3f0f20..5f23bedb9ce 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -512,10 +512,11 @@ static void rna_Modifier_update(Main *UNUSED(bmain), 
Scene *UNUSED(scene), Point
         * repeat this process in any blender area, when only is needed here. 
This approach can be less
         * cleaner, but faster.
         */
+       // XXX: Review this (aligorith)
        Object *obj = (Object *)ptr->id.data;
        if ((obj) && (obj->type == OB_GPENCIL)) {
-               if (obj->gpd) {
-                       BKE_gpencil_batch_cache_dirty(obj->gpd);
+               if (obj->data) {
+                       BKE_gpencil_batch_cache_dirty(obj->data);
                }
        }
        WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->id.data);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to