[Bf-blender-cvs] [56f95297754] master: Refactor: move blenloader code of curve profile to blenkernel

Jacques Lucke noreply at git.blender.org
Tue Jun 23 17:08:52 CEST 2020


Commit: 56f95297754dae0562c107737fd3e8a85b9c34df
Author: Jacques Lucke
Date:   Tue Jun 23 17:02:49 2020 +0200
Branches: master
https://developer.blender.org/rB56f95297754dae0562c107737fd3e8a85b9c34df

Refactor: move blenloader code of curve profile to blenkernel

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

M	source/blender/blenkernel/BKE_curveprofile.h
M	source/blender/blenkernel/intern/curveprofile.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c

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

diff --git a/source/blender/blenkernel/BKE_curveprofile.h b/source/blender/blenkernel/BKE_curveprofile.h
index ecbaa365bac..bf50cde1efc 100644
--- a/source/blender/blenkernel/BKE_curveprofile.h
+++ b/source/blender/blenkernel/BKE_curveprofile.h
@@ -28,6 +28,8 @@
 extern "C" {
 #endif
 
+struct BlendWriter;
+struct BlendDataReader;
 struct CurveProfile;
 struct CurveProfilePoint;
 
@@ -78,6 +80,9 @@ void BKE_curveprofile_evaluate_length_portion(const struct CurveProfile *profile
                                               float *x_out,
                                               float *y_out);
 
+void BKE_curveprofile_blend_write(struct BlendWriter *writer, const struct CurveProfile *profile);
+void BKE_curveprofile_blend_read(struct BlendDataReader *reader, struct CurveProfile *profile);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/curveprofile.c b/source/blender/blenkernel/intern/curveprofile.c
index a748dfbab3e..f43e0355eaa 100644
--- a/source/blender/blenkernel/intern/curveprofile.c
+++ b/source/blender/blenkernel/intern/curveprofile.c
@@ -41,6 +41,8 @@
 #include "BKE_curveprofile.h"
 #include "BKE_fcurve.h"
 
+#include "BLO_read_write.h"
+
 void BKE_curveprofile_free_data(CurveProfile *profile)
 {
   MEM_SAFE_FREE(profile->path);
@@ -1070,3 +1072,17 @@ void BKE_curveprofile_evaluate_length_portion(const CurveProfile *profile,
   *x_out = interpf(profile->table[i].x, profile->table[i + 1].x, lerp_factor);
   *y_out = interpf(profile->table[i].y, profile->table[i + 1].y, lerp_factor);
 }
+
+void BKE_curveprofile_blend_write(struct BlendWriter *writer, const struct CurveProfile *profile)
+{
+  BLO_write_struct(writer, CurveProfile, profile);
+  BLO_write_struct_array(writer, CurveProfilePoint, profile->path_len, profile->path);
+}
+
+/* Expects that the curve profile itself has been read already. */
+void BKE_curveprofile_blend_read(struct BlendDataReader *reader, struct CurveProfile *profile)
+{
+  BLO_read_data_address(reader, &profile->path);
+  profile->table = NULL;
+  profile->segments = NULL;
+}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8c02b067d35..e90849fdf18 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -118,6 +118,7 @@
 #include "BKE_colortools.h"
 #include "BKE_constraint.h"
 #include "BKE_curve.h"
+#include "BKE_curveprofile.h"
 #include "BKE_effect.h"
 #include "BKE_fcurve_driver.h"
 #include "BKE_fluid.h"
@@ -2880,19 +2881,6 @@ static void direct_link_id_common(
 
 /** \} */
 
-/* -------------------------------------------------------------------- */
-/** \name Read CurveProfile
- * \{ */
-
-static void direct_link_curveprofile(BlendDataReader *reader, CurveProfile *profile)
-{
-  BLO_read_data_address(reader, &profile->path);
-  profile->table = NULL;
-  profile->segments = NULL;
-}
-
-/** \} */
-
 /* -------------------------------------------------------------------- */
 /** \name Read ID: Brush
  * \{ */
@@ -5781,7 +5769,7 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object
       BevelModifierData *bmd = (BevelModifierData *)md;
       BLO_read_data_address(reader, &bmd->custom_profile);
       if (bmd->custom_profile) {
-        direct_link_curveprofile(reader, bmd->custom_profile);
+        BKE_curveprofile_blend_read(reader, bmd->custom_profile);
       }
     }
 
@@ -6754,7 +6742,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
     /* Relink toolsettings curve profile */
     BLO_read_data_address(reader, &sce->toolsettings->custom_bevel_profile_preset);
     if (sce->toolsettings->custom_bevel_profile_preset) {
-      direct_link_curveprofile(reader, sce->toolsettings->custom_bevel_profile_preset);
+      BKE_curveprofile_blend_read(reader, sce->toolsettings->custom_bevel_profile_preset);
     }
   }
 
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 8f87ff78ab5..898e43a2c44 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -158,6 +158,7 @@
 #include "BKE_colortools.h"
 #include "BKE_constraint.h"
 #include "BKE_curve.h"
+#include "BKE_curveprofile.h"
 #include "BKE_fcurve.h"
 #include "BKE_fcurve_driver.h"
 #include "BKE_global.h"  // for G
@@ -968,12 +969,6 @@ static void write_animdata(BlendWriter *writer, AnimData *adt)
   write_nladata(writer, &adt->nla_tracks);
 }
 
-static void write_CurveProfile(BlendWriter *writer, CurveProfile *profile)
-{
-  BLO_write_struct(writer, CurveProfile, profile);
-  BLO_write_struct_array(writer, CurveProfilePoint, profile->path_len, profile->path);
-}
-
 static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *sock)
 {
   if (sock->default_value == NULL) {
@@ -1751,7 +1746,7 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase)
     else if (md->type == eModifierType_Bevel) {
       BevelModifierData *bmd = (BevelModifierData *)md;
       if (bmd->custom_profile) {
-        write_CurveProfile(writer, bmd->custom_profile);
+        BKE_curveprofile_blend_write(writer, bmd->custom_profile);
       }
     }
 
@@ -2594,7 +2589,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
   }
   /* Write the curve profile to the file. */
   if (tos->custom_bevel_profile_preset) {
-    write_CurveProfile(writer, tos->custom_bevel_profile_preset);
+    BKE_curveprofile_blend_write(writer, tos->custom_bevel_profile_preset);
   }
 
   write_paint(writer, &tos->imapaint.paint);



More information about the Bf-blender-cvs mailing list