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.
This commit is contained in:
Bastien Montagne 2020-10-07 18:01:25 +02:00
parent 03ef0cfe3c
commit 253dbe71dc
68 changed files with 54 additions and 243 deletions

View File

@ -47,9 +47,6 @@ struct bPoseChannel_Runtime;
/* Allocate a new bAction with the given name */
struct bAction *BKE_action_add(struct Main *bmain, const char name[]);
/* Allocate a copy of the given Action and all its data */
struct bAction *BKE_action_copy(struct Main *bmain, const struct bAction *act_src);
/* Action API ----------------- */
/* types of transforms applied to the given item

View File

@ -143,7 +143,6 @@ struct bArmature *BKE_armature_from_object(struct Object *ob);
int BKE_armature_bonelist_count(struct ListBase *lb);
void BKE_armature_bonelist_free(struct ListBase *lb, const bool do_id_user);
void BKE_armature_editbonelist_free(struct ListBase *lb, const bool do_id_user);
struct bArmature *BKE_armature_copy(struct Main *bmain, const struct bArmature *arm);
void BKE_armature_copy_bone_transforms(struct bArmature *armature_dst,
const struct bArmature *armature_src);

View File

@ -52,7 +52,6 @@ struct Brush *BKE_brush_add_gpencil(struct Main *bmain,
bool BKE_brush_delete(struct Main *bmain, struct Brush *brush);
void BKE_brush_init_gpencil_settings(struct Brush *brush);
struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode);
struct Brush *BKE_brush_copy(struct Main *bmain, const struct Brush *brush);
void BKE_brush_sculpt_reset(struct Brush *brush);

View File

@ -38,8 +38,6 @@ void BKE_cachefiles_exit(void);
void *BKE_cachefile_add(struct Main *bmain, const char *name);
struct CacheFile *BKE_cachefile_copy(struct Main *bmain, const struct CacheFile *cache_file);
void BKE_cachefile_reload(struct Depsgraph *depsgraph, struct CacheFile *cache_file);
void BKE_cachefile_eval(struct Main *bmain,

View File

@ -40,7 +40,6 @@ struct rctf;
/* Camera Datablock */
void *BKE_camera_add(struct Main *bmain, const char *name);
struct Camera *BKE_camera_copy(struct Main *bmain, const struct Camera *cam);
/* Camera Usage */

View File

@ -84,7 +84,6 @@ typedef struct CVKeyIndex {
void BKE_curve_editfont_free(struct Curve *cu);
void BKE_curve_init(struct Curve *cu, const short curve_type);
struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type);
struct Curve *BKE_curve_copy(struct Main *bmain, const struct Curve *cu);
short BKE_curve_type_get(const struct Curve *cu);
void BKE_curve_type_test(struct Object *ob);
void BKE_curve_curve_dimension_update(struct Curve *cu);

View File

@ -113,8 +113,6 @@ struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst);
struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, const bool dup_points);
struct bGPdata *BKE_gpencil_copy(struct Main *bmain, const struct bGPdata *gpd);
struct bGPdata *BKE_gpencil_data_duplicate(struct Main *bmain,
const struct bGPdata *gpd,
bool internal_copy);

View File

@ -35,7 +35,6 @@ struct Object;
struct Scene;
void *BKE_hair_add(struct Main *bmain, const char *name);
struct Hair *BKE_hair_copy(struct Main *bmain, const struct Hair *hair);
struct BoundBox *BKE_hair_boundbox_get(struct Object *ob);

View File

