[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26322] trunk/blender/source/blender: Fix [#20773] NODE ANIMATION: Animating node values broken

Matt Ebb matt at mke3.net
Wed Jan 27 06:42:18 CET 2010


Revision: 26322
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26322
Author:   broken
Date:     2010-01-27 06:42:17 +0100 (Wed, 27 Jan 2010)

Log Message:
-----------
Fix [#20773] NODE ANIMATION: Animating node values broken

Now the compositing node tree will update on frame change if any of the 
nodes are animated.

This doesn't work for playback (i.e. alt a), that's better off waiting until we 
have some kind of frame caching system.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_fcurve.h
    trunk/blender/source/blender/blenkernel/intern/fcurve.c
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/editors/interface/interface_anim.c
    trunk/blender/source/blender/editors/space_node/node_draw.c
    trunk/blender/source/blender/editors/space_node/space_node.c

Modified: trunk/blender/source/blender/blenkernel/BKE_fcurve.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_fcurve.h	2010-01-27 02:21:52 UTC (rev 26321)
+++ trunk/blender/source/blender/blenkernel/BKE_fcurve.h	2010-01-27 05:42:17 UTC (rev 26322)
@@ -36,6 +36,8 @@
 
 struct BezTriple;
 struct StructRNA;
+struct PointerRNA;
+struct PropertyRNA;
 
 #include "DNA_curve_types.h"
 
@@ -191,6 +193,9 @@
  */
 int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName);
 
+/* find an f-curve based on an rna property */
+struct FCurve *rna_get_fcurve(struct PointerRNA *ptr, struct PropertyRNA *prop, int rnaindex, struct bAction **action, int *driven);
+
 /* Binary search algorithm for finding where to 'insert' BezTriple with given frame number.
  * Returns the index to insert at (data already at that index will be offset if replace is 0)
  */

Modified: trunk/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fcurve.c	2010-01-27 02:21:52 UTC (rev 26321)
+++ trunk/blender/source/blender/blenkernel/intern/fcurve.c	2010-01-27 05:42:17 UTC (rev 26322)
@@ -284,6 +284,46 @@
 	return matches;
 }
 
+FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven)
+{
+	FCurve *fcu= NULL;
+	
+	*driven= 0;
+	
+	/* there must be some RNA-pointer + property combon */
+	if(prop && ptr->id.data && RNA_property_animateable(ptr, prop)) {
+		AnimData *adt= BKE_animdata_from_id(ptr->id.data);
+		char *path;
+		
+		if(adt) {
+			if((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
+				/* XXX this function call can become a performance bottleneck */
+				path= RNA_path_from_ID_to_property(ptr, prop);
+				
+				if(path) {
+					/* animation takes priority over drivers */
+					if(adt->action && adt->action->curves.first)
+						fcu= list_find_fcurve(&adt->action->curves, path, rnaindex);
+					
+					/* if not animated, check if driven */
+					if(!fcu && (adt->drivers.first)) {
+						fcu= list_find_fcurve(&adt->drivers, path, rnaindex);
+						
+						if(fcu)
+							*driven= 1;
+					}
+					
+					if(fcu && action)
+						*action= adt->action;
+					
+					MEM_freeN(path);
+				}
+			}
+		}
+	}
+	
+	return fcu;
+}
 
 /* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */
 #define BEZT_BINARYSEARCH_THRESH 	0.00001f

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2010-01-27 02:21:52 UTC (rev 26321)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2010-01-27 05:42:17 UTC (rev 26322)
@@ -35,6 +35,7 @@
 #include <stddef.h>
 #include <string.h>
 
+#include "DNA_anim_types.h"
 #include "DNA_ID.h"
 #include "DNA_image_types.h"
 #include "DNA_node_types.h"
@@ -43,8 +44,11 @@
 #include "DNA_text_types.h"
 #include "DNA_scene_types.h"
 
+#include "RNA_access.h"
+
 #include "BKE_blender.h"
 #include "BKE_colortools.h"
+#include "BKE_fcurve.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
 #include "BKE_library.h"
@@ -2865,6 +2869,54 @@
 	}
 }
 
