[Bf-blender-cvs] [c6e61edb345] blenloader-api: update corrective smooth modifier

Jacques Lucke noreply at git.blender.org
Sat Mar 7 19:09:28 CET 2020


Commit: c6e61edb3459e3bf99856a8963485bf109fe8524
Author: Jacques Lucke
Date:   Sat Mar 7 18:13:15 2020 +0100
Branches: blenloader-api
https://developer.blender.org/rBc6e61edb3459e3bf99856a8963485bf109fe8524

update corrective smooth modifier

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

M	source/blender/blenloader/BLO_callback_api.h
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/modifiers/intern/MOD_correctivesmooth.c

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

diff --git a/source/blender/blenloader/BLO_callback_api.h b/source/blender/blenloader/BLO_callback_api.h
index 99be5aa40b5..295ea6ab83b 100644
--- a/source/blender/blenloader/BLO_callback_api.h
+++ b/source/blender/blenloader/BLO_callback_api.h
@@ -15,7 +15,7 @@ typedef struct BloReader BloReader;
 
 void BLO_write_raw(BloWriter *writer, int size_in_bytes, const void *data_ptr);
 #define BLO_write_raw_array(writer, element_size, length, data_ptr) \
-  BLO_write_raw(writer, (element_size) * (length), data_ptr)
+  BLO_write_raw(writer, (int)(element_size) * (int)(length), data_ptr)
 
 void BLO_write_struct_by_name(BloWriter *writer, const char *struct_name, const void *data_ptr);
 void BLO_write_struct_array_by_name(BloWriter *writer,
@@ -50,7 +50,7 @@ void BLO_read_list(BloReader *reader, struct ListBase *list, BloLinkListFn callb
 #define BLO_read_array_endian_corrected(reader, type_name, ptr, array_size) \
   BLO_read_update_address(reader, ptr); \
   if (BLO_read_requires_endian_switch(reader)) { \
-    BLI_endian_switch_##type_name##_array(ptr, array_size); \
+    BLI_endian_switch_##type_name##_array((void *)ptr, array_size); \
   }
 
 #define BLO_read_array_int32(reader, ptr, array_size) \
@@ -60,7 +60,7 @@ void BLO_read_list(BloReader *reader, struct ListBase *list, BloLinkListFn callb
 #define BLO_read_array_float(reader, ptr, array_size) \
   BLO_read_array_endian_corrected(reader, float, ptr, array_size)
 #define BLO_read_array_float3(reader, ptr, array_size) \
-  BLO_read_array_float(reader, ptr, 3 * (array_size))
+  BLO_read_array_float(reader, ptr, 3 * (int)(array_size))
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6777a5ce99d..a93565731e2 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5481,20 +5481,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb, Object *ob)
       }
       lmd->cache_system = NULL;
     }
-    else if (md->type == eModifierType_CorrectiveSmooth) {
-      CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
-
-      if (csmd->bind_coords) {
-        csmd->bind_coords = newdataadr(fd, csmd->bind_coords);
-        if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
-          BLI_endian_switch_float_array((float *)csmd->bind_coords, csmd->bind_coords_num * 3);
-        }
-      }
-
-      /* runtime only */
-      csmd->delta_cache.deltas = NULL;
-      csmd->delta_cache.totverts = 0;
-    }
     else if (md->type == eModifierType_MeshSequenceCache) {
       MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md;
       msmcd->reader = NULL;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index a233994319d..fdefd94df64 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1670,13 +1670,6 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
 
       writedata(wd, DATA, sizeof(float) * lmd->total_verts * 3, lmd->vertexco);
     }
-    else if (md->type == eModifierType_CorrectiveSmooth) {
-      CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
-
-      if (csmd->bind_coords) {
-        writedata(wd, DATA, sizeof(float[3]) * csmd->bind_coords_num, csmd->bind_coords);
-      }
-    }
   }
 }
 
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index cd08555a9a9..24a9ba3cc80 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -46,6 +46,8 @@
 
 #include "DEG_depsgraph_query.h"
 
+#include "BLO_callback_api.h"
+
 // #define DEBUG_TIME
 
 #include "PIL_time.h"
@@ -114,6 +116,28 @@ static void requiredDataMask(Object *UNUSED(ob),
   }
 }
 
+static void bloWrite(BloWriter *writer, const ModifierData *md)
+{
+  CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
+
+  if (csmd->bind_coords) {
+    BLO_write_raw_array(writer, sizeof(float[3]), csmd->bind_coords_num, csmd->bind_coords);
+  }
+}
+
+static void bloRead(BloReader *reader, ModifierData *md)
+{
+  CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
+
+  if (csmd->bind_coords) {
+    BLO_read_array_float3(reader, csmd->bind_coords, csmd->bind_coords_num);
+  }
+
+  /* runtime only */
+  csmd->delta_cache.deltas = NULL;
+  csmd->delta_cache.totverts = 0;
+}
+
 /* check individual weights for changes and cache values */
 static void mesh_get_weights(MDeformVert *dvert,
                              const int defgrp_index,
@@ -788,6 +812,6 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = {
     /* foreachIDLink */ NULL,
     /* foreachTexLink */ NULL,
     /* freeRuntimeData */ NULL,
-    /* bloWrite */ NULL,
-    /* bloRead */ NULL,
+    /* bloWrite */ bloWrite,
+    /* bloRead */ bloRead,
 };



More information about the Bf-blender-cvs mailing list