Cleanup: Remove no more used `ED_object_single_users`.

This utils was only used for scenes' full copy, and was using old
deprecated ways to deal with ID relations and such. Good riddance!
This commit is contained in:
Bastien Montagne 2020-06-10 18:39:27 +02:00
parent 4f314ee5b9
commit 91462fbb31
2 changed files with 0 additions and 134 deletions

View File

@ -295,10 +295,6 @@ struct Object *ED_object_add_type(struct bContext *C,
unsigned short local_view_bits)
ATTR_NONNULL(1) ATTR_RETURNS_NONNULL;
void ED_object_single_users(struct Main *bmain,
struct Scene *scene,
const bool full,
const bool copy_groups);
void ED_object_single_user(struct Main *bmain, struct Scene *scene, struct Object *ob);
/* object motion paths */

View File

@ -1853,27 +1853,6 @@ void ED_object_single_user(Main *bmain, Scene *scene, Object *ob)
BKE_main_id_clear_newpoins(bmain);
}
static void new_id_matar(Main *bmain, Material **matar, const int totcol)
{
ID *id;
int a;
for (a = 0; a < totcol; a++) {
id = (ID *)matar[a];
if (id && !ID_IS_LINKED(id)) {
if (id->newid) {
matar[a] = (Material *)id->newid;
id_us_plus(id->newid);
id_us_min(id);
}
else if (id->us > 1) {
matar[a] = ID_NEW_SET(id, BKE_material_copy(bmain, matar[a]));
id_us_min(id);
}
}
}
}
static void single_obdata_users(
Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag)
{
@ -2017,115 +1996,6 @@ static void single_mat_users(
FOREACH_OBJECT_FLAG_END;
}
static void single_mat_users_expand(Main *bmain)
{
/* only when 'parent' blocks are LIB_TAG_NEW */
Object *ob;
Mesh *me;
Curve *cu;
MetaBall *mb;
bGPdata *gpd;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, ob->mat, ob->totcol);
}
}
for (me = bmain->meshes.first; me; me = me->id.next) {
if (me->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, me->mat, me->totcol);
}
}
for (cu = bmain->curves.first; cu; cu = cu->id.next) {
if (cu->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, cu->mat, cu->totcol);
}
}
for (mb = bmain->metaballs.first; mb; mb = mb->id.next) {
if (mb->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, mb->mat, mb->totcol);
}
}
for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
if (gpd->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, gpd->mat, gpd->totcol);
}
}
}
/* used for copying scenes */
void ED_object_single_users(Main *bmain,
Scene *scene,
const bool full,
const bool copy_collections)
{
single_object_users(bmain, scene, NULL, 0, copy_collections);
if (full) {
single_obdata_users(bmain, scene, NULL, NULL, 0);
single_object_action_users(bmain, scene, NULL, NULL, 0);
single_mat_users_expand(bmain);
/* Duplicating obdata and other IDs may require another update of the collections and objects
* pointers, especially regarding drivers and custom props, see T66641.
* Note that this whole scene duplication code and 'make single user' functions have to be
* rewritten at some point to make use of proper modern ID management code,
* but that is no small task.
* For now we are doomed to that kind of band-aid to try to cover most of remapping cases. */
/* Will also handle the master collection. */
BKE_libblock_relink_to_newid(&scene->id);
/* Collection and object pointers in collections */
libblock_relink_collection(scene->master_collection, false);
}
/* Relink nodetrees' pointers that have been duplicated. */
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
/* This is a bit convoluted, we want to root ntree of copied IDs and only those,
* so we first check that old ID has been copied and that ntree is root tree of old ID,
* then get root tree of new ID and remap its pointers to new ID... */
if (id->newid && (&ntree->id != id)) {
ntree = ntreeFromID(id->newid);
BKE_libblock_relink_to_newid(&ntree->id);
}
}
FOREACH_NODETREE_END;
/* Relink datablock pointer properties */
{
IDP_RelinkProperty(scene->id.properties);
FOREACH_SCENE_OBJECT_BEGIN (scene, ob) {
if (!ID_IS_LINKED(ob)) {
IDP_RelinkProperty(ob->id.properties);
}
}
FOREACH_SCENE_OBJECT_END;
if (scene->nodetree) {
IDP_RelinkProperty(scene->nodetree->id.properties);
LISTBASE_FOREACH (bNode *, node, &scene->nodetree->nodes) {
IDP_RelinkProperty(node->prop);
}
}
if (scene->world) {
IDP_RelinkProperty(scene->world->id.properties);
}
if (scene->clip) {
IDP_RelinkProperty(scene->clip->id.properties);
}
}
BKE_main_id_clear_newpoins(bmain);
DEG_relations_tag_update(bmain);
}
/** \} */
/* ------------------------------------------------------------------- */