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 | |
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')
68 files changed, 54 insertions, 243 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index e08604f02ad..699387a18c7 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -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 diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 092ca85a570..4e8775aefb3 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -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); diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index b14d24e205a..e551ed76b6f 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -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); diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h index 9912b4e4b70..a6b2aa8540a 100644 --- a/source/blender/blenkernel/BKE_cachefile.h +++ b/source/blender/blenkernel/BKE_cachefile.h @@ -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, diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index 2ea03f30d88..b42fcbe7808 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -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 */ diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 91a9bcbc602..2b238ef18f5 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -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); diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index b07946856fd..7d50599a8f0 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -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); diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h index 3bbe0ffa180..1d7985e5c98 100644 --- a/source/blender/blenkernel/BKE_hair.h +++ b/source/blender/blenkernel/BKE_hair.h @@ -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); diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 369ddc444b6..303945dbf64 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -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); diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 347f16d3e0d..e3d69166b62 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -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); diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 97f78a997e7..0396d050b35 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -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); diff --git a/source/blender/blenkernel/BKE_light.h b/source/blender/blenkernel/BKE_light.h index 9a619f0a0fa..919526b9378 100644 --- a/source/blender/blenkernel/BKE_light.h +++ b/source/blender/blenkernel/BKE_light.h @@ -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); diff --git a/source/blender/blenkernel/BKE_lightprobe.h b/source/blender/blenkernel/BKE_lightprobe.h index e66d4ef75ca..764914ee315 100644 --- a/source/blender/blenkernel/BKE_lightprobe.h +++ b/source/blender/blenkernel/BKE_lightprobe.h @@ -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 } diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h index 19238c4d090..1236a96c8d9 100644 --- a/source/blender/blenkernel/BKE_linestyle.h +++ b/source/blender/blenkernel/BKE_linestyle.h @@ -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); diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 5da8332cc53..80092c1d61a 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -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); diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index aeb7600d647..14ea50f808a 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -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 */ diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 81a90be3fde..8a294c96e26 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -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); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index d976204d0b5..a61e453ec52 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -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); diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index 5321f827143..d33eabeb7e0 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -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, diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 06241aca6da..0a992f2cb58 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -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); diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index dc2a42e3988..a7a837406ac 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -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]); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index bc695013f8c..f726b48ebeb 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -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); diff --git a/source/blender/blenkernel/BKE_pointcloud.h b/source/blender/blenkernel/BKE_pointcloud.h index eaaf22cf9ad..682797991bd 100644 --- a/source/blender/blenkernel/BKE_pointcloud.h +++ b/source/blender/blenkernel/BKE_pointcloud.h @@ -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); diff --git a/source/blender/blenkernel/BKE_speaker.h b/source/blender/blenkernel/BKE_speaker.h index b01824dd794..e288c9f3eb4 100644 --- a/source/blender/blenkernel/BKE_speaker.h +++ b/source/blender/blenkernel/BKE_speaker.h @@ -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 } diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 9d5308de280..c60d5c7bfec 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -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); diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 47ef0c4c63b..ef322d0cd31 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -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); diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h index e199a113410..56962371fe4 100644 --- a/source/blender/blenkernel/BKE_volume.h +++ b/source/blender/blenkernel/BKE_volume.h @@ -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); 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) 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); diff --git a/source/blender/io/collada/BCAnimationSampler.h b/source/blender/io/collada/BCAnimationSampler.h index 34aec00374e..f7f2464a637 100644 --- a/source/blender/io/collada/BCAnimationSampler.h +++ b/source/blender/io/collada/BCAnimationSampler.h @@ -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() diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index da95130a06c..083d7258d0a 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -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); |