diff options
Diffstat (limited to 'source/blender/blenkernel/intern/object_deform.c')
-rw-r--r-- | source/blender/blenkernel/intern/object_deform.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c index 911f5087412..7f9578250f2 100644 --- a/source/blender/blenkernel/intern/object_deform.c +++ b/source/blender/blenkernel/intern/object_deform.c @@ -23,13 +23,16 @@ */ #include <stdlib.h> +#include <string.h> #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" #include "BLI_ghash.h" +#include "BKE_action.h" #include "BKE_object_deform.h" /* own include */ +#include "BKE_object.h" #include "BKE_modifier.h" #include "DNA_armature_types.h" @@ -121,3 +124,33 @@ char *BKE_objdef_validmap_get(Object *ob, const int defbase_tot) return vgroup_validmap; } + +/* Returns total selected vgroups, + * wpi.defbase_sel is assumed malloc'd, all values are set */ +char *BKE_objdef_selected_get(Object *ob, int defbase_tot, int *r_dg_flags_sel_tot) +{ + char *dg_selection = MEM_mallocN(defbase_tot * sizeof(char), __func__); + bDeformGroup *defgroup; + unsigned int i; + Object *armob = BKE_object_pose_armature_get(ob); + (*r_dg_flags_sel_tot) = 0; + + if (armob) { + bPose *pose = armob->pose; + for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, defgroup->name); + if (pchan && (pchan->bone->flag & BONE_SELECTED)) { + dg_selection[i] = TRUE; + (*r_dg_flags_sel_tot) += 1; + } + else { + dg_selection[i] = FALSE; + } + } + } + else { + memset(dg_selection, FALSE, sizeof(char) * defbase_tot); + } + + return dg_selection; +} |