@ -288,9 +288,6 @@ void BKE_image_packfiles_from_mem(struct ReportList *reports,
/* prints memory statistics for images */
void BKE_image_print_memlist(struct Main *bmain);
/* empty image block, of similar type and filename */
struct Image *BKE_image_copy(struct Main *bmain, const struct Image *ima);
/* merge source into dest, and free source */
void BKE_image_merge(struct Main *bmain, struct Image *dest, struct Image *source);

View File

@ -39,7 +39,6 @@ extern "C" {
void BKE_key_free(struct Key *key);
void BKE_key_free_nolib(struct Key *key);
struct Key *BKE_key_add(struct Main *bmain, struct ID *id);
struct Key *BKE_key_copy(struct Main *bmain, const struct Key *key);
struct Key *BKE_key_copy_nolib(struct Key *key);
void BKE_key_sort(struct Key *key);

View File

@ -43,7 +43,6 @@ struct bGPDstroke;
void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
struct Lattice *BKE_lattice_add(struct Main *bmain, const char *name);
struct Lattice *BKE_lattice_copy(struct Main *bmain, const struct Lattice *lt);
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
bool object_deform_mball(struct Object *ob, struct ListBase *dispbase);

View File

@ -35,7 +35,6 @@ struct Light;
struct Main;
struct Light *BKE_light_add(struct Main *bmain, const char *name) ATTR_WARN_UNUSED_RESULT;
struct Light *BKE_light_copy(struct Main *bmain, const struct Light *la) ATTR_WARN_UNUSED_RESULT;
void BKE_light_eval(struct Depsgraph *depsgraph, struct Light *la);

View File

@ -33,7 +33,6 @@ struct Main;
void BKE_lightprobe_type_set(struct LightProbe *probe, const short lightprobe_type);
void *BKE_lightprobe_add(struct Main *bmain, const char *name);
struct LightProbe *BKE_lightprobe_copy(struct Main *bmain, const struct LightProbe *probe);
#ifdef __cplusplus
}

View File

@ -42,7 +42,6 @@ struct bContext;
void BKE_linestyle_init(struct FreestyleLineStyle *linestyle);
FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name);
FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineStyle *linestyle);
FreestyleLineStyle *BKE_linestyle_active_from_view_layer(struct ViewLayer *view_layer);

View File

@ -142,7 +142,6 @@ void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point,
/* general */
struct Mask *BKE_mask_new(struct Main *bmain, const char *name);
struct Mask *BKE_mask_copy_nolib(struct Mask *mask);
struct Mask *BKE_mask_copy(struct Main *bmain, const struct Mask *mask);
void BKE_mask_free(struct Mask *mask);

View File

@ -53,7 +53,6 @@ void BKE_object_material_remap_calc(struct Object *ob_dst,
short *remap_src_to_dst);
struct Material *BKE_material_add(struct Main *bmain, const char *name);
struct Material *BKE_gpencil_material_add(struct Main *bmain, const char *name);
struct Material *BKE_material_copy(struct Main *bmain, const struct Material *ma);
void BKE_gpencil_material_attr_init(struct Material *ma);
/* UNUSED */

View File

@ -38,7 +38,6 @@ struct Object;
struct Scene;
struct MetaBall *BKE_mball_add(struct Main *bmain, const char *name);
struct MetaBall *BKE_mball_copy(struct Main *bmain, const struct MetaBall *mb);
bool BKE_mball_is_any_selected(const struct MetaBall *mb);
bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len);

View File

@ -100,7 +100,6 @@ void BKE_mesh_looptri_get_real_edges(const struct Mesh *mesh,
void BKE_mesh_free(struct Mesh *me);
void BKE_mesh_clear_geometry(struct Mesh *me);
struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
struct Mesh *BKE_mesh_copy(struct Main *bmain, const struct Mesh *me);
void BKE_mesh_copy_settings(struct Mesh *me_dst, const struct Mesh *me_src);
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd);
void BKE_mesh_ensure_skin_customdata(struct Mesh *me);

View File

