2.5 - Animation tweaks - bringing back more code

* Action Editor - IPO curve names are shown properly again. Added anim_ipo_utils.c (old editipo_lib.c) file back. This will need to be removed when I port IPO system to RNA.

* Keyframing code - uncommented more of the code that's now working

* Made the 'preview range' button on timeline header draw more clearly
This commit is contained in:
2008-12-22 10:15:02 +00:00
parent bac4d10174
commit cedb19ef3e
6 changed files with 370 additions and 15 deletions

View File

@@ -0,0 +1,345 @@
/**
* $Id:
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* Contributor(s): Blender Foundation, 2005. Full recode
* Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
*/
/* XXX:
* This file contains some assorted channel-name defines for IPO Curves, which are required
* under the 'old' Adrcode system. These should be replaced in the near future after all
* editors are in place, to use the RNA system instead, in conjunction with the RNA-IPO
* integration step.
*
* -- Joshua Leung, Dec 2008
*/
#include <stdio.h>
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "DNA_curve_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_utildefines.h"
#include "UI_resources.h"
#include "ED_anim_api.h"
// XXX should these be exposed too?
char *getname_ac_ei(int nr);
char *getname_co_ei(int nr);
char *getname_ob_ei(int nr, int colipo);
char *getname_tex_ei(int nr);
char *getname_mtex_ei(int nr);
char *getname_mat_ei(int nr);
char *getname_world_ei(int nr);
char *getname_seq_ei(int nr);
char *getname_cu_ei(int nr);
char *getname_la_ei(int nr);
char *getname_cam_ei(int nr);
char *getname_snd_ei(int nr);
char *getname_fluidsim_ei(int nr);
char *getname_part_ei(int nr);
/* ------------------------- Channel Name Defines ------------------------ */
char *ob_ic_names[OB_TOTNAM] = { "LocX", "LocY", "LocZ", "dLocX", "dLocY", "dLocZ",
"RotX", "RotY", "RotZ", "dRotX", "dRotY", "dRotZ",
"ScaleX", "ScaleY", "ScaleZ", "dScaleX", "dScaleY", "dScaleZ",
"Layer", "Time", "ColR", "ColG", "ColB", "ColA",
"FStreng", "FFall", "RDamp", "Damping", "Perm", "FMaxD" };
char *co_ic_names[CO_TOTNAM] = { "Inf", "HeadTail" };
char *mtex_ic_names[TEX_TOTNAM] = { "OfsX", "OfsY", "OfsZ", "SizeX", "SizeY", "SizeZ",
"texR", "texG", "texB", "DefVar", "Col", "Nor", "Var",
"Disp" };
char *tex_ic_names[TE_TOTNAM] = { "NSize", "NDepth", "NType", "Turb", "Vnw1", "Vnw2",
"Vnw3", "Vnw4", "MinkMExp", "DistM", "ColT", "iScale",
"DistA", "MgType", "MgH", "Lacu", "Oct", "MgOff",
"MgGain", "NBase1", "NBase2", "ColR", "ColG", "ColB", "Bright", "Contras"};
char *ma_ic_names[MA_TOTNAM] = { "R", "G", "B", "SpecR", "SpecG", "SpecB", "MirR",
"MirG", "MirB", "Ref", "Alpha", "Emit", "Amb", "Spec",
"Hard", "SpTra", "Ior", "Mode", "HaSize", "Translu",
"RayMir", "FresMir", "FresMirI", "FresTra", "FresTraI",
"TraGlow" };
char *seq_ic_names[SEQ_TOTNAM] = { "Fac" };
char *cu_ic_names[CU_TOTNAM] = { "Speed" };
char *key_ic_names[KEY_TOTNAM] = { "Speed", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5",
"Key 6", "Key 7", "Key 8", "Key 9", "Key 10",
"Key 11", "Key 12", "Key 13", "Key 14", "Key 15",
"Key 16", "Key 17", "Key 18", "Key 19", "Key 20",
"Key 21", "Key 22", "Key 23", "Key 24", "Key 25",
"Key 26", "Key 27", "Key 28", "Key 29", "Key 30",
"Key 31", "Key 32", "Key 33", "Key 34", "Key 35",
"Key 36", "Key 37", "Key 38", "Key 39", "Key 40",
"Key 41", "Key 42", "Key 43", "Key 44", "Key 45",
"Key 46", "Key 47", "Key 48", "Key 49", "Key 50",
"Key 51", "Key 52", "Key 53", "Key 54", "Key 55",
"Key 56", "Key 57", "Key 58", "Key 59", "Key 60",
"Key 61", "Key 62", "Key 63"};
char *wo_ic_names[WO_TOTNAM] = { "HorR", "HorG", "HorB", "ZenR", "ZenG", "ZenB", "Expos",
"Misi", "MisDi", "MisSta", "MisHi", "StarR", "StarB",
"StarG", "StarDi", "StarSi" };
char *la_ic_names[LA_TOTNAM] = { "Energy", "R", "G", "B", "Dist", "SpoSi", "SpoBl",
"Quad1", "Quad2", "HaInt" };
/* yafray: two curve names added, 'Apert' for aperture, and 'FDist' for focal distance */
char *cam_ic_names[CAM_TOTNAM] = { "Lens", "ClSta", "ClEnd", "Apert", "FDist", "ShiftX", "ShiftY" };
char *snd_ic_names[SND_TOTNAM] = { "Vol", "Pitch", "Pan", "Atten" };
char *ac_ic_names[AC_TOTNAM] = {"LocX", "LocY", "LocZ", "ScaleX", "ScaleY",
"ScaleZ", "RotX", "RotY", "RotZ", "QuatW", "QuatX", "QuatY", "QuatZ"};
char *ic_name_empty[1] ={ "" };
char *fluidsim_ic_names[FLUIDSIM_TOTNAM] = { "Fac-Visc", "Fac-Time", "GravX","GravY","GravZ", "VelX","VelY","VelZ", "Active", "AttrForceStr", "AttrForceRad", "VelForceStr", "VelForceRad" };
char *part_ic_names[PART_TOTNAM] = { "E_Freq", "E_Life", "E_Speed", "E_Angular", "E_Size",
"Angular", "Size", "Drag", "Brown", "Damp", "Length", "Clump",
"GravX", "GravY", "GravZ", "KinkAmp", "KinkFreq", "KinkShape", "BBTilt",
"FStreng", "FFall", "FMaxD", "F2Streng", "F2Fall", "F2MaxD"};
/* ----------------------- Getter functions ----------------------- */
/* gets the appropriate icon for the given blocktype */
int geticon_ipo_blocktype(short blocktype)
{
switch (blocktype) {
case ID_OB:
return ICON_OBJECT;
case ID_PO:
return ICON_POSE_HLT;
case ID_KE:
return ICON_EDIT;
case ID_MA:
return ICON_MATERIAL;
case ID_WO:
return ICON_WORLD;
case ID_CU:
return ICON_CURVE;
case ID_CA:
return ICON_CAMERA;
case ID_LA:
return ICON_LAMP;
case ID_TE:
return ICON_TEXTURE;
case ID_CO:
return ICON_CONSTRAINT;
case ID_FLUIDSIM:
return ICON_WORLD; // uggh
default:
return 0; // what about blank icon?
}
}
/* get name of ipo-curve
* - icu should be valid pointer
* - ob is only needed for a shapekey-related hack
*/
char *getname_ipocurve(IpoCurve *icu, Object *ob)
{
switch (icu->blocktype) {
case ID_OB:
return getname_ob_ei(icu->adrcode, 0); /* dummy 2nd arg */
case ID_PO:
return getname_ac_ei(icu->adrcode);
case ID_KE:
{
static char name[32];
Key *key= ob_get_key(ob);
KeyBlock *kb= key_get_keyblock(key, icu->adrcode);
/* only return name if it has been set, otherwise use
* default method using static string (Key #)
*/
if ((kb) && (kb->name[0] != '\0'))
return kb->name; /* return keyblock's name */
/* in case keyblock is not named or no key/keyblock was found */
sprintf(name, "Key %d", icu->adrcode);
return name;
}
case ID_MA:
return getname_mat_ei(icu->adrcode);
case ID_LA:
return getname_la_ei(icu->adrcode);
case ID_CA:
return getname_cam_ei(icu->adrcode);
case ID_CU:
return getname_cu_ei(icu->adrcode);
default: /* fixme - add all of the other types! */
return NULL;
}
}
char *getname_ac_ei(int nr)
{
switch(nr) {
case AC_LOC_X:
case AC_LOC_Y:
case AC_LOC_Z:
return ac_ic_names[nr-1];
case AC_SIZE_X:
case AC_SIZE_Y:
case AC_SIZE_Z:
return ac_ic_names[nr-10];
case AC_EUL_X:
case AC_EUL_Y:
case AC_EUL_Z:
return ac_ic_names[nr-10];
case AC_QUAT_X:
case AC_QUAT_Y:
case AC_QUAT_Z:
case AC_QUAT_W:
return ac_ic_names[nr-16];
default:
return ic_name_empty[0]; /* empty */
}
}
char *getname_co_ei(int nr)
{
switch(nr){
case CO_ENFORCE:
case CO_HEADTAIL:
return co_ic_names[nr-1];
}
return ic_name_empty[0];
}
char *getname_ob_ei(int nr, int colipo)
{
if(nr>=OB_LOC_X && nr <= OB_PD_FMAXD) return ob_ic_names[nr-1];
return ic_name_empty[0];
}
char *getname_tex_ei(int nr)
{
if(nr>=TE_NSIZE && nr<=TE_CONTRA) return tex_ic_names[nr-1];
return ic_name_empty[0];
}
char *getname_mtex_ei(int nr)
{
if(nr>=MAP_OFS_X && nr<=MAP_DISP) return mtex_ic_names[nr-1];
return ic_name_empty[0];
}
char *getname_mat_ei(int nr)
{
if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
else {
if(nr>=MA_COL_R && nr<=MA_ADD) return ma_ic_names[nr-1];
}
return ic_name_empty[0];
}
char *getname_world_ei(int nr)
{
if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
else {
if(nr>=WO_HOR_R && nr<=WO_STARSIZE) return wo_ic_names[nr-1];
}
return ic_name_empty[0];
}
char *getname_seq_ei(int nr)
{
if(nr == SEQ_FAC1) return seq_ic_names[nr-1];
return ic_name_empty[0];
}
char *getname_cu_ei(int nr)
{
if(nr==CU_SPEED) return cu_ic_names[nr-1];
return ic_name_empty[0];
}
char *getname_la_ei(int nr)
{
if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
else {
if(nr>=LA_ENERGY && nr<=LA_HALOINT) return la_ic_names[nr-1];
}
return ic_name_empty[0];
}
char *getname_cam_ei(int nr)
{
if(nr>=CAM_LENS && nr<=CAM_SHIFT_Y) return cam_ic_names[nr-1];
return ic_name_empty[0];
}
char *getname_snd_ei(int nr)
{
if(nr>=SND_VOLUME && nr<=SND_ATTEN) return snd_ic_names[nr-1];
return ic_name_empty[0];
}
char *getname_fluidsim_ei(int nr)
{
if(nr <= FLUIDSIM_TOTIPO) return fluidsim_ic_names[nr-1];
return ic_name_empty[0];
}
char *getname_part_ei(int nr)
{
if(nr <= PART_TOTIPO) return part_ic_names[nr-1];
return ic_name_empty[0];
}
/* ------------------------------- Color Codes for IPO Channels ---------------------------- */
unsigned int ipo_rainbow(int cur, int tot)
{
float dfac, fac, sat;
dfac= (float)(1.0/( (float)tot+1.0));
/* this calculation makes 2 or 4 different cycles of rainbow colors */
if(cur< tot/2) fac= (float)(cur*2.0f*dfac);
else fac= (float)((cur-tot/2)*2.0f*dfac +dfac);
if(tot > 32) fac= fac*1.95f;
if(fac>1.0f) fac-= 1.0f;
if(fac>0.5f && fac<0.8f) sat= 0.4f;
else sat= 0.5f;
return hsv_to_cpack(fac, sat, 1.0f);
}

