diff options
author | Matt Ebb <matt@mke3.net> | 2010-01-27 08:42:17 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-01-27 08:42:17 +0300 |
commit | de56a6384957d00c49d5e3846a8bcf7350e96daa (patch) | |
tree | 8baf5ad593ee61290e2cb8b02817d3096a647c34 /source/blender/blenkernel/intern | |
parent | 0c77490cb48ad2052fe1ca9d540c7a9fd82c2fa6 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 40 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 56 |
2 files changed, 96 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 28de10a64f9..2084dc7ede7 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -284,6 +284,46 @@ int list_find_data_fcurves (ListBase *dst, ListBase *src, const char *dataPrefix 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 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index e4bab3fbfa1..ec3cf453c4b 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -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 @@ void ntreeCompositTagRender(Scene *curscene) } } +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 @@ int ntreeCompositTagAnimated(bNodeTree *ntree) 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)) { |