[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12131] trunk/blender/source/blender: == Action and NLA Editor Transform ==
Joshua Leung
aligorith at gmail.com
Mon Sep 24 13:29:26 CEST 2007
Revision: 12131
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12131
Author: aligorith
Date: 2007-09-24 13:29:25 +0200 (Mon, 24 Sep 2007)
Log Message:
-----------
== Action and NLA Editor Transform ==
I've refactored the Action and NLA Editor Transform tools to use the Transform System instead of setting up their own transform loops. This should have happened ages ago, but no-one got around to doing so.
* There are still a few bugs left to iron out of a few features, but on the whole it should work as well as it used to. These are: the values which get displayed when working with NLA-scaled actions may not all be correct yet; and the Time-Slide tool in the Action Editor is currently kindof broken.
* One of the main benefits of this work, is that it is now possible to use Numeric Input during Transforms.
* Also, a bug that meant that it was not possible to negatively scale keyframes in the Action Editor has been resolved.
Modified Paths:
--------------
trunk/blender/source/blender/include/BIF_transform.h
trunk/blender/source/blender/include/transform.h
trunk/blender/source/blender/src/editaction.c
trunk/blender/source/blender/src/editnla.c
trunk/blender/source/blender/src/header_action.c
trunk/blender/source/blender/src/transform.c
trunk/blender/source/blender/src/transform_conversions.c
trunk/blender/source/blender/src/transform_generics.c
Modified: trunk/blender/source/blender/include/BIF_transform.h
===================================================================
--- trunk/blender/source/blender/include/BIF_transform.h 2007-09-24 10:00:47 UTC (rev 12130)
+++ trunk/blender/source/blender/include/BIF_transform.h 2007-09-24 11:29:25 UTC (rev 12131)
@@ -55,6 +55,9 @@
#define TFM_BONE_ENVELOPE 16
#define TFM_CURVE_SHRINKFATTEN 17
#define TFM_BONE_ROLL 18
+#define TFM_TIME_TRANSLATE 19
+#define TFM_TIME_SLIDE 20
+#define TFM_TIME_SCALE 21
/* TRANSFORM CONTEXTS */
#define CTX_NONE 0
Modified: trunk/blender/source/blender/include/transform.h
===================================================================
--- trunk/blender/source/blender/include/transform.h 2007-09-24 10:00:47 UTC (rev 12130)
+++ trunk/blender/source/blender/include/transform.h 2007-09-24 11:29:25 UTC (rev 12131)
@@ -339,6 +339,15 @@
void initBoneRoll(TransInfo *t);
int BoneRoll(TransInfo *t, short mval[2]);
+void initTimeTranslate(TransInfo *t);
+int TimeTranslate(TransInfo *t, short mval[2]);
+
+void initTimeSlide(TransInfo *t);
+int TimeSlide(TransInfo *t, short mval[2]);
+
+void initTimeScale(TransInfo *t);
+int TimeScale(TransInfo *t, short mval[2]);
+
/*********************** transform_conversions.c ********** */
struct ListBase;
void flushTransUVs(TransInfo *t);
Modified: trunk/blender/source/blender/src/editaction.c
===================================================================
--- trunk/blender/source/blender/src/editaction.c 2007-09-24 10:00:47 UTC (rev 12130)
+++ trunk/blender/source/blender/src/editaction.c 2007-09-24 11:29:25 UTC (rev 12131)
@@ -80,6 +80,7 @@
#include "BIF_screen.h"
#include "BIF_space.h"
#include "BIF_toolbox.h"
+#include "BIF_transform.h"
#include "BSE_edit.h"
#include "BSE_drawipo.h"
@@ -186,20 +187,7 @@
}
}
-static void meshkey_do_redraw (Key *key)
-{
- if(key->ipo)
- remake_meshaction_ipos(key->ipo);
- DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
-
- allspace(REMAKEIPO, 0);
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWIPO, 0);
- allqueue(REDRAWNLA, 0);
-
-}
-
/* **************************************************** */
/* FILTER->EDIT STRUCTURES */
/*
@@ -737,361 +725,9 @@
/* **************************************************** */
/* TRANSFORM TOOLS */
-/* initialise the transform data - create transverts */
-static TransVert *transform_action_init (int *tvtot, float *minx, float *maxx)
-{
- ListBase act_data = {NULL, NULL};
- bActListElem *ale;
- TransVert *tv;
- void *data;
- short datatype;
- int filter;
- int count= 0;
- float min= 0, max= 0;
- int i;
-
- /* initialise the values being passed by reference */
- *tvtot = *minx = *maxx = 0;
-
- /* determine what type of data we are operating on */
- data = get_action_context(&datatype);
- if (data == NULL) return NULL;
-
- /* filter data */
- filter= (ACTFILTER_VISIBLE | ACTFILTER_FOREDIT | ACTFILTER_IPOKEYS);
- actdata_filter(&act_data, filter, data, datatype);
-
- /* loop 1: fully select ipo-keys and count how many BezTriples are selected */
- for (ale= act_data.first; ale; ale= ale->next)
- count += fullselect_ipo_keys(ale->key_data);
-
- /* stop if trying to build list if nothing selected */
- if (count == 0) {
- /* cleanup temp list */
- BLI_freelistN(&act_data);
- return NULL;
- }
-
- /* Build the transvert structure */
- tv = MEM_callocN (sizeof(TransVert) * count, "transVert");
-
- /* loop 2: build transvert structure */
- for (ale= act_data.first; ale; ale= ale->next)
- *tvtot = add_trans_ipo_keys(ale->key_data, tv, *tvtot);
-
- /* min max, only every other three */
- min= max= tv[1].loc[0];
- for (i=1; i<count; i+=3) {
- if(min>tv[i].loc[0]) min= tv[i].loc[0];
- if(max<tv[i].loc[0]) max= tv[i].loc[0];
- }
- *minx= min;
- *maxx= max;
-
- /* cleanup temp list */
- BLI_freelistN(&act_data);
-
- /* return created transverts */
- return tv;
-}
-
-/* main transform loop for action editor
- * NOTE: yes, this is a very long function that really should be converted to
- * using the transform system proper
- */
-static short transform_action_loop (TransVert *tv, int tvtot, char mode, short context, float minx, float maxx)
-{
- Object *ob= OBACT;
- float deltax, startx;
- float cenf[2];
- float sval[2], cval[2], lastcval[2]={0,0};
- float fac=0.0f, secf= ((float)G.scene->r.frs_sec);
- int loop=1, invert=0;
- int i;
- short cancel=0, firsttime=1;
- short mvals[2], mvalc[2], cent[2];
- char str[256];
-
- /* Do the event loop */
- cent[0] = curarea->winx + (G.saction->v2d.hor.xmax)/2;
- cent[1] = curarea->winy + (G.saction->v2d.hor.ymax)/2;
- areamouseco_to_ipoco(G.v2d, cent, &cenf[0], &cenf[1]);
-
- getmouseco_areawin (mvals);
- areamouseco_to_ipoco(G.v2d, mvals, &sval[0], &sval[1]);
-
- if (NLA_ACTION_SCALED)
- sval[0]= get_action_frame(OBACT, sval[0]);
-
- /* used for drawing */
- if (mode=='t') {
- G.saction->flag |= SACTION_MOVING;
- G.saction->timeslide= sval[0];
- }
-
- startx=sval[0];
- while (loop) {
- if (mode=='t' && minx==maxx)
- break;
-
- /* Get the input:
- * - If we're cancelling, reset transformations
- * - Else calc new transformation
- * Perform the transformations
- */
- while (qtest()) {
- short val;
- unsigned short event= extern_qread(&val);
-
- if (val) {
- switch (event) {
- case LEFTMOUSE:
- case SPACEKEY:
- case RETKEY:
- loop=0;
- break;
- case XKEY:
- break;
- case ESCKEY:
- case RIGHTMOUSE:
- cancel=1;
- loop=0;
- break;
- default:
- arrows_move_cursor(event);
- break;
- };
- }
- }
-
- if (cancel) {
- for (i=0; i<tvtot; i++) {
- tv[i].loc[0]=tv[i].oldloc[0];
- tv[i].loc[1]=tv[i].oldloc[1];
- }
- }
- else {
- getmouseco_areawin (mvalc);
- areamouseco_to_ipoco(G.v2d, mvalc, &cval[0], &cval[1]);
-
- if (NLA_ACTION_SCALED)
- cval[0]= get_action_frame(OBACT, cval[0]);
-
- if (mode=='t')
- G.saction->timeslide= cval[0];
-
- if (!firsttime && lastcval[0]==cval[0] && lastcval[1]==cval[1]) {
- PIL_sleep_ms(1);
- }
- else {
- short autosnap= 0;
-
- /* determine mode of keyframe snapping/autosnap */
- if (mode != 't') {
- switch (G.saction->autosnap) {
- case SACTSNAP_OFF:
- if (G.qual == LR_CTRLKEY)
- autosnap= SACTSNAP_STEP;
- else if (G.qual == LR_SHIFTKEY)
- autosnap= SACTSNAP_FRAME;
- else
- autosnap= SACTSNAP_OFF;
- break;
- case SACTSNAP_STEP:
- autosnap= (G.qual==LR_CTRLKEY)? SACTSNAP_OFF: SACTSNAP_STEP;
- break;
- case SACTSNAP_FRAME:
- autosnap= (G.qual==LR_SHIFTKEY)? SACTSNAP_OFF: SACTSNAP_FRAME;
- break;
- }
- }
-
- for (i=0; i<tvtot; i++) {
- tv[i].loc[0]=tv[i].oldloc[0];
-
- switch (mode) {
- case 't':
- if( sval[0] > minx && sval[0] < maxx) {
- float timefac, cvalc= CLAMPIS(cval[0], minx, maxx);
-
- /* left half */
- if(tv[i].oldloc[0] < sval[0]) {
- timefac= ( sval[0] - tv[i].oldloc[0])/(sval[0] - minx);
- tv[i].loc[0]= cvalc - timefac*( cvalc - minx);
- }
- else {
- timefac= (tv[i].oldloc[0] - sval[0])/(maxx - sval[0]);
- tv[i].loc[0]= cvalc + timefac*(maxx- cvalc);
- }
- }
- break;
- case 'g':
- if (NLA_ACTION_SCALED && context==ACTCONT_ACTION) {
- deltax = get_action_frame_inv(OBACT, cval[0]);
- deltax -= get_action_frame_inv(OBACT, sval[0]);
-
- if (autosnap == SACTSNAP_STEP) {
- if (G.saction->flag & SACTION_DRAWTIME)
- deltax= (float)( floor((deltax/secf) + 0.5f) * secf );
- else
- deltax= (float)( floor(deltax + 0.5f) );
- }
-
- fac = get_action_frame_inv(OBACT, tv[i].loc[0]);
- fac += deltax;
- tv[i].loc[0] = get_action_frame(OBACT, fac);
- }
- else {
- deltax = cval[0] - sval[0];
- fac= deltax;
-
- if (autosnap == SACTSNAP_STEP) {
- if (G.saction->flag & SACTION_DRAWTIME)
- fac= (float)( floor((deltax/secf) + 0.5f) * secf );
- else
- fac= (float)( floor(fac + 0.5f) );
- }
-
- tv[i].loc[0]+=fac;
- }
- break;
- case 's':
- startx=mvals[0]-(ACTWIDTH/2+(curarea->winrct.xmax-curarea->winrct.xmin)/2);
- deltax=mvalc[0]-(ACTWIDTH/2+(curarea->winrct.xmax-curarea->winrct.xmin)/2);
- fac= fabs(deltax/startx);
-
- if (autosnap == SACTSNAP_STEP) {
- if (G.saction->flag & SACTION_DRAWTIME)
- fac= (float)( floor(fac/secf + 0.5f) * secf );
- else
- fac= (float)( floor(fac + 0.5f) );
- }
-
- if (invert) {
- if (i % 03 == 0) {
- memcpy (tv[i].loc, tv[i].oldloc, sizeof(tv[i+2].oldloc));
- }
- if (i % 03 == 2) {
- memcpy (tv[i].loc, tv[i].oldloc, sizeof(tv[i-2].oldloc));
- }
-
- fac *= -1;
- }
- startx= (G.scene->r.cfra);
- if (NLA_ACTION_SCALED && context==ACTCONT_ACTION)
- startx= get_action_frame(OBACT, startx);
-
- tv[i].loc[0]-= startx;
- tv[i].loc[0]*=fac;
- tv[i].loc[0]+= startx;
-
- break;
- }
-
- /* snap key to nearest frame? */
- if (autosnap == SACTSNAP_FRAME) {
- float snapval;
-
- /* convert frame to nla-action time (if needed) */
- if (NLA_ACTION_SCALED && context==ACTCONT_ACTION)
- snapval= get_action_frame_inv(OBACT, tv[i].loc[0]);
- else
- snapval= tv[i].loc[0];
-
- /* snap to nearest frame */
- if (G.saction->flag & SACTION_DRAWTIME)
- snapval= (float)( floor((snapval/secf) + 0.5f) * secf );
- else
- snapval= (float)( floor(snapval+0.5f) );
-
- /* convert frame out of nla-action time */
- if (NLA_ACTION_SCALED && context==ACTCONT_ACTION)
- tv[i].loc[0]= get_action_frame(OBACT, snapval);
- else
- tv[i].loc[0]= snapval;
- }
- }
-
- if (mode=='s') {
- sprintf(str, "scaleX: %.3f", fac);
- headerprint(str);
- }
- else if (mode=='g') {
- if (NLA_ACTION_SCALED && context==ACTCONT_ACTION) {
- /* recalculate the delta based on 'visual' times */
- fac = get_action_frame_inv(OBACT, cval[0]);
- fac -= get_action_frame_inv(OBACT, sval[0]);
- }
-
- if (autosnap == SACTSNAP_STEP) {
- if (G.saction->flag & SACTION_DRAWTIME)
- fac= floor(fac/secf + 0.5f);
- else
- fac= floor(fac + 0.5f);
- }
- else if (autosnap == SACTSNAP_FRAME) {
- if (G.saction->flag & SACTION_DRAWTIME)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list