[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57345] trunk/blender/source/blender/ blenkernel/intern/anim_sys.c: Bugfix [#35382] NLA "Multiply" Blend Mode calculated incorrectly

Joshua Leung aligorith at gmail.com
Mon Jun 10 13:58:57 CEST 2013


Revision: 57345
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57345
Author:   aligorith
Date:     2013-06-10 11:58:57 +0000 (Mon, 10 Jun 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/anim_sys.c

Modified: trunk/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2013-06-10 11:08:39 UTC (rev 57344)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2013-06-10 11:58:57 UTC (rev 57345)
@@ -1701,25 +1701,27 @@
 	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 @@
 			 *	- 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;
 	}
 }




More information about the Bf-blender-cvs mailing list