Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-10-07 19:01:25 +0300
committerBastien Montagne <bastien@blender.org>2020-10-07 19:05:06 +0300
commit253dbe71dcefabc7abfb992d800caa1d963324d1 (patch)
tree6bbfb565734a9fa57bd0d808ac6295dbec9cac24 /source/blender/editors
parent03ef0cfe3c3327647be5289d8ecddea820401221 (diff)
Refactor: remove `BKE_<id_type>_copy` functions.
Those were only shallow wrappers around `BKE_id_copy`, barely used (even fully unused in some cases), and we want to get rid of those ID-specific helpers for the common ID management tasks. Also prevents weird custom behaviors (like `BKE_object_copy`, who was the only basic ID copy function to reset user count of the new copy to zero). Part of 71219.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/curve/editcurve.c2
-rw-r--r--source/blender/editors/mesh/editmesh_mask_extract.c6
-rw-r--r--source/blender/editors/mesh/meshtools.c2
-rw-r--r--source/blender/editors/object/object_add.c18
-rw-r--r--source/blender/editors/object/object_relations.c31
-rw-r--r--source/blender/editors/physics/particle_object.c4
-rw-r--r--source/blender/editors/render/render_shading.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c4
-rw-r--r--source/blender/editors/space_action/action_data.c2
-rw-r--r--source/blender/editors/space_nla/nla_edit.c4
-rw-r--r--source/blender/editors/space_node/node_group.c2
11 files changed, 41 insertions, 38 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 9214e0b283a..15a147b6b86 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1438,7 +1438,7 @@ static int separate_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
newob = newbase->object;
- newcu = newob->data = BKE_curve_copy(bmain, oldcu);
+ newcu = newob->data = BKE_id_copy(bmain, &oldcu->id);
newcu->editnurb = NULL;
id_us_min(&oldcu->id); /* Because new curve is a copy: reduce user count. */
diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c
index 30949605fec..0a9aa724764 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -107,7 +107,7 @@ static int geometry_extract_apply(bContext *C,
BKE_sculpt_mask_layers_ensure(ob, NULL);
Mesh *mesh = ob->data;
- Mesh *new_mesh = BKE_mesh_copy(bmain, mesh);
+ Mesh *new_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh);
BMesh *bm;
@@ -494,7 +494,7 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
BKE_sculpt_mask_layers_ensure(ob, NULL);
Mesh *mesh = ob->data;
- Mesh *new_mesh = BKE_mesh_copy(bmain, mesh);
+ Mesh *new_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
if (ob->mode == OB_MODE_SCULPT) {
ED_sculpt_undo_geometry_begin(ob, "mask slice");
@@ -530,7 +530,7 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
}
Object *new_ob = ED_object_add_type(
C, OB_MESH, NULL, ob->loc, ob->rot, false, local_view_bits);
- Mesh *new_ob_mesh = BKE_mesh_copy(bmain, mesh);
+ Mesh *new_ob_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
const BMAllocTemplate allocsize_new_ob = BMALLOC_TEMPLATE_FROM_ME(new_ob_mesh);
bm = BM_mesh_create(&allocsize_new_ob,
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 471d4847af6..62dd4a22654 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -445,7 +445,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
*/
if (key) {
/* make a duplicate copy that will only be used here... (must remember to free it!) */
- nkey = BKE_key_copy(bmain, key);
+ nkey = (Key *)BKE_id_copy(bmain, &key->id);
/* for all keys in old block, clear data-arrays */
for (kb = key->block.first; kb; kb = kb->next) {
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 55acc8a567d..96f13578513 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2099,7 +2099,8 @@ static void make_object_duplilist_real(bContext *C,
for (dob = lb_duplis->first; dob; dob = dob->next) {
Object *ob_src = DEG_get_original_object(dob->ob);
- Object *ob_dst = ID_NEW_SET(ob_src, BKE_object_copy(bmain, ob_src));
+ Object *ob_dst = ID_NEW_SET(ob_src, BKE_id_copy(bmain, &ob_src->id));
+ id_us_min(&ob_dst->id);
Base *base_dst;
/* font duplis can have a totcol without material, we get them from parent
@@ -2431,7 +2432,8 @@ static Base *duplibase_for_convert(
ob = base->object;
}
- obn = BKE_object_copy(bmain, ob);
+ obn = (Object *)BKE_id_copy(bmain, &ob->id);
+ id_us_min(&obn->id);
DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
BKE_collection_object_add_from(bmain, scene, ob, obn);
@@ -2595,7 +2597,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
id_us_min(&me->id);
/* make a new copy of the mesh */
- newob->data = BKE_mesh_copy(bmain, me);
+ newob->data = BKE_id_copy(bmain, &me->id);
}
else {
newob = ob;
@@ -2669,7 +2671,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
id_us_min(&me->id);
/* make a new copy of the mesh */
- newob->data = BKE_mesh_copy(bmain, me);
+ newob->data = BKE_id_copy(bmain, &me->id);
}
else {
newob = ob;
@@ -2694,7 +2696,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
id_us_min(&me->id);
/* make a new copy of the mesh */
- newob->data = BKE_mesh_copy(bmain, me);
+ newob->data = BKE_id_copy(bmain, &me->id);
}
else {
newob = ob;
@@ -2723,7 +2725,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
- newob->data = BKE_curve_copy(bmain, ob->data);
+ newob->data = BKE_id_copy(bmain, ob->data);
}
else {
newob = ob;
@@ -2794,7 +2796,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
- newob->data = BKE_curve_copy(bmain, ob->data);
+ newob->data = BKE_id_copy(bmain, ob->data);
}
else {
newob = ob;
@@ -2879,7 +2881,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
id_us_min(&pointcloud->id);
/* make a new copy of the pointcloud */
- newob->data = BKE_pointcloud_copy(bmain, pointcloud);
+ newob->data = BKE_id_copy(bmain, &pointcloud->id);
}
else {
newob = ob;
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 1cc762dfb65..80b521b2af3 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1830,7 +1830,8 @@ static Collection *single_object_users_collection(Main *bmain,
/* an object may be in more than one collection */
if ((ob->id.newid == NULL) && ((ob->flag & flag) == flag)) {
if (!ID_IS_LINKED(ob) && BKE_object_scenes_users_get(bmain, ob) > 1) {
- ID_NEW_SET(ob, BKE_object_copy(bmain, ob));
+ ID_NEW_SET(ob, BKE_id_copy(bmain, &ob->id));
+ id_us_min(ob->id.newid);
}
}
}
@@ -1922,26 +1923,26 @@ static void single_obdata_users(
switch (ob->type) {
case OB_LAMP:
- ob->data = la = ID_NEW_SET(ob->data, BKE_light_copy(bmain, ob->data));
+ ob->data = la = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
break;
case OB_CAMERA:
- cam = ob->data = ID_NEW_SET(ob->data, BKE_camera_copy(bmain, ob->data));
+ cam = ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
ID_NEW_REMAP(cam->dof.focus_object);
break;
case OB_MESH:
/* Needed to remap texcomesh below. */
- me = ob->data = ID_NEW_SET(ob->data, BKE_mesh_copy(bmain, ob->data));
+ me = ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
if (me->key) { /* We do not need to set me->key->id.newid here... */
BKE_animdata_copy_id_action(bmain, (ID *)me->key);
}
break;
case OB_MBALL:
- ob->data = ID_NEW_SET(ob->data, BKE_mball_copy(bmain, ob->data));
+ ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
break;
case OB_CURVE:
case OB_SURF:
case OB_FONT:
- ob->data = cu = ID_NEW_SET(ob->data, BKE_curve_copy(bmain, ob->data));
+ ob->data = cu = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
ID_NEW_REMAP(cu->bevobj);
ID_NEW_REMAP(cu->taperobj);
if (cu->key) { /* We do not need to set cu->key->id.newid here... */
@@ -1949,33 +1950,33 @@ static void single_obdata_users(
}
break;
case OB_LATTICE:
- ob->data = lat = ID_NEW_SET(ob->data, BKE_lattice_copy(bmain, ob->data));
+ ob->data = lat = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
if (lat->key) { /* We do not need to set lat->key->id.newid here... */
BKE_animdata_copy_id_action(bmain, (ID *)lat->key);
}
break;
case OB_ARMATURE:
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- ob->data = ID_NEW_SET(ob->data, BKE_armature_copy(bmain, ob->data));
+ ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
BKE_pose_rebuild(bmain, ob, ob->data, true);
break;
case OB_SPEAKER:
- ob->data = ID_NEW_SET(ob->data, BKE_speaker_copy(bmain, ob->data));
+ ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
break;
case OB_LIGHTPROBE:
- ob->data = ID_NEW_SET(ob->data, BKE_lightprobe_copy(bmain, ob->data));
+ ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
break;
case OB_GPENCIL:
- ob->data = ID_NEW_SET(ob->data, BKE_gpencil_copy(bmain, ob->data));
+ ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
break;
case OB_HAIR:
- ob->data = ID_NEW_SET(ob->data, BKE_hair_copy(bmain, ob->data));
+ ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
break;
case OB_POINTCLOUD:
- ob->data = ID_NEW_SET(ob->data, BKE_pointcloud_copy(bmain, ob->data));
+ ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
break;
case OB_VOLUME:
- ob->data = ID_NEW_SET(ob->data, BKE_volume_copy(bmain, ob->data));
+ ob->data = ID_NEW_SET(ob->data, BKE_id_copy(bmain, ob->data));
break;
default:
printf("ERROR %s: can't copy %s\n", __func__, id->name);
@@ -2033,7 +2034,7 @@ static void single_mat_users(
* this functions guaranteed delivers single_users! */
if (ma->id.us > 1) {
- man = BKE_material_copy(bmain, ma);
+ man = (Material *)BKE_id_copy(bmain, &ma->id);
BKE_animdata_copy_id_action(bmain, &man->id);
man->id.us = 0;
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 74d246dc3a0..56bdc5c21f4 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -180,7 +180,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
/* add or copy particle setting */
if (psys->part) {
- part = BKE_particlesettings_copy(bmain, psys->part);
+ part = (ParticleSettings *)BKE_id_copy(bmain, &psys->part->id);
}
else {
part = BKE_particlesettings_add(bmain, "ParticleSettings");
@@ -1155,7 +1155,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
if (duplicate_settings) {
id_us_min(&psys->part->id);
- psys->part = BKE_particlesettings_copy(bmain, psys->part);
+ psys->part = (ParticleSettings *)BKE_id_copy(bmain, &psys->part->id);
}
}
MEM_freeN(tmp_psys);
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 425537b5e13..6fed806c8af 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -820,7 +820,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
/* add or copy texture */
if (tex) {
- tex = BKE_texture_copy(bmain, tex);
+ tex = (Tex *)BKE_id_copy(bmain, &tex->id);
}
else {
tex = BKE_texture_add(bmain, DATA_("Texture"));
@@ -1662,7 +1662,7 @@ static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op)
}
if (lineset->linestyle) {
id_us_min(&lineset->linestyle->id);
- lineset->linestyle = BKE_linestyle_copy(bmain, lineset->linestyle);
+ lineset->linestyle = (FreestyleLineStyle *)BKE_id_copy(bmain, &lineset->linestyle->id);
}
else {
lineset->linestyle = BKE_linestyle_new(bmain, "LineStyle");
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index e239b9619ec..9bf1911aee8 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -70,7 +70,7 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
if (br) {
- br = BKE_brush_copy(bmain, br);
+ br = (Brush *)BKE_id_copy(bmain, &br->id);
}
else {
br = BKE_brush_add(bmain, "Brush", BKE_paint_object_mode_from_paintmode(mode));
@@ -105,7 +105,7 @@ static int brush_add_gpencil_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
if (br) {
- br = BKE_brush_copy(bmain, br);
+ br = (Brush *)BKE_id_copy(bmain, &br->id);
}
else {
br = BKE_brush_add(bmain, "Brush", OB_MODE_PAINT_GPENCIL);
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index bffd6cc421d..d5b185302c1 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -108,7 +108,7 @@ static bAction *action_create_new(bContext *C, bAction *oldact)
*/
if (oldact && GS(oldact->id.name) == ID_AC) {
/* make a copy of the existing action */
- action = BKE_action_copy(CTX_data_main(C), oldact);
+ action = (bAction *)BKE_id_copy(CTX_data_main(C), &oldact->id);
}
else {
/* just make a new (empty) action */
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index dc8f616c5e6..d82a39786d9 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -1928,7 +1928,7 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
/* multi-user? */
if (ID_REAL_USERS(strip->act) > 1) {
/* make a new copy of the action for us to use (it will have 1 user already) */
- bAction *new_action = BKE_action_copy(bmain, strip->act);
+ bAction *new_action = (bAction *)BKE_id_copy(bmain, &strip->act->id);
/* decrement user count of our existing action */
id_us_min(&strip->act->id);
@@ -2029,7 +2029,7 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
}
if (strip->act->id.us > 1) {
/* make a copy of the Action to work on */
- bAction *act = BKE_action_copy(bmain, strip->act);
+ bAction *act = (bAction *)BKE_id_copy(bmain, &strip->act->id);
/* set this as the new referenced action,
* decrementing the users of the old one */
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index e81d83102ac..742d577ccf8 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -286,7 +286,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* firstly, wgroup needs to temporary dummy action
* that can be destroyed, as it shares copies */
- waction = wgroup->adt->action = BKE_action_copy(bmain, wgroup->adt->action);
+ waction = wgroup->adt->action = (bAction *)BKE_id_copy(bmain, &wgroup->adt->action->id);
/* now perform the moving */
BKE_animdata_transfer_by_basepath(bmain, &wgroup->id, &ntree->id, &anim_basepaths);