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/blenkernel/intern/action.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/blenkernel/intern/action.c')
-rw-r--r--source/blender/blenkernel/intern/action.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 96896509f60..f4d4eb1cc9c 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -21,6 +21,7 @@
* All rights reserved.
*
* Contributor(s): Full recode, Ton Roosendaal, Crete 2005
+ * Full recode, Joshua Leung, 2009
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -31,7 +32,8 @@
#include <string.h>
#include <math.h>
-#include <stdlib.h> /* for NULL */
+#include <stdlib.h>
+#include <stddef.h>
#include "MEM_guardedalloc.h"
@@ -68,8 +70,6 @@
#include "RNA_access.h"
#include "RNA_types.h"
-//XXX #include "nla.h"
-
/* *********************** NOTE ON POSE AND ACTION **********************
- Pose is the local (object level) component of armature. The current
@@ -765,7 +765,57 @@ void framechange_poses_clear_unkeyed(void)
}
}
-/* ************************ END Pose channels *************** */
+/* ************************** Bone Groups ************************** */
+
+/* Adds a new bone-group */
+void pose_add_group (Object *ob)
+{
+ bPose *pose= (ob) ? ob->pose : NULL;
+ bActionGroup *grp;
+
+ if (ELEM(NULL, ob, ob->pose))
+ return;
+
+ grp= MEM_callocN(sizeof(bActionGroup), "PoseGroup");
+ strcpy(grp->name, "Group");
+ BLI_addtail(&pose->agroups, grp);
+ BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), 32);
+
+ pose->active_group= BLI_countlist(&pose->agroups);
+}
+
+/* Remove the active bone-group */
+void pose_remove_group (Object *ob)
+{
+ bPose *pose= (ob) ? ob->pose : NULL;
+ bActionGroup *grp = NULL;
+ bPoseChannel *pchan;
+
+ /* sanity checks */
+ if (ELEM(NULL, ob, pose))
+ return;
+ if (pose->active_group <= 0)
+ return;
+
+ /* get group to remove */
+ grp= BLI_findlink(&pose->agroups, pose->active_group-1);
+ if (grp) {
+ /* adjust group references (the trouble of using indices!):
+ * - firstly, make sure nothing references it
+ * - also, make sure that those after this item get corrected
+ */
+ for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (pchan->agrp_index == pose->active_group)
+ pchan->agrp_index= 0;
+ else if (pchan->agrp_index > pose->active_group)
+ pchan->agrp_index--;
+ }
+
+ /* now, remove it from the pose */
+ BLI_freelinkN(&pose->agroups, grp);
+ pose->active_group= 0;
+ }
+}
/* ************** time ****************** */