diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_animsys.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 26 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 2 |
3 files changed, 17 insertions, 14 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; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 1372d2b30a2..00b7df122ee 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1662,7 +1662,7 @@ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index) bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop) { /* check that base ID-block can support animation data */ - if (!id_type_can_have_animdata(ptr->id.data)) + if (!id_can_have_animdata(ptr->id.data)) return false; prop = rna_ensure_property(prop); |