[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50454] trunk/blender/source/blender/ blenkernel/intern/anim_sys.c: Fix cycles continuously updating when creating a driver for a scene property ,

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Sep 6 13:35:16 CEST 2012


Revision: 50454
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50454
Author:   blendix
Date:     2012-09-06 11:35:16 +0000 (Thu, 06 Sep 2012)
Log Message:
-----------
Fix cycles continuously updating when creating a driver for a scene property,
like driving integrator seed with #frame.

The scene drivers are evaluated continuously, which would be nice to fix but
complicated, now it compares the RNA value to see if it actually changed, and
avoids the update in that case, which is a useful optimization by itself.

(merged from tomato branch)

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	2012-09-06 11:34:55 UTC (rev 50453)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c	2012-09-06 11:35:16 UTC (rev 50454)
@@ -1160,6 +1160,7 @@
 		/* set value - only for animatable numerical values */
 		if (RNA_property_animateable(&new_ptr, prop)) {
 			int array_len = RNA_property_array_length(&new_ptr, prop);
+			int written = FALSE;
 			
 			if (array_len && array_index >= array_len) {
 				if (G.debug & G_DEBUG) {
@@ -1173,25 +1174,52 @@
 			
 			switch (RNA_property_type(prop)) {
 				case PROP_BOOLEAN:
-					if (array_len)
-						RNA_property_boolean_set_index(&new_ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
-					else
-						RNA_property_boolean_set(&new_ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
+					if (array_len) {
+						if (RNA_property_boolean_get_index(&new_ptr, prop, array_index) != ANIMSYS_FLOAT_AS_BOOL(value)) {
+							RNA_property_boolean_set_index(&new_ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
+							written = TRUE;
+						}
+					}
+					else {
+						if (RNA_property_boolean_get(&new_ptr, prop) != ANIMSYS_FLOAT_AS_BOOL(value)) {
+							RNA_property_boolean_set(&new_ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
+							written = TRUE;
+						}
+					}
 					break;
 				case PROP_INT:
-					if (array_len)
-						RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value);
-					else
-						RNA_property_int_set(&new_ptr, prop, (int)value);
+					if (array_len) {
+						if (RNA_property_int_get_index(&new_ptr, prop, array_index) != (int)value) {
+							RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value);
+							written = TRUE;
+						}
+					}
+					else {
+						if (RNA_property_int_get(&new_ptr, prop) != (int)value) {
+							RNA_property_int_set(&new_ptr, prop, (int)value);
+							written = TRUE;
+						}
+					}
 					break;
 				case PROP_FLOAT:
-					if (array_len)
-						RNA_property_float_set_index(&new_ptr, prop, array_index, value);
-					else
-						RNA_property_float_set(&new_ptr, prop, value);
+					if (array_len) {
+						if (RNA_property_float_get_index(&new_ptr, prop, array_index) != value) {
+							RNA_property_float_set_index(&new_ptr, prop, array_index, value);
+							written = TRUE;
+						}
+					}
+					else {
+						if (RNA_property_float_get(&new_ptr, prop) != value) {
+							RNA_property_float_set(&new_ptr, prop, value);
+							written = TRUE;
+						}
+					}
 					break;
 				case PROP_ENUM:
-					RNA_property_enum_set(&new_ptr, prop, (int)value);
+					if (RNA_property_enum_get(&new_ptr, prop) != (int)value) {
+						RNA_property_enum_set(&new_ptr, prop, (int)value);
+						written = TRUE;
+					}
 					break;
 				default:
 					/* nothing can be done here... so it is unsuccessful? */
@@ -1201,7 +1229,7 @@
 			/* RNA property update disabled for now - [#28525] [#28690] [#28774] [#28777] */
 #if 0
 			/* buffer property update for later flushing */
-			if (RNA_property_update_check(prop)) {
+			if (written && RNA_property_update_check(prop)) {
 				short skip_updates_hack = 0;
 				
 				/* optimization hacks: skip property updates for those properties
@@ -1221,7 +1249,7 @@
 			/* as long as we don't do property update, we still tag datablock
 			 * as having been updated. this flag does not cause any updates to
 			 * be run, it's for e.g. render engines to synchronize data */
-			if (new_ptr.id.data) {
+			if (written && new_ptr.id.data) {
 				ID *id = new_ptr.id.data;
 				id->flag |= LIB_ID_RECALC;
 				DAG_id_type_tag(G.main, GS(id->name));




More information about the Bf-blender-cvs mailing list