[Bf-blender-cvs] [b9d1026ce02] master: Cleanup: PaintCurve: Move to IDTypeInfo and remove unused BKE API.

Bastien Montagne noreply at git.blender.org
Mon Mar 9 12:49:12 CET 2020


Commit: b9d1026ce02814473401024e7a3666900488003a
Author: Bastien Montagne
Date:   Mon Mar 9 12:35:25 2020 +0100
Branches: master
https://developer.blender.org/rBb9d1026ce02814473401024e7a3666900488003a

Cleanup: PaintCurve: Move to IDTypeInfo and remove unused BKE API.

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

M	source/blender/blenkernel/BKE_idtype.h
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/idtype.c
M	source/blender/blenkernel/intern/lib_id.c
M	source/blender/blenkernel/intern/lib_id_delete.c
M	source/blender/blenkernel/intern/paint.c

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

diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index c6f9471ec42..243275e5219 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -156,7 +156,7 @@ extern IDTypeInfo IDType_ID_WM;
 // extern IDTypeInfo IDType_ID_MSK;
 // extern IDTypeInfo IDType_ID_LS;
 // extern IDTypeInfo IDType_ID_PAL;
-// extern IDTypeInfo IDType_ID_PC;
+extern IDTypeInfo IDType_ID_PC;
 extern IDTypeInfo IDType_ID_CF;
 extern IDTypeInfo IDType_ID_WS;
 extern IDTypeInfo IDType_ID_LP;
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 9650f8eed6e..5283672bdde 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -145,13 +145,7 @@ void BKE_palette_clear(struct Palette *palette);
 
 /* paint curves */
 struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
-void BKE_paint_curve_free(struct PaintCurve *pc);
-void BKE_paint_curve_copy_data(struct Main *bmain,
-                               struct PaintCurve *pc_dst,
-                               const struct PaintCurve *pc_src,
-                               const int flag);
 struct PaintCurve *BKE_paint_curve_copy(struct Main *bmain, const struct PaintCurve *pc);
-void BKE_paint_curve_make_local(struct Main *bmain, struct PaintCurve *pc, const int flags);
 
 bool BKE_paint_ensure(struct ToolSettings *ts, struct Paint **r_paint);
 void BKE_paint_init(struct Main *bmain, struct Scene *sce, ePaintMode mode, const char col[3]);
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index 7bdb824eedd..347327dfd1b 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -83,7 +83,7 @@ static void id_type_init(void)
   // INIT_TYPE(ID_MSK);
   // INIT_TYPE(ID_LS);
   // INIT_TYPE(ID_PAL);
-  // INIT_TYPE(ID_PC);
+  INIT_TYPE(ID_PC);
   INIT_TYPE(ID_CF);
   INIT_TYPE(ID_WS);
   INIT_TYPE(ID_LP);
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index fa6996d8701..ff9f342f27d 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -563,9 +563,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
       }
       return true;
     case ID_PC:
-      if (!test) {
-        BKE_paint_curve_make_local(bmain, (PaintCurve *)id, flags);
-      }
+      BLI_assert(0);
       return true;
     case ID_CF:
       BLI_assert(0);
@@ -767,7 +765,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
         BKE_palette_copy_data(bmain, (Palette *)*r_newid, (Palette *)id, flag);
         break;
       case ID_PC:
-        BKE_paint_curve_copy_data(bmain, (PaintCurve *)*r_newid, (PaintCurve *)id, flag);
+        BLI_assert(0);
         break;
       case ID_CF:
         BLI_assert(0);
@@ -1377,7 +1375,7 @@ void BKE_libblock_init_empty(ID *id)
       /* Nothing to do. */
       break;
     case ID_PC:
-      /* Nothing to do. */
+      BLI_assert(0);
       break;
     case ID_GD:
       /* Nothing to do. */
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index ecaf0e4cb9d..430b40b57df 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -235,7 +235,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
       BKE_palette_free((Palette *)id);
       break;
     case ID_PC:
-      BKE_paint_curve_free((PaintCurve *)id);
+      BLI_assert(0);
       break;
     case ID_CF:
       BLI_assert(0);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index bd585d56a51..35683ca93f4 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -53,6 +53,7 @@
 #include "BKE_context.h"
 #include "BKE_crazyspace.h"
 #include "BKE_gpencil.h"
+#include "BKE_idtype.h"
 #include "BKE_image.h"
 #include "BKE_key.h"
 #include "BKE_lib_id.h"
@@ -74,6 +75,43 @@
 
 #include "bmesh.h"
 
+static void paint_curve_copy_data(Main *UNUSED(bmain),
+                                  ID *id_dst,
+                                  const ID *id_src,
+                                  const int UNUSED(flag))
+{
+  PaintCurve *paint_curve_dst = (PaintCurve *)id_dst;
+  const PaintCurve *paint_curve_src = (const PaintCurve *)id_src;
+
+  if (paint_curve_src->tot_points != 0) {
+    paint_curve_dst->points = MEM_dupallocN(paint_curve_src->points);
+  }
+}
+
+static void paint_curve_free_data(ID *id)
+{
+  PaintCurve *paint_curve = (PaintCurve *)id;
+
+  MEM_SAFE_FREE(paint_curve->points);
+  paint_curve->tot_points = 0;
+}
+
+IDTypeInfo IDType_ID_PC = {
+    .id_code = ID_PC,
+    .id_filter = FILTER_ID_PC,
+    .main_listbase_index = INDEX_ID_PC,
+    .struct_size = sizeof(PaintCurve),
+    .name = "PaintCurve",
+    .name_plural = "paint_curves",
+    .translation_context = BLT_I18NCONTEXT_ID_PAINTCURVE,
+    .flags = 0,
+
+    .init_data = NULL,
+    .copy_data = paint_curve_copy_data,
+    .free_data = paint_curve_free_data,
+    .make_local = NULL,
+};
+
 const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
 const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
 const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
@@ -474,13 +512,6 @@ uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
   return 0;
 }
 
-/** Free (or release) any data used by this paint curve (does not free the pcurve itself). */
-void BKE_paint_curve_free(PaintCurve *pc)
-{
-  MEM_SAFE_FREE(pc->points);
-  pc->tot_points = 0;
-}
-
 PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name)
 {
   PaintCurve *pc;
@@ -490,26 +521,6 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name)
   return pc;
 }
 
-/**
- * Only copy internal data of PaintCurve ID from source to
- * already allocated/initialized destination.
- * You probably never want to use that directly,
- * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
- *
- * WARNING! This function will not handle ID user count!
- *
- * \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
- */
-void BKE_paint_curve_copy_data(Main *UNUSED(bmain),
-                               PaintCurve *pc_dst,
-                               const PaintCurve *pc_src,
-                               const int UNUSED(flag))
-{
-  if (pc_src->tot_points != 0) {
-    pc_dst->points = MEM_dupallocN(pc_src->points);
-  }
-}
-
 PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc)
 {
   PaintCurve *pc_copy;
@@ -517,11 +528,6 @@ PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc)
   return pc_copy;
 }
 
-void BKE_paint_curve_make_local(Main *bmain, PaintCurve *pc, const int flags)
-{
-  BKE_lib_id_make_local_generic(bmain, &pc->id, flags);
-}
-
 Palette *BKE_paint_palette(Paint *p)
 {
   return p ? p->palette : NULL;



More information about the Bf-blender-cvs mailing list