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
diff options
context:
space:
mode:
authorDalai Felinto <dalai@blender.org>2020-03-06 18:35:23 +0300
committerDalai Felinto <dalai@blender.org>2020-03-06 18:43:09 +0300
commit68b6d0302a591ccba843533043632d4d0bc1b40b (patch)
tree301cb6bdeca0d105acb4a5d6c07ce108dcad1a23 /source/blender
parent57daecc2cf88878e56394726759c48f81610806a (diff)
Cleanup: Action: Move to IDTypeInfo, and remove unused BKE API.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_action.h9
-rw-r--r--source/blender/blenkernel/BKE_idtype.h2
-rw-r--r--source/blender/blenkernel/intern/action.c136
-rw-r--r--source/blender/blenkernel/intern/idtype.c2
-rw-r--r--source/blender/blenkernel/intern/lib_id.c6
-rw-r--r--source/blender/blenkernel/intern/lib_id_delete.c2
6 files changed, 81 insertions, 76 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index f74285b5313..5f4f3f35b82 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -47,18 +47,9 @@ struct bPoseChannel_Runtime;
/* Allocate a new bAction with the given name */
struct bAction *BKE_action_add(struct Main *bmain, const char name[]);
-void BKE_action_copy_data(struct Main *bmain,
- struct bAction *act_dst,
- const struct bAction *act_src,
- const int flag);
/* Allocate a copy of the given Action and all its data */
struct bAction *BKE_action_copy(struct Main *bmain, const struct bAction *act_src);
-/* Deallocate all of the Action's data, but not the Action itself */
-void BKE_action_free(struct bAction *act);
-
-void BKE_action_make_local(struct Main *bmain, struct bAction *act, const int flags);
-
/* Action API ----------------- */
/* types of transforms applied to the given item
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 0e726828d1a..21154ecf497 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -146,7 +146,7 @@ extern IDTypeInfo IDType_ID_SCR;
// extern IDTypeInfo IDType_ID_SO;
extern IDTypeInfo IDType_ID_GR;
extern IDTypeInfo IDType_ID_AR;
-// extern IDTypeInfo IDType_ID_AC;
+extern IDTypeInfo IDType_ID_AC;
extern IDTypeInfo IDType_ID_NT;
extern IDTypeInfo IDType_ID_BR;
// extern IDTypeInfo IDType_ID_PA;
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index bcacbccfb28..d59505f1fa6 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -50,6 +50,7 @@
#include "BKE_deform.h"
#include "BKE_fcurve.h"
#include "BKE_idprop.h"
+#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_object.h"
@@ -77,43 +78,9 @@ static CLG_LogRef LOG = {"bke.action"};
*
* ****************************** (ton) ************************************ */
-/* ***************** Library data level operations on action ************** */
+/**************************** Action Datablock ******************************/
-bAction *BKE_action_add(Main *bmain, const char name[])
-{
- bAction *act;
-
- act = BKE_libblock_alloc(bmain, ID_AC, name, 0);
-
- return act;
-}
-
-/* .................................. */
-
-// does copy_fcurve...
-void BKE_action_make_local(Main *bmain, bAction *act, const int flags)
-{
- BKE_lib_id_make_local_generic(bmain, &act->id, flags);
-}
-
-/* .................................. */
-
-/** Free (or release) any data used by this action (does not free the action itself). */
-void BKE_action_free(bAction *act)
-{
- /* No animdata here. */
-
- /* Free F-Curves */
- free_fcurves(&act->curves);
-
- /* Free groups */
- BLI_freelistN(&act->groups);
-
- /* Free pose-references (aka local markers) */
- BLI_freelistN(&act->markers);
-}
-
-/* .................................. */
+/*********************** Armature Datablock ***********************/
/**
* Only copy internal data of Action ID from source
@@ -125,41 +92,45 @@ void BKE_action_free(bAction *act)
*
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
*/
-void BKE_action_copy_data(Main *UNUSED(bmain),
- bAction *act_dst,
- const bAction *act_src,
- const int UNUSED(flag))
+static void action_copy_data(Main *UNUSED(bmain),
+ ID *id_dst,
+ const ID *id_src,
+ const int UNUSED(flag))
{
- bActionGroup *grp_dst, *grp_src;
- FCurve *fcu_dst, *fcu_src;
+ bAction *action_dst = (bAction *)id_dst;
+ const bAction *action_src = (const bAction *)id_src;
+
+ bActionGroup *group_dst, *group_src;
+ FCurve *fcurve_dst, *fcurve_src;
- /* duplicate the lists of groups and markers */
- BLI_duplicatelist(&act_dst->groups, &act_src->groups);
- BLI_duplicatelist(&act_dst->markers, &act_src->markers);
+ /* Duplicate the lists of groups and markers. */
+ BLI_duplicatelist(&action_dst->groups, &action_src->groups);
+ BLI_duplicatelist(&action_dst->markers, &action_src->markers);
- /* copy F-Curves, fixing up the links as we go */
- BLI_listbase_clear(&act_dst->curves);
+ /* Copy F-Curves, fixing up the links as we go. */
+ BLI_listbase_clear(&action_dst->curves);
- for (fcu_src = act_src->curves.first; fcu_src; fcu_src = fcu_src->next) {
- /* duplicate F-Curve */
+ for (fcurve_src = action_src->curves.first; fcurve_src; fcurve_src = fcurve_src->next) {
+ /* Duplicate F-Curve. */
/* XXX TODO pass subdata flag?
* But surprisingly does not seem to be doing any ID refcounting... */
- fcu_dst = copy_fcurve(fcu_src);
+ fcurve_dst = copy_fcurve(fcurve_src);
- BLI_addtail(&act_dst->curves, fcu_dst);
+ BLI_addtail(&action_dst->curves, fcurve_dst);
- /* fix group links (kindof bad list-in-list search, but this is the most reliable way) */
- for (grp_dst = act_dst->groups.first, grp_src = act_src->groups.first; grp_dst && grp_src;
- grp_dst = grp_dst->next, grp_src = grp_src->next) {
- if (fcu_src->grp == grp_src) {
- fcu_dst->grp = grp_dst;
+ /* Fix group links (kindof bad list-in-list search, but this is the most reliable way). */
+ for (group_dst = action_dst->groups.first, group_src = action_src->groups.first;
+ group_dst && group_src;
+ group_dst = group_dst->next, group_src = group_src->next) {
+ if (fcurve_src->grp == group_src) {
+ fcurve_dst->grp = group_dst;
- if (grp_dst->channels.first == fcu_src) {
- grp_dst->channels.first = fcu_dst;
+ if (group_dst->channels.first == fcurve_src) {
+ group_dst->channels.first = fcurve_dst;
}
- if (grp_dst->channels.last == fcu_src) {
- grp_dst->channels.last = fcu_dst;
+ if (group_dst->channels.last == fcurve_src) {
+ group_dst->channels.last = fcurve_dst;
}
break;
}
@@ -167,6 +138,51 @@ void BKE_action_copy_data(Main *UNUSED(bmain),
}
}
+/** Free (or release) any data used by this action (does not free the action itself). */
+static void action_free_data(struct ID *id)
+{
+ bAction *action = (bAction *)id;
+ /* No animdata here. */
+
+ /* Free F-Curves. */
+ free_fcurves(&action->curves);
+
+ /* Free groups. */
+ BLI_freelistN(&action->groups);
+
+ /* Free pose-references (aka local markers). */
+ BLI_freelistN(&action->markers);
+}
+
+IDTypeInfo IDType_ID_AC = {
+ .id_code = ID_AC,
+ .id_filter = FILTER_ID_AC,
+ .main_listbase_index = INDEX_ID_AC,
+ .struct_size = sizeof(bAction),
+ .name = "Action",
+ .name_plural = "actions",
+ .translation_context = BLT_I18NCONTEXT_ID_ACTION,
+ .flags = 0,
+
+ .init_data = NULL,
+ .copy_data = action_copy_data,
+ .free_data = action_free_data,
+ .make_local = NULL,
+};
+
+/* ***************** Library data level operations on action ************** */
+
+bAction *BKE_action_add(Main *bmain, const char name[])
+{
+ bAction *act;
+
+ act = BKE_libblock_alloc(bmain, ID_AC, name, 0);
+
+ return act;
+}
+
+/* .................................. */
+
bAction *BKE_action_copy(Main *bmain, const bAction *act_src)
{
bAction *act_copy;
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index a420ab17a26..85ba9c6d2a8 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -73,7 +73,7 @@ static void id_type_init(void)
// INIT_TYPE(ID_SO);
INIT_TYPE(ID_GR);
INIT_TYPE(ID_AR);
- // INIT_TYPE(ID_AC);
+ INIT_TYPE(ID_AC);
INIT_TYPE(ID_NT);
INIT_TYPE(ID_BR);
// INIT_TYPE(ID_PA);
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index a60589de503..0f1dd16fdc5 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -540,9 +540,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
BLI_assert(0);
return true;
case ID_AC:
- if (!test) {
- BKE_action_make_local(bmain, (bAction *)id, flags);
- }
+ BLI_assert(0);
return true;
case ID_NT:
BLI_assert(0);
@@ -758,7 +756,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
BLI_assert(0);
break;
case ID_AC:
- BKE_action_copy_data(bmain, (bAction *)*r_newid, (bAction *)id, flag);
+ BLI_assert(0);
break;
case ID_NT:
BLI_assert(0);
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 583a610b8ae..9b8b0b8c418 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -206,7 +206,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
BLI_assert(0);
break;
case ID_AC:
- BKE_action_free((bAction *)id);
+ BLI_assert(0);
break;
case ID_NT:
BLI_assert(0);