[Bf-blender-cvs] [b651812] master: Cleanup/fix animsys 'id_type_can_have_animdata()'.

Bastien Montagne noreply at git.blender.org
Thu Jul 7 21:23:24 CEST 2016


Commit: b651812721ebf7e6da43e122514df7b69035386d
Author: Bastien Montagne
Date:   Thu Jul 7 20:48:33 2016 +0200
Branches: master
https://developer.blender.org/rBb651812721ebf7e6da43e122514df7b69035386d

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.

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

M	source/blender/blenkernel/BKE_animsys.h
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/makesrna/intern/rna_access.c

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

diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 772e085..983f3ce 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 91b33f3..10e7b01 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 1372d2b..00b7df1 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);




More information about the Bf-blender-cvs mailing list