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:
authorJoshua Leung <aligorith@gmail.com>2009-07-21 14:18:08 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-21 14:18:08 +0400
commit6d074526f24320eb23be6ad14fd372a2f9c70b89 (patch)
treebfdd6138ce9b24dc8d234b8472f558e2878c5586 /source/blender/makesrna/intern/rna_pose.c
parent8c9ade81e8a916521fbfb110aade7627131f3610 (diff)
2.5 - Restoring Bone Groups
* Added Bone Groups UI to 'Armature' context buttons for now. Later, it may be more convenient to have these with bones instead? * Added operators for the operations that can be performed on these groups. Moved the core adding/removing functions to blenkernel so that they can be used elsewhere in future if need be. * Properly wrapped bone groups in RNA. Copied the way that Vertex Groups are wrapped, since they share some similarities. Setting colours for bone groups still needs more work though.
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose.c')
-rw-r--r--source/blender/makesrna/intern/rna_pose.c137
1 files changed, 126 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index c7ee7887aff..e15310a02bf 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -107,11 +107,106 @@ static int rna_PoseChannel_has_ik_get(PointerRNA *ptr)
return ED_pose_channel_in_IK_chain(ob, pchan);
}
+static PointerRNA rna_Pose_active_bone_group_get(PointerRNA *ptr)
+{
+ bPose *pose= (bPose*)ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_BoneGroup, BLI_findlink(&pose->agroups, pose->active_group-1));
+}
+
+static int rna_Pose_active_bone_group_index_get(PointerRNA *ptr)
+{
+ bPose *pose= (bPose*)ptr->data;
+ return MAX2(pose->active_group-1, 0);
+}
+
+static void rna_Pose_active_bone_group_index_set(PointerRNA *ptr, int value)
+{
+ bPose *pose= (bPose*)ptr->data;
+ pose->active_group= value+1;
+}
+
+static void rna_Pose_active_bone_group_index_range(PointerRNA *ptr, int *min, int *max)
+{
+ bPose *pose= (bPose*)ptr->data;
+
+ *min= 0;
+ *max= BLI_countlist(&pose->agroups)-1;
+ *max= MAX2(0, *max);
+}
+
+void rna_pose_bgroup_name_index_get(PointerRNA *ptr, char *value, int index)
+{
+ bPose *pose= (bPose*)ptr->data;
+ bActionGroup *grp;
+
+ grp= BLI_findlink(&pose->agroups, index-1);
+
+ if(grp) BLI_strncpy(value, grp->name, sizeof(grp->name));
+ else BLI_strncpy(value, "", sizeof(grp->name)); // XXX if invalid pointer, won't this crash?
+}
+
+int rna_pose_bgroup_name_index_length(PointerRNA *ptr, int index)
+{
+ bPose *pose= (bPose*)ptr->data;
+ bActionGroup *grp;
+
+ grp= BLI_findlink(&pose->agroups, index-1);
+ return (grp)? strlen(grp->name): 0;
+}
+
+void rna_pose_bgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
+{
+ bPose *pose= (bPose*)ptr->data;
+ bActionGroup *grp;
+ int a;
+
+ for (a=1, grp=pose->agroups.first; grp; grp=grp->next, a++) {
+ if (strcmp(grp->name, value) == 0) {
+ *index= a;
+ return;
+ }
+ }
+
+ *index= 0;
+}
+
+void rna_pose_pgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
+{
+ bPose *pose= (bPose*)ptr->data;
+ bActionGroup *grp;
+
+ for (grp= pose->agroups.first; grp; grp= grp->next) {
+ if (strcmp(grp->name, value) == 0) {
+ BLI_strncpy(result, value, maxlen);
+ return;
+ }
+ }
+
+ BLI_strncpy(result, "", maxlen);
+}
+
#else
-/* users shouldn't be editing pose channel data directly -- better to set ipos and let blender calc pose_channel stuff */
-/* it's going to be weird for users to find IK flags and other such here, instead of in bone where they would expect them
- -- is there any way to put a doc in bone, pointing them here? */
+static void rna_def_bone_group(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna= RNA_def_struct(brna, "BoneGroup", NULL);
+ RNA_def_struct_sdna(srna, "bActionGroup");
+ RNA_def_struct_ui_text(srna, "Bone Group", "Groups of Pose Channels (Bones).");
+
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_struct_name_property(srna, prop);
+
+ // TODO: add some runtime-collections stuff to access grouped bones
+
+ // FIXME: this needs more work - probably a custom template?
+ prop= RNA_def_property(srna, "custom_color", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "customCol");
+ RNA_def_property_ui_text(prop, "Custom Color", "Index of custom color set.");
+}
static void rna_def_pose_channel(BlenderRNA *brna)
{
@@ -341,27 +436,47 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface.");
}
-void RNA_def_pose(BlenderRNA *brna)
+static void rna_def_pose(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
-
- rna_def_pose_channel(brna);
-
+
+ /* struct definition */
srna= RNA_def_struct(brna, "Pose", NULL);
RNA_def_struct_sdna(srna, "bPose");
RNA_def_struct_ui_text(srna, "Pose", "A collection of pose channels, including settings for animating bones.");
+ /* pose channels */
prop= RNA_def_property(srna, "pose_channels", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "chanbase", NULL);
RNA_def_property_struct_type(prop, "PoseChannel");
RNA_def_property_ui_text(prop, "Pose Channels", "Individual pose channels for the armature.");
- /* commented for now... missing info... */
- /*prop= RNA_def_property(srna, "action_groups", PROP_COLLECTION, PROP_NONE);
+ /* bone groups */
+ prop= RNA_def_property(srna, "bone_groups", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "agroups", NULL);
- RNA_def_property_struct_type(prop, "ActionGroup");
- RNA_def_property_ui_text(prop, "Action Groups", "Groups of bones.");*/
+ RNA_def_property_struct_type(prop, "BoneGroup");
+ RNA_def_property_ui_text(prop, "Bone Groups", "Groups of the bones.");
+
+ prop= RNA_def_property(srna, "active_bone_group", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "BoneGroup");
+ RNA_def_property_pointer_funcs(prop, "rna_Pose_active_bone_group_get", "rna_Pose_active_bone_group_set", NULL);
+ RNA_def_property_ui_text(prop, "Active Bone Group", "Bone groups of the pose.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
+
+ prop= RNA_def_property(srna, "active_bone_group_index", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "active_group");
+ RNA_def_property_int_funcs(prop, "rna_Pose_active_bone_group_index_get", "rna_Pose_active_bone_group_index_set", "rna_Pose_active_bone_group_index_range");
+ RNA_def_property_ui_text(prop, "Active Bone Group Index", "Active index in bone groups array.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
+}
+
+void RNA_def_pose(BlenderRNA *brna)
+{
+ rna_def_pose(brna);
+ rna_def_pose_channel(brna);
+
+ rna_def_bone_group(brna);
}
#endif