diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-09-06 15:35:16 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-09-06 15:35:16 +0400 |
commit | f647348420758b1b1d1bb4ab82c70caaee571d99 (patch) | |
tree | 2e0f933bc1fe359e2a73ffb226fd1e64832c6d97 /source/blender/blenkernel/intern | |
parent | a18b60c0c893a3684ca310100d11a05660cdaf7e (diff) |
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)
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index d8ad1ceb1b1..6a3dae93639 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1160,6 +1160,7 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in /* 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 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in 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 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in /* 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 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in /* 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)); |