Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-09-10 12:02:42 +0300
committerJacques Lucke <jacques@blender.org>2020-09-10 12:02:42 +0300
commit2cd41f49cfcef58205b7e630be9a1430aafdd299 (patch)
tree8ec49ca70853e382cd9a7b2b227b6dd6346c03c3 /source
parent538817d9a86c446cdab7b6b2e84378e1f9b99f22 (diff)
Refactor: move Action .blend I/O to IDTypeInfo callbacks
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/action.c112
-rw-r--r--source/blender/blenloader/intern/readfile.c75
-rw-r--r--source/blender/blenloader/intern/writefile.c22
3 files changed, 112 insertions, 97 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 089d8bef09e..64a8ae15fd3 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -28,6 +28,9 @@
#include "MEM_guardedalloc.h"
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
@@ -63,6 +66,8 @@
#include "RNA_access.h"
+#include "BLO_read_write.h"
+
#include "CLG_log.h"
static CLG_LogRef LOG = {"bke.action"};
@@ -169,6 +174,105 @@ static void action_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+static void action_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ bAction *act = (bAction *)id;
+ if (act->id.us > 0 || BLO_write_is_undo(writer)) {
+ BLO_write_id_struct(writer, bAction, id_address, &act->id);
+ BKE_id_blend_write(writer, &act->id);
+
+ BKE_fcurve_blend_write(writer, &act->curves);
+
+ LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
+ BLO_write_struct(writer, bActionGroup, grp);
+ }
+
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
+ BLO_write_struct(writer, TimeMarker, marker);
+ }
+ }
+}
+
+static void action_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ bAction *act = (bAction *)id;
+
+ BLO_read_list(reader, &act->curves);
+ BLO_read_list(reader, &act->chanbase); // XXX deprecated - old animation system
+ BLO_read_list(reader, &act->groups);
+ BLO_read_list(reader, &act->markers);
+
+ // XXX deprecated - old animation system <<<
+ LISTBASE_FOREACH (bActionChannel *, achan, &act->chanbase) {
+ BLO_read_data_address(reader, &achan->grp);
+
+ BLO_read_list(reader, &achan->constraintChannels);
+ }
+ // >>> XXX deprecated - old animation system
+
+ BKE_fcurve_blend_read_data(reader, &act->curves);
+
+ LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) {
+ BLO_read_data_address(reader, &agrp->channels.first);
+ BLO_read_data_address(reader, &agrp->channels.last);
+ }
+}
+
+static void blend_read_lib_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
+{
+ LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
+ BLO_read_id_address(reader, id->lib, &chan->ipo);
+ }
+}
+
+static void action_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ bAction *act = (bAction *)id;
+
+ // XXX deprecated - old animation system <<<
+ LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
+ BLO_read_id_address(reader, act->id.lib, &chan->ipo);
+ blend_read_lib_constraint_channels(reader, &act->id, &chan->constraintChannels);
+ }
+ // >>> XXX deprecated - old animation system
+
+ BKE_fcurve_blend_read_lib(reader, &act->id, &act->curves);
+
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
+ if (marker->camera) {
+ BLO_read_id_address(reader, act->id.lib, &marker->camera);
+ }
+ }
+}
+
+static void blend_read_expand_constraint_channels(BlendExpander *expander, ListBase *chanbase)
+{
+ LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
+ BLO_expand(expander, chan->ipo);
+ }
+}
+
+static void action_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ bAction *act = (bAction *)id;
+
+ // XXX deprecated - old animation system --------------
+ LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
+ BLO_expand(expander, chan->ipo);
+ blend_read_expand_constraint_channels(expander, &chan->constraintChannels);
+ }
+ // ---------------------------------------------------
+
+ /* F-Curves in Action */
+ BKE_fcurve_blend_read_expand(expander, &act->curves);
+
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
+ if (marker->camera) {
+ BLO_expand(expander, marker->camera);
+ }
+ }
+}
+
IDTypeInfo IDType_ID_AC = {
.id_code = ID_AC,
.id_filter = FILTER_ID_AC,
@@ -186,10 +290,10 @@ IDTypeInfo IDType_ID_AC = {
.foreach_id = action_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_write = action_blend_write,
+ .blend_read_data = action_blend_read_data,
+ .blend_read_lib = action_blend_read_lib,
+ .blend_read_expand = action_blend_read_expand,
};
/* ***************** Library data level operations on action ************** */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 93023b5e1db..462849a5c29 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2688,52 +2688,9 @@ static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBas
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Read ID: Action
+/** \name Read: Keyingsets
* \{ */
-static void lib_link_action(BlendLibReader *reader, bAction *act)
-{
- // XXX deprecated - old animation system <<<
- LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
- BLO_read_id_address(reader, act->id.lib, &chan->ipo);
- lib_link_constraint_channels(reader, &act->id, &chan->constraintChannels);
- }
- // >>> XXX deprecated - old animation system
-
- BKE_fcurve_blend_read_lib(reader, &act->id, &act->curves);
-
- LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
- if (marker->camera) {
- BLO_read_id_address(reader, act->id.lib, &marker->camera);
- }
- }
-}
-
-static void direct_link_action(BlendDataReader *reader, bAction *act)
-{
- BLO_read_list(reader, &act->curves);
- BLO_read_list(reader, &act->chanbase); // XXX deprecated - old animation system
- BLO_read_list(reader, &act->groups);
- BLO_read_list(reader, &act->markers);
-
- // XXX deprecated - old animation system <<<
- LISTBASE_FOREACH (bActionChannel *, achan, &act->chanbase) {
- BLO_read_data_address(reader, &achan->grp);
-
- BLO_read_list(reader, &achan->constraintChannels);
- }
- // >>> XXX deprecated - old animation system
-
- BKE_fcurve_blend_read_data(reader, &act->curves);
-
- LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) {
- BLO_read_data_address(reader, &agrp->channels.first);
- BLO_read_data_address(reader, &agrp->channels.last);
- }
-}
-
-/* ------- */
-
static void lib_link_keyingsets(BlendLibReader *reader, ID *id, ListBase *list)
{
/* here, we're only interested in the ID pointer stored in some of the paths */
@@ -8066,9 +8023,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_AR:
direct_link_armature(&reader, (bArmature *)id);
break;
- case ID_AC:
- direct_link_action(&reader, (bAction *)id);
- break;
case ID_NT:
direct_link_nodetree(&reader, (bNodeTree *)id);
break;
@@ -8116,6 +8070,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
break;
case ID_ME:
case ID_LT:
+ case ID_AC:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
@@ -8827,9 +8782,6 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_KE:
lib_link_key(&reader, (Key *)id);
break;
- case ID_AC:
- lib_link_action(&reader, (bAction *)id);
- break;
case ID_SIM:
lib_link_simulation(&reader, (Simulation *)id);
break;
@@ -8842,6 +8794,7 @@ static void lib_link_all(FileData *fd, Main *bmain)
break;
case ID_ME:
case ID_LT:
+ case ID_AC:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
@@ -9463,25 +9416,6 @@ static void expand_id(BlendExpander *expander, ID *id)
expand_id_embedded_id(expander, id);
}
-static void expand_action(BlendExpander *expander, bAction *act)
-{
- // XXX deprecated - old animation system --------------
- LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
- BLO_expand(expander, chan->ipo);
- expand_constraint_channels(expander, &chan->constraintChannels);
- }
- // ---------------------------------------------------
-
- /* F-Curves in Action */
- BKE_fcurve_blend_read_expand(expander, &act->curves);
-
- LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
- if (marker->camera) {
- BLO_expand(expander, marker->camera);
- }
- }
-}
-
static void expand_keyingsets(BlendExpander *expander, ListBase *list)
{
/* expand the ID-pointers in KeyingSets's paths */
@@ -10159,9 +10093,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
case ID_AR:
expand_armature(&expander, (bArmature *)id);
break;
- case ID_AC:
- expand_action(&expander, (bAction *)id); // XXX deprecated - old animation system
- break;
case ID_GR:
expand_collection(&expander, (Collection *)id);
break;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index fbd73e20648..429045222f0 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -660,24 +660,6 @@ static void writelist_id(WriteData *wd, int filecode, const char *structname, co
* These functions are used by blender's .blend system for file saving/loading.
* \{ */
-static void write_action(BlendWriter *writer, bAction *act, const void *id_address)
-{
- if (act->id.us > 0 || BLO_write_is_undo(writer)) {
- BLO_write_id_struct(writer, bAction, id_address, &act->id);
- BKE_id_blend_write(writer, &act->id);
-
- BKE_fcurve_blend_write(writer, &act->curves);
-
- LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
- BLO_write_struct(writer, bActionGroup, grp);
- }
-
- LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
- BLO_write_struct(writer, TimeMarker, marker);
- }
- }
-}
-
static void write_keyingsets(BlendWriter *writer, ListBase *list)
{
LISTBASE_FOREACH (KeyingSet *, ks, list) {
@@ -3691,9 +3673,6 @@ static bool write_file_handle(Main *mainvar,
case ID_AR:
write_armature(&writer, (bArmature *)id_buffer, id);
break;
- case ID_AC:
- write_action(&writer, (bAction *)id_buffer, id);
- break;
case ID_OB:
write_object(&writer, (Object *)id_buffer, id);
break;
@@ -3741,6 +3720,7 @@ static bool write_file_handle(Main *mainvar,
break;
case ID_ME:
case ID_LT:
+ case ID_AC:
/* Do nothing, handled in IDTypeInfo callback. */
break;
case ID_LI: