Revision: 23342
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23342
Author:   aligorith
Date:     2009-09-19 02:18:42 +0200 (Sat, 19 Sep 2009)

Log Message:
-----------
2.5 - Pose Enhancement Tools 

This commit restores the 'Relax Pose' tool, and also introduces two others: 
'Push Pose' and 'Pose Breakdowner'.
Be aware that this commit is just the initial starting point, with some parts 
yet to be done.

A short description of these tools follows:
* Relax Pose (Alt-E) - makes the current pose more like the poses on either 
side of it
* Push Pose (Ctrl-E) - exaggerates the current pose
* Breakdowner (Shift-E)[not working yet] - when this works, it will allow for 
interactive selection of a good in-between pose to act as a breakdown. 

Todo's:
* Connect up the 'percentage' slider in the operator settings to allow these 
effects to be dialed in/out, exaggerating/relaxing/moveing-between-keyframes by 
varying degrees until the desired effect is reached.
* Allow these effects to be interactively dialed in/out. The idea is to use the 
mouse to interactively set the percentage slider value initially, then use the 
percentage slider to tweak later.
* Figure out why breakdown breaks down 

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_fcurve.h
    trunk/blender/source/blender/blenkernel/intern/fcurve.c
    trunk/blender/source/blender/editors/animation/keyframes_draw.c
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/armature/armature_intern.h
    trunk/blender/source/blender/editors/armature/armature_ops.c
    trunk/blender/source/blender/editors/armature/poselib.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/include/ED_keyframes_draw.h
    trunk/blender/source/blender/editors/screen/screen_ops.c

Added Paths:
-----------
    trunk/blender/source/blender/editors/armature/poseSlide.c

Modified: trunk/blender/source/blender/blenkernel/BKE_fcurve.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_fcurve.h        2009-09-18 
22:25:49 UTC (rev 23341)
+++ trunk/blender/source/blender/blenkernel/BKE_fcurve.h        2009-09-19 
00:18:42 UTC (rev 23342)
@@ -153,6 +153,11 @@
 /* find matching F-Curve in the given list of F-Curves */
 struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const 
int array_index);
 
+/* Binary search algorithm for finding where to 'insert' BezTriple with given 
frame number.
+ * Returns the index to insert at (data already at that index will be offset 
if replace is 0)
+ */
+int binarysearch_bezt_index(struct BezTriple array[], float frame, int 
arraylen, short *replace);
+
 /* get the time extents for F-Curve */
 void calc_fcurve_range(struct FCurve *fcu, float *min, float *max);
 

Modified: trunk/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fcurve.c     2009-09-18 
22:25:49 UTC (rev 23341)
+++ trunk/blender/source/blender/blenkernel/intern/fcurve.c     2009-09-19 
00:18:42 UTC (rev 23342)
@@ -200,6 +200,85 @@
        return NULL;
 }
 
