Minor Code Cleanup (ShapeKeys):
Added a new API method for ShapeKeys, which is useful for finding a certain KeyBlock from a Key.
This commit is contained in:
@@ -59,6 +59,7 @@ int do_ob_key(struct Object *ob);
|
||||
|
||||
struct Key *ob_get_key(struct Object *ob);
|
||||
struct KeyBlock *ob_get_keyblock(struct Object *ob);
|
||||
struct KeyBlock *key_get_keyblock(struct Key *key, int index);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1386,3 +1386,23 @@ KeyBlock *ob_get_keyblock(Object *ob)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* get the appropriate KeyBlock given an index */
|
||||
KeyBlock *key_get_keyblock(Key *key, int index)
|
||||
{
|
||||
KeyBlock *kb;
|
||||
int i;
|
||||
|
||||
if (key) {
|
||||
kb= key->block.first;
|
||||
|
||||
for (i= 1; i < key->totkey; i++) {
|
||||
kb= kb->next;
|
||||
|
||||
if (index==i)
|
||||
return kb;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -160,14 +160,14 @@ static void meshactionbuts(SpaceAction *saction, Object *ob, Key *key)
|
||||
|
||||
glRects(NAMEWIDTH, 0, NAMEWIDTH+SLIDERWIDTH, curarea->winy);
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
for (i=1 ; i < key->totkey ; ++ i) {
|
||||
for (i=1; i < key->totkey; i++) {
|
||||
make_rvk_slider(block, ob, i,
|
||||
x, y, SLIDERWIDTH-2, CHANNELHEIGHT-1, "Slider to control Shape Keys");
|
||||
|
||||
y-=CHANNELHEIGHT+CHANNELSKIP;
|
||||
|
||||
/* see sliderval array in editkey.c */
|
||||
if(i>=255) break;
|
||||
if(i >= 255) break;
|
||||
}
|
||||
}
|
||||
uiDrawBlock(block);
|
||||
|
||||
@@ -1652,20 +1652,20 @@ static void clever_keyblock_names (Key *key, short *mval)
|
||||
* an invalid key number (and we don't deal
|
||||
* with the speed ipo).
|
||||
*/
|
||||
|
||||
|
||||
keynum = get_nearest_key_num(key, mval, &x);
|
||||
if ( (keynum < 1) || (keynum >= key->totkey) )
|
||||
return;
|
||||
|
||||
kb= key->block.first;
|
||||
for (i=0; i<keynum; ++i) kb = kb->next;
|
||||
|
||||
if (kb->name[0] == '\0') {
|
||||
|
||||
kb= key_get_keyblock(key, keynum);
|
||||
if (kb == NULL)
|
||||
return;
|
||||
|
||||
|
||||
if (kb->name[0] == '\0')
|
||||
sprintf(str, "Key %d", keynum);
|
||||
}
|
||||
else {
|
||||
else
|
||||
strcpy(str, kb->name);
|
||||
}
|
||||
|
||||
if ( (kb->slidermin >= kb->slidermax) ) {
|
||||
kb->slidermin = 0.0;
|
||||
|
||||
@@ -148,24 +148,16 @@ char *getname_ipocurve(IpoCurve *icu, Object *ob)
|
||||
{
|
||||
static char name[32];
|
||||
Key *key= ob_get_key(ob);
|
||||
KeyBlock *kb= key_get_keyblock(key, icu->adrcode);
|
||||
|
||||
if (key) {
|
||||
KeyBlock *kb= key->block.first;
|
||||
int i;
|
||||
|
||||
for (i= 1; i < key->totkey; i++) {
|
||||
kb= kb->next;
|
||||
|
||||
if (icu->adrcode == i) {
|
||||
/* only return name if it has been set, otherwise use
|
||||
* default method using static string (Key #)
|
||||
*/
|
||||
if (kb->name[0] == '\0')
|
||||
break; /* stop looping through keyblocks */
|
||||
else
|
||||
return kb->name; /* return keyblock's name */
|
||||
}
|
||||
}
|
||||
if (kb) {
|
||||
/* only return name if it has been set, otherwise use
|
||||
* default method using static string (Key #)
|
||||
*/
|
||||
if (kb->name[0] == '\0')
|
||||
break; /* stop looping through keyblocks */
|
||||
else
|
||||
return kb->name; /* return keyblock's name */
|
||||
}
|
||||
|
||||
/* in case keyblock is not named or no key/keyblock was found */
|
||||
|
||||
Reference in New Issue
Block a user