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:
authorJoshua Leung <aligorith@gmail.com>2013-07-01 17:57:00 +0400
committerJoshua Leung <aligorith@gmail.com>2013-07-01 17:57:00 +0400
commit64bc3ce89adeaedc606ab465c51f0f1cf3bc907b (patch)
tree28121a6beb45125d4785a36d3fcebcd7e3468e36 /source/blender/blenkernel/intern/anim_sys.c
parent72a5c1f007564db03c54218a4099bec2e2c8131e (diff)
Bugfix [#35856] Bones gets scaled chaotically when during NLA Strip Blend In/Out
This was one of the consequences of r.57333 (i.e. influence shouldn't be ignored on the first strip that animates a channel), as scale should really default to a base value of 1 (instead of things being blended against 0 as per all other properties). The end result was that bones were getting scaled to zero here when the influence of their strip fell to zero. Now, we use the RNA default values of properties to initialise their initial values. This may/may not work well in all cases: 1) For properties which don't have the appropriate RNA defaults set, this will be problematic. But, most properties people are likely to animate here I think are already set up correctly. 2) It may not always be nice to have values "snapping back" to default values. In this case, you should still be defining a strip at the bottom of your NLA stack which defines what the appropriate rest poses *should* be for your shot.
Diffstat (limited to 'source/blender/blenkernel/intern/anim_sys.c')
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c56
1 files changed, 47 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 65e1f433c20..001964087b8 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1639,8 +1639,46 @@ static NlaEvalChannel *nlaevalchan_find_match(ListBase *channels, PointerRNA *pt
return NULL;
}
+/* initialise default value for NlaEvalChannel, so that it doesn't blend things wrong */
+static void nlaevalchan_value_init(NlaEvalChannel *nec)
+{
+ PointerRNA *ptr = &nec->ptr;
+ PropertyRNA *prop = nec->prop;
+ int index = nec->index;
+
+ /* NOTE: while this doesn't work for all RNA properties as default values aren't in fact
+ * set properly for most of them, at least the common ones (which also happen to get used
+ * in NLA strips a lot, e.g. scale) are set correctly.
+ */
+ switch (RNA_property_type(prop)) {
+ case PROP_BOOLEAN:
+ if (RNA_property_array_length(ptr, prop))
+ nec->value = (float)RNA_property_boolean_get_default_index(ptr, prop, index);
+ else
+ nec->value = (float)RNA_property_boolean_get_default(ptr, prop);
+ break;
+ case PROP_INT:
+ if (RNA_property_array_length(ptr, prop))
+ nec->value = (float)RNA_property_int_get_default_index(ptr, prop, index);
+ else
+ nec->value = (float)RNA_property_int_get_default(ptr, prop);
+ break;
+ case PROP_FLOAT:
+ if (RNA_property_array_length(ptr, prop))
+ nec->value = RNA_property_float_get_default_index(ptr, prop, index);
+ else
+ nec->value = RNA_property_float_get_default(ptr, prop);
+ break;
+ case PROP_ENUM:
+ nec->value = (float)RNA_property_enum_get_default(ptr, prop);
+ break;
+ default:
+ break;
+ }
+}
+
/* verify that an appropriate NlaEvalChannel for this F-Curve exists */
-static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, ListBase *channels, NlaEvalStrip *nes, FCurve *fcu, short *newChan)
+static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, ListBase *channels, NlaEvalStrip *nes, FCurve *fcu)
{
NlaEvalChannel *nec;
NlaStrip *strip = nes->strip;
@@ -1674,22 +1712,23 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, ListBase *channels, N
/* allocate a new struct for this if none found */
if (nec == NULL) {
nec = MEM_callocN(sizeof(NlaEvalChannel), "NlaEvalChannel");
- *newChan = 1;
BLI_addtail(channels, nec);
+ /* store property links for writing to the property later */
nec->ptr = new_ptr;
nec->prop = prop;
nec->index = fcu->array_index;
+
+ /* initialise value using default value of property [#35856] */
+ nlaevalchan_value_init(nec);
}
- else
- *newChan = 0;
/* we can now return */
return nec;
}
/* accumulate (i.e. blend) the given value on to the channel it affects */
-static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, short UNUSED(newChan), float value)
+static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, float value)
{
NlaStrip *strip = nes->strip;
short blendmode = strip->blendmode;
@@ -1756,7 +1795,7 @@ static void nlaevalchan_buffers_accumulate(ListBase *channels, ListBase *tmp_buf
* otherwise, add the current channel to the buffer for efficiency
*/
if (necd)
- nlaevalchan_accumulate(necd, nes, 0, nec->value);
+ nlaevalchan_accumulate(necd, nes, nec->value);
else {
BLI_remlink(tmp_buffer, nec);
BLI_addtail(channels, nec);
@@ -1853,7 +1892,6 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr, ListBase *channels, Li
for (fcu = strip->act->curves.first; fcu; fcu = fcu->next) {
NlaEvalChannel *nec;
float value = 0.0f;
- short newChan = -1;
/* check if this curve should be skipped */
if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED))
@@ -1875,9 +1913,9 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr, ListBase *channels, Li
/* get an NLA evaluation channel to work with, and accumulate the evaluated value with the value(s)
* stored in this channel if it has been used already
*/
- nec = nlaevalchan_verify(ptr, channels, nes, fcu, &newChan);
+ nec = nlaevalchan_verify(ptr, channels, nes, fcu);
if (nec)
- nlaevalchan_accumulate(nec, nes, newChan, value);
+ nlaevalchan_accumulate(nec, nes, value);
}
/* unlink this strip's modifiers from the parent's modifiers again */