[Bf-blender-cvs] [3208454aa81] master: Cleanup: Animation, move AnimData API to `anim_data.c`/`BKE_anim_data.h`

Sybren A. Stüvel noreply at git.blender.org
Fri Apr 3 16:51:49 CEST 2020


Commit: 3208454aa81f57d40f51ffc47e026d2a00c4f4ac
Author: Sybren A. Stüvel
Date:   Fri Apr 3 13:07:36 2020 +0200
Branches: master
https://developer.blender.org/rB3208454aa81f57d40f51ffc47e026d2a00c4f4ac

Cleanup: Animation, move AnimData API to `anim_data.c`/`BKE_anim_data.h`

The `BKE_animsys.h` and `anim_sys.c` files already had a an "AnimData
API" section. The code in that section has now been split off, and
placed into `BKE_anim_data.h` and `anim_data.c`.

All files that used to include `BKE_animsys.h` have been adjusted to
only include the animation headers they need (sometimes none).

No functional changes.

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

A	source/blender/blenkernel/BKE_anim_data.h
M	source/blender/blenkernel/BKE_animsys.h
M	source/blender/blenkernel/CMakeLists.txt
A	source/blender/blenkernel/intern/anim_data.c
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/cachefile.c
M	source/blender/blenkernel/intern/camera.c
M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/dynamicpaint.c
M	source/blender/blenkernel/intern/fcurve.c
M	source/blender/blenkernel/intern/hair.c
M	source/blender/blenkernel/intern/ipo.c
M	source/blender/blenkernel/intern/key.c
M	source/blender/blenkernel/intern/lattice.c
M	source/blender/blenkernel/intern/lib_id.c
M	source/blender/blenkernel/intern/lib_id_delete.c
M	source/blender/blenkernel/intern/lib_query.c
M	source/blender/blenkernel/intern/light.c
M	source/blender/blenkernel/intern/lightprobe.c
M	source/blender/blenkernel/intern/linestyle.c
M	source/blender/blenkernel/intern/material.c
M	source/blender/blenkernel/intern/mball.c
M	source/blender/blenkernel/intern/mesh.c
M	source/blender/blenkernel/intern/movieclip.c
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/pointcloud.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/seqprefetch.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/blenkernel/intern/speaker.c
M	source/blender/blenkernel/intern/texture.c
M	source/blender/blenkernel/intern/volume.cc
M	source/blender/blenkernel/intern/world.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/depsgraph/intern/builder/deg_builder.cc
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
M	source/blender/depsgraph/intern/node/deg_node_id.cc
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/animation/anim_deps.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/animation/anim_motion_paths.c
M	source/blender/editors/animation/drivers.c
M	source/blender/editors/animation/fmodifier_ui.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/armature/armature_relations.c
M	source/blender/editors/armature/pose_utils.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/curve/editcurve_undo.c
M	source/blender/editors/gpencil/gpencil_data.c
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/render/render_opengl.c
M	source/blender/editors/render/render_shading.c
M	source/blender/editors/space_action/action_data.c
M	source/blender/editors/space_graph/graph_buttons.c
M	source/blender/editors/space_nla/nla_channels.c
M	source/blender/editors/space_node/node_relationships.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/io/alembic/intern/abc_writer_mesh.cc
M	source/blender/io/collada/AnimationExporter.h
M	source/blender/io/collada/SceneExporter.h
M	source/blender/io/usd/intern/abstract_hierarchy_iterator.cc
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_animation.c
M	source/blender/makesrna/intern/rna_fcurve.c
M	source/blender/makesrna/intern/rna_fcurve_api.c
M	source/blender/makesrna/intern/rna_nla.c
M	source/blender/makesrna/intern/rna_scene_api.c
M	source/blender/makesrna/intern/rna_sequencer.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_tracking.c
M	source/blender/python/intern/bpy_rna_anim.c
M	source/blender/render/intern/source/pipeline.c
M	source/blender/render/intern/source/render_texture.c

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

