[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38649] branches/soc-2011-pepper/source/ blender: == RNA Property Updates get called by Animation System now ==

Joshua Leung aligorith at gmail.com
Sun Jul 24 06:34:47 CEST 2011


Revision: 38649
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38649
Author:   aligorith
Date:     2011-07-24 04:34:46 +0000 (Sun, 24 Jul 2011)
Log Message:
-----------
== RNA Property Updates get called by Animation System now ==

This fixes bug #26764 and several others like it, where modifier
properties (and others, but most visibly modifiers) would not do
anything when animated or driven, as modifier properties require the
RNA update calls to tag the modifiers to get recalculated.

While just adding a call to RNA_property_update() could have gotten
this working (as per the Campbell's patch attached in the report, and
also my own attempt #25881). However, on production rigs, the
performance cost of this is untenatable (on my own tests, without
these updates, I was getting ~5fps on such a rig, but only 0.9fps or
possibly even worse with the updates added).

Hence, this commit adds a property-update caching system to the RNA
level, which aims to reduce to the number of times that the update
functions end up needing to get called.

While this is much faster than without the caching, I also added an
optimisation for pose bones (which are numerous in production rigs) so
that their property updates are skipped, since they are useless to the
animsys (they only tag the depsgraph for updating). This gets things
moving at a more acceptable framerate.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/blenkernel/BKE_animsys.h
    branches/soc-2011-pepper/source/blender/blenkernel/intern/action.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/anim.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/anim_sys.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/blender.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/key.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/object.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/particle_system.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/scene.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/sequencer.c
    branches/soc-2011-pepper/source/blender/editors/space_view3d/drawanimviz.c
    branches/soc-2011-pepper/source/blender/editors/space_view3d/drawarmature.c
    branches/soc-2011-pepper/source/blender/makesrna/RNA_access.h
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_access.c
    branches/soc-2011-pepper/source/blender/render/intern/source/pipeline.c

Modified: branches/soc-2011-pepper/source/blender/blenkernel/BKE_animsys.h
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/BKE_animsys.h	2011-07-24 00:59:03 UTC (rev 38648)
+++ branches/soc-2011-pepper/source/blender/blenkernel/BKE_animsys.h	2011-07-24 04:34:46 UTC (rev 38649)
@@ -140,10 +140,10 @@
 /* In general, these ones should be called to do all animation evaluation */
 
 /* Evaluation loop for evaluating animation data  */
-void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, float ctime, short recalc);
+void BKE_animsys_evaluate_animdata(struct Scene *scene, struct ID *id, struct AnimData *adt, float ctime, short recalc);
 
 /* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only */
-void BKE_animsys_evaluate_all_animation(struct Main *main, float ctime);
+void BKE_animsys_evaluate_all_animation(struct Main *main, struct Scene *scene, float ctime);
 
 
 /* ------------ Specialised API --------------- */

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/action.c	2011-07-24 00:59:03 UTC (rev 38648)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/action.c	2011-07-24 04:34:46 UTC (rev 38649)
@@ -1197,7 +1197,7 @@
 		adt.action= act;
 		
 		/* execute effects of Action on to workob (or it's PoseChannels) */
-		BKE_animsys_evaluate_animdata(&workob->id, &adt, cframe, ADT_RECALC_ANIM);
+		BKE_animsys_evaluate_animdata(NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM);
 	}
 }
 

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/anim.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/anim.c	2011-07-24 00:59:03 UTC (rev 38648)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/anim.c	2011-07-24 04:34:46 UTC (rev 38649)
@@ -796,7 +796,7 @@
 			 * and/or other objects which may affect this object's transforms are not updated either.
 			 * However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine!
 			 */
-			BKE_animsys_evaluate_animdata(&ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
+			BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
 			where_is_object_time(scene, ob, (float)scene->r.cfra);
 			
 			dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated);
@@ -811,7 +811,7 @@
 	 */
 	scene->r.cfra= cfrao;
 	
-	BKE_animsys_evaluate_animdata(&ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
+	BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
 	where_is_object_time(scene, ob, (float)scene->r.cfra);
 	
 	/* but, to make sure unkeyed object transforms are still sane, 

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/anim_sys.c	2011-07-24 00:59:03 UTC (rev 38648)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/anim_sys.c	2011-07-24 04:34:46 UTC (rev 38649)
@@ -1116,7 +1116,7 @@
 		{
 			int array_len= RNA_property_array_length(&new_ptr, prop);
 			
-			if(array_len && array_index >= array_len)
+			if (array_len && array_index >= array_len)
 			{
 				if (G.f & G_DEBUG) {
 					printf("Animato: Invalid array index. ID = '%s',  '%s[%d]', array length is %d \n",
@@ -1154,6 +1154,23 @@
 					/* nothing can be done here... so it is unsuccessful? */
 					return 0;
 			}
+			
+			/* buffer property update for later flushing */
+			if (RNA_property_update_check(prop)) {
+				short skip_updates_hack = 0;
+				
+				/* optimisation hacks: skip property updates for those properties
+				 * for we know that which the updates in RNA were really just for
+				 * flushing property editing via UI/Py
+				 */
+				if (RNA_struct_is_a(new_ptr.type, &RNA_PoseBone)) {
+					/* bone transforms - update pose (i.e. tag depsgraph) */
+					skip_updates_hack = 1;
+				}				
+				
+				if (skip_updates_hack == 0)
+					RNA_property_update_cache_add(&new_ptr, prop);
+			}
 		}
 		
 		/* successful */
