[Bf-blender-cvs] [394b107aeff] gpencil-new-data-proposal: Move DNA structs to separate file

Falk David noreply at git.blender.org
Tue May 10 12:25:31 CEST 2022


Commit: 394b107aeff75ee4b12c03bd63a6c70712ce7440
Author: Falk David
Date:   Mon May 2 12:51:20 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB394b107aeff75ee4b12c03bd63a6c70712ce7440

Move DNA structs to separate file

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

A	source/blender/blenkernel/intern/gpencil_new_proposal.hh
M	source/blender/blenkernel/intern/gpencil_new_proposal_test.cc

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

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
similarity index 54%
copy from source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
copy to source/blender/blenkernel/intern/gpencil_new_proposal.hh
index a2c51f3d00b..b14290490a5 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -1,48 +1,28 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
 /** \file
- * \ingroup bke
+ * \ingroup DNA
  */
 
-#include "BKE_curves.hh"
+#pragma once
 
-#include "testing/testing.h"
+#include "DNA_ID.h"
+#include "DNA_curves_types.h"
+#include "DNA_customdata_types.h"
 
-namespace blender::bke::gpencil {
-
-class GPencilFrame : public CurvesGeometry {
- public:
-  GPencilFrame(){};
-  ~GPencilFrame() = default;
-
-  CurvesGeometry &as_curves_geometry()
-  {
-    CurvesGeometry *geometry = reinterpret_cast<CurvesGeometry *>(this);
-    return *geometry;
-  }
-
-  bool bounds_min_max(float3 &min, float3 &max)
-  {
-    return as_curves_geometry().bounds_min_max(min, max);
-  }
-};
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+/* Note: This should be in a file like BKE_gpencil.hh */
+namespace blender::bke::gpencil {
 class GPDataRuntime {
  public:
   /* Runtime Data */
   /* void *stroke_painting_buffer; */
 };
-
-class GPencilData : blender::dna::gpencil::GPData {
- public:
-  GPencilData();
-  ~GPencilData();
-};
-
 }  // namespace blender::bke::gpencil
 
-namespace blender::dna::gpencil {
-
 #ifdef __cplusplus
 class GPDataRuntime;
 using GPDataRuntimeHandle = blender::bke::gpencil::GPDataRuntime;
@@ -58,22 +38,37 @@ typedef struct GPLayerGroup {
   int layer_indices_size;
 
   char name[128];
+
+  /* ... */
 } GPLayerGroup;
 
 typedef struct GPLayer {
   char name[128];
+
   int flag;
+
+  /* ... */
 } GPLayer;
 
+typedef struct GPFrame {
+  CurvesGeometry strokes;
+
+  int flag;
+
+  int start;
+  int end;
+
+  /* ... */
+} GPFrame;
+
 typedef struct GPData {
-  CurvesGeometry *frames;
+  GPFrame *frames;
   int frames_size;
   CustomData frame_data;
   int active_frame_index;
 
   GPLayer *layers;
   int layers_size;
-  CustomData layer_data;
   int active_layer_index;
 
   GPLayerGroup default_group;
@@ -81,13 +76,14 @@ typedef struct GPData {
   GPDataRuntimeHandle *runtime;
 } GPData;
 
+/* This is the ID_GP structure that holds all the */
 typedef struct GreasePencil {
   ID id;
   /* Animation data (must be immediately after id). */
   struct AnimData *adt;
 
-  /**/
-  GPData grease_pencil_data;
+  /* Pointer to the actual data-block containing the frames, layers and layer groups. */
+  GPData *grease_pencil_data;
 
   int flag;
 
@@ -99,16 +95,6 @@ typedef struct GreasePencil {
   /* ... */
 } GreasePencil;
 
-}  // namespace blender::dna::gpencil
-
-namespace blender::bke::gpencil::tests {
-
-TEST(gpencil_proposal, Foo)
-{
-  using namespace blender::bke::gpencil;
-  GPencilFrame my_frame;
-  float3 min, max;
-  EXPECT_FALSE(my_frame.bounds_min_max(min, max));
+#ifdef __cplusplus
 }
-
-}  // namespace blender::bke::gpencil::tests
\ No newline at end of file
+#endif
\ No newline at end of file
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index a2c51f3d00b..27397331e45 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -3,12 +3,13 @@
 /** \file
  * \ingroup bke
  */
-
 #include "BKE_curves.hh"
+#include "BLI_math_vec_types.hh"
 
+#include "gpencil_new_proposal.hh"
 #include "testing/testing.h"
 
-namespace blender::bke::gpencil {
+namespace blender::bke {
 
 class GPencilFrame : public CurvesGeometry {
  public:
@@ -27,85 +28,18 @@ class GPencilFrame : public CurvesGeometry {
   }
 };
 
-class GPDataRuntime {
+class GPData : ::GPData {
  public:
-  /* Runtime Data */
-  /* void *stroke_painting_buffer; */
+  GPData();
+  ~GPData();
 };
 
-class GPencilData : blender::dna::gpencil::GPData {
- public:
-  GPencilData();
-  ~GPencilData();
-};
-
-}  // namespace blender::bke::gpencil
-
-namespace blender::dna::gpencil {
-
-#ifdef __cplusplus
-class GPDataRuntime;
-using GPDataRuntimeHandle = blender::bke::gpencil::GPDataRuntime;
-#else
-typedef struct GPDataRuntimeHandle GPDataRuntimeHandle;
-#endif
-
-typedef struct GPLayerGroup {
-  struct GPLayerGroup *children;
-  int children_size;
-
-  int *layer_indices;
-  int layer_indices_size;
-
-  char name[128];
-} GPLayerGroup;
-
-typedef struct GPLayer {
-  char name[128];
-  int flag;
-} GPLayer;
-
-typedef struct GPData {
-  CurvesGeometry *frames;
-  int frames_size;
-  CustomData frame_data;
-  int active_frame_index;
-
-  GPLayer *layers;
-  int layers_size;
-  CustomData layer_data;
-  int active_layer_index;
-
-  GPLayerGroup default_group;
-
-  GPDataRuntimeHandle *runtime;
-} GPData;
-
-typedef struct GreasePencil {
-  ID id;
-  /* Animation data (must be immediately after id). */
-  struct AnimData *adt;
-
-  /**/
-  GPData grease_pencil_data;
-
-  int flag;
-
-  /** Materials array. */
-  struct Material **mat;
-  /** Total materials. */
-  short totcol;
-
-  /* ... */
-} GreasePencil;
-
-}  // namespace blender::dna::gpencil
+}  // namespace blender::bke
 
 namespace blender::bke::gpencil::tests {
 
 TEST(gpencil_proposal, Foo)
 {
-  using namespace blender::bke::gpencil;
   GPencilFrame my_frame;
   float3 min, max;
   EXPECT_FALSE(my_frame.bounds_min_max(min, max));



More information about the Bf-blender-cvs mailing list