From b651812721ebf7e6da43e122514df7b69035386d Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 7 Jul 2016 20:48:33 +0200 Subject: 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. --- source/blender/blenkernel/intern/anim_sys.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern/anim_sys.c') 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; -- cgit v1.2.3