Fix T46163: NLA properties with drivers aren't displayed as having drivers

While such drivers will generally get evaluated too late to be of much
use during animations, it can still be useful to allow using drivers to
control a whole bunch of NLA strip properties (i.e. syncing NLA strip
timings via a single property/control).

Keyframe insertion however is still not allowed on these properties
(and an error message will now be displayed when trying to do so,
instead of silently failing), as it is useless.
This commit is contained in:
Joshua Leung 2017-10-20 17:04:57 +13:00
parent 959a58da9e
commit ae72a9206e
4 changed files with 46 additions and 2 deletions

View File

@ -40,6 +40,9 @@ struct bAction;
struct Scene;
struct Speaker;
struct PointerRNA;
struct PropertyRNA;
/* ----------------------------- */
/* Data Management */
@ -103,6 +106,8 @@ bool BKE_nlatrack_has_animated_strips(struct NlaTrack *nlt);
bool BKE_nlatracks_have_animated_strips(ListBase *tracks);
void BKE_nlastrip_validate_fcurves(struct NlaStrip *strip);
bool BKE_nlastrip_has_curves_for_property(const struct PointerRNA *ptr, const struct PropertyRNA *prop);
void BKE_nla_validate_state(struct AnimData *adt);
/* ............ */

View File

@ -61,6 +61,7 @@
#include "BKE_curve.h"
#include "BKE_global.h"
#include "BKE_object.h"
#include "BKE_nla.h"
#include "RNA_access.h"
@ -335,7 +336,7 @@ FCurve *rna_get_fcurve_context_ui(
if (r_action) *r_action = NULL;
/* Special case for NLA Control Curves... */
if (ptr->type == &RNA_NlaStrip) {
if (BKE_nlastrip_has_curves_for_property(ptr, prop)) {
NlaStrip *strip = (NlaStrip *)ptr->data;
/* Set the special flag, since it cannot be a normal action/driver

View File

@ -1417,6 +1417,40 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
}
}
/* Check if the given RNA pointer + property combo should be handled by
* NLA strip curves or not.
*/
bool BKE_nlastrip_has_curves_for_property(const PointerRNA *ptr, const PropertyRNA *prop)
{
/* sanity checks */
if (ELEM(NULL, ptr, prop))
return false;
/* 1) Must be NLA strip */
if (ptr->type == &RNA_NlaStrip) {
/* 2) Must be one of the predefined properties */
static PropertyRNA *prop_influence = NULL;
static PropertyRNA *prop_time = NULL;
static bool needs_init = true;
/* Init the properties on first use */
if (needs_init) {
prop_influence = RNA_struct_type_find_property(&RNA_NlaStrip, "influence");
prop_time = RNA_struct_type_find_property(&RNA_NlaStrip, "strip_time");
needs_init = false;
}
/* Check if match */
if (ELEM(prop, prop_influence, prop_time)) {
return true;
}
}
/* No criteria met */
return false;
}
/* Sanity Validation ------------------------------------ */
static bool nla_editbone_name_check(void *arg, const char *name)

View File

@ -1789,6 +1789,10 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
if (fcu) {
success = insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, 0);
}
else {
BKE_report(op->reports, RPT_ERROR,
"This property cannot be animated as it will not get updated correctly");
}
}
else if (UI_but_flag_is_set(but, UI_BUT_DRIVEN)) {
/* Driven property - Find driver */
@ -1884,7 +1888,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
}
if (ptr.id.data && ptr.data && prop) {
if (ptr.type == &RNA_NlaStrip) {
if (BKE_nlastrip_has_curves_for_property(&ptr, prop)) {
/* Handle special properties for NLA Strips, whose F-Curves are stored on the
* strips themselves. These are stored separately or else the properties will
* not have any effect.