diff --git a/source/blender/blenkernel/BKE_anim_data.h b/source/blender/blenkernel/BKE_anim_data.h
new file mode 100644
index 00000000000..071254be783
--- /dev/null
+++ b/source/blender/blenkernel/BKE_anim_data.h
@@ -0,0 +1,95 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
+ * All rights reserved.
+ */
+
+#ifndef __BKE_ANIM_DATA_H__
+#define __BKE_ANIM_DATA_H__
+
+/** \file
+ * \ingroup bke
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "BLI_sys_types.h" /* for bool */
+
+struct AnimData;
+struct ID;
+struct Main;
+struct ReportList;
+struct bAction;
+
+/* ************************************* */
+/* AnimData API */
+
+/* Check if the given ID-block can have AnimData */
+bool id_type_can_have_animdata(const short id_type);
+bool id_can_have_animdata(const struct ID *id);
+
+/* Get AnimData from the given ID-block */
+struct AnimData *BKE_animdata_from_id(struct ID *id);
+
+/* Add AnimData to the given ID-block */
+struct AnimData *BKE_animdata_add_id(struct ID *id);
+
+/* Set active action used by AnimData from the given ID-block */
+bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act);
+
+/* Free AnimData */
+void BKE_animdata_free(struct ID *id, const bool do_id_user);
+
+/* Return true if the ID-block has non-empty AnimData. */
+bool BKE_animdata_id_is_animated(const struct ID *id);
+
+/* Copy AnimData */
+struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const int flag);
+
+/* Copy AnimData */
+bool BKE_animdata_copy_id(struct Main *bmain,
+                          struct ID *id_to,
+                          struct ID *id_from,
+                          const int flag);
+
+/* Copy AnimData Actions */
+void BKE_animdata_copy_id_action(struct Main *bmain, struct ID *id, const bool set_newid);
+
+/* Merge copies of data from source AnimData block */
+typedef enum eAnimData_MergeCopy_Modes {
+  /* Keep destination action */
+  ADT_MERGECOPY_KEEP_DST = 0,
+
+  /* Use src action (make a new copy) */
+  ADT_MERGECOPY_SRC_COPY = 1,
+
+  /* Use src action (but just reference the existing version) */
+  ADT_MERGECOPY_SRC_REF = 2,
+} eAnimData_MergeCopy_Modes;
+
+void BKE_animdata_merge_copy(struct Main *bmain,
+                             struct ID *dst_id,
+                             struct ID *src_id,
+                             eAnimData_MergeCopy_Modes action_mode,
+                             bool fix_drivers);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BKE_ANIM_DATA_H__*/
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 3debe94c264..a8915c178d4 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -48,58 +48,6 @@ struct bAction;
 struct bActionGroup;
 struct bContext;
 