View File

@@ -351,6 +351,8 @@ static void draw_keylist(gla2DDrawInfo *di, ListBase *keys, ListBase *blocks, fl
glDisable(GL_BLEND);
}
/* *************************** Channel Drawing Funcs *************************** */
void draw_object_channel(gla2DDrawInfo *di, ActKeysInc *aki, Object *ob, float ypos)
{
ListBase keys = {0, 0};
@@ -420,7 +422,7 @@ void draw_gpl_channel(gla2DDrawInfo *di, ActKeysInc *aki, bGPDlayer *gpl, float
BLI_freelistN(&keys);
}
/* --------------- Conversion: data -> keyframe list ------------------ */
/* *************************** Keyframe List Conversions *************************** */
void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
{

View File

@@ -382,8 +382,6 @@ void insert_vert_icu (IpoCurve *icu, float x, float y, short fast)
}
}
#if 0 // XXX code to clean up
/* ------------------- Get Data ------------------------ */
/* Get pointer to use to get values from */
@@ -772,7 +770,7 @@ static float visualkey_get_value (ID *id, int blocktype, char *actname, char *co
return 0.0;
}
#if 0 // XXX code to clean up
/* ------------------------- Insert Key API ------------------------- */
/* Main Keyframing API call:

View File

@@ -36,6 +36,7 @@ struct View2D;
struct gla2DDrawInfo;
struct Object;
struct bActionGroup;
struct IpoCurve;
/* ************************************************ */
/* ANIMATION CHANNEL FILTERING */
@@ -243,16 +244,25 @@ enum {
} eAnimEditDraw_CurrentFrame;
/* main call to draw current-frame indicator in an Animation Editor */
void ANIM_draw_cfra(const bContext *C, struct View2D *v2d, short flag);
void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag);
/* ------------- Preview Range Drawing -------------- */
/* main call to draw preview range curtains */
void ANIM_draw_previewrange(const bContext *C, struct View2D *v2d);
void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d);
/* ************************************************* */
/* ASSORTED TOOLS */
/* ------------ IPO Adrcode <-> Icons/Names Mapping ------------ */
int geticon_ipo_blocktype(short blocktype);
char *getname_ipocurve(struct IpoCurve *icu, struct Object *ob);
unsigned int ipo_rainbow(int cur, int tot);
/* ------------- NLA-Mapping ----------------------- */
/* Obtain the Object providing NLA-scaling for the given channel if applicable */

