diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-11 13:39:36 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-12 12:05:18 +0300 |
commit | fac1892e110956c7ed285ef2d7b097d632bcc25e (patch) | |
tree | 85c9d33dcdbe1e167e08c452e36064e1dfe6eec8 /source/blender/blenkernel/intern/layer.c | |
parent | 9c406b786faea9fee6489f0a1a21cab42a3d5cf3 (diff) |
Depsgraph: Bind base by it's index
For the performance we convert object bases list to an array
during view layer evaluation. This makes it possible to have
very cheap index-based base lookup.
The goal of this change is to get rid of base used for function
binding, and avoid scene datablock expansion at the depsgraph
construction time.
Diffstat (limited to 'source/blender/blenkernel/intern/layer.c')
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 4d3b4e43043..50c7dc0c02f 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -216,6 +216,8 @@ void BKE_view_layer_free_ex(ViewLayer *view_layer, const bool do_id_user) MEM_freeN(view_layer->id_properties); } + MEM_SAFE_FREE(view_layer->object_bases_array); + MEM_freeN(view_layer); } @@ -503,6 +505,8 @@ void BKE_view_layer_copy_data( view_layer_dst->basact = base_dst; } } + + view_layer_dst->object_bases_array = NULL; } /** @@ -2358,11 +2362,19 @@ static void layer_eval_layer_collection(const EvaluationContext *eval_ctx, static void layer_eval_layer_collection_post(ViewLayer *view_layer) { DEG_debug_print_eval(__func__, view_layer->name, view_layer); - /* if base is not selectabled, clear select */ + /* Create array of bases, for fast index-based lookup. */ + const int num_object_bases = BLI_listbase_count(&view_layer->object_bases); + MEM_SAFE_FREE(view_layer->object_bases_array); + view_layer->object_bases_array = MEM_malloc_arrayN( + num_object_bases, sizeof(Base *), "view_layer->object_bases_array"); + int base_index = 0; for (Base *base = view_layer->object_bases.first; base; base = base->next) { + /* if base is not selectabled, clear select. */ if ((base->flag & BASE_SELECTABLED) == 0) { base->flag &= ~BASE_SELECTED; } + /* Store base in the array. */ + view_layer->object_bases_array[base_index++] = base; } } |