@@ -2132,8 +2149,9 @@
  * and that the flags for which parts of the anim-data settings need to be recalculated 
  * have been set already by the depsgraph. Now, we use the recalc 
  */
-void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short recalc)
+void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float ctime, short recalc)
 {
+	Main *bmain = G.main; // xxx - to get passed in!
 	PointerRNA id_ptr;
 	
 	/* sanity checks */
@@ -2184,6 +2202,10 @@
 	 */
 	animsys_evaluate_overrides(&id_ptr, adt);
 	
+	/* execute and clear all cached property update functions */
+	RNA_property_update_cache_flush(bmain, scene);
+	RNA_property_update_cache_free();
+	
 	/* clear recalc flag now */
 	adt->recalc= 0;
 }
@@ -2195,7 +2217,7 @@
  * 'local' (i.e. belonging in the nearest ID-block that setting is related to, not a
  * standard 'root') block are overridden by a larger 'user'
  */
-void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
+void BKE_animsys_evaluate_all_animation (Main *main, Scene *scene, float ctime)
 {
 	ID *id;
 
@@ -2211,7 +2233,7 @@
 	for (id= first; id; id= id->next) { \
 		if (ID_REAL_USERS(id) > 0) { \
 			AnimData *adt= BKE_animdata_from_id(id); \
-			BKE_animsys_evaluate_animdata(id, adt, ctime, aflag); \
+			BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag); \
 		} \
 	}
 	/* another macro for the "embedded" nodetree cases 
@@ -2227,9 +2249,9 @@
 			NtId_Type *ntp= (NtId_Type *)id; \
 			if (ntp->nodetree) { \
 				AnimData *adt2= BKE_animdata_from_id((ID *)ntp->nodetree); \
-				BKE_animsys_evaluate_animdata((ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \
+				BKE_animsys_evaluate_animdata(scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \
 			} \
-			BKE_animsys_evaluate_animdata(id, adt, ctime, aflag); \
+			BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag); \
 		} \
 	}
 	

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/blender.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/blender.c	2011-07-24 00:59:03 UTC (rev 38648)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/blender.c	2011-07-24 04:34:46 UTC (rev 38649)
@@ -90,6 +90,8 @@
 
 #include "BKE_utildefines.h"
 
+#include "RNA_access.h"
+
 #include "WM_api.h" // XXXXX BAD, very BAD dependency (bad level call) - remove asap, elubie
 
 Global G;
@@ -239,6 +241,9 @@
 //	CTX_wm_manager_set(C, NULL);
 	clear_global();	
 	
+	/* clear old property update cache, in case some old references are left dangling */
+	RNA_property_update_cache_free();
+	
 	G.main= bfd->main;
 
 	CTX_data_main_set(C, G.main);

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/key.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/key.c	2011-07-24 00:59:03 UTC (rev 38648)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/key.c	2011-07-24 04:34:46 UTC (rev 38649)
@@ -1400,7 +1400,7 @@
 		/* do shapekey local drivers */
 		float ctime= (float)scene->r.cfra; // XXX this needs to be checked
 		
-		BKE_animsys_evaluate_animdata(&key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
+		BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
 		
 		if(ob->type==OB_MESH) do_mesh_key(scene, ob, key, out, tot);
 		else if(ob->type==OB_LATTICE) do_latt_key(scene, ob, key, out, tot);

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/object.c	2011-07-24 00:59:03 UTC (rev 38648)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/object.c	2011-07-24 04:34:46 UTC (rev 38649)
@@ -2084,7 +2084,7 @@
 	if(ob==NULL) return;
 	
 	/* execute drivers only, as animation has already been done */
-	BKE_animsys_evaluate_animdata(&ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
+	BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
 	
 	if(ob->parent) {
 		Object *par= ob->parent;
@@ -2623,7 +2623,7 @@
 			if(adt) {
 				/* evaluate drivers */
 				// XXX: for mesh types, should we push this to derivedmesh instead?
-				BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS);
+				BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS);
 			}
 
 			/* includes all keys and modifiers */

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/particle_system.c	2011-07-24 00:59:03 UTC (rev 38648)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/particle_system.c	2011-07-24 04:34:46 UTC (rev 38649)
@@ -1801,7 +1801,7 @@
 	if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
 		/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
 		while(ob) {
-			BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM);
+			BKE_animsys_evaluate_animdata(sim->scene, &ob->id, ob->adt, pa->time, ADT_RECALC_ANIM);
 			ob = ob->parent;
 		}
 		ob = sim->ob;
@@ -4253,7 +4253,7 @@
 		return;
 
 	/* execute drivers only, as animation has already been done */
-	BKE_animsys_evaluate_animdata(&part->id, part->adt, cfra, ADT_RECALC_DRIVERS);
+	BKE_animsys_evaluate_animdata(scene, &part->id, part->adt, cfra, ADT_RECALC_DRIVERS);
 
 	if(psys->recalc & PSYS_RECALC_TYPE)
 		psys_changed_type(&sim);
@@ -4291,7 +4291,7 @@
 				for(i=0; i<=part->hair_step; i++){
 					hcfra=100.0f*(float)i/(float)psys->part->hair_step;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list