diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-07 21:48:33 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-07 22:21:33 +0300 |
commit | b651812721ebf7e6da43e122514df7b69035386d (patch) | |
tree | 4ec5dd506225aa86d143abebd7e39a6b22247b0c /source/blender/blenkernel | |
parent | 25e36579709e7ed8a7bf047811321c3dba174489 (diff) |
Cleanup/fix animsys 'id_type_can_have_animdata()'.
This func now actually takes an ID type as argument, added new 'id_can_have_animdata()'
to check whether a datablock may be animated or not.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_animsys.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 26 |
2 files changed, 16 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 772e08589c1..983f3ce22b8 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -50,7 +50,8 @@ struct AnimMapper; /* AnimData API */ /* Check if the given ID-block can have AnimData */ -bool id_type_can_have_animdata(struct ID *id); +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); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 91b33f3efd3..10e7b019505 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -79,15 +79,11 @@ /* Getter/Setter -------------------------------------------- */ /* Check if ID can have AnimData */ -bool id_type_can_have_animdata(ID *id) +bool id_type_can_have_animdata(const short id_type) { - /* sanity check */ - if (id == NULL) - return false; - /* Only some ID-blocks have this info for now */ /* TODO: finish adding this for the other blocktypes */ - switch (GS(id->name)) { + switch (id_type) { /* has AnimData */ case ID_OB: case ID_ME: case ID_MB: case ID_CU: case ID_AR: case ID_LT: @@ -101,9 +97,7 @@ bool id_type_can_have_animdata(ID *id) case ID_MC: case ID_MSK: case ID_GD: - { return true; - } /* no AnimData */ default: @@ -111,6 +105,14 @@ bool id_type_can_have_animdata(ID *id) } } +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, @@ -122,7 +124,7 @@ AnimData *BKE_animdata_from_id(ID *id) * types that do to be of type IdAdtTemplate, and extract the * AnimData that way */ - if (id_type_can_have_animdata(id)) { + if (id_can_have_animdata(id)) { IdAdtTemplate *iat = (IdAdtTemplate *)id; return iat->adt; } @@ -140,7 +142,7 @@ AnimData *BKE_animdata_add_id(ID *id) * types that do to be of type IdAdtTemplate, and add the AnimData * to it using the template */ - if (id_type_can_have_animdata(id)) { + if (id_can_have_animdata(id)) { IdAdtTemplate *iat = (IdAdtTemplate *)id; /* check if there's already AnimData, in which case, don't add */ @@ -221,7 +223,7 @@ void BKE_animdata_free(ID *id, const bool do_id_user) /* Only some ID-blocks have this info for now, so we cast the * types that do to be of type IdAdtTemplate */ - if (id_type_can_have_animdata(id)) { + if (id_can_have_animdata(id)) { IdAdtTemplate *iat = (IdAdtTemplate *)id; AnimData *adt = iat->adt; @@ -1049,7 +1051,7 @@ void BKE_animdata_fix_paths_remove(ID *id, const char *prefix) */ NlaTrack *nlt; - if (id_type_can_have_animdata(id)) { + if (id_can_have_animdata(id)) { IdAdtTemplate *iat = (IdAdtTemplate *)id; AnimData *adt = iat->adt; |