[Bf-blender-cvs] [6f76154cf2a] greasepencil-object: Remove deprecated data and move to new file conversion tools
Antonio Vazquez
noreply at git.blender.org
Mon Jun 4 17:25:44 CEST 2018
Commit: 6f76154cf2ab90260bba12f99b206dc25ff9ac47
Author: Antonio Vazquez
Date: Mon Jun 4 17:07:12 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB6f76154cf2ab90260bba12f99b206dc25ff9ac47
Remove deprecated data and move to new file conversion tools
These tools are included inside a file with DNA_DEPRECATED_ALLOW
===================================================================
M source/blender/blenkernel/BKE_gpencil.h
M source/blender/blenkernel/intern/gpencil.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/editors/gpencil/CMakeLists.txt
M source/blender/editors/gpencil/gpencil_data.c
A source/blender/editors/gpencil/gpencil_old.c
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 1a2d7024920..2569a5ecaa4 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -137,12 +137,6 @@ void BKE_gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
struct Material *BKE_gpencil_get_material_from_brush(struct Brush *brush);
struct Material *BKE_gpencil_material_ensure(struct Main *bmain, struct Object *ob);
-/* Palettes - Deprecated (2.78-2.79) Only to convert old files */
-void BKE_gpencil_free_palettes(struct ListBase *list);
-
-struct bGPDpalette *BKE_gpencil_palette_addnew(struct bGPdata *gpd, const char *name);
-struct bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(struct bGPDpalette *palette, const char *name);
-
/* object boundbox */
bool BKE_gpencil_stroke_minmax(
const struct bGPDstroke *gps, const bool use_select,
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 1c2d78bbea4..5c63eb1e6d1 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -281,9 +281,6 @@ void BKE_gpencil_free(bGPdata *gpd, bool free_all)
if (free_all) {
/* clear cache */
BKE_gpencil_batch_cache_free(gpd);
-
- /* free palettes (deprecated) */
- BKE_gpencil_free_palettes(&gpd->palettes);
}
}
@@ -1078,98 +1075,6 @@ Material *BKE_gpencil_material_ensure(Main *bmain, Object *ob)
return ma;
}
-/* ************************************************** */
-/* GP Palettes API (Deprecated) */
-
-/* Free all of a gp-colors */
-static void free_gpencil_colors(bGPDpalette *palette)
-{
- /* error checking */
- if (palette == NULL) {
- return;
- }
-
- /* free colors */
- BLI_freelistN(&palette->colors);
-}
-
-/* Free all of the gp-palettes and colors */
-void BKE_gpencil_free_palettes(ListBase *list)
-{
- bGPDpalette *palette_next;
-
- /* error checking */
- if (list == NULL) {
- return;
- }
-
- /* delete palettes */
- for (bGPDpalette *palette = list->first; palette; palette = palette_next) {
- palette_next = palette->next;
- /* free palette colors */
- free_gpencil_colors(palette);
-
- MEM_freeN(palette);
- }
- BLI_listbase_clear(list);
-}
-
-
-/* add a new gp-palette */
-bGPDpalette *BKE_gpencil_palette_addnew(bGPdata *gpd, const char *name)
-{
- bGPDpalette *palette;
-
- /* check that list is ok */
- if (gpd == NULL) {
- return NULL;
- }
-
- /* allocate memory and add to end of list */
- palette = MEM_callocN(sizeof(bGPDpalette), "bGPDpalette");
-
- /* add to datablock */
- BLI_addtail(&gpd->palettes, palette);
-
- /* set basic settings */
- /* auto-name */
- BLI_strncpy(palette->info, name, sizeof(palette->info));
- BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), '.', offsetof(bGPDpalette, info),
- sizeof(palette->info));
-
- /* return palette */
- return palette;
-}
-
-/* add a new gp-palettecolor */
-bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, const char *name)
-{
- bGPDpalettecolor *palcolor;
-
- /* check that list is ok */
- if (palette == NULL) {
- return NULL;
- }
-
- /* allocate memory and add to end of list */
- palcolor = MEM_callocN(sizeof(bGPDpalettecolor), "bGPDpalettecolor");
-
- /* add to datablock */
- BLI_addtail(&palette->colors, palcolor);
-
- /* set basic settings */
- copy_v4_v4(palcolor->color, U.gpencil_new_layer_col);
- ARRAY_SET_ITEMS(palcolor->fill, 1.0f, 1.0f, 1.0f);
-
- /* auto-name */
- BLI_strncpy(palcolor->info, name, sizeof(palcolor->info));
- BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
- sizeof(palcolor->info));
-
- /* return palette color */
- return palcolor;
-}
-
/* ************************************************** */
/* GP Object - Boundbox Support */
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 1b73eda877f..685859198b6 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -76,6 +76,9 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
+#include "BLI_string_utils.h"
+
+#include "BLT_translation.h"
#include "BLO_readfile.h"
@@ -87,6 +90,64 @@
#include "MEM_guardedalloc.h"
+/* ************************************************** */
+/* GP Palettes API (Deprecated) */
+
+/* add a new gp-palette */
+static bGPDpalette *BKE_gpencil_palette_addnew(bGPdata *gpd, const char *name)
+{
+ bGPDpalette *palette;
+
+ /* check that list is ok */
+ if (gpd == NULL) {
+ return NULL;
+ }
+
+ /* allocate memory and add to end of list */
+ palette = MEM_callocN(sizeof(bGPDpalette), "bGPDpalette");
+
+ /* add to datablock */
+ BLI_addtail(&gpd->palettes, palette);
+
+ /* set basic settings */
+ /* auto-name */
+ BLI_strncpy(palette->info, name, sizeof(palette->info));
+ BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), '.', offsetof(bGPDpalette, info),
+ sizeof(palette->info));
+
+ /* return palette */
+ return palette;
+}
+
+/* add a new gp-palettecolor */
+static bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, const char *name)
+{
+ bGPDpalettecolor *palcolor;
+
+ /* check that list is ok */
+ if (palette == NULL) {
+ return NULL;
+ }
+
+ /* allocate memory and add to end of list */
+ palcolor = MEM_callocN(sizeof(bGPDpalettecolor), "bGPDpalettecolor");
+
+ /* add to datablock */
+ BLI_addtail(&palette->colors, palcolor);
+
+ /* set basic settings */
+ copy_v4_v4(palcolor->color, U.gpencil_new_layer_col);
+ ARRAY_SET_ITEMS(palcolor->fill, 1.0f, 1.0f, 1.0f);
+
+ /* auto-name */
+ BLI_strncpy(palcolor->info, name, sizeof(palcolor->info));
+ BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
+ sizeof(palcolor->info));
+
+ /* return palette color */
+ return palcolor;
+}
+
/**
* Setup rotation stabilization from ancient single track spec.
* Former Version of 2D stabilization used a single tracking marker to determine the rotation
diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt
index b7c39b8f2f2..e4d206c2e48 100644
--- a/source/blender/editors/gpencil/CMakeLists.txt
+++ b/source/blender/editors/gpencil/CMakeLists.txt
@@ -55,6 +55,7 @@ set(SRC
gpencil_select.c
gpencil_undo.c
gpencil_utils.c
+ gpencil_old.c
gpencil_intern.h
)
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 8682d999c4d..431aa5f1126 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -2394,125 +2394,3 @@ void GPENCIL_OT_color_choose(wmOperatorType *ot)
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Index of Color", 0, INT_MAX);
}
-/* ***************** Convert old 2.7 files to 2.8 ************************ */
-static int gpencil_convert_old_files_poll(bContext *C)
-{
- Scene *scene = CTX_data_scene(C);
-
- return (int) (scene->gpd != NULL);
-}
-
-static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
-
- /* Convert grease pencil scene datablock to GP object */
- if ((scene->gpd) && (view_layer != NULL)) {
- Object *ob;
- ob = BKE_object_add_for_data(bmain, view_layer, OB_GPENCIL, "GP_Scene", &scene->gpd->id, false);
- zero_v3(ob->loc);
-
- Paint *paint = BKE_brush_get_gpencil_paint(ts);
- /* if not exist, create a new one */
- if (paint->brush == NULL) {
- /* create new brushes */
- BKE_brush_gpencil_presets(C);
- }
-
- /* convert grease pencil palettes (version >= 2.78) to materials and weights */
- bGPdata *gpd = scene->gpd;
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
-
- /* create material slot */
- BKE_object_material_slot_add(bmain, ob);
- Material *ma = BKE_material_add_gpencil(bmain, palcolor->info);
- assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_EXISTING);
-
- /* copy color settings */
- MaterialGPencilStyle *gp_style = ma->gp_style;
- copy_v4_v4(gp_style->stroke_rgba, palcolor->color);
- copy_v4_v4(gp_style->fill_rgba, palcolor->fill);
- gp_style->flag = palcolor->flag;
-
- /* fix strokes */
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
- if ((gps->colorname[0] != '\0') &&
- (STREQ(gps->colorname, palcolor->info)))
- {
- gps->mat_nr = ob->totcol - 1;
- gps->colorname[0] = '\0';
- /* create weights array */
- gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights");
- }
- }
- }
- }
- }
- }
-
- /* free palettes */
- BKE_gpencil_free_palettes(&gpd->palettes);
-
- /* set cache as dirty */
- BKE_gpencil_batch_cache_dirty(ob->data);
-
- scene->gpd = NULL;
- }
-
-#if 0 /* GPXX */
- /* Handle object-linked grease pencil datablocks */
- for (Object *ob = bmain->object.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_GPENCIL;
- }
- 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);
- }
- }
- }
-#endif
-
- /* notifiers */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list