@ -35,8 +35,6 @@ struct MovieClipScopes;
struct MovieClipUser;
struct MovieDistortion;
struct MovieClip *BKE_movieclip_copy(struct Main *bmain, const struct MovieClip *clip);
struct MovieClip *BKE_movieclip_file_add(struct Main *bmain, const char *name);
struct MovieClip *BKE_movieclip_file_add_exists_ex(struct Main *bmain,
const char *filepath,

View File

@ -136,7 +136,6 @@ void *BKE_object_obdata_add_from_type(struct Main *bmain, int type, const char *
ATTR_NONNULL(1);
int BKE_object_obdata_to_type(const struct ID *id) ATTR_NONNULL(1);
struct Object *BKE_object_copy(struct Main *bmain, const struct Object *ob);
bool BKE_object_is_libdata(const struct Object *ob);
bool BKE_object_obdata_is_libdata(const struct Object *ob);

View File

@ -137,7 +137,6 @@ void BKE_paint_set_overlay_override(enum eOverlayFlags flag);
/* palettes */
struct Palette *BKE_palette_add(struct Main *bmain, const char *name);
struct Palette *BKE_palette_copy(struct Main *bmain, const struct Palette *palette);
struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
bool BKE_palette_is_empty(const struct Palette *palette);
void BKE_palette_color_remove(struct Palette *palette, struct PaletteColor *color);
@ -154,7 +153,6 @@ bool BKE_palette_from_hash(struct Main *bmain,
/* paint curves */
struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
struct PaintCurve *BKE_paint_curve_copy(struct Main *bmain, const struct PaintCurve *pc);
bool BKE_paint_ensure(struct ToolSettings *ts, struct Paint **r_paint);
void BKE_paint_init(struct Main *bmain, struct Scene *sce, ePaintMode mode, const char col[3]);

View File

@ -371,8 +371,6 @@ struct ModifierData *object_copy_particle_system(struct Main *bmain,
const struct ParticleSystem *psys_orig);
void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob);
struct ParticleSettings *BKE_particlesettings_add(struct Main *bmain, const char *name);
struct ParticleSettings *BKE_particlesettings_copy(struct Main *bmain,
const struct ParticleSettings *part);
void psys_reset(struct ParticleSystem *psys, int mode);
void psys_find_parents(struct ParticleSimulationData *sim, const bool use_render_params);

View File

@ -41,7 +41,6 @@ extern const char *POINTCLOUD_ATTR_RADIUS;
void *BKE_pointcloud_add(struct Main *bmain, const char *name);
void *BKE_pointcloud_add_default(struct Main *bmain, const char *name);
struct PointCloud *BKE_pointcloud_copy(struct Main *bmain, const struct PointCloud *pointcloud);
struct BoundBox *BKE_pointcloud_boundbox_get(struct Object *ob);

View File

@ -29,7 +29,6 @@ struct Main;
struct Speaker;
void *BKE_speaker_add(struct Main *bmain, const char *name);
struct Speaker *BKE_speaker_copy(struct Main *bmain, const struct Speaker *spk);
#ifdef __cplusplus
}

View File

@ -39,7 +39,6 @@ struct Text *BKE_text_load_ex(struct Main *bmain,
const char *relpath,
const bool is_internal);
struct Text *BKE_text_load(struct Main *bmain, const char *file, const char *relpath);
struct Text *BKE_text_copy(struct Main *bmain, const struct Text *ta);
void BKE_text_clear(struct Text *text);
void BKE_text_write(struct Text *text, const char *str);
int BKE_text_file_modified_check(struct Text *text);

View File

@ -45,7 +45,6 @@ struct TexResult;
void BKE_texture_mtex_foreach_id(struct LibraryForeachIDData *data, struct MTex *mtex);
void BKE_texture_default(struct Tex *tex);
struct Tex *BKE_texture_copy(struct Main *bmain, const struct Tex *tex);
struct Tex *BKE_texture_add(struct Main *bmain, const char *name);
void BKE_texture_type_set(struct Tex *tex, int type);

View File

@ -43,7 +43,6 @@ void BKE_volumes_init(void);
void BKE_volume_init_grids(struct Volume *volume);
void *BKE_volume_add(struct Main *bmain, const char *name);
struct Volume *BKE_volume_copy(struct Main *bmain, const struct Volume *volume);
struct BoundBox *BKE_volume_boundbox_get(struct Object *ob);

View File

@ -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 */

View File

@ -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 */

View File

@ -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);
}
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -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 */

View File

@ -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. */

View File

@ -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)
{

View File

@ -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)
{

View File

@ -971,18 +971,6 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
return gpl_dst;
}
/**
* 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.
*

View File

@ -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);

View File

@ -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 */

View File

@ -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)
{

View File

@ -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, &lt->id);
}
bool object_deform_mball(Object *ob, ListBase *dispbase)
{
if (ob->parent && ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) {

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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) {

View File

@ -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) {

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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... */
@ -1785,19 +1785,6 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
copy_v3_v3(ob_tar->scale, ob_src->scale);
}
/**
* 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.).
*

View File

@ -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");

View File

@ -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 */
/************************************************/

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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. */

View File

@ -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,

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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 */

View File

@ -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 */

View File

@ -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);

View File

@ -40,7 +40,8 @@ class BCAnimation {
BCAnimation(bContext *C, Object *ob) : mContext(C)
{
Main *bmain = CTX_data_main(mContext);
reference = BKE_object_copy(bmain, ob);
reference = (Object *)BKE_id_copy(bmain, &ob->id);
id_us_min(&reference->id);
}
~BCAnimation()

View File

@ -415,7 +415,8 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
// source_node->getOriginalId().c_str() : NULL);
Main *bmain = CTX_data_main(mContext);
Object *obn = BKE_object_copy(bmain, source_ob);
Object *obn = (Object *)BKE_id_copy(bmain, &source_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, sce, source_ob, obn);