+static int node_animation_properties(bNodeTree *ntree, bNode *node)
+{
+	bNodeSocket *sock;
+	ListBase *lb;
+	Link *link;
+	PointerRNA ptr;
+	PropertyRNA *prop;
+	
+	/* check to see if any of the node's properties have fcurves */
+	RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
+	lb = RNA_struct_defined_properties(ptr.type);
+	
+	for (link=lb->first; link; link=link->next) {
+		int driven, len=1, index;
+		prop = (PropertyRNA *)link;
+		
+		if (RNA_property_array_check(&ptr, prop))
+			len = RNA_property_array_length(&ptr, prop);
+		
+		for (index=0; index<len; index++) {
+			if (rna_get_fcurve(&ptr, prop, index, NULL, &driven)) {
+				NodeTagChanged(ntree, node);
+				return 1;
+			}
+		}
+	}
+	
+	/* now check node sockets */
+	for (sock = node->inputs.first; sock; sock=sock->next) {
+		int driven, len=1, index;
+		
+		RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
+		prop = RNA_struct_find_property(&ptr, "default_value");
+		
+		if (RNA_property_array_check(&ptr, prop))
+			len = RNA_property_array_length(&ptr, prop);
+		
+		for (index=0; index<len; index++) {
+			if (rna_get_fcurve(&ptr, prop, index, NULL, &driven)) {
+				NodeTagChanged(ntree, node);
+				return 1;
+			}
+		}
+	}
+
+	return 0;
+}
+
 /* tags nodes that have animation capabilities */
 int ntreeCompositTagAnimated(bNodeTree *ntree)
 {
@@ -2874,6 +2926,10 @@
 	if(ntree==NULL) return 0;
 	
 	for(node= ntree->nodes.first; node; node= node->next) {
+		
+		tagged = node_animation_properties(ntree, node);
+		
+		/* otherwise always tag these node types */
 		if(node->type==CMP_NODE_IMAGE) {
 			Image *ima= (Image *)node->id;
 			if(ima && ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {

Modified: trunk/blender/source/blender/editors/interface/interface_anim.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_anim.c	2010-01-27 02:21:52 UTC (rev 26321)
+++ trunk/blender/source/blender/editors/interface/interface_anim.c	2010-01-27 05:42:17 UTC (rev 26322)
@@ -30,45 +30,7 @@
 
 static FCurve *ui_but_get_fcurve(uiBut *but, bAction **action, int *driven)
 {
-	FCurve *fcu= NULL;
-
-	*driven= 0;
-
-	/* there must be some RNA-pointer + property combo for this button */
-	if(but->rnaprop && but->rnapoin.id.data && 
-		RNA_property_animateable(&but->rnapoin, but->rnaprop)) 
-	{
-		AnimData *adt= BKE_animdata_from_id(but->rnapoin.id.data);
-		char *path;
-		
-		if(adt) {
-			if((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
-				/* XXX this function call can become a performance bottleneck */
-				path= RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
-
-				if(path) {
-					/* animation takes priority over drivers */
-					if(adt->action && adt->action->curves.first)
-						fcu= list_find_fcurve(&adt->action->curves, path, but->rnaindex);
-					
-					/* if not animated, check if driven */
-					if(!fcu && (adt->drivers.first)) {
-						fcu= list_find_fcurve(&adt->drivers, path, but->rnaindex);
-						
-						if(fcu)
-							*driven= 1;
-					}
-
-					if(fcu && action)
-						*action= adt->action;
-
-					MEM_freeN(path);
-				}
-			}
-		}
-	}
-
-	return fcu;
+	return rna_get_fcurve(&but->rnapoin, but->rnaprop, but->rnaindex, action, driven);
 }
 
 void ui_but_anim_flag(uiBut *but, float cfra)

Modified: trunk/blender/source/blender/editors/space_node/node_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_draw.c	2010-01-27 02:21:52 UTC (rev 26321)
+++ trunk/blender/source/blender/editors/space_node/node_draw.c	2010-01-27 05:42:17 UTC (rev 26322)
@@ -109,22 +109,9 @@
 		NodeTagChanged(edittree, node);
 		/* don't use NodeTagIDChanged, it gives far too many recomposites for image, scene layers, ... */
 			
-		/* not the best implementation of the world... but we need it to work now :) */
-		if(node->type==CMP_NODE_R_LAYERS && node->custom2) {
-			/* add event for this window (after render curarea can be changed) */
-			//addqueue(curarea->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
-			
-			//composite_node_render(snode, node);
-			//snode_notify(snode);
-			
-			/* add another event, a render can go fullscreen and open new window */
-			//addqueue(curarea->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
-		}
-		else {
-			node= node_tree_get_editgroup(nodetree);
-			if(node)
-				NodeTagIDChanged(nodetree, node->id);
-		}
+		node= node_tree_get_editgroup(nodetree);
+		if(node)
+			NodeTagIDChanged(nodetree, node->id);
 
 		WM_main_add_notifier(NC_SCENE|ND_NODES, id);
 	}			

Modified: trunk/blender/source/blender/editors/space_node/space_node.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/space_node.c	2010-01-27 02:21:52 UTC (rev 26321)
+++ trunk/blender/source/blender/editors/space_node/space_node.c	2010-01-27 05:42:17 UTC (rev 26322)
@@ -170,8 +170,12 @@
 	/* preview renders */
 	switch(wmn->category) {
 		case NC_SCENE:
-			if(wmn->data==ND_NODES)
-				ED_area_tag_refresh(sa);
+			switch (wmn->data) {
+				case ND_NODES:
+				case ND_FRAME:
+					ED_area_tag_refresh(sa);
+					break;
+			}
 			break;
 		case NC_WM:
 			if(wmn->data==ND_FILEREAD)





More information about the Bf-blender-cvs mailing list