Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-07-09 12:27:31 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-07-09 12:28:40 +0400
commit08eac0c3675ff4baff4ad3d0aae4d5ab10a8a133 (patch)
tree491addec2ce6b240d86a2e70aecf5dcb32a252f2 /source/blender/makesrna/intern/rna_pose.c
parent02eb03f8687c30f598147082857a3b1d5dd1f007 (diff)
Add bone_groups.new() and bone_groups.remove() methods to RNA.
To do so, matching BKE 'API' was also refactored a bit: * Get Pose data instead of Object, as parameter; * Removed some sanity checks not needed at such a low level (callers are supposed to do that); * You can now remove an arbitrary bone group, not only the active one. Based on patch by pkrime (Paolo Acampora), with own edits. Reviewers: #python, pkrime, aligorith Reviewed By: aligorith Differential Revision: https://developer.blender.org/D522
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose.c')
-rw-r--r--source/blender/makesrna/intern/rna_pose.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 18e4ac6b004..9f05d61eeff 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -140,7 +140,32 @@ static char *rna_PoseBone_path(PointerRNA *ptr)
return BLI_sprintfN("pose.bones[\"%s\"]", name_esc);
}
+/* Bone groups only. */
+
+static bActionGroup *rna_bone_group_new(ID *id, bPose *pose, const char *name)
+{
+ bActionGroup *grp = BKE_pose_add_group(pose, name);
+ WM_main_add_notifier(NC_OBJECT | ND_POSE | NA_ADDED, id);
+ return grp;
+}
+
+static void rna_bone_group_remove(ID *id, bPose *pose, ReportList *reports, PointerRNA *grp_ptr)
+{
+ bActionGroup *grp = grp_ptr->data;
+ const int grp_idx = BLI_findindex(&pose->agroups, grp);
+
+ if (grp_idx == -1) {
+ BKE_reportf(reports, RPT_ERROR, "Bone group '%s' not found in this object", grp->name);
+ return;
+ }
+
+ BKE_pose_remove_group(pose, grp, grp_idx + 1);
+ WM_main_add_notifier(NC_OBJECT | ND_POSE | NA_REMOVED, id);
+}
+
+
/* shared for actions groups and bone groups */
+
void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value)
{
bActionGroup *grp = ptr->data;
@@ -1241,14 +1266,30 @@ static void rna_def_bone_groups(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
PropertyRNA *prop;
-/* FunctionRNA *func; */
-/* PropertyRNA *parm; */
+ FunctionRNA *func;
+ PropertyRNA *parm;
RNA_def_property_srna(cprop, "BoneGroups");
srna = RNA_def_struct(brna, "BoneGroups", NULL);
RNA_def_struct_sdna(srna, "bPose");
RNA_def_struct_ui_text(srna, "Bone Groups", "Collection of bone groups");
+ func = RNA_def_function(srna, "new", "rna_bone_group_new");
+ RNA_def_function_ui_description(func, "Add a new bone group to the object");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID); /* ID needed for refresh */
+ RNA_def_string(func, "name", "Group", MAX_NAME, "", "Name of the new group");
+ /* return type */
+ parm = RNA_def_pointer(func, "group", "BoneGroup", "", "New bone group");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_bone_group_remove");
+ RNA_def_function_ui_description(func, "Remove a bone group from this object");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); /* ID needed for refresh */
+ /* bone group to remove */
+ parm = RNA_def_pointer(func, "group", "BoneGroup", "", "Removed bone group");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
+
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "BoneGroup");
RNA_def_property_flag(prop, PROP_EDITABLE);