diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-06 15:11:01 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-06 15:11:01 +0300 |
commit | d2312602125a452e6562a76ab91779943c67396d (patch) | |
tree | da74fa2bce05d94d6bc800021d837b494e6936d7 /source/blender/blenkernel/intern/material.c | |
parent | b98b331d04fe3a335cc0656809b4b09196507500 (diff) |
Replace of (id->lib != NULL) check by meaningful macro.
Idea is to replace hard-to-track (id->lib != NULL) 'is linked datablock' check everywhere in Blender
by a macro doing the same thing. This will allow to easily spot those checks in future, and more importantly,
to easily change it (see work done in asset-engine branch).
Note: did not touch to readfile.c, since there most of the time 'id->lib' check actually concerns the pointer,
and not a check whether ID is linked or not. Will have a closer look at it later.
Reviewers: campbellbarton, brecht, sergey
Differential Revision: https://developer.blender.org/D2082
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index db5ac54ada9..7231620550e 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -245,7 +245,7 @@ Material *BKE_material_copy(Material *ma) BLI_listbase_clear(&man->gpumaterial); - if (ma->id.lib) { + if (ID_IS_LINKED_DATABLOCK(ma)) { BKE_id_lib_local_paths(G.main, ma->id.lib, &man->id); } @@ -305,7 +305,7 @@ void BKE_material_make_local(Material *ma) * - mixed: make copy */ - if (ma->id.lib == NULL) return; + if (!ID_IS_LINKED_DATABLOCK(ma)) return; /* One local user; set flag and return. */ if (ma->id.us == 1) { @@ -322,7 +322,7 @@ void BKE_material_make_local(Material *ma) if (ob->mat) { for (a = 0; a < ob->totcol; a++) { if (ob->mat[a] == ma) { - if (ob->id.lib) is_lib = true; + if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true; else is_local = true; } } @@ -335,7 +335,7 @@ void BKE_material_make_local(Material *ma) if (me->mat) { for (a = 0; a < me->totcol; a++) { if (me->mat[a] == ma) { - if (me->id.lib) is_lib = true; + if (ID_IS_LINKED_DATABLOCK(me)) is_lib = true; else is_local = true; } } @@ -348,7 +348,7 @@ void BKE_material_make_local(Material *ma) if (cu->mat) { for (a = 0; a < cu->totcol; a++) { if (cu->mat[a] == ma) { - if (cu->id.lib) is_lib = true; + if (ID_IS_LINKED_DATABLOCK(cu)) is_lib = true; else is_local = true; } } @@ -361,7 +361,7 @@ void BKE_material_make_local(Material *ma) if (mb->mat) { for (a = 0; a < mb->totcol; a++) { if (mb->mat[a] == ma) { - if (mb->id.lib) is_lib = true; + if (ID_IS_LINKED_DATABLOCK(mb)) is_lib = true; else is_local = true; } } @@ -389,7 +389,7 @@ void BKE_material_make_local(Material *ma) if (ob->mat) { for (a = 0; a < ob->totcol; a++) { if (ob->mat[a] == ma) { - if (ob->id.lib == NULL) { + if (!ID_IS_LINKED_DATABLOCK(ob)) { ob->mat[a] = ma_new; id_us_plus(&ma_new->id); id_us_min(&ma->id); @@ -405,7 +405,7 @@ void BKE_material_make_local(Material *ma) if (me->mat) { for (a = 0; a < me->totcol; a++) { if (me->mat[a] == ma) { - if (me->id.lib == NULL) { + if (!ID_IS_LINKED_DATABLOCK(me)) { me->mat[a] = ma_new; id_us_plus(&ma_new->id); id_us_min(&ma->id); @@ -421,7 +421,7 @@ void BKE_material_make_local(Material *ma) if (cu->mat) { for (a = 0; a < cu->totcol; a++) { if (cu->mat[a] == ma) { - if (cu->id.lib == NULL) { + if (!ID_IS_LINKED_DATABLOCK(cu)) { cu->mat[a] = ma_new; id_us_plus(&ma_new->id); id_us_min(&ma->id); @@ -437,7 +437,7 @@ void BKE_material_make_local(Material *ma) if (mb->mat) { for (a = 0; a < mb->totcol; a++) { if (mb->mat[a] == ma) { - if (mb->id.lib == NULL) { + if (!ID_IS_LINKED_DATABLOCK(mb)) { mb->mat[a] = ma_new; id_us_plus(&ma_new->id); id_us_min(&ma->id); @@ -852,8 +852,8 @@ void assign_material(Object *ob, Material *ma, short act, int assign_type) if (act < 1) act = 1; /* prevent crashing when using accidentally */ - BLI_assert(ob->id.lib == NULL); - if (ob->id.lib) return; + BLI_assert(!ID_IS_LINKED_DATABLOCK(ob)); + if (ID_IS_LINKED_DATABLOCK(ob)) return; /* test arraylens */ @@ -1121,7 +1121,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) Group *group; for (group = G.main->group.first; group; group = group->id.next) { - if (!group->id.lib && STREQ(group->id.name, ma->group->id.name)) { + if (!ID_IS_LINKED_DATABLOCK(group) && STREQ(group->id.name, ma->group->id.name)) { ma->group = group; } } @@ -2230,7 +2230,7 @@ int do_version_tface(Main *main) /* 1st part: marking mesh materials to update */ for (me = main->mesh.first; me; me = me->id.next) { - if (me->id.lib) continue; + if (ID_IS_LINKED_DATABLOCK(me)) continue; /* get the active tface layer */ index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); @@ -2284,7 +2284,7 @@ int do_version_tface(Main *main) * at doversion time: direct_link might not have happened on it, * so ma->mtex is not pointing to valid memory yet. * later we could, but it's better not */ - else if (ma->id.lib) + else if (ID_IS_LINKED_DATABLOCK(ma)) continue; /* material already marked as disputed */ @@ -2349,7 +2349,7 @@ int do_version_tface(Main *main) /* we shouldn't loop through the materials created in the loop. make the loop stop at its original length) */ for (ma = main->mat.first, a = 0; ma; ma = ma->id.next, a++) { - if (ma->id.lib) continue; + if (ID_IS_LINKED_DATABLOCK(ma)) continue; /* disputed material */ if (ma->game.flag == MAT_BGE_DISPUTED) { |