diff options
author | Bastien Montagne <bastien@blender.org> | 2020-10-07 19:01:25 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-10-07 19:05:06 +0300 |
commit | 253dbe71dcefabc7abfb992d800caa1d963324d1 (patch) | |
tree | 6bbfb565734a9fa57bd0d808ac6295dbec9cac24 /source/blender/blenkernel/intern | |
parent | 03ef0cfe3c3327647be5289d8ecddea820401221 (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/blenkernel/intern')
28 files changed, 9 insertions, 167 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 4d92390cdcb..1f8c1cca113 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -310,11 +310,6 @@ bAction *BKE_action_add(Main *bmain, const char name[]) /* .................................. */ -bAction *BKE_action_copy(Main *bmain, const bAction *act_src) -{ - return (bAction *)BKE_id_copy(bmain, &act_src->id); -} - /* *************** Action Groups *************** */ /* Get the active action-group for an Action */ diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index c677d976783..6ff705a0379 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -397,13 +397,13 @@ static void animdata_copy_id_action(Main *bmain, if (adt) { if (adt->action && (do_linked_id || !ID_IS_LINKED(adt->action))) { id_us_min((ID *)adt->action); - adt->action = set_newid ? ID_NEW_SET(adt->action, BKE_action_copy(bmain, adt->action)) : - BKE_action_copy(bmain, adt->action); + adt->action = set_newid ? ID_NEW_SET(adt->action, BKE_id_copy(bmain, &adt->action->id)) : + BKE_id_copy(bmain, &adt->action->id); } if (adt->tmpact && (do_linked_id || !ID_IS_LINKED(adt->tmpact))) { id_us_min((ID *)adt->tmpact); - adt->tmpact = set_newid ? ID_NEW_SET(adt->tmpact, BKE_action_copy(bmain, adt->tmpact)) : - BKE_action_copy(bmain, adt->tmpact); + adt->tmpact = set_newid ? ID_NEW_SET(adt->tmpact, BKE_id_copy(bmain, &adt->tmpact->id)) : + BKE_id_copy(bmain, &adt->tmpact->id); } } bNodeTree *ntree = ntreeFromID(id); @@ -452,8 +452,8 @@ void BKE_animdata_merge_copy( /* handle actions... */ if (action_mode == ADT_MERGECOPY_SRC_COPY) { /* make a copy of the actions */ - dst->action = BKE_action_copy(bmain, src->action); - dst->tmpact = BKE_action_copy(bmain, src->tmpact); + dst->action = (bAction *)BKE_id_copy(bmain, &src->action->id); + dst->tmpact = (bAction *)BKE_id_copy(bmain, &src->tmpact->id); } else if (action_mode == ADT_MERGECOPY_SRC_REF) { /* make a reference to it */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 742f57f32a3..ed8c811c116 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -426,11 +426,6 @@ static void copy_bonechildren_custom_handles(Bone *bone_dst, bArmature *arm_dst) } } -bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm) -{ - return (bArmature *)BKE_id_copy(bmain, &arm->id); -} - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index e1524422c3b..3dfddbeed24 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -170,7 +170,7 @@ static void brush_make_local(Main *bmain, ID *id, const int flags) id_fake_user_set(&brush->id); } else { - Brush *brush_new = BKE_brush_copy(bmain, brush); /* Ensures FAKE_USER is set */ + Brush *brush_new = (Brush *)BKE_id_copy(bmain, &brush->id); /* Ensures FAKE_USER is set */ brush_new->id.us = 0; @@ -1531,11 +1531,6 @@ struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mo return NULL; } -Brush *BKE_brush_copy(Main *bmain, const Brush *brush) -{ - return (Brush *)BKE_id_copy(bmain, &brush->id); -} - void BKE_brush_debug_print_state(Brush *br) { /* create a fake brush and set it to the defaults */ diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index 65dcf3673d6..8abf5515645 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -254,11 +254,6 @@ void *BKE_cachefile_add(Main *bmain, const char *name) return cache_file; } -CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file) -{ - return (CacheFile *)BKE_id_copy(bmain, &cache_file->id); -} - void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file) { /* To force reload, free the handle and tag depsgraph to load it again. */ diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 1183e359d93..d54bebeafb9 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -220,11 +220,6 @@ void *BKE_camera_add(Main *bmain, const char *name) return cam; } -Camera *BKE_camera_copy(Main *bmain, const Camera *cam) -{ - return (Camera *)BKE_id_copy(bmain, &cam->id); -} - /* get the camera's dof value, takes the dof object into account */ float BKE_camera_object_dof_distance(Object *ob) { diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index eb469f5400f..be82252159c 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -425,11 +425,6 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type) return cu; } -Curve *BKE_curve_copy(Main *bmain, const Curve *cu) -{ - return (Curve *)BKE_id_copy(bmain, &cu->id); -} - /* Get list of nurbs from editnurbs structure */ ListBase *BKE_curve_editNurbs_get(Curve *cu) { diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index f40cfba5077..31cd812f8df 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -972,18 +972,6 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src) } /** - * Standard API to make a copy of GP data-block, separate from copying its data. - * - * \param bmain: Main pointer - * \param gpd: Grease pencil data-block - * \return Pointer to new data-block - */ -bGPdata *BKE_gpencil_copy(Main *bmain, const bGPdata *gpd) -{ - return (bGPdata *)BKE_id_copy(bmain, &gpd->id); -} - -/** * Make a copy of a given gpencil data-block. * * XXX: Should this be deprecated? diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c index 5d995cbbb4d..3a35836d4d5 100644 --- a/source/blender/blenkernel/intern/hair.c +++ b/source/blender/blenkernel/intern/hair.c @@ -251,11 +251,6 @@ void *BKE_hair_add(Main *bmain, const char *name) return hair; } -Hair *BKE_hair_copy(Main *bmain, const Hair *hair) -{ - return (Hair *)BKE_id_copy(bmain, &hair->id); -} - BoundBox *BKE_hair_boundbox_get(Object *ob) { BLI_assert(ob->type == OB_HAIR); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d1f29c39f63..29cf3cc0a8d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -600,12 +600,6 @@ static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src) } } -/* empty image block, of similar type and filename */ -Image *BKE_image_copy(Main *bmain, const Image *ima) -{ - return (Image *)BKE_id_copy(bmain, &ima->id); -} - void BKE_image_merge(Main *bmain, Image *dest, Image *source) { /* sanity check */ diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index a0c4405535a..b93adf43751 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -296,11 +296,6 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */ return key; } -Key *BKE_key_copy(Main *bmain, const Key *key) -{ - return (Key *)BKE_id_copy(bmain, &key->id); -} - /* XXX TODO get rid of this! */ Key *BKE_key_copy_nolib(Key *key) { diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 950c08bf770..bb62e4c2495 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -401,11 +401,6 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name) return lt; } -Lattice *BKE_lattice_copy(Main *bmain, const Lattice *lt) -{ - return (Lattice *)BKE_id_copy(bmain, <->id); -} - bool object_deform_mball(Object *ob, ListBase *dispbase) { if (ob->parent && ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) { diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index 74226c92681..c8abe296f59 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -220,11 +220,6 @@ Light *BKE_light_add(Main *bmain, const char *name) return la; } -Light *BKE_light_copy(Main *bmain, const Light *la) -{ - return (Light *)BKE_id_copy(bmain, &la->id); -} - void BKE_light_eval(struct Depsgraph *depsgraph, Light *la) { DEG_debug_print_eval(depsgraph, __func__, la->id.name, la); diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c index 2a355ede9d7..debd9706b5e 100644 --- a/source/blender/blenkernel/intern/lightprobe.c +++ b/source/blender/blenkernel/intern/lightprobe.c @@ -141,8 +141,3 @@ void *BKE_lightprobe_add(Main *bmain, const char *name) return probe; } - -LightProbe *BKE_lightprobe_copy(Main *bmain, const LightProbe *probe) -{ - return (LightProbe *)BKE_id_copy(bmain, &probe->id); -} diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index eae7f49cfac..f32a62376ac 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -810,11 +810,6 @@ FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name) return linestyle; } -FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineStyle *linestyle) -{ - return (FreestyleLineStyle *)BKE_id_copy(bmain, &linestyle->id); -} - FreestyleLineStyle *BKE_linestyle_active_from_view_layer(ViewLayer *view_layer) { FreestyleConfig *config = &view_layer->freestyle_config; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index ab69adf2643..2f71d1ad99f 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1074,11 +1074,6 @@ Mask *BKE_mask_copy_nolib(Mask *mask) return mask_new; } -Mask *BKE_mask_copy(Main *bmain, const Mask *mask) -{ - return (Mask *)BKE_id_copy(bmain, &mask->id); -} - void BKE_mask_point_free(MaskSplinePoint *point) { if (point->uw) { diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index db9fccbc443..70cb06185c9 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -317,11 +317,6 @@ Material *BKE_gpencil_material_add(Main *bmain, const char *name) return ma; } -Material *BKE_material_copy(Main *bmain, const Material *ma) -{ - return (Material *)BKE_id_copy(bmain, &ma->id); -} - Material ***BKE_object_material_array_p(Object *ob) { if (ob->type == OB_MESH) { diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 0829b1b5b57..84f07b7bc60 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -217,11 +217,6 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name) return mb; } -MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb) -{ - return (MetaBall *)BKE_id_copy(bmain, &mb->id); -} - /* most simple meta-element adding function * don't do context manipulation here (rna uses) */ MetaElem *BKE_mball_element_add(MetaBall *mb, const int type) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 16adc65c4f7..4486c9eb926 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1017,11 +1017,6 @@ Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference) return result; } -Mesh *BKE_mesh_copy(Main *bmain, const Mesh *me) -{ - return (Mesh *)BKE_id_copy(bmain, &me->id); -} - BMesh *BKE_mesh_to_bmesh_ex(const Mesh *me, const struct BMeshCreateParams *create_params, const struct BMeshFromMeshParams *convert_params) diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 861ea26f7fb..36f9e47421b 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1918,11 +1918,6 @@ void BKE_movieclip_build_proxy_frame_for_ibuf(MovieClip *clip, } } -MovieClip *BKE_movieclip_copy(Main *bmain, const MovieClip *clip) -{ - return (MovieClip *)BKE_id_copy(bmain, &clip->id); -} - float BKE_movieclip_remap_scene_to_clip_frame(const MovieClip *clip, float framenr) { return framenr - (float)clip->start_frame + 1.0f; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 676277dae8c..6ab47f1b1f8 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -360,9 +360,9 @@ static void object_make_local(Main *bmain, ID *id, const int flags) } } else { - Object *ob_new = BKE_object_copy(bmain, ob); + Object *ob_new = (Object *)BKE_id_copy(bmain, &ob->id); + id_us_min(&ob_new->id); - ob_new->id.us = 0; ob_new->proxy = ob_new->proxy_from = ob_new->proxy_group = NULL; /* setting newid is mandatory for complex make_lib_local logic... */ @@ -1786,19 +1786,6 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src) } /** - * Copy objects, will re-initialize cached simulation data. - */ -Object *BKE_object_copy(Main *bmain, const Object *ob) -{ - Object *ob_copy = (Object *)BKE_id_copy(bmain, &ob->id); - - /* We increase object user count when linking to Collections. */ - id_us_min(&ob_copy->id); - - return ob_copy; -} - -/** * Perform deep-copy of object and its 'children' data-blocks (obdata, materials, actions, etc.). * * \param dupflag: Controls which sub-data are also duplicated diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index df4a78b8c5b..fd37ceed568 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -677,11 +677,6 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name) return pc; } -PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc) -{ - return (PaintCurve *)BKE_id_copy(bmain, &pc->id); -} - Palette *BKE_paint_palette(Paint *p) { return p ? p->palette : NULL; @@ -739,11 +734,6 @@ Palette *BKE_palette_add(Main *bmain, const char *name) return palette; } -Palette *BKE_palette_copy(Main *bmain, const Palette *palette) -{ - return (Palette *)BKE_id_copy(bmain, &palette->id); -} - PaletteColor *BKE_palette_color_add(Palette *palette) { PaletteColor *color = MEM_callocN(sizeof(*color), "Palette Color"); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e984308b873..8d091767709 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3907,11 +3907,6 @@ void BKE_particlesettings_twist_curve_init(ParticleSettings *part) part->twistcurve = cumap; } -ParticleSettings *BKE_particlesettings_copy(Main *bmain, const ParticleSettings *part) -{ - return (ParticleSettings *)BKE_id_copy(bmain, &part->id); -} - /************************************************/ /* Textures */ /************************************************/ diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c index 9f2e9efa8cb..a130117ded5 100644 --- a/source/blender/blenkernel/intern/pointcloud.c +++ b/source/blender/blenkernel/intern/pointcloud.c @@ -230,11 +230,6 @@ void *BKE_pointcloud_add_default(Main *bmain, const char *name) return pointcloud; } -PointCloud *BKE_pointcloud_copy(Main *bmain, const PointCloud *pointcloud) -{ - return (PointCloud *)BKE_id_copy(bmain, &pointcloud->id); -} - BoundBox *BKE_pointcloud_boundbox_get(Object *ob) { BLI_assert(ob->type == OB_POINTCLOUD); diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index 8e1d0aae721..2f65442fd48 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -124,8 +124,3 @@ void *BKE_speaker_add(Main *bmain, const char *name) return spk; } - -Speaker *BKE_speaker_copy(Main *bmain, const Speaker *spk) -{ - return (Speaker *)BKE_id_copy(bmain, &spk->id); -} diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index b8eabc29f39..84b5b526eff 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -516,11 +516,6 @@ Text *BKE_text_load(Main *bmain, const char *file, const char *relpath) return BKE_text_load_ex(bmain, file, relpath, false); } -Text *BKE_text_copy(Main *bmain, const Text *ta) -{ - return (Text *)BKE_id_copy(bmain, &ta->id); -} - void BKE_text_clear(Text *text) /* called directly from rna */ { txt_sel_all(text); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 8c46b192b0b..c2325eeeab0 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -455,13 +455,6 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot) /* ------------------------------------------------------------------------- */ -Tex *BKE_texture_copy(Main *bmain, const Tex *tex) -{ - return (Tex *)BKE_id_copy(bmain, &tex->id); -} - -/* ------------------------------------------------------------------------- */ - Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle) { MTex *mtex = NULL; diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index f7c7a2ec323..382787fd0f9 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -610,11 +610,6 @@ void *BKE_volume_add(Main *bmain, const char *name) return volume; } -Volume *BKE_volume_copy(Main *bmain, const Volume *volume) -{ - return (Volume *)BKE_id_copy(bmain, &volume->id); -} - /* Sequence */ static int volume_sequence_frame(const Depsgraph *depsgraph, const Volume *volume) |