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:
authorJacques Lucke <mail@jlucke.com>2019-04-17 19:09:33 +0300
committerJacques Lucke <mail@jlucke.com>2019-04-17 19:09:33 +0300
commit81ce3801bf0a876b73b73817ca1a61b4e81b214d (patch)
treed9f749b8d494c68903b3f591434522c119177f7e /source/blender/blenkernel/intern/fcurve.c
parent5f5a22970b4f7b3c42f73cf1f5a5dac4f32a14b0 (diff)
Animation: Refactor storage usage during fcurve modifier evaluation
Previously, when a fcurve modifier used storage, many heap allocations were done. This caused major slowdowns as described in T63656. Furthermore, the storage usage was a special case only used by the Cycles modifier. This refactor makes storage usage the "normal" case. That reduces the overall complexity. The storage is stack allocated now. The framerate on the provided test scene went up from ~5 fps to ~16 fps. Reviewers: angavrilov Differential Revision: https://developer.blender.org/D4701
Diffstat (limited to 'source/blender/blenkernel/intern/fcurve.c')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 4a2a610918c..f93a5e65845 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -2851,12 +2851,15 @@ static float fcurve_eval_samples(FCurve *fcu, FPoint *fpts, float evaltime)
*/
static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue)
{
- FModifierStackStorage *storage;
float devaltime;
/* evaluate modifiers which modify time to evaluate the base curve at */
- storage = evaluate_fmodifiers_storage_new(&fcu->modifiers);
- devaltime = evaluate_time_fmodifiers(storage, &fcu->modifiers, fcu, cvalue, evaltime);
+ FModifiersStackStorage storage;
+ storage.modifier_count = BLI_listbase_count(&fcu->modifiers);
+ storage.size_per_modifier = evaluate_fmodifiers_storage_size_per_modifier(&fcu->modifiers);
+ storage.buffer = alloca(storage.modifier_count * storage.size_per_modifier);
+
+ devaltime = evaluate_time_fmodifiers(&storage, &fcu->modifiers, fcu, cvalue, evaltime);
/* evaluate curve-data
* - 'devaltime' instead of 'evaltime', as this is the time that the last time-modifying
@@ -2868,9 +2871,7 @@ static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue)
cvalue = fcurve_eval_samples(fcu, fcu->fpt, devaltime);
/* evaluate modifiers */
- evaluate_value_fmodifiers(storage, &fcu->modifiers, fcu, &cvalue, devaltime);
-
- evaluate_fmodifiers_storage_free(storage);
+ evaluate_value_fmodifiers(&storage, &fcu->modifiers, fcu, &cvalue, devaltime);
/* if curve can only have integral values, perform truncation (i.e. drop the decimal part)
* here so that the curve can be sampled correctly