From c5ba912a3d1de03ffd0b1c1818b1026f75bbb8b3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 10 Jun 2013 11:58:57 +0000 Subject: 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. --- source/blender/blenkernel/intern/anim_sys.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern/anim_sys.c') 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; } } -- cgit v1.2.3