Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2011-07-24 08:34:46 +0400
committerJoshua Leung <aligorith@gmail.com>2011-07-24 08:34:46 +0400
commit6a392e8cb505b753a0bac24e42778306007c45b8 (patch)
tree6d34591894fec168b8535fae88455ef8446f0a2a /source/blender/blenkernel/intern/anim_sys.c
parentc22f26d2032b7116477e6a378407a10b6d7e3276 (diff)
== 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.
Diffstat (limited to 'source/blender/blenkernel/intern/anim_sys.c')
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 69458ec7401..3e59accc599 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1116,7 +1116,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
{
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 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
/* 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 @@ static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt)
* 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 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re
*/
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 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re
* '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 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
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 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
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); \
} \
}