batch remove .'s used with RNA_def_struct_ui_text
[blender.git] / source / blender / editors / armature / poseSlide.c
index 1e0df79d0e6865e8af1c0750f67ae869a3f2e200..b0fb882d37d79f8a6806ab56fa17d3d27e4e5f07 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_arithb.h"
+#include "BLI_math.h"
 #include "BLI_blenlib.h"
 #include "BLI_dynstr.h"
 #include "BLI_dlrbTree.h"
@@ -178,7 +178,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode)
        /* for each Pose-Channel which gets affected, get the F-Curves for that channel 
         * and set the relevant transform flags...
         */
-       CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans) 
+       CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) 
        {
                ListBase curves = {NULL, NULL};
                int transFlags = action_get_item_transforms(act, pso->ob, pchan, &curves);
@@ -195,7 +195,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode)
                        pfl->pchan= pchan;
                        
                        /* get the RNA path to this pchan - this needs to be freed! */
-                       RNA_pointer_create((ID *)pso->ob, &RNA_PoseChannel, pchan, &ptr);
+                       RNA_pointer_create((ID *)pso->ob, &RNA_PoseBone, pchan, &ptr);
                        pfl->pchan_path= RNA_path_from_ID_to_struct(&ptr);
                        
                        /* add linkage data to operator data */
@@ -287,7 +287,6 @@ static void pose_slide_refresh (bContext *C, tPoseSlideOp *pso)
        
        /* note, notifier might evolve */
        WM_event_add_notifier(C, NC_OBJECT|ND_POSE, pso->ob);
-       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); 
 }
 
 /* helper for apply() callabcks - find the next F-Curve with matching path... */
@@ -417,7 +416,7 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
        float cframe;
        
        /* get the path to use - this should be quaternion rotations only (needs care) */
-       path= BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation");
+       path= BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion");
        
        /* get the current frame number */
        cframe= (float)pso->cframe;
@@ -461,7 +460,20 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
                /* perform blending */
                if (pso->mode == POSESLIDE_BREAKDOWN) {
                        /* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */
-                       QuatInterpol(pchan->quat, quat_prev, quat_next, pso->percentage);
+                       interp_qt_qtqt(pchan->quat, quat_prev, quat_next, pso->percentage);
+               }
+               else if (pso->mode == POSESLIDE_PUSH) {
+                       float quat_diff[4], quat_orig[4];
+                       
+                       /* calculate the delta transform from the previous to the current */
+                       // TODO: investigate ways to favour one transform more?
+                       sub_qt_qtqt(quat_diff, pchan->quat, quat_prev);
+                       
+                       /* make a copy of the original rotation */
+                       QUATCOPY(quat_orig, pchan->quat);
+                       
+                       /* increase the original by the delta transform, by an amount determined by percentage */
+                       add_qt_qtqt(pchan->quat, quat_orig, quat_diff, pso->percentage);
                }
                else {
                        float quat_interp[4], quat_orig[4];
@@ -470,16 +482,13 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
                        /* perform this blending several times until a satisfactory result is reached */
                        while (iters-- > 0) {
                                /* calculate the interpolation between the endpoints */
-                               QuatInterpol(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame) );
+                               interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame) );
                                
                                /* make a copy of the original rotation */
                                QUATCOPY(quat_orig, pchan->quat);
                                
-                               /* tricky interpolations - mode-dependent blending between original and new */
-                               if (pso->mode == POSESLIDE_RELAX) // xxx this was the original code, so should work fine
-                                       QuatInterpol(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f);
-                               else // I'm just guessing here...
-                                       QuatInterpol(pchan->quat, quat_orig, quat_interp, 6.0f/5.0f);
+                               /* tricky interpolations - blending between original and new */
+                               interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f);
                        }
                }
        }
@@ -612,22 +621,15 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *
                /* cancel if no keyframes found... */
        if (pso->keys.root) {
                ActKeyColumn *ak;
+               float cframe= (float)pso->cframe;
                
                /* firstly, check if the current frame is a keyframe... */
-               ak= cfra_find_actkeycolumn(pso->keys.root, pso->cframe);
+               ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe);
                
                if (ak == NULL) {
                        /* current frame is not a keyframe, so search */
-                       ActKeyColumn *pk= cfra_find_nearest_next_ak(pso->keys.root, pso->cframe, 0);
-                       ActKeyColumn *nk= cfra_find_nearest_next_ak(pso->keys.root, pso->cframe, 1);
-                       
-                       /* check if we found good keyframes */
-                       if ((pk == nk) && (pk != NULL)) {
-                               if (pk->cfra < pso->cframe)
-                                       nk= nk->next;
-                               else if (nk->cfra > pso->cframe)
-                                       pk= pk->prev;
-                       }
+                       ActKeyColumn *pk= (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe);
+                       ActKeyColumn *nk= (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe);
                        
                        /* new set the frames */
                                /* prev frame */
@@ -860,7 +862,7 @@ void POSE_OT_relax (wmOperatorType *ot)
        /* identifiers */
        ot->name= "Relax Pose";
        ot->idname= "POSE_OT_relax";
-       ot->description= "Make the current pose more similar to its surrounding ones.";
+       ot->description= "Make the current pose more similar to its surrounding ones";
        
        /* callbacks */
        ot->exec= pose_slide_relax_exec;
@@ -917,7 +919,7 @@ void POSE_OT_breakdown (wmOperatorType *ot)
        /* identifiers */
        ot->name= "Pose Breakdowner";
        ot->idname= "POSE_OT_breakdown";
-       ot->description= "Create a suitable breakdown pose on the current frame.";
+       ot->description= "Create a suitable breakdown pose on the current frame";
        
        /* callbacks */
        ot->exec= pose_slide_breakdown_exec;