From fb2f95c91a368d38a0d7714e27047933d6b88baf Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 27 Jan 2017 18:47:11 +0100 Subject: Fix T50534: Part I, cleanup loop normals generated during modifier stack evaluation. Those could stay around, and be displayed in 3DView even when autosmooth was disabled (but would not be 'active'). --- source/blender/blenkernel/intern/DerivedMesh.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 1f937d837b4..160adcc3988 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2215,6 +2215,12 @@ static void mesh_calc_modifiers( } } + /* Some modifiers, like datatransfer, may generate those data as temp layer, we do not want to keep them, + * as they are used by display code when available (i.e. even if autosmooth is disabled). */ + if (!do_loop_normals && CustomData_has_layer(&finaldm->loopData, CD_NORMAL)) { + CustomData_free_layers(&finaldm->loopData, CD_NORMAL, finaldm->numLoopData); + } + #ifdef WITH_GAMEENGINE /* NavMesh - this is a hack but saves having a NavMesh modifier */ if ((ob->gameflag & OB_NAVMESH) && (finaldm->type == DM_TYPE_CDDM)) { @@ -2550,6 +2556,15 @@ static void editbmesh_calc_modifiers( /* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */ if (!do_loop_normals) { dm_ensure_display_normals(*r_final); + + /* Some modifiers, like datatransfer, may generate those data, we do not want to keep them, + * as they are used by display code when available (i.e. even if autosmooth is disabled). */ + if (CustomData_has_layer(&(*r_final)->loopData, CD_NORMAL)) { + CustomData_free_layers(&(*r_final)->loopData, CD_NORMAL, (*r_final)->numLoopData); + } + if (r_cage && CustomData_has_layer(&(*r_cage)->loopData, CD_NORMAL)) { + CustomData_free_layers(&(*r_cage)->loopData, CD_NORMAL, (*r_cage)->numLoopData); + } } /* add an orco layer if needed */ -- cgit v1.2.3 From 6c23a1b8b951ba76965ae2b33188dfaa4b4f2a29 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Sun, 29 Jan 2017 14:19:58 -0300 Subject: Remove `BKE_boundbox_ray_hit_check` Remove `BKE_boundbox_ray_hit_check` since it is no longer being used and can be easily replaced by `isect_ray_aabb_v3_simple` --- source/blender/blenkernel/intern/object.c | 39 ------------------------------- 1 file changed, 39 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e93bfcdda83..41f725ba2cb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2816,45 +2816,6 @@ int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, return 1; } -/* - * Test a bounding box for ray intersection - * assumes the ray is already local to the boundbox space - */ -bool BKE_boundbox_ray_hit_check( - const struct BoundBox *bb, - const float ray_start[3], const float ray_normal[3], - float *r_lambda) -{ - const int triangle_indexes[12][3] = { - {0, 1, 2}, {0, 2, 3}, - {3, 2, 6}, {3, 6, 7}, - {1, 2, 6}, {1, 6, 5}, - {5, 6, 7}, {4, 5, 7}, - {0, 3, 7}, {0, 4, 7}, - {0, 1, 5}, {0, 4, 5}}; - - bool result = false; - int i; - - for (i = 0; i < 12 && (!result || r_lambda); i++) { - float lambda; - int v1, v2, v3; - v1 = triangle_indexes[i][0]; - v2 = triangle_indexes[i][1]; - v3 = triangle_indexes[i][2]; - if (isect_ray_tri_v3(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL) && - (!r_lambda || *r_lambda > lambda)) - { - result = true; - if (r_lambda) { - *r_lambda = lambda; - } - } - } - - return result; -} - static int pc_cmp(const void *a, const void *b) { const LinkData *ad = a, *bd = b; -- cgit v1.2.3 From 4580ace4c1fe984f707385ea0318c53389fd2916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Mon, 30 Jan 2017 10:46:24 +0100 Subject: Alembic/CacheFile: fix crash de-referencing NULL pointer. --- source/blender/blenkernel/intern/cachefile.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index deeb35bd880..3dce08eb756 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -215,7 +215,9 @@ void BKE_cachefile_clean(Scene *scene, CacheFile *cache_file) if (cache_file == mcmd->cache_file) { #ifdef WITH_ALEMBIC - CacheReader_free(mcmd->reader); + if (mcmd->reader != NULL) { + CacheReader_free(mcmd->reader); + } #endif mcmd->reader = NULL; mcmd->object_path[0] = '\0'; @@ -231,7 +233,9 @@ void BKE_cachefile_clean(Scene *scene, CacheFile *cache_file) if (cache_file == data->cache_file) { #ifdef WITH_ALEMBIC - CacheReader_free(data->reader); + if (data->reader != NULL) { + CacheReader_free(data->reader); + } #endif data->reader = NULL; data->object_path[0] = '\0'; -- cgit v1.2.3 From 4443bad30a3926a33c3ead60f509f637ad29d6c5 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 30 Jan 2017 21:00:07 +0100 Subject: Add optional, free-after-use usages mapping of IDs to Main. The new MainIDRelations stores two mappings, one from ID users to ID used, the other vice-versa. That data is assumed to be short-living runtime, code creating it is responsible to clear it asap. It will be much useful in places where we handle relations between IDs for a lot of them at once. Note: This commit is not fully functional, that is, the infamous, ugly, PoS non-ID nodetrees will not be handled correctly when building relations. Fix needed here is a bit noisy, so will be done in next own commit. --- source/blender/blenkernel/intern/library.c | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 77013a55d18..a06386f2f6a 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -76,6 +76,7 @@ #include "BLI_ghash.h" #include "BLI_linklist.h" #include "BLI_memarena.h" +#include "BLI_mempool.h" #include "BLI_string_utils.h" #include "BLI_threads.h" @@ -1252,6 +1253,10 @@ void BKE_main_free(Main *mainvar) } } + if (mainvar->relations) { + BKE_main_relations_free(mainvar); + } + BLI_spin_end((SpinLock *)mainvar->lock); MEM_freeN(mainvar->lock); DEG_evaluation_context_free(mainvar->eval_ctx); @@ -1268,6 +1273,78 @@ void BKE_main_unlock(struct Main *bmain) BLI_spin_unlock((SpinLock *) bmain->lock); } + +static int main_relations_create_cb(void *user_data, ID *id_self, ID **id_pointer, int cd_flag) +{ + MainIDRelations *rel = user_data; + + if (*id_pointer) { + MainIDRelationsEntry *entry, **entry_p; + + entry = BLI_mempool_alloc(rel->entry_pool); + if (BLI_ghash_ensure_p(rel->id_user_to_used, id_self, (void ***)&entry_p)) { + entry->next = *entry_p; + } + else { + entry->next = NULL; + } + entry->id_pointer = id_pointer; + entry->usage_flag = cd_flag; + *entry_p = entry; + + entry = BLI_mempool_alloc(rel->entry_pool); + if (BLI_ghash_ensure_p(rel->id_used_to_user, *id_pointer, (void ***)&entry_p)) { + entry->next = *entry_p; + } + else { + entry->next = NULL; + } + entry->id_pointer = (ID **)id_self; + entry->usage_flag = cd_flag; + *entry_p = entry; + } + + return IDWALK_RET_NOP; +} + +/** Generate the mappings between used IDs and their users, and vice-versa. */ +void BKE_main_relations_create(Main *bmain) +{ + ListBase *lbarray[MAX_LIBARRAY]; + ID *id; + int a; + + if (bmain->relations != NULL) { + BKE_main_relations_free(bmain); + } + + bmain->relations = MEM_mallocN(sizeof(*bmain->relations), __func__); + bmain->relations->id_used_to_user = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); + bmain->relations->id_user_to_used = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); + bmain->relations->entry_pool = BLI_mempool_create(sizeof(MainIDRelationsEntry), 128, 128, BLI_MEMPOOL_NOP); + + for (a = set_listbasepointers(bmain, lbarray); a--; ) { + for (id = lbarray[a]->first; id; id = id->next) { + BKE_library_foreach_ID_link(id, main_relations_create_cb, bmain->relations, IDWALK_READONLY); + } + } +} + +void BKE_main_relations_free(Main *bmain) +{ + if (bmain->relations) { + if (bmain->relations->id_used_to_user) { + BLI_ghash_free(bmain->relations->id_used_to_user, NULL, NULL); + } + if (bmain->relations->id_user_to_used) { + BLI_ghash_free(bmain->relations->id_user_to_used, NULL, NULL); + } + BLI_mempool_destroy(bmain->relations->entry_pool); + MEM_freeN(bmain->relations); + bmain->relations = NULL; + } +} + /** * Generates a raw .blend file thumbnail data from given image. * -- cgit v1.2.3 From fbd28d375a758d81b925867efef4d02482d414c6 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 30 Jan 2017 21:34:23 +0100 Subject: Fix missing non-ID nodetrees in ID relationships built from library_query.c This shall fix both existing code (bpy mapping, and local/lib usages checks), and new Main->relations generation. --- source/blender/blenkernel/intern/library.c | 6 +++++- source/blender/blenkernel/intern/library_query.c | 22 +++++++++++++++------- source/blender/blenkernel/intern/library_remap.c | 8 ++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index a06386f2f6a..bb426ac0279 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -274,8 +274,12 @@ void BKE_id_clear_newpoin(ID *id) } static int id_expand_local_callback( - void *UNUSED(user_data), struct ID *id_self, struct ID **id_pointer, int UNUSED(cd_flag)) + void *UNUSED(user_data), struct ID *id_self, struct ID **id_pointer, int cd_flag) { + if (cd_flag & IDWALK_PRIVATE) { + return IDWALK_RET_NOP; + } + /* Can hapen that we get unlinkable ID here, e.g. with shapekey referring to itself (through drivers)... * Just skip it, shape key can only be either indirectly linked, or fully local, period. * And let's curse one more time that stupid useless shapekey ID type! */ diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index fa75c906fb1..28f66b52793 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -85,6 +85,7 @@ #define FOREACH_FINALIZE_VOID FOREACH_FINALIZE: (void)0 #define FOREACH_CALLBACK_INVOKE_ID_PP(_data, id_pp, cb_flag) \ + CHECK_TYPE(id_pp, ID **); \ if (!((_data)->status & IDWALK_STOP)) { \ const int _flag = (_data)->flag; \ ID *old_id = *(id_pp); \ @@ -265,8 +266,13 @@ static void library_foreach_paint(LibraryForeachIDData *data, Paint *paint) } static void library_foreach_ID_as_subdata_link( - ID *id, LibraryIDLinkCallback callback, void *user_data, int flag, LibraryForeachIDData *data) + ID **id_pp, LibraryIDLinkCallback callback, void *user_data, int flag, LibraryForeachIDData *data) { + /* Needed e.g. for callbacks handling relationships... This call shall be absolutely readonly. */ + ID *id = *id_pp; + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pp, IDWALK_PRIVATE); + BLI_assert(id == *id_pp); + if (flag & IDWALK_RECURSE) { /* Defer handling into main loop, recursively calling BKE_library_foreach_ID_link in IDWALK_RECURSE case is * troublesome, see T49553. */ @@ -278,6 +284,8 @@ static void library_foreach_ID_as_subdata_link( else { BKE_library_foreach_ID_link(id, callback, user_data, flag); } + + FOREACH_FINALIZE_VOID; } /** @@ -342,7 +350,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u CALLBACK_INVOKE(scene->clip, IDWALK_USER); if (scene->nodetree) { /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ - library_foreach_ID_as_subdata_link((ID *)scene->nodetree, callback, user_data, flag, &data); + library_foreach_ID_as_subdata_link((ID **)&scene->nodetree, callback, user_data, flag, &data); } /* DO NOT handle scene->basact here, it's doubling with the loop over whole scene->base later, * since basact is just a pointer to one of those items. */ @@ -606,7 +614,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u } if (material->nodetree) { /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ - library_foreach_ID_as_subdata_link((ID *)material->nodetree, callback, user_data, flag, &data); + library_foreach_ID_as_subdata_link((ID **)&material->nodetree, callback, user_data, flag, &data); } CALLBACK_INVOKE(material->group, IDWALK_USER); break; @@ -617,7 +625,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u Tex *texture = (Tex *) id; if (texture->nodetree) { /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ - library_foreach_ID_as_subdata_link((ID *)texture->nodetree, callback, user_data, flag, &data); + library_foreach_ID_as_subdata_link((ID **)&texture->nodetree, callback, user_data, flag, &data); } CALLBACK_INVOKE(texture->ima, IDWALK_USER); if (texture->env) { @@ -650,7 +658,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u } if (lamp->nodetree) { /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ - library_foreach_ID_as_subdata_link((ID *)lamp->nodetree, callback, user_data, flag, &data); + library_foreach_ID_as_subdata_link((ID **)&lamp->nodetree, callback, user_data, flag, &data); } break; } @@ -690,7 +698,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u } if (world->nodetree) { /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ - library_foreach_ID_as_subdata_link((ID *)world->nodetree, callback, user_data, flag, &data); + library_foreach_ID_as_subdata_link((ID **)&world->nodetree, callback, user_data, flag, &data); } break; } @@ -834,7 +842,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u } if (linestyle->nodetree) { /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ - library_foreach_ID_as_subdata_link((ID *)linestyle->nodetree, callback, user_data, flag, &data); + library_foreach_ID_as_subdata_link((ID **)&linestyle->nodetree, callback, user_data, flag, &data); } for (lsm = linestyle->color_modifiers.first; lsm; lsm = lsm->next) { diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index d7d566a9ec0..5fba7b75b1e 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -158,6 +158,10 @@ enum { static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id_p, int cb_flag) { + if (cb_flag & IDWALK_PRIVATE) { + return IDWALK_RET_NOP; + } + IDRemap *id_remap_data = user_data; ID *old_id = id_remap_data->old_id; ID *new_id = id_remap_data->new_id; @@ -687,6 +691,10 @@ void BKE_libblock_relink_ex( static int id_relink_to_newid_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag) { + if (cd_flag & IDWALK_PRIVATE) { + return IDWALK_RET_NOP; + } + ID *id = *id_pointer; if (id) { /* See: NEW_ID macro */ -- cgit v1.2.3 From eadfd901ad7c3af4d85b05618352a96a9b4ca9de Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 30 Jan 2017 21:41:44 +0100 Subject: Optimization: pass Main to BKE_library_foreach_ID_link() and use its relations. Use Main->relations in BKE_library_foreach_ID_link(), when possible (i.e. IDWALK_READONLY is set), and if the data is available of course. This is quite minor optimization, no sensible improvements are expected, but does not hurt either to avoid potentially tens of looping over e.g. objects constraints and modifiers, or heap of drivers... --- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/library.c | 12 ++++----- source/blender/blenkernel/intern/library_query.c | 32 +++++++++++++++++------- source/blender/blenkernel/intern/library_remap.c | 6 ++--- source/blender/blenkernel/intern/object.c | 2 +- 5 files changed, 34 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 0d509ecea06..57b707a31d3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -239,7 +239,7 @@ void BKE_brush_make_local(Main *bmain, Brush *brush, const bool lib_local) if (lib_local || is_local) { if (!is_lib) { id_clear_lib_data(bmain, &brush->id); - BKE_id_expand_local(&brush->id); + BKE_id_expand_local(bmain, &brush->id); /* enable fake user by default */ id_fake_user_set(&brush->id); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index bb426ac0279..3f75bb8ec69 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -293,9 +293,9 @@ static int id_expand_local_callback( /** * Expand ID usages of given id as 'extern' (and no more indirect) linked data. Used by ID copy/make_local functions. */ -void BKE_id_expand_local(ID *id) +void BKE_id_expand_local(Main *bmain, ID *id) { - BKE_library_foreach_ID_link(id, id_expand_local_callback, NULL, 0); + BKE_library_foreach_ID_link(bmain, id, id_expand_local_callback, NULL, IDWALK_READONLY); } /** @@ -304,7 +304,7 @@ void BKE_id_expand_local(ID *id) void BKE_id_copy_ensure_local(Main *bmain, ID *old_id, ID *new_id) { if (ID_IS_LINKED_DATABLOCK(old_id)) { - BKE_id_expand_local(new_id); + BKE_id_expand_local(bmain, new_id); BKE_id_lib_local_paths(bmain, old_id->lib, new_id); } } @@ -331,7 +331,7 @@ void BKE_id_make_local_generic(Main *bmain, ID *id, const bool id_in_mainlist, c if (lib_local || is_local) { if (!is_lib) { id_clear_lib_data_ex(bmain, id, id_in_mainlist); - BKE_id_expand_local(id); + BKE_id_expand_local(bmain, id); } else { ID *id_new; @@ -1329,7 +1329,7 @@ void BKE_main_relations_create(Main *bmain) for (a = set_listbasepointers(bmain, lbarray); a--; ) { for (id = lbarray[a]->first; id; id = id->next) { - BKE_library_foreach_ID_link(id, main_relations_create_cb, bmain->relations, IDWALK_READONLY); + BKE_library_foreach_ID_link(NULL, id, main_relations_create_cb, bmain->relations, IDWALK_READONLY); } } } @@ -1777,7 +1777,7 @@ void BKE_library_make_local( * some indirect usages. So instead of making a copy that se'll likely get rid of later, directly make * that data block local. Saves a tremendous amount of time with complex scenes... */ id_clear_lib_data_ex(bmain, id, true); - BKE_id_expand_local(id); + BKE_id_expand_local(bmain, id); id->tag &= ~LIB_TAG_DOIT; } else { diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index 28f66b52793..03c4b803350 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -282,7 +282,7 @@ static void library_foreach_ID_as_subdata_link( } } else { - BKE_library_foreach_ID_link(id, callback, user_data, flag); + BKE_library_foreach_ID_link(NULL, id, callback, user_data, flag); } FOREACH_FINALIZE_VOID; @@ -293,7 +293,7 @@ static void library_foreach_ID_as_subdata_link( * * \note: May be extended to be recursive in the future. */ -void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *user_data, int flag) +void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag) { LibraryForeachIDData data; int i; @@ -321,10 +321,22 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u #define CALLBACK_INVOKE(check_id_super, cb_flag) \ FOREACH_CALLBACK_INVOKE(&data, check_id_super, cb_flag) - do { + for (; id != NULL; id = (flag & IDWALK_RECURSE) ? BLI_LINKSTACK_POP(data.ids_todo) : NULL) { data.self_id = id; data.cd_flag = ID_IS_LINKED_DATABLOCK(id) ? IDWALK_INDIRECT_USAGE : 0; + if (bmain != NULL && bmain->relations != NULL && (flag & IDWALK_READONLY)) { + /* Note that this is minor optimization, even in worst cases (like id being an object with lots of + * drivers and constraints and modifiers, or material etc. with huge node tree), + * but we might as well use it (Main->relations is always assumed valid, it's responsability of code + * creating it to free it, especially if/when it starts modifying Main database). */ + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->id_user_to_used, id); + for (; entry != NULL; entry = entry->next) { + FOREACH_CALLBACK_INVOKE_ID_PP(&data, entry->id_pointer, entry->usage_flag); + } + continue; + } + AnimData *adt = BKE_animdata_from_id(id); if (adt) { library_foreach_animationData(&data, adt); @@ -899,7 +911,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u break; } - } while ((id = (flag & IDWALK_RECURSE) ? BLI_LINKSTACK_POP(data.ids_todo) : NULL)); + } FOREACH_FINALIZE: if (data.ids_handled) { @@ -1088,7 +1100,7 @@ int BKE_library_ID_use_ID(ID *id_user, ID *id_used) iter.curr_id = id_user; iter.count_direct = iter.count_indirect = 0; - BKE_library_foreach_ID_link(iter.curr_id, foreach_libblock_id_users_callback, (void *)&iter, IDWALK_NOP); + BKE_library_foreach_ID_link(NULL, iter.curr_id, foreach_libblock_id_users_callback, (void *)&iter, IDWALK_READONLY); return iter.count_direct + iter.count_indirect; } @@ -1117,7 +1129,7 @@ static bool library_ID_is_used(Main *bmain, void *idv, const bool check_linked) } iter.curr_id = id_curr; BKE_library_foreach_ID_link( - id_curr, foreach_libblock_id_users_callback, &iter, IDWALK_NOP); + bmain, id_curr, foreach_libblock_id_users_callback, &iter, IDWALK_READONLY); is_defined = ((check_linked ? iter.count_indirect : iter.count_direct) != 0); } @@ -1168,7 +1180,7 @@ void BKE_library_ID_test_usages(Main *bmain, void *idv, bool *is_used_local, boo continue; } iter.curr_id = id_curr; - BKE_library_foreach_ID_link(id_curr, foreach_libblock_id_users_callback, &iter, IDWALK_NOP); + BKE_library_foreach_ID_link(bmain, id_curr, foreach_libblock_id_users_callback, &iter, IDWALK_READONLY); is_defined = (iter.count_direct != 0 && iter.count_indirect != 0); } @@ -1245,7 +1257,8 @@ void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag) /* Unused ID (so far), no need to check it further. */ continue; } - BKE_library_foreach_ID_link(id, foreach_libblock_used_linked_data_tag_clear_cb, &do_loop, IDWALK_NOP); + BKE_library_foreach_ID_link( + bmain, id, foreach_libblock_used_linked_data_tag_clear_cb, &do_loop, IDWALK_READONLY); } } } @@ -1272,7 +1285,8 @@ void BKE_library_indirectly_used_data_tag_clear(Main *bmain) /* Local or non-indirectly-used ID (so far), no need to check it further. */ continue; } - BKE_library_foreach_ID_link(id, foreach_libblock_used_linked_data_tag_clear_cb, &do_loop, IDWALK_NOP); + BKE_library_foreach_ID_link( + bmain, id, foreach_libblock_used_linked_data_tag_clear_cb, &do_loop, IDWALK_READONLY); } } } diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 5fba7b75b1e..ff66c37a09b 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -438,7 +438,7 @@ ATTR_NONNULL(1) static void libblock_remap_data( #endif r_id_remap_data->id = id; libblock_remap_data_preprocess(r_id_remap_data); - BKE_library_foreach_ID_link(id, foreach_libblock_remap_callback, (void *)r_id_remap_data, IDWALK_NOP); + BKE_library_foreach_ID_link(NULL, id, foreach_libblock_remap_callback, (void *)r_id_remap_data, IDWALK_NOP); } else { i = set_listbasepointers(bmain, lb_array); @@ -460,7 +460,7 @@ ATTR_NONNULL(1) static void libblock_remap_data( r_id_remap_data->id = id_curr; libblock_remap_data_preprocess(r_id_remap_data); BKE_library_foreach_ID_link( - id_curr, foreach_libblock_remap_callback, (void *)r_id_remap_data, IDWALK_NOP); + NULL, id_curr, foreach_libblock_remap_callback, (void *)r_id_remap_data, IDWALK_NOP); } } } @@ -719,7 +719,7 @@ void BKE_libblock_relink_to_newid(ID *id) if (ID_IS_LINKED_DATABLOCK(id)) return; - BKE_library_foreach_ID_link(id, id_relink_to_newid_looper, NULL, 0); + BKE_library_foreach_ID_link(NULL, id, id_relink_to_newid_looper, NULL, 0); } void BKE_libblock_free_data(Main *UNUSED(bmain), ID *id) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 41f725ba2cb..09b3a7312bb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1204,7 +1204,7 @@ void BKE_object_make_local_ex(Main *bmain, Object *ob, const bool lib_local, con if (lib_local || is_local) { if (!is_lib) { id_clear_lib_data(bmain, &ob->id); - BKE_id_expand_local(&ob->id); + BKE_id_expand_local(bmain, &ob->id); if (clear_proxy) { if (ob->proxy_from != NULL) { ob->proxy_from->proxy = NULL; -- cgit v1.2.3 From bc4aeefe82205efbc9803ba158ec7055cb13ae11 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 30 Jan 2017 21:47:48 +0100 Subject: Make 'make local' twice quicker. Use new Main->relations ID usages mapping in BKE_library_make_local(). This allows a noticeable simplification in code, and can be up to twice quicker as previous code (Make Local: All from 2 to 1 minute e.g. in a huge production file with thousands of linked data-blocks). Note that new code has been successfuly tested with several complex cases (production files from Agent327), as well as some testcases from recent bug reports related to that function. But as always, nothing beats real usage by real users, so please check this before we release 2.79. ;) Main areas that would be affected: Make Local operations (L shortcut in 3DView), and append from libraries. --- source/blender/blenkernel/intern/library.c | 159 ++++++++++++++++++++++++++--- 1 file changed, 145 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 3f75bb8ec69..daa8c6f5e5c 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1704,6 +1704,53 @@ void BKE_main_id_clear_newpoins(Main *bmain) } } + +static void library_make_local_copying_check(ID *id, GSet *loop_tags, MainIDRelations *id_relations, GSet *done_ids) +{ + if (BLI_gset_haskey(done_ids, id)) { + return; /* Already checked, nothing else to do. */ + } + + MainIDRelationsEntry *entry = BLI_ghash_lookup(id_relations->id_used_to_user, id); + BLI_gset_insert(loop_tags, id); + for (; entry != NULL; entry = entry->next) { + ID *par_id = (ID *)entry->id_pointer; /* used_to_user stores ID pointer, not pointer to ID pointer... */ + + /* Shapekeys are considered 'private' to their owner ID here, and never tagged (since they cannot be linked), + * so we have to switch effective parent to their owner. */ + if (GS(par_id->name) == ID_KE) { + par_id = ((Key *)par_id)->from; + } + + if (par_id->lib == NULL) { + /* Local user, early out to avoid some gset querying... */ + continue; + } + if (!BLI_gset_haskey(done_ids, par_id)) { + if (BLI_gset_haskey(loop_tags, par_id)) { + /* We are in a 'dependency loop' of IDs, this does not say us anything, skip it. + * Note that this is the situation that can lead to archipelagoes of linked data-blocks + * (since all of them have non-local users, they would all be duplicated, leading to a loop of unused + * linked data-blocks that cannot be freed since they all use each other...). */ + continue; + } + /* Else, recursively check that user ID. */ + library_make_local_copying_check(par_id, loop_tags, id_relations, done_ids); + } + + if (par_id->tag & LIB_TAG_DOIT) { + /* This user will be fully local in future, so far so good, nothing to do here but check next user. */ + } + else { + /* This user won't be fully local in future, so current ID won't be either. And we are done checking it. */ + id->tag &= ~LIB_TAG_DOIT; + break; + } + } + BLI_gset_add(done_ids, id); + BLI_gset_remove(loop_tags, id, NULL); +} + /** Make linked datablocks local. * * \param bmain Almost certainly G.main. @@ -1714,11 +1761,10 @@ void BKE_main_id_clear_newpoins(Main *bmain) /* Note: Old (2.77) version was simply making (tagging) datablocks as local, without actually making any check whether * they were also indirectly used or not... * - * Current version uses regular id_make_local callback, which is not super-efficient since this ends up - * duplicating some IDs and then removing original ones (due to missing knowledge of which ID uses some other ID). - * - * However, we now have a first check that allows us to use 'direct localization' of a lot of IDs, so performances - * are now *reasonably* OK. + * Current version uses regular id_make_local callback, with advanced pre-processing step to detect all cases of + * IDs currently indirectly used, but which will be used by local data only once this function is finished. + * This allows to avoid any uneeded duplication of IDs, and hence all time lost afterwards to remove + * orphaned linked data-blocks... */ void BKE_library_make_local( Main *bmain, const Library *lib, GHash *old_to_new_ids, const bool untagged_only, const bool set_fake) @@ -1729,9 +1775,12 @@ void BKE_library_make_local( LinkNode *todo_ids = NULL; LinkNode *copied_ids = NULL; - LinkNode *linked_loop_candidates = NULL; MemArena *linklist_mem = BLI_memarena_new(512 * sizeof(*todo_ids), __func__); + BKE_main_relations_create(bmain); + + GSet *done_ids = BLI_gset_ptr_new(__func__); + /* Step 1: Detect datablocks to make local. */ for (a = set_listbasepointers(bmain, lbarray); a--; ) { id = lbarray[a]->first; @@ -1741,16 +1790,25 @@ void BKE_library_make_local( const bool do_skip = (id && !BKE_idcode_is_linkable(GS(id->name))); for (; id; id = id->next) { + ID *ntree = (ID *)ntreeFromID(id); + id->tag &= ~LIB_TAG_DOIT; + if (ntree != NULL) { + ntree->tag &= ~LIB_TAG_DOIT; + } if (id->lib == NULL) { id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW); } - /* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so its - * possible to tag data you don't want to be made local, used for - * appending data, so any libdata already linked wont become local - * (very nasty to discover all your links are lost after appending). + /* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so its possible to tag data you don't want to + * be made local, used for appending data, so any libdata already linked wont become local (very nasty + * to discover all your links are lost after appending). * Also, never ever make proxified objects local, would not make any sense. */ + /* Some more notes: + * - Shapekeys are never tagged here (since they are not linkable). + * - Nodetrees used in materials etc. have to be tagged manually, since they do not exist in Main (!). + * This is ok-ish on 'make local' side of things (since those are handled by their 'owner' IDs), + * but complicates slightly the pre-processing of relations between IDs at step 2... */ else if (!do_skip && id->tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW) && ELEM(lib, NULL, id->lib) && !(GS(id->name) == ID_OB && ((Object *)id)->proxy_from != NULL) && @@ -1758,13 +1816,32 @@ void BKE_library_make_local( { BLI_linklist_prepend_arena(&todo_ids, id, linklist_mem); id->tag |= LIB_TAG_DOIT; + + /* Tag those nasty non-ID nodetrees, but do not add them to todo list, making them local is handled + * by 'owner' ID. This is needed for library_make_local_copying_check() to work OK at step 2. */ + if (ntree != NULL) { + ntree->tag |= LIB_TAG_DOIT; + } + } + else { + /* Linked ID that we won't be making local (needed info for step 2, see below). */ + BLI_gset_add(done_ids, id); } } } /* Step 2: Check which datablocks we can directly make local (because they are only used by already, or future, - * local data), others will need to be duplicated and further processed later. */ - BKE_library_indirectly_used_data_tag_clear(bmain); + * local data), others will need to be duplicated. */ + GSet *loop_tags = BLI_gset_ptr_new(__func__); + for (LinkNode *it = todo_ids; it; it = it->next) { + library_make_local_copying_check(it->link, loop_tags, bmain->relations, done_ids); + BLI_assert(BLI_gset_size(loop_tags) == 0); + } + BLI_gset_free(loop_tags, NULL); + BLI_gset_free(done_ids, NULL); + + /* Next step will most likely add new IDs, better to get rid of this mapping now. */ + BKE_main_relations_free(bmain); /* Step 3: Make IDs local, either directly (quick and simple), or using generic process, * which involves more complex checks and might instead create a local copy of original linked ID. */ @@ -1774,7 +1851,7 @@ void BKE_library_make_local( if (id->tag & LIB_TAG_DOIT) { /* We know all users of this object are local or will be made fully local, even if currently there are - * some indirect usages. So instead of making a copy that se'll likely get rid of later, directly make + * some indirect usages. So instead of making a copy that we'll likely get rid of later, directly make * that data block local. Saves a tremendous amount of time with complex scenes... */ id_clear_lib_data_ex(bmain, id, true); BKE_id_expand_local(bmain, id); @@ -1813,6 +1890,9 @@ void BKE_library_make_local( /* Step 4: We have to remap local usages of old (linked) ID to new (local) id in a separated loop, * as lbarray ordering is not enough to ensure us we did catch all dependencies * (e.g. if making local a parent object before its child...). See T48907. */ + /* TODO This is now the biggest step by far (in term of processing time). We may be able to gain here by + * using again main->relations mapping, but... this implies BKE_libblock_remap & co to be able to update + * main->relations on the fly. Have to think about it a bit more, and see whether new code is OK first, anyway. */ for (LinkNode *it = copied_ids; it; it = it->next) { id = it->link; @@ -1831,6 +1911,53 @@ void BKE_library_make_local( } } + /* Note: Keeping both version of the code (old one being safer, since it still has checks against unused IDs) + * for now, we can remove old one once it has been tested for some time in master... */ +#if 1 + /* Step 5: proxy 'remapping' hack. */ + for (LinkNode *it = copied_ids; it; it = it->next) { + /* Attempt to re-link copied proxy objects. This allows appending of an entire scene + * from another blend file into this one, even when that blend file contains proxified + * armatures that have local references. Since the proxified object needs to be linked + * (not local), this will only work when the "Localize all" checkbox is disabled. + * TL;DR: this is a dirty hack on top of an already weak feature (proxies). */ + if (GS(id->name) == ID_OB && ((Object *)id)->proxy != NULL) { + Object *ob = (Object *)id; + Object *ob_new = (Object *)id->newid; + bool is_local = false, is_lib = false; + + /* Proxies only work when the proxified object is linked-in from a library. */ + if (ob->proxy->id.lib == NULL) { + printf("Warning, proxy object %s will loose its link to %s, because the " + "proxified object is local.\n", id->newid->name, ob->proxy->id.name); + continue; + } + + BKE_library_ID_test_usages(bmain, id, &is_local, &is_lib); + + /* We can only switch the proxy'ing to a made-local proxy if it is no longer + * referred to from a library. Not checking for local use; if new local proxy + * was not used locally would be a nasty bug! */ + if (is_local || is_lib) { + printf("Warning, made-local proxy object %s will loose its link to %s, " + "because the linked-in proxy is referenced (is_local=%i, is_lib=%i).\n", + id->newid->name, ob->proxy->id.name, is_local, is_lib); + } + else { + /* we can switch the proxy'ing from the linked-in to the made-local proxy. + * BKE_object_make_proxy() shouldn't be used here, as it allocates memory that + * was already allocated by BKE_object_make_local_ex() (which called BKE_object_copy_ex). */ + ob_new->proxy = ob->proxy; + ob_new->proxy_group = ob->proxy_group; + ob_new->proxy_from = ob->proxy_from; + ob_new->proxy->proxy_from = ob_new; + ob->proxy = ob->proxy_from = ob->proxy_group = NULL; + } + } + } +#else + LinkNode *linked_loop_candidates = NULL; + /* Step 5: remove datablocks that have been copied to be localized and are no more used in the end... * Note that we may have to loop more than once here, to tackle dependencies between linked objects... */ bool do_loop = true; @@ -1881,6 +2008,8 @@ void BKE_library_make_local( if (!is_local) { if (!is_lib) { /* Not used at all, we can free it! */ + BLI_assert(!"Unused linked data copy remaining from MakeLibLocal process, should not happen anymore"); + printf("\t%s (from %s)\n", id->name, id->lib->id.name); BKE_libblock_free(bmain, id); it->link = NULL; do_loop = true; @@ -1894,7 +2023,7 @@ void BKE_library_make_local( /* Grrrrrrr... those half-datablocks-stuff... grrrrrrrrrrr... * Here we have to also tag them as potential candidates, otherwise they would falsy report - * ID they used as 'directly used' in fourth step. */ + * ID they used as 'directly used' in sixth step. */ ID *ntree = (ID *)ntreeFromID(id); if (ntree != NULL) { ntree->tag |= LIB_TAG_DOIT; @@ -1919,6 +2048,7 @@ void BKE_library_make_local( /* Note: in theory here we are only handling datablocks forming exclusive linked dependency-cycles-based * archipelagos, so no need to check again after we have deleted one, as done in previous step. */ if (id->tag & LIB_TAG_DOIT) { + BLI_assert(!"Unused linked data copy remaining from MakeLibLocal process (archipelago case), should not happen anymore"); /* Object's deletion rely on valid ob->data, but ob->data may have already been freed here... * Setting it to NULL may not be 100% correct, but should be safe and do the work. */ if (GS(id->name) == ID_OB) { @@ -1939,6 +2069,7 @@ void BKE_library_make_local( it->link = NULL; } } +#endif BKE_main_id_clear_newpoins(bmain); BLI_memarena_free(linklist_mem); -- cgit v1.2.3 From a50b173952c85a51828f28569a9923bd29764292 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 30 Jan 2017 22:27:38 -0300 Subject: Use the same solution to test the pixel distance to the AABB, with BoundBox The previous solution took arbitrary values to determine if the mouse was near or not to the Bound Box (it simply scaled the Bound Box). Now the same function that detected the distance from the BVHTree nodes to the mouse is used in the Bound Box --- source/blender/blenkernel/intern/object.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 09b3a7312bb..e5393666a7e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1204,7 +1204,7 @@ void BKE_object_make_local_ex(Main *bmain, Object *ob, const bool lib_local, con if (lib_local || is_local) { if (!is_lib) { id_clear_lib_data(bmain, &ob->id); - BKE_id_expand_local(bmain, &ob->id); + BKE_id_expand_local(&ob->id); if (clear_proxy) { if (ob->proxy_from != NULL) { ob->proxy_from->proxy = NULL; @@ -2236,18 +2236,6 @@ void BKE_boundbox_minmax(const BoundBox *bb, float obmat[4][4], float r_min[3], } } -void BKE_boundbox_scale(struct BoundBox *bb_dst, const struct BoundBox *bb_src, float scale) -{ - float cent[3]; - BKE_boundbox_calc_center_aabb(bb_src, cent); - - for (int i = 0; i < ARRAY_SIZE(bb_dst->vec); i++) { - bb_dst->vec[i][0] = ((bb_src->vec[i][0] - cent[0]) * scale) + cent[0]; - bb_dst->vec[i][1] = ((bb_src->vec[i][1] - cent[1]) * scale) + cent[1]; - bb_dst->vec[i][2] = ((bb_src->vec[i][2] - cent[2]) * scale) + cent[2]; - } -} - /** * Returns a BBox which each dimensions are at least epsilon. * \note In case a given dimension needs to be enlarged, its final value will be in [epsilon, 3 * epsilon] range. -- cgit v1.2.3 From a928a9c1e199923090a6ea070332fb8003646590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Tue, 31 Jan 2017 06:59:11 +0100 Subject: Fix compilation error: too few arguments to function call. D2492 by @tomjpsun. --- source/blender/blenkernel/intern/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e5393666a7e..ff8be5892e9 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1204,7 +1204,7 @@ void BKE_object_make_local_ex(Main *bmain, Object *ob, const bool lib_local, con if (lib_local || is_local) { if (!is_lib) { id_clear_lib_data(bmain, &ob->id); - BKE_id_expand_local(&ob->id); + BKE_id_expand_local(bmain, &ob->id); if (clear_proxy) { if (ob->proxy_from != NULL) { ob->proxy_from->proxy = NULL; -- cgit v1.2.3 From 60e387f5e3ae41c4b1e507f5aa4d8673a9f8765f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 31 Jan 2017 09:47:59 +0100 Subject: Cleanup: Rename callback flags from library_query to `IDWALK_CB_...` Better to have clear way to tell whether flag is parameter for BKE_library_foreach_ID_link(), parameter for its callback function, or return value from this callback function. --- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/library_query.c | 234 ++++++++++----------- source/blender/blenkernel/intern/library_remap.c | 18 +- source/blender/blenkernel/intern/particle_system.c | 10 +- source/blender/blenkernel/intern/rigidbody.c | 8 +- source/blender/blenkernel/intern/sca.c | 44 ++-- 6 files changed, 158 insertions(+), 158 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index daa8c6f5e5c..7350e014d43 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -276,7 +276,7 @@ void BKE_id_clear_newpoin(ID *id) static int id_expand_local_callback( void *UNUSED(user_data), struct ID *id_self, struct ID **id_pointer, int cd_flag) { - if (cd_flag & IDWALK_PRIVATE) { + if (cd_flag & IDWALK_CB_PRIVATE) { return IDWALK_RET_NOP; } diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index 03c4b803350..9aaf2b24c5d 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -162,7 +162,7 @@ static void library_foreach_constraintObjectLooper(bConstraint *UNUSED(con), ID bool is_reference, void *user_data) { LibraryForeachIDData *data = (LibraryForeachIDData *) user_data; - const int cd_flag = is_reference ? IDWALK_USER : IDWALK_NOP; + const int cd_flag = is_reference ? IDWALK_CB_USER : IDWALK_CB_NOP; FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cd_flag); FOREACH_FINALIZE_VOID; @@ -208,7 +208,7 @@ static void library_foreach_nla_strip(LibraryForeachIDData *data, NlaStrip *stri { NlaStrip *substrip; - FOREACH_CALLBACK_INVOKE(data, strip->act, IDWALK_USER); + FOREACH_CALLBACK_INVOKE(data, strip->act, IDWALK_CB_USER); for (substrip = strip->strips.first; substrip; substrip = substrip->next) { library_foreach_nla_strip(data, substrip); @@ -231,14 +231,14 @@ static void library_foreach_animationData(LibraryForeachIDData *data, AnimData * /* only used targets */ DRIVER_TARGETS_USED_LOOPER(dvar) { - FOREACH_CALLBACK_INVOKE_ID(data, dtar->id, IDWALK_NOP); + FOREACH_CALLBACK_INVOKE_ID(data, dtar->id, IDWALK_CB_NOP); } DRIVER_TARGETS_LOOPER_END } } - FOREACH_CALLBACK_INVOKE(data, adt->action, IDWALK_USER); - FOREACH_CALLBACK_INVOKE(data, adt->tmpact, IDWALK_USER); + FOREACH_CALLBACK_INVOKE(data, adt->action, IDWALK_CB_USER); + FOREACH_CALLBACK_INVOKE(data, adt->tmpact, IDWALK_CB_USER); for (nla_track = adt->nla_tracks.first; nla_track; nla_track = nla_track->next) { for (nla_strip = nla_track->strips.first; nla_strip; nla_strip = nla_strip->next) { @@ -251,16 +251,16 @@ static void library_foreach_animationData(LibraryForeachIDData *data, AnimData * static void library_foreach_mtex(LibraryForeachIDData *data, MTex *mtex) { - FOREACH_CALLBACK_INVOKE(data, mtex->object, IDWALK_NOP); - FOREACH_CALLBACK_INVOKE(data, mtex->tex, IDWALK_USER); + FOREACH_CALLBACK_INVOKE(data, mtex->object, IDWALK_CB_NOP); + FOREACH_CALLBACK_INVOKE(data, mtex->tex, IDWALK_CB_USER); FOREACH_FINALIZE_VOID; } static void library_foreach_paint(LibraryForeachIDData *data, Paint *paint) { - FOREACH_CALLBACK_INVOKE(data, paint->brush, IDWALK_USER); - FOREACH_CALLBACK_INVOKE(data, paint->palette, IDWALK_USER); + FOREACH_CALLBACK_INVOKE(data, paint->brush, IDWALK_CB_USER); + FOREACH_CALLBACK_INVOKE(data, paint->palette, IDWALK_CB_USER); FOREACH_FINALIZE_VOID; } @@ -270,7 +270,7 @@ static void library_foreach_ID_as_subdata_link( { /* Needed e.g. for callbacks handling relationships... This call shall be absolutely readonly. */ ID *id = *id_pp; - FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pp, IDWALK_PRIVATE); + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pp, IDWALK_CB_PRIVATE); BLI_assert(id == *id_pp); if (flag & IDWALK_RECURSE) { @@ -323,7 +323,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call for (; id != NULL; id = (flag & IDWALK_RECURSE) ? BLI_LINKSTACK_POP(data.ids_todo) : NULL) { data.self_id = id; - data.cd_flag = ID_IS_LINKED_DATABLOCK(id) ? IDWALK_INDIRECT_USAGE : 0; + data.cd_flag = ID_IS_LINKED_DATABLOCK(id) ? IDWALK_CB_INDIRECT_USAGE : 0; if (bmain != NULL && bmain->relations != NULL && (flag & IDWALK_READONLY)) { /* Note that this is minor optimization, even in worst cases (like id being an object with lots of @@ -346,7 +346,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call case ID_LI: { Library *lib = (Library *) id; - CALLBACK_INVOKE(lib->parent, IDWALK_NOP); + CALLBACK_INVOKE(lib->parent, IDWALK_CB_NOP); break; } case ID_SCE: @@ -356,39 +356,39 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call SceneRenderLayer *srl; Base *base; - CALLBACK_INVOKE(scene->camera, IDWALK_NOP); - CALLBACK_INVOKE(scene->world, IDWALK_USER); - CALLBACK_INVOKE(scene->set, IDWALK_NOP); - CALLBACK_INVOKE(scene->clip, IDWALK_USER); + CALLBACK_INVOKE(scene->camera, IDWALK_CB_NOP); + CALLBACK_INVOKE(scene->world, IDWALK_CB_USER); + CALLBACK_INVOKE(scene->set, IDWALK_CB_NOP); + CALLBACK_INVOKE(scene->clip, IDWALK_CB_USER); if (scene->nodetree) { /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ library_foreach_ID_as_subdata_link((ID **)&scene->nodetree, callback, user_data, flag, &data); } /* DO NOT handle scene->basact here, it's doubling with the loop over whole scene->base later, * since basact is just a pointer to one of those items. */ - CALLBACK_INVOKE(scene->obedit, IDWALK_NOP); + CALLBACK_INVOKE(scene->obedit, IDWALK_CB_NOP); for (srl = scene->r.layers.first; srl; srl = srl->next) { FreestyleModuleConfig *fmc; FreestyleLineSet *fls; if (srl->mat_override) { - CALLBACK_INVOKE(srl->mat_override, IDWALK_USER); + CALLBACK_INVOKE(srl->mat_override, IDWALK_CB_USER); } if (srl->light_override) { - CALLBACK_INVOKE(srl->light_override, IDWALK_USER); + CALLBACK_INVOKE(srl->light_override, IDWALK_CB_USER); } for (fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) { if (fmc->script) { - CALLBACK_INVOKE(fmc->script, IDWALK_NOP); + CALLBACK_INVOKE(fmc->script, IDWALK_CB_NOP); } } for (fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) { if (fls->group) { - CALLBACK_INVOKE(fls->group, IDWALK_USER); + CALLBACK_INVOKE(fls->group, IDWALK_CB_USER); } if (fls->linestyle) { - CALLBACK_INVOKE(fls->linestyle, IDWALK_USER); + CALLBACK_INVOKE(fls->linestyle, IDWALK_CB_USER); } } } @@ -397,39 +397,39 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call Sequence *seq; SEQP_BEGIN(scene->ed, seq) { - CALLBACK_INVOKE(seq->scene, IDWALK_NOP); - CALLBACK_INVOKE(seq->scene_camera, IDWALK_NOP); - CALLBACK_INVOKE(seq->clip, IDWALK_USER); - CALLBACK_INVOKE(seq->mask, IDWALK_USER); - CALLBACK_INVOKE(seq->sound, IDWALK_USER); + CALLBACK_INVOKE(seq->scene, IDWALK_CB_NOP); + CALLBACK_INVOKE(seq->scene_camera, IDWALK_CB_NOP); + CALLBACK_INVOKE(seq->clip, IDWALK_CB_USER); + CALLBACK_INVOKE(seq->mask, IDWALK_CB_USER); + CALLBACK_INVOKE(seq->sound, IDWALK_CB_USER); for (SequenceModifierData *smd = seq->modifiers.first; smd; smd = smd->next) { - CALLBACK_INVOKE(smd->mask_id, IDWALK_USER); + CALLBACK_INVOKE(smd->mask_id, IDWALK_CB_USER); } } SEQ_END } - CALLBACK_INVOKE(scene->gpd, IDWALK_USER); + CALLBACK_INVOKE(scene->gpd, IDWALK_CB_USER); for (base = scene->base.first; base; base = base->next) { - CALLBACK_INVOKE(base->object, IDWALK_USER); + CALLBACK_INVOKE(base->object, IDWALK_CB_USER); } for (TimeMarker *marker = scene->markers.first; marker; marker = marker->next) { - CALLBACK_INVOKE(marker->camera, IDWALK_NOP); + CALLBACK_INVOKE(marker->camera, IDWALK_CB_NOP); } if (toolsett) { - CALLBACK_INVOKE(toolsett->skgen_template, IDWALK_NOP); + CALLBACK_INVOKE(toolsett->skgen_template, IDWALK_CB_NOP); - CALLBACK_INVOKE(toolsett->particle.scene, IDWALK_NOP); - CALLBACK_INVOKE(toolsett->particle.object, IDWALK_NOP); - CALLBACK_INVOKE(toolsett->particle.shape_object, IDWALK_NOP); + CALLBACK_INVOKE(toolsett->particle.scene, IDWALK_CB_NOP); + CALLBACK_INVOKE(toolsett->particle.object, IDWALK_CB_NOP); + CALLBACK_INVOKE(toolsett->particle.shape_object, IDWALK_CB_NOP); library_foreach_paint(&data, &toolsett->imapaint.paint); - CALLBACK_INVOKE(toolsett->imapaint.stencil, IDWALK_USER); - CALLBACK_INVOKE(toolsett->imapaint.clone, IDWALK_USER); - CALLBACK_INVOKE(toolsett->imapaint.canvas, IDWALK_USER); + CALLBACK_INVOKE(toolsett->imapaint.stencil, IDWALK_CB_USER); + CALLBACK_INVOKE(toolsett->imapaint.clone, IDWALK_CB_USER); + CALLBACK_INVOKE(toolsett->imapaint.canvas, IDWALK_CB_USER); if (toolsett->vpaint) { library_foreach_paint(&data, &toolsett->vpaint->paint); @@ -439,7 +439,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call } if (toolsett->sculpt) { library_foreach_paint(&data, &toolsett->sculpt->paint); - CALLBACK_INVOKE(toolsett->sculpt->gravity_object, IDWALK_NOP); + CALLBACK_INVOKE(toolsett->sculpt->gravity_object, IDWALK_CB_NOP); } if (toolsett->uvsculpt) { library_foreach_paint(&data, &toolsett->uvsculpt->paint); @@ -450,7 +450,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call BKE_rigidbody_world_id_loop(scene->rigidbody_world, library_foreach_rigidbodyworldSceneLooper, &data); } - CALLBACK_INVOKE(scene->gm.dome.warptext, IDWALK_NOP); + CALLBACK_INVOKE(scene->gm.dome.warptext, IDWALK_CB_NOP); break; } @@ -462,51 +462,51 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call /* Object is special, proxies make things hard... */ const int data_cd_flag = data.cd_flag; - const int proxy_cd_flag = (object->proxy || object->proxy_group) ? IDWALK_INDIRECT_USAGE : 0; + const int proxy_cd_flag = (object->proxy || object->proxy_group) ? IDWALK_CB_INDIRECT_USAGE : 0; /* object data special case */ data.cd_flag |= proxy_cd_flag; if (object->type == OB_EMPTY) { /* empty can have NULL or Image */ - CALLBACK_INVOKE_ID(object->data, IDWALK_USER); + CALLBACK_INVOKE_ID(object->data, IDWALK_CB_USER); } else { /* when set, this can't be NULL */ if (object->data) { - CALLBACK_INVOKE_ID(object->data, IDWALK_USER | IDWALK_NEVER_NULL); + CALLBACK_INVOKE_ID(object->data, IDWALK_CB_USER | IDWALK_CB_NEVER_NULL); } } data.cd_flag = data_cd_flag; - CALLBACK_INVOKE(object->parent, IDWALK_NOP); - CALLBACK_INVOKE(object->track, IDWALK_NOP); + CALLBACK_INVOKE(object->parent, IDWALK_CB_NOP); + CALLBACK_INVOKE(object->track, IDWALK_CB_NOP); /* object->proxy is refcounted, but not object->proxy_group... *sigh* */ - CALLBACK_INVOKE(object->proxy, IDWALK_USER); - CALLBACK_INVOKE(object->proxy_group, IDWALK_NOP); + CALLBACK_INVOKE(object->proxy, IDWALK_CB_USER); + CALLBACK_INVOKE(object->proxy_group, IDWALK_CB_NOP); /* Special case! * Since this field is set/owned by 'user' of this ID (and not ID itself), it is only indirect usage * if proxy object is linked... Twisted. */ if (object->proxy_from) { - data.cd_flag = ID_IS_LINKED_DATABLOCK(object->proxy_from) ? IDWALK_INDIRECT_USAGE : 0; + data.cd_flag = ID_IS_LINKED_DATABLOCK(object->proxy_from) ? IDWALK_CB_INDIRECT_USAGE : 0; } - CALLBACK_INVOKE(object->proxy_from, IDWALK_NOP); + CALLBACK_INVOKE(object->proxy_from, IDWALK_CB_NOP); data.cd_flag = data_cd_flag; - CALLBACK_INVOKE(object->poselib, IDWALK_USER); + CALLBACK_INVOKE(object->poselib, IDWALK_CB_USER); data.cd_flag |= proxy_cd_flag; for (i = 0; i < object->totcol; i++) { - CALLBACK_INVOKE(object->mat[i], IDWALK_USER); + CALLBACK_INVOKE(object->mat[i], IDWALK_CB_USER); } data.cd_flag = data_cd_flag; - CALLBACK_INVOKE(object->gpd, IDWALK_USER); - CALLBACK_INVOKE(object->dup_group, IDWALK_USER); + CALLBACK_INVOKE(object->gpd, IDWALK_CB_USER); + CALLBACK_INVOKE(object->dup_group, IDWALK_CB_USER); if (object->pd) { - CALLBACK_INVOKE(object->pd->tex, IDWALK_USER); - CALLBACK_INVOKE(object->pd->f_source, IDWALK_NOP); + CALLBACK_INVOKE(object->pd->tex, IDWALK_CB_USER); + CALLBACK_INVOKE(object->pd->f_source, IDWALK_CB_NOP); } /* Note that ob->effect is deprecated, so no need to handle it here. */ @@ -515,21 +515,21 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call data.cd_flag |= proxy_cd_flag; for (pchan = object->pose->chanbase.first; pchan; pchan = pchan->next) { - CALLBACK_INVOKE(pchan->custom, IDWALK_USER); + CALLBACK_INVOKE(pchan->custom, IDWALK_CB_USER); BKE_constraints_id_loop(&pchan->constraints, library_foreach_constraintObjectLooper, &data); } data.cd_flag = data_cd_flag; } if (object->rigidbody_constraint) { - CALLBACK_INVOKE(object->rigidbody_constraint->ob1, IDWALK_NOP); - CALLBACK_INVOKE(object->rigidbody_constraint->ob2, IDWALK_NOP); + CALLBACK_INVOKE(object->rigidbody_constraint->ob1, IDWALK_CB_NOP); + CALLBACK_INVOKE(object->rigidbody_constraint->ob2, IDWALK_CB_NOP); } if (object->lodlevels.first) { LodLevel *level; for (level = object->lodlevels.first; level; level = level->next) { - CALLBACK_INVOKE(level->source, IDWALK_NOP); + CALLBACK_INVOKE(level->source, IDWALK_CB_NOP); } } @@ -541,10 +541,10 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call } if (object->soft) { - CALLBACK_INVOKE(object->soft->collision_group, IDWALK_NOP); + CALLBACK_INVOKE(object->soft->collision_group, IDWALK_CB_NOP); if (object->soft->effector_weights) { - CALLBACK_INVOKE(object->soft->effector_weights->group, IDWALK_NOP); + CALLBACK_INVOKE(object->soft->effector_weights->group, IDWALK_CB_NOP); } } @@ -557,10 +557,10 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call case ID_ME: { Mesh *mesh = (Mesh *) id; - CALLBACK_INVOKE(mesh->texcomesh, IDWALK_USER); - CALLBACK_INVOKE(mesh->key, IDWALK_USER); + CALLBACK_INVOKE(mesh->texcomesh, IDWALK_CB_USER); + CALLBACK_INVOKE(mesh->key, IDWALK_CB_USER); for (i = 0; i < mesh->totcol; i++) { - CALLBACK_INVOKE(mesh->mat[i], IDWALK_USER); + CALLBACK_INVOKE(mesh->mat[i], IDWALK_CB_USER); } /* XXX Really not happy with this - probably texface should rather use some kind of @@ -572,7 +572,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call MTexPoly *txface = (MTexPoly *)mesh->pdata.layers[i].data; for (int j = 0; j < mesh->totpoly; j++, txface++) { - CALLBACK_INVOKE(txface->tpage, IDWALK_USER_ONE); + CALLBACK_INVOKE(txface->tpage, IDWALK_CB_USER_ONE); } } } @@ -582,7 +582,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call MTFace *tface = (MTFace *)mesh->fdata.layers[i].data; for (int j = 0; j < mesh->totface; j++, tface++) { - CALLBACK_INVOKE(tface->tpage, IDWALK_USER_ONE); + CALLBACK_INVOKE(tface->tpage, IDWALK_CB_USER_ONE); } } } @@ -593,17 +593,17 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call case ID_CU: { Curve *curve = (Curve *) id; - CALLBACK_INVOKE(curve->bevobj, IDWALK_NOP); - CALLBACK_INVOKE(curve->taperobj, IDWALK_NOP); - CALLBACK_INVOKE(curve->textoncurve, IDWALK_NOP); - CALLBACK_INVOKE(curve->key, IDWALK_USER); + CALLBACK_INVOKE(curve->bevobj, IDWALK_CB_NOP); + CALLBACK_INVOKE(curve->taperobj, IDWALK_CB_NOP); + CALLBACK_INVOKE(curve->textoncurve, IDWALK_CB_NOP); + CALLBACK_INVOKE(curve->key, IDWALK_CB_USER); for (i = 0; i < curve->totcol; i++) { - CALLBACK_INVOKE(curve->mat[i], IDWALK_USER); + CALLBACK_INVOKE(curve->mat[i], IDWALK_CB_USER); } - CALLBACK_INVOKE(curve->vfont, IDWALK_USER); - CALLBACK_INVOKE(curve->vfontb, IDWALK_USER); - CALLBACK_INVOKE(curve->vfonti, IDWALK_USER); - CALLBACK_INVOKE(curve->vfontbi, IDWALK_USER); + CALLBACK_INVOKE(curve->vfont, IDWALK_CB_USER); + CALLBACK_INVOKE(curve->vfontb, IDWALK_CB_USER); + CALLBACK_INVOKE(curve->vfonti, IDWALK_CB_USER); + CALLBACK_INVOKE(curve->vfontbi, IDWALK_CB_USER); break; } @@ -611,7 +611,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call { MetaBall *metaball = (MetaBall *) id; for (i = 0; i < metaball->totcol; i++) { - CALLBACK_INVOKE(metaball->mat[i], IDWALK_USER); + CALLBACK_INVOKE(metaball->mat[i], IDWALK_CB_USER); } break; } @@ -628,7 +628,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ library_foreach_ID_as_subdata_link((ID **)&material->nodetree, callback, user_data, flag, &data); } - CALLBACK_INVOKE(material->group, IDWALK_USER); + CALLBACK_INVOKE(material->group, IDWALK_CB_USER); break; } @@ -639,24 +639,24 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ library_foreach_ID_as_subdata_link((ID **)&texture->nodetree, callback, user_data, flag, &data); } - CALLBACK_INVOKE(texture->ima, IDWALK_USER); + CALLBACK_INVOKE(texture->ima, IDWALK_CB_USER); if (texture->env) { - CALLBACK_INVOKE(texture->env->object, IDWALK_NOP); - CALLBACK_INVOKE(texture->env->ima, IDWALK_USER); + CALLBACK_INVOKE(texture->env->object, IDWALK_CB_NOP); + CALLBACK_INVOKE(texture->env->ima, IDWALK_CB_USER); } if (texture->pd) - CALLBACK_INVOKE(texture->pd->object, IDWALK_NOP); + CALLBACK_INVOKE(texture->pd->object, IDWALK_CB_NOP); if (texture->vd) - CALLBACK_INVOKE(texture->vd->object, IDWALK_NOP); + CALLBACK_INVOKE(texture->vd->object, IDWALK_CB_NOP); if (texture->ot) - CALLBACK_INVOKE(texture->ot->object, IDWALK_NOP); + CALLBACK_INVOKE(texture->ot->object, IDWALK_CB_NOP); break; } case ID_LT: { Lattice *lattice = (Lattice *) id; - CALLBACK_INVOKE(lattice->key, IDWALK_USER); + CALLBACK_INVOKE(lattice->key, IDWALK_CB_USER); break; } @@ -678,7 +678,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call case ID_CA: { Camera *camera = (Camera *) id; - CALLBACK_INVOKE(camera->dof_ob, IDWALK_NOP); + CALLBACK_INVOKE(camera->dof_ob, IDWALK_CB_NOP); break; } @@ -689,14 +689,14 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call * (see also foreach_libblock_id_users_callback). */ Key *key = (Key *) id; - CALLBACK_INVOKE_ID(key->from, IDWALK_NOP); + CALLBACK_INVOKE_ID(key->from, IDWALK_CB_NOP); break; } case ID_SCR: { bScreen *screen = (bScreen *) id; - CALLBACK_INVOKE(screen->scene, IDWALK_USER_ONE); + CALLBACK_INVOKE(screen->scene, IDWALK_CB_USER_ONE); break; } @@ -718,7 +718,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call case ID_SPK: { Speaker *speaker = (Speaker *) id; - CALLBACK_INVOKE(speaker->sound, IDWALK_USER); + CALLBACK_INVOKE(speaker->sound, IDWALK_CB_USER); break; } @@ -727,7 +727,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call Group *group = (Group *) id; GroupObject *gob; for (gob = group->gobject.first; gob; gob = gob->next) { - CALLBACK_INVOKE(gob->ob, IDWALK_USER_ONE); + CALLBACK_INVOKE(gob->ob, IDWALK_CB_USER_ONE); } break; } @@ -736,9 +736,9 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call { bNodeTree *ntree = (bNodeTree *) id; bNode *node; - CALLBACK_INVOKE(ntree->gpd, IDWALK_USER); + CALLBACK_INVOKE(ntree->gpd, IDWALK_CB_USER); for (node = ntree->nodes.first; node; node = node->next) { - CALLBACK_INVOKE_ID(node->id, IDWALK_USER); + CALLBACK_INVOKE_ID(node->id, IDWALK_CB_USER); } break; } @@ -746,9 +746,9 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call case ID_BR: { Brush *brush = (Brush *) id; - CALLBACK_INVOKE(brush->toggle_brush, IDWALK_NOP); - CALLBACK_INVOKE(brush->clone.image, IDWALK_NOP); - CALLBACK_INVOKE(brush->paint_curve, IDWALK_USER); + CALLBACK_INVOKE(brush->toggle_brush, IDWALK_CB_NOP); + CALLBACK_INVOKE(brush->clone.image, IDWALK_CB_NOP); + CALLBACK_INVOKE(brush->paint_curve, IDWALK_CB_USER); library_foreach_mtex(&data, &brush->mtex); library_foreach_mtex(&data, &brush->mask_mtex); break; @@ -757,10 +757,10 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call case ID_PA: { ParticleSettings *psett = (ParticleSettings *) id; - CALLBACK_INVOKE(psett->dup_group, IDWALK_NOP); - CALLBACK_INVOKE(psett->dup_ob, IDWALK_NOP); - CALLBACK_INVOKE(psett->bb_ob, IDWALK_NOP); - CALLBACK_INVOKE(psett->collision_group, IDWALK_NOP); + CALLBACK_INVOKE(psett->dup_group, IDWALK_CB_NOP); + CALLBACK_INVOKE(psett->dup_ob, IDWALK_CB_NOP); + CALLBACK_INVOKE(psett->bb_ob, IDWALK_CB_NOP); + CALLBACK_INVOKE(psett->collision_group, IDWALK_CB_NOP); for (i = 0; i < MAX_MTEX; i++) { if (psett->mtex[i]) { @@ -769,16 +769,16 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call } if (psett->effector_weights) { - CALLBACK_INVOKE(psett->effector_weights->group, IDWALK_NOP); + CALLBACK_INVOKE(psett->effector_weights->group, IDWALK_CB_NOP); } if (psett->pd) { - CALLBACK_INVOKE(psett->pd->tex, IDWALK_USER); - CALLBACK_INVOKE(psett->pd->f_source, IDWALK_NOP); + CALLBACK_INVOKE(psett->pd->tex, IDWALK_CB_USER); + CALLBACK_INVOKE(psett->pd->f_source, IDWALK_CB_NOP); } if (psett->pd2) { - CALLBACK_INVOKE(psett->pd2->tex, IDWALK_USER); - CALLBACK_INVOKE(psett->pd2->f_source, IDWALK_NOP); + CALLBACK_INVOKE(psett->pd2->tex, IDWALK_CB_USER); + CALLBACK_INVOKE(psett->pd2->f_source, IDWALK_CB_NOP); } if (psett->boids) { @@ -789,11 +789,11 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call for (rule = state->rules.first; rule; rule = rule->next) { if (rule->type == eBoidRuleType_Avoid) { BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule; - CALLBACK_INVOKE(gabr->ob, IDWALK_NOP); + CALLBACK_INVOKE(gabr->ob, IDWALK_CB_NOP); } else if (rule->type == eBoidRuleType_FollowLeader) { BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule; - CALLBACK_INVOKE(flbr->ob, IDWALK_NOP); + CALLBACK_INVOKE(flbr->ob, IDWALK_CB_NOP); } } } @@ -809,19 +809,19 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call MovieTrackingTrack *track; MovieTrackingPlaneTrack *plane_track; - CALLBACK_INVOKE(clip->gpd, IDWALK_USER); + CALLBACK_INVOKE(clip->gpd, IDWALK_CB_USER); for (track = tracking->tracks.first; track; track = track->next) { - CALLBACK_INVOKE(track->gpd, IDWALK_USER); + CALLBACK_INVOKE(track->gpd, IDWALK_CB_USER); } for (object = tracking->objects.first; object; object = object->next) { for (track = object->tracks.first; track; track = track->next) { - CALLBACK_INVOKE(track->gpd, IDWALK_USER); + CALLBACK_INVOKE(track->gpd, IDWALK_CB_USER); } } for (plane_track = tracking->plane_tracks.first; plane_track; plane_track = plane_track->next) { - CALLBACK_INVOKE(plane_track->image, IDWALK_USER); + CALLBACK_INVOKE(plane_track->image, IDWALK_CB_USER); } break; } @@ -836,7 +836,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call for (mask_spline = mask_layer->splines.first; mask_spline; mask_spline = mask_spline->next) { for (i = 0; i < mask_spline->tot_point; i++) { MaskSplinePoint *point = &mask_spline->points[i]; - CALLBACK_INVOKE_ID(point->parent.id, IDWALK_USER); + CALLBACK_INVOKE_ID(point->parent.id, IDWALK_CB_USER); } } } @@ -861,7 +861,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) { LineStyleColorModifier_DistanceFromObject *p = (LineStyleColorModifier_DistanceFromObject *)lsm; if (p->target) { - CALLBACK_INVOKE(p->target, IDWALK_NOP); + CALLBACK_INVOKE(p->target, IDWALK_CB_NOP); } } } @@ -869,7 +869,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) { LineStyleAlphaModifier_DistanceFromObject *p = (LineStyleAlphaModifier_DistanceFromObject *)lsm; if (p->target) { - CALLBACK_INVOKE(p->target, IDWALK_NOP); + CALLBACK_INVOKE(p->target, IDWALK_CB_NOP); } } } @@ -877,7 +877,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call if (lsm->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) { LineStyleThicknessModifier_DistanceFromObject *p = (LineStyleThicknessModifier_DistanceFromObject *)lsm; if (p->target) { - CALLBACK_INVOKE(p->target, IDWALK_NOP); + CALLBACK_INVOKE(p->target, IDWALK_CB_NOP); } } } @@ -888,7 +888,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call bAction *act = (bAction *) id; for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { - CALLBACK_INVOKE(marker->camera, IDWALK_NOP); + CALLBACK_INVOKE(marker->camera, IDWALK_CB_NOP); } break; } @@ -931,11 +931,11 @@ FOREACH_FINALIZE: */ void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cd_flag) { - if (cd_flag & IDWALK_USER) { + if (cd_flag & IDWALK_CB_USER) { id_us_min(id_src); id_us_plus(id_dst); } - else if (cd_flag & IDWALK_USER_ONE) { + else if (cd_flag & IDWALK_CB_USER_ONE) { id_us_ensure_real(id_dst); } } @@ -1069,7 +1069,7 @@ static int foreach_libblock_id_users_callback(void *user_data, ID *self_id, ID * (iter->id->tag & LIB_TAG_EXTRAUSER) ? 1 : 0, (iter->id->tag & LIB_TAG_EXTRAUSER_SET) ? 1 : 0, (cb_flag & IDWALK_INDIRECT_USAGE) ? 1 : 0); #endif - if (cb_flag & IDWALK_INDIRECT_USAGE) { + if (cb_flag & IDWALK_CB_INDIRECT_USAGE) { iter->count_indirect++; } else { diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index ff66c37a09b..91896ebdc66 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -158,7 +158,7 @@ enum { static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id_p, int cb_flag) { - if (cb_flag & IDWALK_PRIVATE) { + if (cb_flag & IDWALK_CB_PRIVATE) { return IDWALK_RET_NOP; } @@ -173,14 +173,14 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id } if (*id_p && (*id_p == old_id)) { - const bool is_indirect = (cb_flag & IDWALK_INDIRECT_USAGE) != 0; + const bool is_indirect = (cb_flag & IDWALK_CB_INDIRECT_USAGE) != 0; const bool skip_indirect = (id_remap_data->flag & ID_REMAP_SKIP_INDIRECT_USAGE) != 0; /* Note: proxy usage implies LIB_TAG_EXTERN, so on this aspect it is direct, * on the other hand since they get reset to lib data on file open/reload it is indirect too... * Edit Mode is also a 'skip direct' case. */ const bool is_obj = (GS(id->name) == ID_OB); const bool is_obj_editmode = (is_obj && BKE_object_is_in_editmode((Object *)id)); - const bool is_never_null = ((cb_flag & IDWALK_NEVER_NULL) && (new_id == NULL) && + const bool is_never_null = ((cb_flag & IDWALK_CB_NEVER_NULL) && (new_id == NULL) && (id_remap_data->flag & ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0); const bool skip_never_null = (id_remap_data->flag & ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0; @@ -189,7 +189,7 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id id->name, old_id->name, old_id, new_id ? new_id->name : "", new_id, skip_indirect); #endif - if ((id_remap_data->flag & ID_REMAP_FLAG_NEVER_NULL_USAGE) && (cb_flag & IDWALK_NEVER_NULL)) { + if ((id_remap_data->flag & ID_REMAP_FLAG_NEVER_NULL_USAGE) && (cb_flag & IDWALK_CB_NEVER_NULL)) { id->tag |= LIB_TAG_DOIT; } @@ -207,10 +207,10 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id else { BLI_assert(0); } - if (cb_flag & IDWALK_USER) { + if (cb_flag & IDWALK_CB_USER) { id_remap_data->skipped_refcounted++; } - else if (cb_flag & IDWALK_USER_ONE) { + else if (cb_flag & IDWALK_CB_USER_ONE) { /* No need to count number of times this happens, just a flag is enough. */ id_remap_data->status |= ID_REMAP_IS_USER_ONE_SKIPPED; } @@ -220,13 +220,13 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id *id_p = new_id; DAG_id_tag_update_ex(id_remap_data->bmain, id_self, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } - if (cb_flag & IDWALK_USER) { + if (cb_flag & IDWALK_CB_USER) { id_us_min(old_id); /* We do not want to handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */ if (new_id) new_id->us++; } - else if (cb_flag & IDWALK_USER_ONE) { + else if (cb_flag & IDWALK_CB_USER_ONE) { id_us_ensure_real(new_id); /* We cannot affect old_id->us directly, LIB_TAG_EXTRAUSER(_SET) are assumed to be set as needed, * that extra user is processed in final handling... */ @@ -691,7 +691,7 @@ void BKE_libblock_relink_ex( static int id_relink_to_newid_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag) { - if (cd_flag & IDWALK_PRIVATE) { + if (cd_flag & IDWALK_CB_PRIVATE) { return IDWALK_RET_NOP; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index ee435051151..943dc781246 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4328,12 +4328,12 @@ void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func, { ParticleTarget *pt; - func(psys, (ID **)&psys->part, userdata, IDWALK_USER | IDWALK_NEVER_NULL); - func(psys, (ID **)&psys->target_ob, userdata, IDWALK_NOP); - func(psys, (ID **)&psys->parent, userdata, IDWALK_NOP); + func(psys, (ID **)&psys->part, userdata, IDWALK_CB_USER | IDWALK_CB_NEVER_NULL); + func(psys, (ID **)&psys->target_ob, userdata, IDWALK_CB_NOP); + func(psys, (ID **)&psys->parent, userdata, IDWALK_CB_NOP); for (pt = psys->targets.first; pt; pt = pt->next) { - func(psys, (ID **)&pt->ob, userdata, IDWALK_NOP); + func(psys, (ID **)&pt->ob, userdata, IDWALK_CB_NOP); } /* Even though psys->part should never be NULL, this can happen as an exception during deletion. @@ -4343,7 +4343,7 @@ void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func, int p; for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) { - func(psys, (ID **)&pa->boid->ground, userdata, IDWALK_NOP); + func(psys, (ID **)&pa->boid->ground, userdata, IDWALK_CB_NOP); } } } diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index b5f34a29ebb..5353cc26295 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -974,14 +974,14 @@ void BKE_rigidbody_world_groups_relink(RigidBodyWorld *rbw) void BKE_rigidbody_world_id_loop(RigidBodyWorld *rbw, RigidbodyWorldIDFunc func, void *userdata) { - func(rbw, (ID **)&rbw->group, userdata, IDWALK_NOP); - func(rbw, (ID **)&rbw->constraints, userdata, IDWALK_NOP); - func(rbw, (ID **)&rbw->effector_weights->group, userdata, IDWALK_NOP); + func(rbw, (ID **)&rbw->group, userdata, IDWALK_CB_NOP); + func(rbw, (ID **)&rbw->constraints, userdata, IDWALK_CB_NOP); + func(rbw, (ID **)&rbw->effector_weights->group, userdata, IDWALK_CB_NOP); if (rbw->objects) { int i; for (i = 0; i < rbw->numbodies; i++) { - func(rbw, (ID **)&rbw->objects[i], userdata, IDWALK_NOP); + func(rbw, (ID **)&rbw->objects[i], userdata, IDWALK_CB_NOP); } } } diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index fa221348932..7920d8b5696 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -992,19 +992,19 @@ void BKE_sca_sensors_id_loop(ListBase *senslist, SCASensorIDFunc func, void *use bSensor *sensor; for (sensor = senslist->first; sensor; sensor = sensor->next) { - func(sensor, (ID **)&sensor->ob, userdata, IDWALK_NOP); + func(sensor, (ID **)&sensor->ob, userdata, IDWALK_CB_NOP); switch (sensor->type) { case SENS_TOUCH: /* DEPRECATED */ { bTouchSensor *ts = sensor->data; - func(sensor, (ID **)&ts->ma, userdata, IDWALK_NOP); + func(sensor, (ID **)&ts->ma, userdata, IDWALK_CB_NOP); break; } case SENS_MESSAGE: { bMessageSensor *ms = sensor->data; - func(sensor, (ID **)&ms->fromObject, userdata, IDWALK_NOP); + func(sensor, (ID **)&ms->fromObject, userdata, IDWALK_CB_NOP); break; } case SENS_ALWAYS: @@ -1035,7 +1035,7 @@ void BKE_sca_controllers_id_loop(ListBase *contlist, SCAControllerIDFunc func, v case CONT_PYTHON: { bPythonCont *pc = controller->data; - func(controller, (ID **)&pc->text, userdata, IDWALK_NOP); + func(controller, (ID **)&pc->text, userdata, IDWALK_CB_NOP); break; } case CONT_LOGIC_AND: @@ -1056,89 +1056,89 @@ void BKE_sca_actuators_id_loop(ListBase *actlist, SCAActuatorIDFunc func, void * bActuator *actuator; for (actuator = actlist->first; actuator; actuator = actuator->next) { - func(actuator, (ID **)&actuator->ob, userdata, IDWALK_NOP); + func(actuator, (ID **)&actuator->ob, userdata, IDWALK_CB_NOP); switch (actuator->type) { case ACT_ADD_OBJECT: /* DEPRECATED */ { bAddObjectActuator *aoa = actuator->data; - func(actuator, (ID **)&aoa->ob, userdata, IDWALK_NOP); + func(actuator, (ID **)&aoa->ob, userdata, IDWALK_CB_NOP); break; } case ACT_ACTION: { bActionActuator *aa = actuator->data; - func(actuator, (ID **)&aa->act, userdata, IDWALK_NOP); + func(actuator, (ID **)&aa->act, userdata, IDWALK_CB_NOP); break; } case ACT_SOUND: { bSoundActuator *sa = actuator->data; - func(actuator, (ID **)&sa->sound, userdata, IDWALK_NOP); + func(actuator, (ID **)&sa->sound, userdata, IDWALK_CB_NOP); break; } case ACT_EDIT_OBJECT: { bEditObjectActuator *eoa = actuator->data; - func(actuator, (ID **)&eoa->ob, userdata, IDWALK_NOP); - func(actuator, (ID **)&eoa->me, userdata, IDWALK_NOP); + func(actuator, (ID **)&eoa->ob, userdata, IDWALK_CB_NOP); + func(actuator, (ID **)&eoa->me, userdata, IDWALK_CB_NOP); break; } case ACT_SCENE: { bSceneActuator *sa = actuator->data; - func(actuator, (ID **)&sa->scene, userdata, IDWALK_NOP); - func(actuator, (ID **)&sa->camera, userdata, IDWALK_NOP); + func(actuator, (ID **)&sa->scene, userdata, IDWALK_CB_NOP); + func(actuator, (ID **)&sa->camera, userdata, IDWALK_CB_NOP); break; } case ACT_PROPERTY: { bPropertyActuator *pa = actuator->data; - func(actuator, (ID **)&pa->ob, userdata, IDWALK_NOP); + func(actuator, (ID **)&pa->ob, userdata, IDWALK_CB_NOP); break; } case ACT_OBJECT: { bObjectActuator *oa = actuator->data; - func(actuator, (ID **)&oa->reference, userdata, IDWALK_NOP); + func(actuator, (ID **)&oa->reference, userdata, IDWALK_CB_NOP); break; } case ACT_CAMERA: { bCameraActuator *ca = actuator->data; - func(actuator, (ID **)&ca->ob, userdata, IDWALK_NOP); + func(actuator, (ID **)&ca->ob, userdata, IDWALK_CB_NOP); break; } case ACT_MESSAGE: { bMessageActuator *ma = actuator->data; - func(actuator, (ID **)&ma->toObject, userdata, IDWALK_NOP); + func(actuator, (ID **)&ma->toObject, userdata, IDWALK_CB_NOP); break; } case ACT_2DFILTER: { bTwoDFilterActuator *tdfa = actuator->data; - func(actuator, (ID **)&tdfa->text, userdata, IDWALK_NOP); + func(actuator, (ID **)&tdfa->text, userdata, IDWALK_CB_NOP); break; } case ACT_PARENT: { bParentActuator *pa = actuator->data; - func(actuator, (ID **)&pa->ob, userdata, IDWALK_NOP); + func(actuator, (ID **)&pa->ob, userdata, IDWALK_CB_NOP); break; } case ACT_ARMATURE: { bArmatureActuator *aa = actuator->data; - func(actuator, (ID **)&aa->target, userdata, IDWALK_NOP); - func(actuator, (ID **)&aa->subtarget, userdata, IDWALK_NOP); + func(actuator, (ID **)&aa->target, userdata, IDWALK_CB_NOP); + func(actuator, (ID **)&aa->subtarget, userdata, IDWALK_CB_NOP); break; } case ACT_STEERING: { bSteeringActuator *sa = actuator->data; - func(actuator, (ID **)&sa->target, userdata, IDWALK_NOP); - func(actuator, (ID **)&sa->navmesh, userdata, IDWALK_NOP); + func(actuator, (ID **)&sa->target, userdata, IDWALK_CB_NOP); + func(actuator, (ID **)&sa->navmesh, userdata, IDWALK_CB_NOP); break; } /* Note: some types seems to be non-implemented? ACT_LAMP, ACT_MATERIAL... */ -- cgit v1.2.3 From b5682a6fdd8a3ebbea1fd4a75c72fe8c9c3326c5 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 31 Jan 2017 10:41:25 +0100 Subject: Cleanup: use 'cb_flag', not 'cd_flag' for library_query callbacks. `cd_flag` tends to be used for CustomData flags in mesh area, while for library_query those are rather callback flags... --- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/library.c | 10 ++-- source/blender/blenkernel/intern/library_query.c | 62 ++++++++++++------------ source/blender/blenkernel/intern/library_remap.c | 6 +-- 4 files changed, 40 insertions(+), 40 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index a8341939692..294a4ce76b7 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2563,7 +2563,7 @@ void DAG_on_visible_update(Main *bmain, const bool do_time) } static void dag_id_flush_update__isDependentTexture( - void *userData, Object *UNUSED(ob), ID **idpoin, int UNUSED(cd_flag)) + void *userData, Object *UNUSED(ob), ID **idpoin, int UNUSED(cb_flag)) { struct { ID *id; bool is_dependent; } *data = userData; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 7350e014d43..6b4b492b212 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -274,9 +274,9 @@ void BKE_id_clear_newpoin(ID *id) } static int id_expand_local_callback( - void *UNUSED(user_data), struct ID *id_self, struct ID **id_pointer, int cd_flag) + void *UNUSED(user_data), struct ID *id_self, struct ID **id_pointer, int cb_flag) { - if (cd_flag & IDWALK_CB_PRIVATE) { + if (cb_flag & IDWALK_CB_PRIVATE) { return IDWALK_RET_NOP; } @@ -1278,7 +1278,7 @@ void BKE_main_unlock(struct Main *bmain) } -static int main_relations_create_cb(void *user_data, ID *id_self, ID **id_pointer, int cd_flag) +static int main_relations_create_cb(void *user_data, ID *id_self, ID **id_pointer, int cb_flag) { MainIDRelations *rel = user_data; @@ -1293,7 +1293,7 @@ static int main_relations_create_cb(void *user_data, ID *id_self, ID **id_pointe entry->next = NULL; } entry->id_pointer = id_pointer; - entry->usage_flag = cd_flag; + entry->usage_flag = cb_flag; *entry_p = entry; entry = BLI_mempool_alloc(rel->entry_pool); @@ -1304,7 +1304,7 @@ static int main_relations_create_cb(void *user_data, ID *id_self, ID **id_pointe entry->next = NULL; } entry->id_pointer = (ID **)id_self; - entry->usage_flag = cd_flag; + entry->usage_flag = cb_flag; *entry_p = entry; } diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index 9aaf2b24c5d..9685f1f5af6 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -84,12 +84,12 @@ #define FOREACH_FINALIZE _finalize #define FOREACH_FINALIZE_VOID FOREACH_FINALIZE: (void)0 -#define FOREACH_CALLBACK_INVOKE_ID_PP(_data, id_pp, cb_flag) \ +#define FOREACH_CALLBACK_INVOKE_ID_PP(_data, id_pp, _cb_flag) \ CHECK_TYPE(id_pp, ID **); \ if (!((_data)->status & IDWALK_STOP)) { \ const int _flag = (_data)->flag; \ ID *old_id = *(id_pp); \ - const int callback_return = (_data)->callback((_data)->user_data, (_data)->self_id, id_pp, cb_flag | (_data)->cd_flag); \ + const int callback_return = (_data)->callback((_data)->user_data, (_data)->self_id, id_pp, _cb_flag | (_data)->cb_flag); \ if (_flag & IDWALK_READONLY) { \ BLI_assert(*(id_pp) == old_id); \ } \ @@ -130,7 +130,7 @@ enum { typedef struct LibraryForeachIDData { ID *self_id; int flag; - int cd_flag; + int cb_flag; LibraryIDLinkCallback callback; void *user_data; int status; @@ -141,19 +141,19 @@ typedef struct LibraryForeachIDData { } LibraryForeachIDData; static void library_foreach_rigidbodyworldSceneLooper( - struct RigidBodyWorld *UNUSED(rbw), ID **id_pointer, void *user_data, int cd_flag) + struct RigidBodyWorld *UNUSED(rbw), ID **id_pointer, void *user_data, int cb_flag) { LibraryForeachIDData *data = (LibraryForeachIDData *) user_data; - FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cd_flag); + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag); FOREACH_FINALIZE_VOID; } static void library_foreach_modifiersForeachIDLink( - void *user_data, Object *UNUSED(object), ID **id_pointer, int cd_flag) + void *user_data, Object *UNUSED(object), ID **id_pointer, int cb_flag) { LibraryForeachIDData *data = (LibraryForeachIDData *) user_data; - FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cd_flag); + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag); FOREACH_FINALIZE_VOID; } @@ -162,44 +162,44 @@ static void library_foreach_constraintObjectLooper(bConstraint *UNUSED(con), ID bool is_reference, void *user_data) { LibraryForeachIDData *data = (LibraryForeachIDData *) user_data; - const int cd_flag = is_reference ? IDWALK_CB_USER : IDWALK_CB_NOP; - FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cd_flag); + const int cb_flag = is_reference ? IDWALK_CB_USER : IDWALK_CB_NOP; + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag); FOREACH_FINALIZE_VOID; } static void library_foreach_particlesystemsObjectLooper( - ParticleSystem *UNUSED(psys), ID **id_pointer, void *user_data, int cd_flag) + ParticleSystem *UNUSED(psys), ID **id_pointer, void *user_data, int cb_flag) { LibraryForeachIDData *data = (LibraryForeachIDData *) user_data; - FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cd_flag); + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag); FOREACH_FINALIZE_VOID; } static void library_foreach_sensorsObjectLooper( - bSensor *UNUSED(sensor), ID **id_pointer, void *user_data, int cd_flag) + bSensor *UNUSED(sensor), ID **id_pointer, void *user_data, int cb_flag) { LibraryForeachIDData *data = (LibraryForeachIDData *) user_data; - FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cd_flag); + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag); FOREACH_FINALIZE_VOID; } static void library_foreach_controllersObjectLooper( - bController *UNUSED(controller), ID **id_pointer, void *user_data, int cd_flag) + bController *UNUSED(controller), ID **id_pointer, void *user_data, int cb_flag) { LibraryForeachIDData *data = (LibraryForeachIDData *) user_data; - FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cd_flag); + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag); FOREACH_FINALIZE_VOID; } static void library_foreach_actuatorsObjectLooper( - bActuator *UNUSED(actuator), ID **id_pointer, void *user_data, int cd_flag) + bActuator *UNUSED(actuator), ID **id_pointer, void *user_data, int cb_flag) { LibraryForeachIDData *data = (LibraryForeachIDData *) user_data; - FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cd_flag); + FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag); FOREACH_FINALIZE_VOID; } @@ -323,7 +323,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call for (; id != NULL; id = (flag & IDWALK_RECURSE) ? BLI_LINKSTACK_POP(data.ids_todo) : NULL) { data.self_id = id; - data.cd_flag = ID_IS_LINKED_DATABLOCK(id) ? IDWALK_CB_INDIRECT_USAGE : 0; + data.cb_flag = ID_IS_LINKED_DATABLOCK(id) ? IDWALK_CB_INDIRECT_USAGE : 0; if (bmain != NULL && bmain->relations != NULL && (flag & IDWALK_READONLY)) { /* Note that this is minor optimization, even in worst cases (like id being an object with lots of @@ -461,11 +461,11 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call ParticleSystem *psys; /* Object is special, proxies make things hard... */ - const int data_cd_flag = data.cd_flag; - const int proxy_cd_flag = (object->proxy || object->proxy_group) ? IDWALK_CB_INDIRECT_USAGE : 0; + const int data_cb_flag = data.cb_flag; + const int proxy_cb_flag = (object->proxy || object->proxy_group) ? IDWALK_CB_INDIRECT_USAGE : 0; /* object data special case */ - data.cd_flag |= proxy_cd_flag; + data.cb_flag |= proxy_cb_flag; if (object->type == OB_EMPTY) { /* empty can have NULL or Image */ CALLBACK_INVOKE_ID(object->data, IDWALK_CB_USER); @@ -476,7 +476,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call CALLBACK_INVOKE_ID(object->data, IDWALK_CB_USER | IDWALK_CB_NEVER_NULL); } } - data.cd_flag = data_cd_flag; + data.cb_flag = data_cb_flag; CALLBACK_INVOKE(object->parent, IDWALK_CB_NOP); CALLBACK_INVOKE(object->track, IDWALK_CB_NOP); @@ -488,18 +488,18 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call * Since this field is set/owned by 'user' of this ID (and not ID itself), it is only indirect usage * if proxy object is linked... Twisted. */ if (object->proxy_from) { - data.cd_flag = ID_IS_LINKED_DATABLOCK(object->proxy_from) ? IDWALK_CB_INDIRECT_USAGE : 0; + data.cb_flag = ID_IS_LINKED_DATABLOCK(object->proxy_from) ? IDWALK_CB_INDIRECT_USAGE : 0; } CALLBACK_INVOKE(object->proxy_from, IDWALK_CB_NOP); - data.cd_flag = data_cd_flag; + data.cb_flag = data_cb_flag; CALLBACK_INVOKE(object->poselib, IDWALK_CB_USER); - data.cd_flag |= proxy_cd_flag; + data.cb_flag |= proxy_cb_flag; for (i = 0; i < object->totcol; i++) { CALLBACK_INVOKE(object->mat[i], IDWALK_CB_USER); } - data.cd_flag = data_cd_flag; + data.cb_flag = data_cb_flag; CALLBACK_INVOKE(object->gpd, IDWALK_CB_USER); CALLBACK_INVOKE(object->dup_group, IDWALK_CB_USER); @@ -513,12 +513,12 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call if (object->pose) { bPoseChannel *pchan; - data.cd_flag |= proxy_cd_flag; + data.cb_flag |= proxy_cb_flag; for (pchan = object->pose->chanbase.first; pchan; pchan = pchan->next) { CALLBACK_INVOKE(pchan->custom, IDWALK_CB_USER); BKE_constraints_id_loop(&pchan->constraints, library_foreach_constraintObjectLooper, &data); } - data.cd_flag = data_cd_flag; + data.cb_flag = data_cb_flag; } if (object->rigidbody_constraint) { @@ -929,13 +929,13 @@ FOREACH_FINALIZE: /** * re-usable function, use when replacing ID's */ -void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cd_flag) +void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cb_flag) { - if (cd_flag & IDWALK_CB_USER) { + if (cb_flag & IDWALK_CB_USER) { id_us_min(id_src); id_us_plus(id_dst); } - else if (cd_flag & IDWALK_CB_USER_ONE) { + else if (cb_flag & IDWALK_CB_USER_ONE) { id_us_ensure_real(id_dst); } } diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 91896ebdc66..a408b498f18 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -689,9 +689,9 @@ void BKE_libblock_relink_ex( } } -static int id_relink_to_newid_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag) +static int id_relink_to_newid_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cb_flag) { - if (cd_flag & IDWALK_CB_PRIVATE) { + if (cb_flag & IDWALK_CB_PRIVATE) { return IDWALK_RET_NOP; } @@ -699,7 +699,7 @@ static int id_relink_to_newid_looper(void *UNUSED(user_data), ID *UNUSED(self_id if (id) { /* See: NEW_ID macro */ if (id->newid) { - BKE_library_update_ID_link_user(id->newid, id, cd_flag); + BKE_library_update_ID_link_user(id->newid, id, cb_flag); *id_pointer = id->newid; } else if (id->tag & LIB_TAG_NEW) { -- cgit v1.2.3 From 86747ff1804e084e9129ec1dd31279b39fc00cd8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 2 Feb 2017 14:32:05 +0100 Subject: Fix T50535: Cycles render segfault when Explode modifier before hair particle modifier + UV material Tricky issue caused by CDDM_copy() coying MFACE array but not MTFACE which confused logic later on. Now we don't copy ANY tessellation unless it is requested to. Thanks Bastien for help and review! --- source/blender/blenkernel/intern/cdderivedmesh.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index f2dd2a3fcf6..fc3e358cb25 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -2408,36 +2408,46 @@ static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces) int numLoops = source->numLoopData; int numPolys = source->numPolyData; + /* NOTE: Don't copy tessellation faces if not requested explicitly. */ + /* ensure these are created if they are made on demand */ source->getVertDataArray(source, CD_ORIGINDEX); source->getEdgeDataArray(source, CD_ORIGINDEX); - source->getTessFaceDataArray(source, CD_ORIGINDEX); source->getPolyDataArray(source, CD_ORIGINDEX); /* this initializes dm, and copies all non mvert/medge/mface layers */ - DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces, + DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, + faces_from_tessfaces ? numTessFaces : 0, numLoops, numPolys); dm->deformedOnly = source->deformedOnly; dm->cd_flag = source->cd_flag; dm->dirty = source->dirty; + /* Tessellation data is never copied, so tag it here. */ + dm->dirty |= DM_DIRTY_TESS_CDLAYERS; + CustomData_copy_data(&source->vertData, &dm->vertData, 0, 0, numVerts); CustomData_copy_data(&source->edgeData, &dm->edgeData, 0, 0, numEdges); - CustomData_copy_data(&source->faceData, &dm->faceData, 0, 0, numTessFaces); /* now add mvert/medge/mface layers */ cddm->mvert = source->dupVertArray(source); cddm->medge = source->dupEdgeArray(source); - cddm->mface = source->dupTessFaceArray(source); CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, cddm->mvert, numVerts); CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, cddm->medge, numEdges); - CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, cddm->mface, numTessFaces); - if (!faces_from_tessfaces) + if (!faces_from_tessfaces) { DM_DupPolys(source, dm); - else + } + else { + source->getTessFaceDataArray(source, CD_ORIGINDEX); + CustomData_copy_data(&source->faceData, &dm->faceData, 0, 0, numTessFaces); + + cddm->mface = source->dupTessFaceArray(source); + CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, cddm->mface, numTessFaces); + CDDM_tessfaces_to_faces(dm); + } cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP); cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY); -- cgit v1.2.3