diff options
author | Joshua Leung <aligorith@gmail.com> | 2013-06-10 15:58:57 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2013-06-10 15:58:57 +0400 |
commit | c5ba912a3d1de03ffd0b1c1818b1026f75bbb8b3 (patch) | |
tree | 9cf5391fa55bf17728fe743a98bd8a24ffe7d83b /source | |
parent | b1fb86cbe7d6ad66835ea09300e7c3a33c4e02d6 (diff) |
Bugfix [#35382] NLA "Multiply" Blend Mode calculated incorrectly
The "Multiply" blending mode for NLA strips worked incorrectly. Instead of
modulating the influence of the current strip, it was in fact scaling the result
of the entire stack (with the strip applied). This caused problems when
influence = 0, as it was in fact muting everything instead of just controlling
the strip we are interested in.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 515fd729d1c..65e1f433c20 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1701,25 +1701,27 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, short if (nes->strip_mode == NES_TIME_TRANSITION_END) inf *= nes->strip_time; - /* premultiply the value by the weighting factor */ + /* optimisation: no need to try applying if there is no influence */ if (IS_EQ(inf, 0)) return; - value *= inf; /* perform blending */ switch (blendmode) { case NLASTRIP_MODE_ADD: /* simply add the scaled value on to the stack */ - nec->value += value; + nec->value += (value * inf); break; case NLASTRIP_MODE_SUBTRACT: /* simply subtract the scaled value from the stack */ - nec->value -= value; + nec->value -= (value * inf); break; case NLASTRIP_MODE_MULTIPLY: /* multiply the scaled value with the stack */ - nec->value *= value; + /* Formula Used: + * result = fac * (a * b) + (1 - fac) * a + */ + nec->value = inf * (nec->value * value) + (1 - inf) * nec->value; break; case NLASTRIP_MODE_REPLACE: @@ -1728,7 +1730,7 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, short * - the influence of the accumulated data (elsewhere, that is called dstweight) * is 1 - influence, since the strip's influence is srcweight */ - nec->value = nec->value * (1.0f - inf) + value; + nec->value = nec->value * (1.0f - inf) + (value * inf); break; } } |