View File

@@ -730,11 +730,10 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
mute = ICON_MUTE_IPO_OFF;
sel = SEL_ICU(icu);
//if (saction->pin)
// sprintf(name, getname_ipocurve(icu, NULL)); // xxx func to eventually eliminate
//else
// sprintf(name, getname_ipocurve(icu, ac->obact)); // xxx func to eventually eliminate
sprintf(name, "[IPO Curve]"); // FIXME xxx
if (saction->pin)
sprintf(name, getname_ipocurve(icu, NULL)); // xxx func to eventually eliminate
else
sprintf(name, getname_ipocurve(icu, ac->obact)); // xxx func to eventually eliminate
}
break;
case ANIMTYPE_FILLIPO: /* ipo expand widget */
@@ -742,7 +741,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
bActionChannel *achan = (bActionChannel *)ale->data;
indent = 1;
//special = geticon_ipo_blocktype(achan->ipo->blocktype); // xxx func to eventually eliminate
special = geticon_ipo_blocktype(achan->ipo->blocktype); // xxx func to eventually eliminate
group= (ale->grp) ? 1 : 0;
grp= ale->grp;
@@ -817,7 +816,8 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
case SPACE_VIEW3D:
{
/* this shouldn't cause any overflow... */
//sprintf(name, "3DView[%02d]:%s", sa->win, view3d_get_name(sa->spacedata.first)); // XXX missing func..
//sprintf(name, "3DView:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func..
sprintf(name, "3dView");
special= ICON_VIEW3D;
}
break;

View File

@@ -457,8 +457,8 @@ void time_header_buttons(const bContext *C, ARegion *ar)
uiBlockBeginAlign(block);
uiDefButI(block, TOG, B_TL_PREVIEWON,"Preview",
xco,yco, XIC, YIC,
uiDefButI(block, TOG, B_TL_PREVIEWON,"PR",
xco,yco, XIC*3, YIC,
&scene->r.psfra,0, 1, 0, 0,
"Show settings for frame range of animation preview");