[Bf-blender-cvs] [04e439513b8] greasepencil-object: GP Branch: Use ob->data instead of ob->gpd for storing GP object's GPencil datablock
Joshua Leung
noreply at git.blender.org
Sat Nov 4 05:47:26 CET 2017
Commit: 04e439513b8ab8f967a5fbb7a223ccf469eba547
Author: Joshua Leung
Date: Sun Oct 29 03:53:44 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB04e439513b8ab8f967a5fbb7a223ccf469eba547
GP Branch: Use ob->data instead of ob->gpd for storing GP object's GPencil datablock
WARNING: Old files created in the GP branch may break after this commit!
* There won't be data loss, but it will be necessary to manually fix this
per-file as needed. The old ob->gpd pointer remains for now to ease the
transition.
* The code will attempt to version patch old files that store data in this
pointer. However, right now, this only works for GP Objects and for Empties.
===================================================================
M source/blender/blenkernel/intern/gpencil.c
M source/blender/blenkernel/intern/gpencil_modifier.c
M source/blender/blenkernel/intern/object_update.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/draw/engines/gpencil/gpencil_geom.c
M source/blender/draw/engines/gpencil/gpencil_vfx.c
M source/blender/editors/animation/anim_draw.c
M source/blender/editors/animation/anim_filter.c
M source/blender/editors/gpencil/drawgpencil.c
M source/blender/editors/gpencil/gpencil_data.c
M source/blender/editors/gpencil/gpencil_edit.c
M source/blender/editors/gpencil/gpencil_utils.c
M source/blender/editors/object/object_add.c
M source/blender/editors/object/object_edit.c
M source/blender/editors/object/object_modifier.c
M source/blender/editors/object/object_transform.c
M source/blender/editors/object/object_vgroup.c
M source/blender/editors/screen/screen_ops.c
M source/blender/editors/space_outliner/outliner_tree.c
M source/blender/editors/space_time/space_time.c
M source/blender/makesrna/intern/rna_object.c
M source/blender/modifiers/intern/MOD_gpencilarray.c
M source/blender/modifiers/intern/MOD_gpencilcolor.c
M source/blender/modifiers/intern/MOD_gpencildupli.c
M source/blender/modifiers/intern/MOD_gpencillattice.c
M source/blender/modifiers/intern/MOD_gpencilnoise.c
M source/blender/modifiers/intern/MOD_gpencilopacity.c
M source/blender/modifiers/intern/MOD_gpencilsimplify.c
M source/blender/modifiers/intern/MOD_gpencilsubdiv.c
M source/blender/modifiers/intern/MOD_gpencilthick.c
M source/blender/modifiers/intern/MOD_gpenciltint.c
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index fb49c078373..5eb806baf4d 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2142,7 +2142,7 @@ static void boundbox_gpencil(Object *ob)
}
bb = ob->bb;
- gpd = ob->gpd;
+ gpd = ob->data;
gpencil_minmax(gpd, min, max);
BKE_boundbox_init_from_minmax(bb, min, max);
@@ -2153,11 +2153,17 @@ static void boundbox_gpencil(Object *ob)
/* get bounding box */
BoundBox *BKE_gpencil_boundbox_get(Object *ob)
{
- if ((!ob) || (ob->gpd == NULL))
+ bGPdata *gpd;
+
+ if (ELEM(NULL, ob, ob->data))
return NULL;
-
- if ((ob->bb) && ((ob->bb->flag & BOUNDBOX_DIRTY) == 0) && ((ob->gpd->flag & GP_DATA_CACHE_IS_DIRTY) == 0))
+
+ gpd = ob->data;
+ if ((ob->bb) && ((ob->bb->flag & BOUNDBOX_DIRTY) == 0) &&
+ ((gpd->flag & GP_DATA_CACHE_IS_DIRTY) == 0))
+ {
return ob->bb;
+ }
boundbox_gpencil(ob);
@@ -2170,7 +2176,7 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob)
/* remove a vertex group */
void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup)
{
- bGPdata *gpd = ob->gpd;
+ bGPdata *gpd = ob->data;
bGPDspoint *pt = NULL;
bGPDweight *gpw = NULL;
const int def_nr = BLI_findindex(&ob->defbase, defgroup);
@@ -2217,7 +2223,7 @@ bGPDweight *BKE_gpencil_vgroup_add_point_weight(bGPDspoint *pt, int index, float
}
}
- ++pt->totweight;
+ pt->totweight++;
if (pt->totweight == 1) {
pt->weights = MEM_callocN(sizeof(bGPDweight), "gp_weight");
}
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index b1b59865fcd..c978350e007 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -986,7 +986,7 @@ bool BKE_gpencil_has_geometry_modifiers(Object *ob)
void BKE_gpencil_stroke_modifiers(Object *ob, bGPDlayer *gpl, bGPDframe *UNUSED(gpf), bGPDstroke *gps)
{
ModifierData *md;
- bGPdata *gpd = ob->gpd;
+ bGPdata *gpd = ob->data;
bool is_edit = GPENCIL_ANY_EDIT_MODE(gpd);
int id = 0;
@@ -1042,7 +1042,7 @@ void BKE_gpencil_stroke_modifiers(Object *ob, bGPDlayer *gpl, bGPDframe *UNUSED(
void BKE_gpencil_geometry_modifiers(Object *ob, bGPDlayer *gpl, bGPDframe *gpf)
{
ModifierData *md;
- bGPdata *gpd = ob->gpd;
+ bGPdata *gpd = ob->data;
bool is_edit = GPENCIL_ANY_EDIT_MODE(gpd);
int id = 0;
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 3cc3b99b585..08b386d85cc 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -324,7 +324,7 @@ void BKE_object_eval_uber_data(const EvaluationContext *eval_ctx,
BKE_curve_batch_cache_dirty(ob->data, BKE_CURVE_BATCH_DIRTY_ALL);
break;
case OB_GPENCIL:
- BKE_gpencil_batch_cache_dirty(ob->gpd);
+ BKE_gpencil_batch_cache_dirty(ob->data);
break;
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index dc390661c70..22927892875 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -434,15 +434,43 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
ob = BKE_object_add(main, scene, sl, OB_GPENCIL, "GP_Scene");
zero_v3(ob->loc);
- ob->gpd = scene->gpd;
+ ob->data = scene->gpd;
scene->gpd = NULL;
/* set cache as dirty */
- BKE_gpencil_batch_cache_dirty(ob->gpd);
+ BKE_gpencil_batch_cache_dirty(ob->data);
}
/* set default mode as object */
scene->toolsettings->gpencil_src = GP_TOOL_SOURCE_OBJECT;
}
+
+ /* Handle object-linked grease pencil datablocks */
+ for (Object *ob = main->scene.first; ob; ob = ob->id.next) {
+ if (ob->gpd) {
+ if (ob->type == OB_GPENCIL) {
+ /* GP Object - remap the links */
+ ob->data = ob->gpd;
+ ob->gpd = NULL;
+ }
+ else if (ob->type == OB_EMPTY) {
+ /* Empty with GP data - This should be able to be converted
+ * to a GP object with little data loss
+ */
+ ob->data = ob->gpd;
+ ob->gpd = NULL;
+ ob->type = OB_EMPTY;
+ }
+ else {
+ /* FIXME: What to do in this case?
+ *
+ * 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);
+ }
+ }
+ }
/* 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 7e9b363ff28..65a93bc8775 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -437,6 +437,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Object *ob)
case OB_SURF:
case OB_MBALL:
case OB_LATTICE:
+ case OB_GPENCIL:
build_obdata_geom(scene, ob);
/* TODO(sergey): Only for until we support granular
* update of curves.
@@ -494,30 +495,6 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Object *ob)
build_particles(scene, ob);
}
- /* Grease pencil. */
- if (ob->gpd != NULL) {
- build_gpencil(ob->gpd);
-
- /* Temporary uber-update node, which does everything.
- * It is for the being we're porting old dependencies into the new system.
- * We'll get rid of this node as soon as all the granular update functions
- * are filled in.
- *
- * TODO(sergey): Get rid of this node.
- * XXX: This code should go as soon as gp object stores its data in obdata
- */
- OperationDepsNode *op_node;
- op_node = add_operation_node(&ob->id,
- DEG_NODE_TYPE_GEOMETRY,
- function_bind(BKE_object_eval_uber_data,
- _1,
- scene,
- ob),
- DEG_OPCODE_GEOMETRY_UBEREVAL);
- op_node->set_as_exit();
-
- }
-
/* Object that this is a proxy for. */
if (ob->proxy) {
ob->proxy->proxy_from = ob;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 04c0ed74bef..4d92ad75af5 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -511,6 +511,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o
case OB_SURF:
case OB_MBALL:
case OB_LATTICE:
+ case OB_GPENCIL:
{
build_obdata_geom(bmain, scene, ob);
break;
@@ -551,48 +552,6 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o
build_particles(scene, ob);
}
- /* Grease pencil. */
- if (ob->gpd != NULL) {
- build_gpencil(ob->gpd);
-
- // XXX: Remove duplicated code... quick hack for now
- if (ob->modifiers.first != NULL) {
- OperationKey obdata_ubereval_key(&ob->id,
- DEG_NODE_TYPE_GEOMETRY,
- DEG_OPCODE_GEOMETRY_UBEREVAL);
-
- LINKLIST_FOREACH (ModifierData *, md, &ob->modifiers) {
- const ModifierTypeInfo *mti = modifierType_getInfo((ModifierType)md->type);
-
- if (mti->updateDepsgraph) {
- DepsNodeHandle handle = create_node_handle(obdata_ubereval_key);
- mti->updateDepsgraph(
- md,
- bmain,
- scene,
- ob,
- reinterpret_cast< ::DepsNodeHandle* >(&handle));
- }
-
- if (BKE_object_modifier_use_time(ob, md)) {
- TimeSourceKey time_src_key;
- add_relation(time_src_key, obdata_ubereval_key, "Time Source");
-
- /* Hacky fix for T45633 (Animated modifiers aren't updated)
- *
- * This check works because BKE_object_modifier_use_time() tests
- * for either the modifier needing time, or that it is animated.
- */
- /* XXX: Remove this hack when these links are added as part of build_animdata() instead */
- if (modifier_dependsOnTime(md) == false && needs_animdata_node(&ob->id)) {
- ComponentKey animation_key(&ob->id, DEG_NODE_TYPE_ANIMATION);
- add_relation(animation_key, obdata_ubereval_key, "Modifier Animation");
- }
- }
- }
- }
- }
-
/* Object that this is a proxy for. */
if (ob->proxy != NULL) {
ob->proxy->proxy_from = ob;
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 c76e1c3909e..c2b02fc75ee 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -102,7 +102,7 @@ void gpencil_object_cache_add(tGPencilObjectCache *cache_array, Object *ob, int
static GpencilBatchCache *gpencil_batch_get_element(Object *ob)
{
- bGPdata *gpd = ob->gpd;
+ bGPdata *gpd = ob->data;
if (gpd->batch_cache_data == NULL) {
gpd->batch_cache_data = BLI_ghash_str_new("GP batch cache data");
return NULL;
@@ -166,7 +166,7 @@ static void gpencil_batch_cache_check_free_slots(Object *ob, bGPdata *UNUSED(gpd
static void gpencil_batch_cache_init(Object *ob, int cfra)
{
GpencilBatchCache *cache = gpencil_batch_get_element(ob);
- bGPdata *gpd = ob->gpd;
+ bGPdata *gpd = ob->data;
if (G.debug_value >= 664) {
printf("gpencil_batch_cache_init: %s\n", ob->id.name);
@@ -228,7 +228,7 @@ static void gpencil_batch_cache_clear(GpencilBatchCache *cache, bGPdata *gpd)
/* get cache */
static GpencilBatchCache *gpencil_batch_cache_get(Object *ob, int cfra)
{
- bGPdata *gpd = ob->gpd;
+ bGPdata *gpd = ob->data;
if (!gpencil_batch_cache_valid(ob, gpd, cfra)) {
if (G.debug_value >= 664) {
@@ -1208,8 +1208,8 @@ void gpencil_array_modifiers(GPENCIL_StorageLis
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list