Animato - Driver + ShapeKey bugfixes
* ShapeKey conversions should now go to the correct places * Added fix for drivers to prevent crashes when no driver object is provided (Franky from BBB seems to have one such driver for some reason). * Temporarily disabled a check when evaluating drivers for whether the driver is tagged for evaluation. Drivers still need to be correctly tagged AND ordered by the Depsgraph to work correctly.
This commit is contained in:
@@ -229,7 +229,9 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
|
||||
}
|
||||
else {
|
||||
/* failed to get path */
|
||||
printf("Animato: Invalid path '%s[%d]' \n", path, array_index);
|
||||
printf("Animato: Invalid path. ID = '%s', '%s [%d]' \n",
|
||||
(ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "<No ID>",
|
||||
path, array_index);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -291,7 +293,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim
|
||||
if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0)
|
||||
{
|
||||
/* check if driver itself is tagged for recalculation */
|
||||
if ((driver) && (driver->flag & DRIVER_FLAG_RECALC)) {
|
||||
if ((driver) /*&& (driver->flag & DRIVER_FLAG_RECALC)*/) { // XXX driver recalc flag is not set yet by depsgraph!
|
||||
/* evaluate this using values set already in other places */
|
||||
// NOTE: for 'layering' option later on, we should check if we should remove old value before adding new to only be done when drivers only changed
|
||||
calculate_fcurve(fcu, ctime);
|
||||
|
||||
@@ -447,24 +447,34 @@ static float driver_get_driver_value (ChannelDriver *driver, short target)
|
||||
{
|
||||
PointerRNA id_ptr, ptr;
|
||||
PropertyRNA *prop;
|
||||
ID *id;
|
||||
char *path;
|
||||
int index;
|
||||
float value= 0.0f;
|
||||
|
||||
/* get RNA-pointer for the ID-block given in driver */
|
||||
if (target == 2) {
|
||||
if (target == 1) {
|
||||
/* second target */
|
||||
RNA_id_pointer_create(driver->id2, &id_ptr);
|
||||
id= driver->id2;
|
||||
path= driver->rna_path2;
|
||||
index= driver->array_index2;
|
||||
}
|
||||
else {
|
||||
/* first/main target */
|
||||
RNA_id_pointer_create(driver->id, &id_ptr);
|
||||
id= driver->id;
|
||||
path= driver->rna_path;
|
||||
index= driver->array_index;
|
||||
}
|
||||
|
||||
/* error check for missing pointer... */
|
||||
if (id == NULL) {
|
||||
printf("Error: driver doesn't have any valid target to use \n");
|
||||
driver->flag |= DRIVER_FLAG_INVALID;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
/* get property to read from, and get value as appropriate */
|
||||
if (RNA_path_resolve(&id_ptr, path, &ptr, &prop)) {
|
||||
switch (RNA_property_type(&ptr, prop)) {
|
||||
@@ -511,9 +521,10 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
|
||||
case DRIVER_TYPE_CHANNEL: /* channel/setting drivers channel/setting */
|
||||
return driver_get_driver_value(driver, 0);
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
|
||||
case DRIVER_TYPE_PYTHON: /* expression */
|
||||
{
|
||||
#ifndef DISABLE_PYTHON
|
||||
/* check for empty or invalid expression */
|
||||
if ( (driver->expression[0] == '\0') ||
|
||||
(driver->flag & DRIVER_FLAG_INVALID) )
|
||||
@@ -526,8 +537,10 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
|
||||
*/
|
||||
//return BPY_pydriver_eval(driver); // XXX old func
|
||||
return 1.0f;
|
||||
}
|
||||
#endif /* DISABLE_PYTHON*/
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case DRIVER_TYPE_ROTDIFF: /* difference of rotations of 2 bones (should be in same armature) */
|
||||
{
|
||||
|
||||
@@ -277,7 +277,10 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *array_index)
|
||||
|
||||
/* block will be attached to ID_KE block, and setting that we alter is the 'value' (which sets keyblock.curval) */
|
||||
// XXX adrcode 0 was dummy 'speed' curve
|
||||
sprintf(buf, "keys[%d].value", adrcode-1); // XXX this doesn't seem too safe...
|
||||
if (adrcode == 0)
|
||||
sprintf(buf, "speed");
|
||||
else
|
||||
sprintf(buf, "keys[%d].value", adrcode);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -710,6 +713,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
|
||||
if (idriver->blocktype == ID_AR) {
|
||||
/* ID_PO */
|
||||
if (idriver->adrcode == OB_ROT_DIFF) {
|
||||
printf("idriver_to_cdriver - rotdiff %p \n", idriver->ob);
|
||||
/* Rotational Difference is a special type of driver now... */
|
||||
cdriver->type= DRIVER_TYPE_ROTDIFF;
|
||||
|
||||
@@ -727,6 +731,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
|
||||
cdriver->rna_path2= get_rna_access(-1, -1, idriver->name+DRIVER_NAME_OFFS, NULL, NULL);
|
||||
}
|
||||
else {
|
||||
printf("idriver_to_cdriver - arm %p \n", idriver->ob);
|
||||
/* 'standard' driver */
|
||||
cdriver->type= DRIVER_TYPE_CHANNEL;
|
||||
cdriver->id= (ID *)idriver->ob;
|
||||
@@ -767,12 +772,15 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver)
|
||||
}
|
||||
else {
|
||||
/* ID_OB */
|
||||
printf("idriver_to_cdriver - ob %p \n", idriver->ob);
|
||||
cdriver->type= DRIVER_TYPE_CHANNEL;
|
||||
cdriver->id= (ID *)idriver->ob;
|
||||
cdriver->rna_path= get_rna_access(ID_OB, idriver->adrcode, idriver->name, NULL, &cdriver->array_index);
|
||||
cdriver->rna_path= get_rna_access(ID_OB, idriver->adrcode, NULL, NULL, &cdriver->array_index);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\tcdriver -> id = %p \n", cdriver->id);
|
||||
|
||||
/* free old driver */
|
||||
MEM_freeN(idriver);
|
||||
|
||||
@@ -945,11 +953,14 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char *actname, char *constname)
|
||||
adt->action= add_empty_action("ConvertedAction"); // XXX we need a better name for this...
|
||||
printf("added new action \n");
|
||||
}
|
||||
printf("\ticu to action fcurve (%p %d) -> (%p %s %d) \n", icu, icu->adrcode, fcu, fcu->rna_path, fcu->array_index);
|
||||
|
||||
/* add F-Curve to action */
|
||||
BLI_addtail(&adt->action->curves, fcu);
|
||||
}
|
||||
else {
|
||||
printf("\ticu to driver fcurve (%p %d) -> (%p %s %d) \n", icu, icu->adrcode, fcu, fcu->rna_path, fcu->array_index);
|
||||
|
||||
/* add F-Curve to AnimData's drivers */
|
||||
BLI_addtail(&adt->drivers, fcu);
|
||||
}
|
||||
|
||||
@@ -1025,7 +1025,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
|
||||
case ANIMTYPE_FILLACTD:
|
||||
{
|
||||
bAction *act= (bAction *)ale->data;
|
||||
act->flag ^= ACT_EXPANDED;
|
||||
act->flag ^= ACT_COLLAPSED;
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_FILLMATD:
|
||||
|
||||
@@ -170,7 +170,7 @@ typedef enum eAnimFilter_Flags {
|
||||
#define FILTER_CUR_OBJD(cu) ((cu->flag & CU_DS_EXPAND))
|
||||
/* 'Sub-object/Action' channels (flags stored in Action) */
|
||||
#define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED))
|
||||
#define EXPANDED_ACTC(actc) ((actc->flag & ACT_EXPANDED))
|
||||
#define EXPANDED_ACTC(actc) ((actc->flag & ACT_COLLAPSED)==0)
|
||||
|
||||
/* Actions (also used for Dopesheet) */
|
||||
/* Action Channel Group */
|
||||
|
||||
@@ -653,8 +653,8 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
int filter;
|
||||
|
||||
View2D *v2d= &ar->v2d;
|
||||
float x= 0.0f, y= 0.0f;
|
||||
int items, height;
|
||||
float x= 0.0f, y= 0.0f, height;
|
||||
int items;
|
||||
|
||||
/* build list of channels to draw */
|
||||
filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
|
||||
|
||||
@@ -108,6 +108,7 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_borderselect", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
|
||||
|
||||
/* column select */
|
||||
// XXX KKEY would be nice to keep for 'keyframe' lines
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN);
|
||||
@@ -144,7 +145,7 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
|
||||
#endif // XXX code to be sanitied for new system
|
||||
|
||||
/* transform system */
|
||||
transform_keymap_for_space(wm, keymap, /*SPACE_IPO*/SPACE_ACTION); // xxx
|
||||
transform_keymap_for_space(wm, keymap, SPACE_IPO);
|
||||
}
|
||||
|
||||
/* --------------- */
|
||||
|
||||
@@ -274,6 +274,16 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
|
||||
km= WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, 0, 0);
|
||||
RNA_int_set(km->ptr, "mode", TFM_TIME_SLIDE);
|
||||
break;
|
||||
case SPACE_IPO:
|
||||
km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
|
||||
RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
|
||||
|
||||
//km = WM_keymap_add_item(keymap, "TFM_OT_transform", RKEY, KM_PRESS, 0, 0);
|
||||
//RNA_int_set(km->ptr, "mode", TFM_ROTATION);
|
||||
|
||||
km = WM_keymap_add_item(keymap, "TFM_OT_transform", SKEY, KM_PRESS, 0, 0);
|
||||
RNA_int_set(km->ptr, "mode", TFM_RESIZE);
|
||||
break;
|
||||
case SPACE_NODE:
|
||||
km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
|
||||
RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
|
||||
|
||||
@@ -261,7 +261,7 @@ typedef struct bAction {
|
||||
/* Flags for the action */
|
||||
typedef enum eAction_Flags {
|
||||
/* flags for displaying in UI */
|
||||
ACT_EXPANDED = (1<<0),
|
||||
ACT_COLLAPSED = (1<<0),
|
||||
ACT_SELECTED = (1<<1),
|
||||
|
||||
/* flags for evaluation/editing */
|
||||
|
||||
Reference in New Issue
Block a user