macro to check if an object type supports vgroups
authorCampbell Barton <ideasman42@gmail.com>
Tue, 1 Nov 2011 06:45:36 +0000 (06:45 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 1 Nov 2011 06:45:36 +0000 (06:45 +0000)
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/key.c
source/blender/editors/object/object_vgroup.c
source/blender/makesdna/DNA_object_types.h

index c244c26..aebf319 100644 (file)
@@ -703,7 +703,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC
                                ct->type = CONSTRAINT_OBTYPE_BONE; \
                                ct->rotOrder= (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \
                        }\
-                       else if (ELEM(ct->tar->type, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) { \
+                       else if (OB_TYPE_SUPPORT_VGROUP(ct->tar->type) && (ct->subtarget[0])) { \
                                ct->type = CONSTRAINT_OBTYPE_VERT; \
                                ct->rotOrder = EULER_ORDER_DEFAULT; \
                        } \
index 0a46714..6d09511 100644 (file)
@@ -1381,7 +1381,7 @@ float *do_ob_key(Scene *scene, Object *ob)
                        ob->shapenr= 1;
                }
                
-               if(ELEM(ob->type, OB_MESH, OB_LATTICE)) {
+               if (OB_TYPE_SUPPORT_VGROUP(ob->type)) {
                        float *weights= get_weights_array(ob, kb->vgroup);
 
                        cp_key(0, tot, tot, out, key, actkb, kb, weights, 0);
index d4ee68f..ce6730a 100644 (file)
@@ -99,8 +99,7 @@ int ED_vgroup_object_is_edit_mode(Object *ob)
 bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name)
 {
        bDeformGroup *defgroup;
-       
-       if(!ob || !ELEM(ob->type, OB_MESH, OB_LATTICE))
+       if(!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type))
                return NULL;
        
        defgroup = MEM_callocN(sizeof(bDeformGroup), "add deformGroup");
@@ -2013,7 +2012,7 @@ static int vertex_group_poll(bContext *C)
 {
        Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
        ID *data= (ob)? ob->data: NULL;
-       return (ob && !ob->id.lib && ELEM(ob->type, OB_MESH, OB_LATTICE) && data && !data->lib);
+       return (ob && !ob->id.lib && OB_TYPE_SUPPORT_VGROUP(ob->type) && data && !data->lib);
 }
 
 static int vertex_group_poll_edit(bContext *C)
index 19eff75..38daf8b 100644 (file)
@@ -321,6 +321,7 @@ typedef struct DupliObject {
 
 /* check if the object type supports materials */
 #define OB_TYPE_SUPPORT_MATERIAL(_type) ((_type)  >= OB_MESH && (_type) <= OB_MBALL)
+#define OB_TYPE_SUPPORT_VGROUP(_type)   (ELEM(_type, OB_MESH, OB_LATTICE))
 
 /* partype: first 4 bits: type */
 #define PARTYPE                        15