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:
authorTon Roosendaal <ton@blender.org>2005-10-28 12:11:15 +0400
committerTon Roosendaal <ton@blender.org>2005-10-28 12:11:15 +0400
commit595447a85ea2e388fa17b4a44dacf256ac97f343 (patch)
tree3461e1157f41cbe304f8e346cd2ac5c8333c395d /source/blender/src/editkey.c
parent0dde486eeae6c563059bfab408f1ed5bd239ad85 (diff)
Here's another milestone: Shape Keys now can be inserted in Actions and NLA
It works like for moving Object Ipos to the Action, press the Action icon in the header of the IpoWindow, to the left of the mode selection menu. It then creates an Action (if not existed) and moves the Shape Ipo to the Action, using custom channel "Shape". Main code change was that evaluating Ipo Curves for Relative Shapes had to be recoded, but that's pretty minor and even much cleaner. (added "curval" in the KeyBlock struct). That this feature can work is thanks to the full modifier/derivedmesh recode Daniel did, can't give him enough credits! :) Also; small fixes in Outliner, for clicking on the Ipo icon (sets the Ipo window to show that Ipo).
Diffstat (limited to 'source/blender/src/editkey.c')
-rw-r--r--source/blender/src/editkey.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/source/blender/src/editkey.c b/source/blender/src/editkey.c
index 2262d3298cf..32adf6289ac 100644
--- a/source/blender/src/editkey.c
+++ b/source/blender/src/editkey.c
@@ -44,19 +44,21 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
+#include "DNA_action_types.h"
#include "DNA_curve_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view2d_types.h"
-#include "DNA_lattice_types.h"
-#include "DNA_scene_types.h"
+#include "BKE_action.h"
#include "BKE_anim.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
@@ -96,7 +98,7 @@ float meshslidervals[64] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
-static IpoCurve *get_key_icu(Key *key, int keynum)
+static IpoCurve *get_key_icu(Ipo *ipo, int keynum)
{
/* return the Ipocurve that has the specified
* keynum as ardcode -- return NULL if no such
@@ -104,13 +106,10 @@ static IpoCurve *get_key_icu(Key *key, int keynum)
*/
IpoCurve *icu;
- /* why this? (ton) */
- if (!(key->ipo)) {
- key->ipo= add_ipo("KeyIpo", ID_KE);
+ if (!ipo)
return NULL;
- }
- for (icu = key->ipo->curve.first; icu ; icu = icu->next) {
+ for (icu = ipo->curve.first; icu ; icu = icu->next) {
if (!icu->adrcode) continue;
if (icu->adrcode == keynum) return icu;
}
@@ -144,23 +143,26 @@ static BezTriple *get_bezt_icu_time(IpoCurve *icu, float *frame, float *val) {
return bezt;
}
-static void rvk_slider_func(void *voidkey, void *voidkeynum)
+static void rvk_slider_func(void *voidob, void *voidkeynum)
{
/* the callback for the rvk sliders ... copies the
* value from the temporary array into a bezier at the
* right frame on the right ipo curve (creating both the
* ipo curve and the bezier if needed).
*/
+ Object *ob= voidob;
IpoCurve *icu=NULL;
BezTriple *bezt=NULL;
- Key *key = (Key *) voidkey;
- Object *ob= OBACT;
float cfra, rvkval;
int keynum = (int) voidkeynum;
cfra = frame_to_float(CFRA);
- icu = verify_ipocurve(&key->id, ID_KE, NULL, NULL, keynum);
+ /* ipo on action or ob? */
+ if(ob->ipoflag & OB_ACTION_KEY)
+ icu = verify_ipocurve(&ob->id, ID_KE, "Shape", NULL, keynum);
+ else
+ icu = verify_ipocurve(&ob->id, ID_KE, NULL, NULL, keynum);
if (icu) {
/* if the ipocurve exists, try to get a bezier
@@ -184,8 +186,6 @@ static void rvk_slider_func(void *voidkey, void *voidkeynum)
*/
sort_time_ipocurve(icu);
testhandles_ipocurve(icu);
-
- do_ipo(key->ipo);
ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
@@ -195,10 +195,9 @@ static void rvk_slider_func(void *voidkey, void *voidkeynum)
allqueue (REDRAWNLA, 0);
allqueue (REDRAWIPO, 0);
allspace(REMAKEIPO, 0);
-
}
-static float getrvkval(Key *key, int keynum)
+static float getrvkval(Ipo *ipo, int keynum)
{
/* get the value of the rvk from the
* ipo curve at the current time -- return 0
@@ -210,7 +209,7 @@ static float getrvkval(Key *key, int keynum)
float cfra;
cfra = frame_to_float(CFRA);
- icu = get_key_icu(key, keynum);
+ icu = get_key_icu(ipo, keynum);
if (icu) {
bezt = get_bezt_icu_time(icu, &cfra, &rvkval);
if (!bezt) {
@@ -222,17 +221,32 @@ static float getrvkval(Key *key, int keynum)
}
-void make_rvk_slider(uiBlock *block, Key *key, int keynum,
+void make_rvk_slider(uiBlock *block, Object *ob, int keynum,
int x, int y, int w, int h, char *tip)
{
/* create a slider for the rvk */
- uiBut *but;
+ uiBut *but;
+ Ipo *ipo= NULL;
+ Key *key= ob_get_key(ob);
KeyBlock *kb;
float min, max;
int i;
+ if(key==NULL) return;
+
+ /* ipo on action or ob? */
+ if(ob->ipoflag & OB_ACTION_KEY) {
+ if(ob->action) {
+ bActionChannel *achan;
+
+ achan= get_action_channel(ob->action, "Shape");
+ if(achan) ipo= achan->ipo;
+ }
+ }
+ else ipo= key->ipo;
+
/* global array */
- meshslidervals[keynum] = getrvkval(key, keynum);
+ meshslidervals[keynum] = getrvkval(ipo, keynum);
kb= key->block.first;
for (i=0; i<keynum; ++i) kb = kb->next;
@@ -252,7 +266,7 @@ void make_rvk_slider(uiBlock *block, Key *key, int keynum,
x, y , w, h,
meshslidervals+keynum, min, max, 10, 2, tip);
- uiButSetFunc(but, rvk_slider_func, key, (void *)keynum);
+ uiButSetFunc(but, rvk_slider_func, ob, (void *)keynum);
// no hilite, the winmatrix is not correct later on...
uiButSetFlag(but, UI_NO_HILITE);