Moved and renamed ED_pose_channel_in_IK_chain() ->
authorJoshua Leung <aligorith@gmail.com>
Fri, 13 Sep 2013 03:03:46 +0000 (03:03 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 13 Sep 2013 03:03:46 +0000 (03:03 +0000)
BKE_pose_channel_in_IK_chain()

This was needed for depsgraph work, and it's cleaner for RNA to have fewer
dependencies on editors

source/blender/blenkernel/BKE_action.h
source/blender/blenkernel/intern/action.c
source/blender/editors/armature/pose_edit.c
source/blender/editors/include/ED_armature.h
source/blender/editors/space_view3d/drawarmature.c
source/blender/makesrna/intern/rna_pose.c

index 12c9f6b449f2e2b9bd01a127b3487907e1e91e84..d485632955d83c8a0834bd18a0ca6ccfd341d1d1 100644 (file)
@@ -203,6 +203,9 @@ void BKE_pose_ikparam_init(struct bPose *pose);
 /* initialize a bItasc structure with default value */
 void BKE_pose_itasc_init(struct bItasc *itasc);
 
+/* Checks if a bone is part of an IK chain or not */
+bool BKE_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);
+
 /* clears BONE_UNKEYED flags for frame changing */
 // XXX to be deprecated for a more general solution in animsys...
 void framechange_poses_clear_unkeyed(void);
index bfef3542c4599e42bc96443e3d6383f02dcbe1d7..644fefad3b0a4c959d47400a43c11eaacc72c4f2 100644 (file)
@@ -594,11 +594,43 @@ void BKE_pose_ikparam_init(bPose *pose)
        }
 }
 
+
+/* only for real IK, not for auto-IK */
+static bool pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
+{
+       bConstraint *con;
+       Bone *bone;
+       
+       /* No need to check if constraint is active (has influence),
+        * since all constraints with CONSTRAINT_IK_AUTO are active */
+       for (con = pchan->constraints.first; con; con = con->next) {
+               if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+                       bKinematicConstraint *data = con->data;
+                       if ((data->rootbone == 0) || (data->rootbone > level)) {
+                               if ((data->flag & CONSTRAINT_IK_AUTO) == 0)
+                                       return true;
+                       }
+               }
+       }
+       for (bone = pchan->bone->childbase.first; bone; bone = bone->next) {
+               pchan = BKE_pose_channel_find_name(ob->pose, bone->name);
+               if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1))
+                       return true;
+       }
+       return false;
+}
+
+bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
+{
+       return pose_channel_in_IK_chain(ob, pchan, 0);
+}
+
+
 void BKE_pose_channels_hash_make(bPose *pose) 
 {
        if (!pose->chanhash) {
                bPoseChannel *pchan;
-
+               
                pose->chanhash = BLI_ghash_str_new("make_pose_chan gh");
                for (pchan = pose->chanbase.first; pchan; pchan = pchan->next)
                        BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
index e84008c3d159d9c1e77db4542acef10d11a42631..31ff1e161e81499b16e5937e979194fa35844f8a 100644 (file)
@@ -148,36 +148,6 @@ static short pose_has_protected_selected(Object *ob, short warn)
 }
 #endif
 
-/* only for real IK, not for auto-IK */
-static int pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
-{
-       bConstraint *con;
-       Bone *bone;
-       
-       /* No need to check if constraint is active (has influence),
-        * since all constraints with CONSTRAINT_IK_AUTO are active */
-       for (con = pchan->constraints.first; con; con = con->next) {
-               if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
-                       bKinematicConstraint *data = con->data;
-                       if (data->rootbone == 0 || data->rootbone > level) {
-                               if ((data->flag & CONSTRAINT_IK_AUTO) == 0)
-                                       return 1;
-                       }
-               }
-       }
-       for (bone = pchan->bone->childbase.first; bone; bone = bone->next) {
-               pchan = BKE_pose_channel_find_name(ob->pose, bone->name);
-               if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1))
-                       return 1;
-       }
-       return 0;
-}
-
-int ED_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
-{
-       return pose_channel_in_IK_chain(ob, pchan, 0);
-}
-
 /* ********************************************** */
 /* Motion Paths */
 
index 454ccbcb9e69840facc7d42e1888e385be9fc5dc..225d8a0e5a37e4e45272de3fa1ce02fb6ddce2b8 100644 (file)
@@ -167,7 +167,6 @@ void ED_armature_ebone_selectflag_disable(EditBone *ebone, int flag);
 /* poseobject.c */
 void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
 void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
-int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);
 void ED_pose_deselectall(struct Object *ob, int test);
 void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
 struct Object *ED_pose_object_from_context(struct bContext *C);
index 6961ada462d0303e52d4d82b8da18f33149fa3b7..2634dd3ec088db0061099c435982e4aa15f7d7e1 100644 (file)
@@ -1538,7 +1538,7 @@ static void draw_pose_dofs(Object *ob)
                        if (bone->flag & BONE_SELECTED) {
                                if (bone->layer & arm->layer) {
                                        if (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ZLIMIT)) {
-                                               if (ED_pose_channel_in_IK_chain(ob, pchan)) {
+                                               if (BKE_pose_channel_in_IK_chain(ob, pchan)) {
                                                        float corner[4][3], posetrans[3], mat[4][4];
                                                        float phi = 0.0f, theta = 0.0f, scale;
                                                        int a, i;
index 8c73aacc7247ab17b0efc352cf5503212fe10d8c..35347d656df367760197b74dbe84643eec2a0cb3 100644 (file)
@@ -261,7 +261,7 @@ static int rna_PoseChannel_has_ik_get(PointerRNA *ptr)
        Object *ob = (Object *)ptr->id.data;
        bPoseChannel *pchan = (bPoseChannel *)ptr->data;
 
-       return ED_pose_channel_in_IK_chain(ob, pchan);
+       return BKE_pose_channel_in_IK_chain(ob, pchan);
 }
 
 static StructRNA *rna_IKParam_refine(PointerRNA *ptr)