+/* threshold for binary-searching keyframes - threshold here should be good 
enough for now, but should become userpref */
+#define BEZT_BINARYSEARCH_THRESH       0.00001f
+
+/* Binary search algorithm for finding where to insert BezTriple. (for use by 
insert_bezt_fcurve)
+ * Returns the index to insert at (data already at that index will be offset 
if replace is 0)
+ */
+int binarysearch_bezt_index (BezTriple array[], float frame, int arraylen, 
short *replace)
+{
+       int start=0, end=arraylen;
+       int loopbreaker= 0, maxloop= arraylen * 2;
+       
+       /* initialise replace-flag first */
+       *replace= 0;
+       
+       /* sneaky optimisations (don't go through searching process if...):
+        *      - keyframe to be added is to be added out of current bounds
+        *      - keyframe to be added would replace one of the existing ones 
on bounds
+        */
+       if ((arraylen <= 0) || (array == NULL)) {
+               printf("Warning: binarysearch_bezt_index() encountered invalid 
array \n");
+               return 0;
+       }
+       else {
+               /* check whether to add before/after/on */
+               float framenum;
+               
+               /* 'First' Keyframe (when only one keyframe, this case is used) 
*/
+               framenum= array[0].vec[1][0];
+               if (IS_EQT(frame, framenum, BEZT_BINARYSEARCH_THRESH)) {
+                       *replace = 1;
+                       return 0;
+               }
+               else if (frame < framenum)
+                       return 0;
+                       
+               /* 'Last' Keyframe */
+               framenum= array[(arraylen-1)].vec[1][0];
+               if (IS_EQT(frame, framenum, BEZT_BINARYSEARCH_THRESH)) {
+                       *replace= 1;
+                       return (arraylen - 1);
+               }
+               else if (frame > framenum)
+                       return arraylen;
+       }
+       
+       
+       /* most of the time, this loop is just to find where to put it
+        * 'loopbreaker' is just here to prevent infinite loops 
+        */
+       for (loopbreaker=0; (start <= end) && (loopbreaker < maxloop); 
loopbreaker++) {
+               /* compute and get midpoint */
+               int mid = start + ((end - start) / 2);  /* we calculate the 
midpoint this way to avoid int overflows... */
+               float midfra= array[mid].vec[1][0];
+               
+               /* check if exactly equal to midpoint */
+               if (IS_EQT(frame, midfra, BEZT_BINARYSEARCH_THRESH)) {
+                       *replace = 1;
+                       return mid;
+               }
+               
+               /* repeat in upper/lower half */
+               if (frame > midfra)
+                       start= mid + 1;
+               else if (frame < midfra)
+                       end= mid - 1;
+       }
+       
+       /* print error if loop-limit exceeded */
+       if (loopbreaker == (maxloop-1)) {
+               printf("Error: binarysearch_bezt_index() was taking too long 
\n");
+               
+               // include debug info 
+               printf("\tround = %d: start = %d, end = %d, arraylen = %d \n", 
loopbreaker, start, end, arraylen);
+       }
+       
+       /* not found, so return where to place it */
+       return start;
+}
+
 /* Calculate the extents of F-Curve's data */
 void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, 
float *ymax)
 {

Modified: trunk/blender/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_draw.c     
2009-09-18 22:25:49 UTC (rev 23341)
+++ trunk/blender/source/blender/editors/animation/keyframes_draw.c     
2009-09-19 00:18:42 UTC (rev 23342)
@@ -316,7 +316,7 @@
 /* *************************** Keyframe Drawing *************************** */
 
 /* helper function - find actkeycolumn that occurs on cframe */
-static ActKeyColumn *cfra_find_actkeycolumn (ActKeyColumn *ak, float cframe)
+ActKeyColumn *cfra_find_actkeycolumn (ActKeyColumn *ak, float cframe)
 {
        /* sanity checks */
        if (ak == NULL)
@@ -331,6 +331,28 @@
                return ak; /* match */
 }
 
+/* helper function - find actkeycolumn that occurs on cframe, or the nearest 
one if not found */
+ActKeyColumn *cfra_find_nearest_next_ak (ActKeyColumn *ak, float cframe, short 
next)
+{
+       ActKeyColumn *akn= NULL;
+       
+       /* sanity checks */
+       if (ak == NULL)
+               return NULL;
+       
+       /* check if this is a match, or whether it is in some subtree */
+       if (cframe < ak->cfra)
+               akn= cfra_find_nearest_next_ak(ak->left, cframe, next);
+       else if (cframe > ak->cfra)
+               akn= cfra_find_nearest_next_ak(ak->right, cframe, next);
+               
+       /* if no match found (or found match), just use the current one */
+       if (akn == NULL)
+               return ak;
+       else
+               return akn;
+}
+
 /* -------- */
 
 /* coordinates for diamond shape */

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c 2009-09-18 
22:25:49 UTC (rev 23341)
+++ trunk/blender/source/blender/editors/animation/keyframing.c 2009-09-19 
00:18:42 UTC (rev 23342)
@@ -176,85 +176,6 @@
 
 /* -------------- BezTriple Insertion -------------------- */
 
-/* threshold for inserting keyframes - threshold here should be good enough 
for now, but should become userpref */
-#define BEZT_INSERT_THRESH     0.00001f
-
-/* Binary search algorithm for finding where to insert BezTriple. (for use by 
insert_bezt_icu)
- * Returns the index to insert at (data already at that index will be offset 
if replace is 0)
- */
-static int binarysearch_bezt_index (BezTriple array[], float frame, int 
arraylen, short *replace)
-{
-       int start=0, end=arraylen;
-       int loopbreaker= 0, maxloop= arraylen * 2;
-       
-       /* initialise replace-flag first */
-       *replace= 0;
-       
-       /* sneaky optimisations (don't go through searching process if...):
-        *      - keyframe to be added is to be added out of current bounds
-        *      - keyframe to be added would replace one of the existing ones 
on bounds
-        */
-       if ((arraylen <= 0) || (array == NULL)) {
-               printf("Warning: binarysearch_bezt_index() encountered invalid 
array \n");
-               return 0;
-       }
-       else {
-               /* check whether to add before/after/on */
-               float framenum;
-               
-               /* 'First' Keyframe (when only one keyframe, this case is used) 
*/
-               framenum= array[0].vec[1][0];
-               if (IS_EQT(frame, framenum, BEZT_INSERT_THRESH)) {
-                       *replace = 1;
-                       return 0;
-               }
-               else if (frame < framenum)
-                       return 0;
-                       
-               /* 'Last' Keyframe */
-               framenum= array[(arraylen-1)].vec[1][0];
-               if (IS_EQT(frame, framenum, BEZT_INSERT_THRESH)) {
-                       *replace= 1;
-                       return (arraylen - 1);
-               }
-               else if (frame > framenum)
-                       return arraylen;
-       }
-       
-       
-       /* most of the time, this loop is just to find where to put it
-        * 'loopbreaker' is just here to prevent infinite loops 
-        */
-       for (loopbreaker=0; (start <= end) && (loopbreaker < maxloop); 
loopbreaker++) {
-               /* compute and get midpoint */
-               int mid = start + ((end - start) / 2);  /* we calculate the 
midpoint this way to avoid int overflows... */
-               float midfra= array[mid].vec[1][0];
-               
-               /* check if exactly equal to midpoint */
-               if (IS_EQT(frame, midfra, BEZT_INSERT_THRESH)) {
-                       *replace = 1;
-                       return mid;
-               }
-               
-               /* repeat in upper/lower half */
-               if (frame > midfra)
-                       start= mid + 1;
-               else if (frame < midfra)
-                       end= mid - 1;
-       }
-       
-       /* print error if loop-limit exceeded */
-       if (loopbreaker == (maxloop-1)) {
-               printf("Error: binarysearch_bezt_index() was taking too long 
\n");
-               
-               // include debug info 
-               printf("\tround = %d: start = %d, end = %d, arraylen = %d \n", 
loopbreaker, start, end, arraylen);
-       }
-       
-       /* not found, so return where to place it */
-       return start;
-}
-
 /* This function adds a given BezTriple to an F-Curve. It will allocate 
  * memory for the array if needed, and will insert the BezTriple into a
  * suitable place in chronological order.

Modified: trunk/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_intern.h     
2009-09-18 22:25:49 UTC (rev 23341)
+++ trunk/blender/source/blender/editors/armature/armature_intern.h     
2009-09-19 00:18:42 UTC (rev 23342)
@@ -118,12 +118,20 @@
 
 /* ******************************************************* */
 /* PoseLib */
+
 void POSELIB_OT_pose_add(struct wmOperatorType *ot);
 void POSELIB_OT_pose_remove(struct wmOperatorType *ot);
 void POSELIB_OT_pose_rename(struct wmOperatorType *ot);
 void POSELIB_OT_browse_interactive(struct wmOperatorType *ot);
 
 /* ******************************************************* */
+/* Pose Sliding Tools */
+
+void POSE_OT_push(struct wmOperatorType *ot);
+void POSE_OT_relax(struct wmOperatorType *ot);
+void POSE_OT_breakdown(struct wmOperatorType *ot);
+
+/* ******************************************************* */
 /* editarmature.c */
 struct bArmature;
 struct EditBone;

Modified: trunk/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_ops.c        
2009-09-18 22:25:49 UTC (rev 23341)
+++ trunk/blender/source/blender/editors/armature/armature_ops.c        
2009-09-19 00:18:42 UTC (rev 23342)
@@ -196,6 +196,11 @@
        WM_operatortype_append(POSELIB_OT_pose_remove);
        WM_operatortype_append(POSELIB_OT_pose_rename);
        
+       /* POSE SLIDING */
+       WM_operatortype_append(POSE_OT_push);
+       WM_operatortype_append(POSE_OT_relax);
+       WM_operatortype_append(POSE_OT_breakdown);
+       
        /* TESTS */
        WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context 
iterators... to be removed
 }
@@ -365,5 +370,11 @@
        WM_keymap_add_item(keymap, "POSELIB_OT_pose_add", LKEY, KM_PRESS, 
KM_SHIFT, 0);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to