[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12640] trunk/blender/source/blender/ blenkernel/intern/armature.c: Patch #7779: Make the 'Hold' option work with NLA action modifiers

Joshua Leung aligorith at gmail.com
Wed Nov 21 05:49:14 CET 2007


Revision: 12640
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12640
Author:   aligorith
Date:     2007-11-21 05:49:13 +0100 (Wed, 21 Nov 2007)

Log Message:
-----------
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)

Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.

If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.

This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.

Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.

Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip

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

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2007-11-21 04:08:00 UTC (rev 12639)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2007-11-21 04:49:13 UTC (rev 12640)
@@ -1888,12 +1888,42 @@
 static void do_strip_modifiers(Object *armob, Bone *bone, bPoseChannel *pchan)
 {
 	bActionModifier *amod;
-	bActionStrip *strip;
+	bActionStrip *strip, *strip2;
 	float scene_cfra= G.scene->r.cfra;
+	int do_modif;
 
 	for (strip=armob->nlastrips.first; strip; strip=strip->next) {
-		if(scene_cfra>=strip->start && scene_cfra<=strip->end) {
+		do_modif=0;
+		
+		if (scene_cfra>=strip->start && scene_cfra<=strip->end)
+			do_modif=1;
+		
+		if ((scene_cfra > strip->end) && (strip->flag & ACTSTRIP_HOLDLASTFRAME)) {
+			do_modif=1;
 			
+			/* if there are any other strips active, ignore modifiers for this strip - 
+			 * 'hold' option should only hold action modifiers if there are 
+			 * no other active strips */
+			for (strip2=strip->next; strip2; strip2=strip2->next) {
+				if (strip2 == strip) continue;
+				
+				if (scene_cfra>=strip2->start && scene_cfra<=strip2->end) {
+					if (!(strip2->flag & ACTSTRIP_MUTE))
+						do_modif=0;
+				}
+			}
+			
+			/* if there are any later, activated, strips with 'hold' set, they take precedence, 
+			 * so ignore modifiers for this strip */
+			for (strip2=strip->next; strip2; strip2=strip2->next) {
+				if (scene_cfra < strip2->start) continue;
+				if ((strip2->flag & ACTSTRIP_HOLDLASTFRAME) && !(strip2->flag & ACTSTRIP_MUTE)) {
+					do_modif=0;
+				}
+			}
+		}
+		
+		if (do_modif) {
 			/* temporal solution to prevent 2 strips accumulating */
 			if(scene_cfra==strip->end && strip->next && strip->next->start==scene_cfra)
 				continue;





More information about the Bf-blender-cvs mailing list