[Bf-blender-cvs] [1762d5f43a4] master: Refactor: move Ipo .blend I/O to IDTypeInfo callbacks

Jacques Lucke noreply at git.blender.org
Fri Nov 6 18:33:41 CET 2020


Commit: 1762d5f43a4086b4492efb507c6085b0d841aaac
Author: Jacques Lucke
Date:   Fri Nov 6 18:33:33 2020 +0100
Branches: master
https://developer.blender.org/rB1762d5f43a4086b4492efb507c6085b0d841aaac

Refactor: move Ipo .blend I/O to IDTypeInfo callbacks

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

M	source/blender/blenkernel/intern/ipo.c
M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 5d2defa3030..9696d920640 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -52,6 +52,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_dynstr.h"
+#include "BLI_endian_switch.h"
 #include "BLI_string_utils.h"
 #include "BLI_utildefines.h"
 
@@ -75,6 +76,8 @@
 
 #include "SEQ_sequencer.h"
 
+#include "BLO_read_write.h"
+
 #ifdef WIN32
 #  include "BLI_math_base.h" /* M_PI */
 #endif
@@ -110,6 +113,69 @@ static void ipo_free_data(ID *id)
   }
 }
 
+static void ipo_blend_read_data(BlendDataReader *reader, ID *id)
+{
+  Ipo *ipo = (Ipo *)id;
+
+  BLO_read_list(reader, &(ipo->curve));
+
+  LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
+    BLO_read_data_address(reader, &icu->bezt);
+    BLO_read_data_address(reader, &icu->bp);
+    BLO_read_data_address(reader, &icu->driver);
+
+    /* Undo generic endian switching. */
+    if (BLO_read_requires_endian_switch(reader)) {
+      BLI_endian_switch_int16(&icu->blocktype);
+      if (icu->driver != NULL) {
+
+        /* Undo generic endian switching. */
+        if (BLO_read_requires_endian_switch(reader)) {
+          BLI_endian_switch_int16(&icu->blocktype);
+          if (icu->driver != NULL) {
+            BLI_endian_switch_int16(&icu->driver->blocktype);
+          }
+        }
+      }
+
+      /* Undo generic endian switching. */
+      if (BLO_read_requires_endian_switch(reader)) {
+        BLI_endian_switch_int16(&ipo->blocktype);
+        if (icu->driver != NULL) {
+          BLI_endian_switch_int16(&icu->driver->blocktype);
+        }
+      }
+    }
+  }
+
+  /* Undo generic endian switching. */
+  if (BLO_read_requires_endian_switch(reader)) {
+    BLI_endian_switch_int16(&ipo->blocktype);
+  }
+}
+
+static void ipo_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+  Ipo *ipo = (Ipo *)id;
+
+  LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
+    if (icu->driver) {
+      BLO_read_id_address(reader, ipo->id.lib, &icu->driver->ob);
+    }
+  }
+}
+
+static void ipo_blend_read_expand(BlendExpander *expander, ID *id)
+{
+  Ipo *ipo = (Ipo *)id;
+
+  LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
+    if (icu->driver) {
+      BLO_expand(expander, icu->driver->ob);
+    }
+  }
+}
+
 IDTypeInfo IDType_ID_IP = {
     .id_code = ID_IP,
     .id_filter = 0,
@@ -129,9 +195,9 @@ IDTypeInfo IDType_ID_IP = {
     .foreach_cache = NULL,
 
     .blend_write = NULL,
-    .blend_read_data = NULL,
-    .blend_read_lib = NULL,
-    .blend_read_expand = NULL,
+    .blend_read_data = ipo_blend_read_data,
+    .blend_read_lib = ipo_blend_read_lib,
+    .blend_read_expand = ipo_blend_read_expand,
 
     .blend_read_undo_preserve = NULL,
 };
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9cb7ed7c71c..02b419fc5fc 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2485,56 +2485,6 @@ static void direct_link_id_common(
 /** \name Read Animation (legacy for version patching)
  * \{ */
 
-/* XXX deprecated - old animation system */
-static void lib_link_ipo(BlendLibReader *reader, Ipo *ipo)
-{
-  LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
-    if (icu->driver) {
-      BLO_read_id_address(reader, ipo->id.lib, &icu->driver->ob);
-    }
-  }
-}
-
-/* XXX deprecated - old animation system */
-static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
-{
-  BLO_read_list(reader, &(ipo->curve));
-
-  LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
-    BLO_read_data_address(reader, &icu->bezt);
-    BLO_read_data_address(reader, &icu->bp);
-    BLO_read_data_address(reader, &icu->driver);
-
-    /* Undo generic endian switching. */
-    if (BLO_read_requires_endian_switch(reader)) {
-      BLI_endian_switch_int16(&icu->blocktype);
-      if (icu->driver != NULL) {
-
-        /* Undo generic endian switching. */
-        if (BLO_read_requires_endian_switch(reader)) {
-          BLI_endian_switch_int16(&icu->blocktype);
-          if (icu->driver != NULL) {
-            BLI_endian_switch_int16(&icu->driver->blocktype);
-          }
-        }
-      }
-
-      /* Undo generic endian switching. */
-      if (BLO_read_requires_endian_switch(reader)) {
-        BLI_endian_switch_int16(&ipo->blocktype);
-        if (icu->driver != NULL) {
-          BLI_endian_switch_int16(&icu->driver->blocktype);
-        }
-      }
-    }
-  }
-
-  /* Undo generic endian switching. */
-  if (BLO_read_requires_endian_switch(reader)) {
-    BLI_endian_switch_int16(&ipo->blocktype);
-  }
-}
-
 /** \} */
 
 /* -------------------------------------------------------------------- */
@@ -3357,12 +3307,10 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
     case ID_SCR:
       success = direct_link_screen(&reader, (bScreen *)id);
       break;
-    case ID_IP:
-      direct_link_ipo(&reader, (Ipo *)id);
-      break;
     case ID_LI:
       direct_link_library(fd, (Library *)id, main);
       break;
+    case ID_IP:
     case ID_OB:
     case ID_SCE:
     case ID_WM:
@@ -3980,13 +3928,10 @@ static void lib_link_all(FileData *fd, Main *bmain)
      * Please keep order of entries in that switch matching that order, it's easier to quickly see
      * whether something is wrong then. */
     switch (GS(id->name)) {
-      case ID_IP:
-        /* XXX deprecated... still needs to be maintained for version patches still. */
-        lib_link_ipo(&reader, (Ipo *)id);
-        break;
       case ID_LI:
         lib_link_library(&reader, (Library *)id); /* Only init users. */
         break;
+      case ID_IP:
       case ID_OB:
       case ID_SCE:
       case ID_WM:
@@ -4601,16 +4546,6 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
 
 static BLOExpandDoitCallback expand_doit;
 
-// XXX deprecated - old animation system
-static void expand_ipo(BlendExpander *expander, Ipo *ipo)
-{
-  LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
-    if (icu->driver) {
-      BLO_expand(expander, icu->driver->ob);
-    }
-  }
-}
-
 static void expand_id(BlendExpander *expander, ID *id);
 
 static void expand_id_embedded_id(BlendExpander *expander, ID *id)
@@ -4691,9 +4626,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
           }
 
           switch (GS(id->name)) {
-            case ID_IP:
-              expand_ipo(&expander, (Ipo *)id); /* XXX deprecated - old animation system */
-              break;
             default:
               break;
           }



More information about the Bf-blender-cvs mailing list