-/* ************************************* */
-/* AnimData API */
-
-/* Check if the given ID-block can have AnimData */
-bool id_type_can_have_animdata(const short id_type);
-bool id_can_have_animdata(const struct ID *id);
-
-/* Get AnimData from the given ID-block */
-struct AnimData *BKE_animdata_from_id(struct ID *id);
-
-/* Add AnimData to the given ID-block */
-struct AnimData *BKE_animdata_add_id(struct ID *id);
-
-/* Set active action used by AnimData from the given ID-block */
-bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act);
-
-/* Free AnimData */
-void BKE_animdata_free(struct ID *id, const bool do_id_user);
-
-/* Return true if the ID-block has non-empty AnimData. */
-bool BKE_animdata_id_is_animated(const struct ID *id);
-
-/* Copy AnimData */
-struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const int flag);
-
-/* Copy AnimData */
-bool BKE_animdata_copy_id(struct Main *bmain,
-                          struct ID *id_to,
-                          struct ID *id_from,
-                          const int flag);
-
-/* Copy AnimData Actions */
-void BKE_animdata_copy_id_action(struct Main *bmain, struct ID *id, const bool set_newid);
-
-/* Merge copies of data from source AnimData block */
-typedef enum eAnimData_MergeCopy_Modes {
-  /* Keep destination action */
-  ADT_MERGECOPY_KEEP_DST = 0,
-
-  /* Use src action (make a new copy) */
-  ADT_MERGECOPY_SRC_COPY = 1,
-
-  /* Use src action (but just reference the existing version) */
-  ADT_MERGECOPY_SRC_REF = 2,
-} eAnimData_MergeCopy_Modes;
-
-void BKE_animdata_merge_copy(struct Main *bmain,
-                             struct ID *dst_id,
-                             struct ID *src_id,
-                             eAnimData_MergeCopy_Modes action_mode,
-                             bool fix_drivers);
-
 /* ************************************* */
 /* KeyingSets API */
 
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index ba4339f56ac..6e612df33d5 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -70,6 +70,7 @@ set(SRC
   intern/DerivedMesh.c
   intern/action.c
   intern/addon.c
+  intern/anim_data.c
   intern/anim_path.c
   intern/anim_sys.c
   intern/anim_visualization.c
@@ -251,6 +252,7 @@ set(SRC
   BKE_DerivedMesh.h
   BKE_action.h
   BKE_addon.h
+  BKE_anim_data.h
   BKE_anim_path.h
   BKE_anim_visualization.h
   BKE_animsys.h
diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c
new file mode 100644
index 00000000000..cd56796c3cf
--- /dev/null
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -0,0 +1,1435 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+#include "MEM_guardedalloc.h"
+
+#include <string.h>
+
+#include "BKE_action.h"
+#include "BKE_anim_data.h"
+#include "BKE_animsys.h"
+#include "BKE_context.h"
+#include "BKE_fcurve.h"
+#include "BKE_global.h"
+#include "BKE_lib_id.h"
+#include "BKE_main.h"
+#include "BKE_nla.h"
+#include "BKE_node.h"
+#include "BKE_report.h"
+
+#include "DNA_ID.h"
+#include "DNA_anim_types.h"
+#include "DNA_light_types.h"
+#include "DNA_node_types.h"
+#include "DNA_space_types.h"
+#include "DNA_windowmanager_types.h"
+#include "DNA_world_types.h"
+
+#include "BLI_alloca.h"
+#include "BLI_dynstr.h"
+#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
+#include "DEG_depsgraph.h"
+
+#include "RNA_access.h"
+
+#include "CLG_log.h"
+
+static CLG_LogRef LOG = {"bke.anim_sys"};
+
+/* ***************************************** */
+/* AnimData API */
+
+/* Getter/Setter -------------------------------------------- */
+
+/* Check if ID can have AnimData */
+bool id_type_can_have_animdata(const short id_type)
+{
+  /* Only some ID-blocks have this info for now */
+  /* TODO: finish adding this for the other blocktypes */
+  switch (id_type) {
+    /* has AnimData */
+    case ID_OB:
+    case ID_ME:
+    case ID_MB:
+    case ID_CU:
+    case ID_AR:
+    case ID_LT:
+    case ID_KE:
+    case ID_PA:
+    case ID_MA:
+    case ID_TE:
+    case ID_NT:
+    case ID_LA:
+    case ID_CA:
+    case ID_WO:
+    case ID_LS:
+    case ID_LP:
+    case ID_SPK:
+    case ID_SCE:
+    case ID_MC:
+    case ID_MSK:
+    case ID_GD:
+    case ID_CF:
+    case ID_HA:
+    case ID_PT:
+    case ID_VO:
+      return true;
+
+    /* no AnimData */
+    default:
+      return false;
+  }
+}
+
+bool id_can_have_animdata(const ID *id)
+{
+  /* sanity check */
+  if (id == NULL) {
+    return false;
+  }
+
+  return id_type_can_have_animdata(GS(id->name));
+}
+
+/* Get AnimData from the given ID-block. In order for this to work, we assume that
+ * the AnimData pointer is stored immediately after the given ID-block in the struct,
+ * as per IdAdtTemplate.
+ */
+AnimData *BKE_animdata_from_id(ID *id)
+{
+  /* only some ID-blocks have this info for now, so we cast the
+   * types that do to be of type IdAdtTemplate, and extract the
+   * AnimData that way
+   */
+  if (id_can_have_animdata(id)) {
+    IdAdtTemplate *iat = (IdAdtTemplate *)id;
+    return iat->adt;
+  }
+  else {
+    return NULL;
+  }
+}
+
+/* Add AnimData to the given ID-block. In order for this to work, we assume that
+ * the AnimData pointer is stored immediately after the given ID-block in the struct,
+ * as per IdAdtTemplate. Also note that
+ */
+AnimData *BKE_animdata_add_id(ID *id)
+{
+  /* Only some ID-blocks have this info for now, so we cast the
+   * types that do to be of type IdAdtTemplate, and add the AnimData
+   * to it using the template
+   */
+  if (id_can_have_animdata(id)) {
+    IdAdtTemplate *iat = (IdAdtTemplate *)id;
+
+    /* check if there's already AnimData, in which case, don't add */
+    

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list