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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2016-07-10 15:52:00 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-07-10 15:52:00 +0300
commit87b974caa1e2b780c8031d67a42488039036c489 (patch)
tree6776b8d35f25b2c458f90e0ba4cfa497782ebc30 /source/blender/blenkernel
parentae2033aca2047afbfe0bf449bcd01b5b79a124b8 (diff)
Cleanup/Refactor: pass Main pointer to all ID copy functions.
Also allows us to get rid of a few _copy_ex() versions...
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_action.h2
-rw-r--r--source/blender/blenkernel/BKE_armature.h2
-rw-r--r--source/blender/blenkernel/BKE_brush.h2
-rw-r--r--source/blender/blenkernel/BKE_camera.h2
-rw-r--r--source/blender/blenkernel/BKE_curve.h3
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h3
-rw-r--r--source/blender/blenkernel/BKE_group.h2
-rw-r--r--source/blender/blenkernel/BKE_key.h3
-rw-r--r--source/blender/blenkernel/BKE_lamp.h2
-rw-r--r--source/blender/blenkernel/BKE_lattice.h3
-rw-r--r--source/blender/blenkernel/BKE_library.h5
-rw-r--r--source/blender/blenkernel/BKE_mask.h2
-rw-r--r--source/blender/blenkernel/BKE_material.h2
-rw-r--r--source/blender/blenkernel/BKE_mball.h3
-rw-r--r--source/blender/blenkernel/BKE_mesh.h3
-rw-r--r--source/blender/blenkernel/BKE_node.h2
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/BKE_particle.h2
-rw-r--r--source/blender/blenkernel/BKE_scene.h2
-rw-r--r--source/blender/blenkernel/BKE_speaker.h2
-rw-r--r--source/blender/blenkernel/BKE_texture.h2
-rw-r--r--source/blender/blenkernel/BKE_world.h2
-rw-r--r--source/blender/blenkernel/intern/action.c8
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c12
-rw-r--r--source/blender/blenkernel/intern/armature.c8
-rw-r--r--source/blender/blenkernel/intern/brush.c11
-rw-r--r--source/blender/blenkernel/intern/camera.c8
-rw-r--r--source/blender/blenkernel/intern/curve.c13
-rw-r--r--source/blender/blenkernel/intern/gpencil.c5
-rw-r--r--source/blender/blenkernel/intern/group.c6
-rw-r--r--source/blender/blenkernel/intern/key.c9
-rw-r--r--source/blender/blenkernel/intern/lamp.c10
-rw-r--r--source/blender/blenkernel/intern/lattice.c13
-rw-r--r--source/blender/blenkernel/intern/library.c61
-rw-r--r--source/blender/blenkernel/intern/linestyle.c2
-rw-r--r--source/blender/blenkernel/intern/mask.c6
-rw-r--r--source/blender/blenkernel/intern/material.c12
-rw-r--r--source/blender/blenkernel/intern/mball.c11
-rw-r--r--source/blender/blenkernel/intern/mesh.c17
-rw-r--r--source/blender/blenkernel/intern/nla.c2
-rw-r--r--source/blender/blenkernel/intern/node.c10
-rw-r--r--source/blender/blenkernel/intern/object.c8
-rw-r--r--source/blender/blenkernel/intern/particle.c8
-rw-r--r--source/blender/blenkernel/intern/scene.c16
-rw-r--r--source/blender/blenkernel/intern/speaker.c6
-rw-r--r--source/blender/blenkernel/intern/text.c2
-rw-r--r--source/blender/blenkernel/intern/texture.c10
-rw-r--r--source/blender/blenkernel/intern/world.c10
48 files changed, 153 insertions, 184 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index cb282b46bec..07fa6ac71f6 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -58,7 +58,7 @@ extern "C" {
struct bAction *add_empty_action(struct Main *bmain, const char name[]);
/* Allocate a copy of the given Action and all its data */
-struct bAction *BKE_action_copy(struct bAction *src);
+struct bAction *BKE_action_copy(struct Main *bmain, struct bAction *src);
/* Deallocate all of the Action's data, but not the Action itself */
void BKE_action_free(struct bAction *act);
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index cc082c084ce..8004724ddf3 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -77,7 +77,7 @@ int BKE_armature_bonelist_count(struct ListBase *lb);
void BKE_armature_bonelist_free(struct ListBase *lb);
void BKE_armature_free(struct bArmature *arm);
void BKE_armature_make_local(struct bArmature *arm);
-struct bArmature *BKE_armature_copy(struct bArmature *arm);
+struct bArmature *BKE_armature_copy(struct Main *bmain, struct bArmature *arm);
/* Bounding box. */
struct BoundBox *BKE_armature_boundbox_get(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index c663458963c..309785783ec 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -44,7 +44,7 @@ void BKE_brush_system_exit(void);
void BKE_brush_init(struct Brush *brush);
struct Brush *BKE_brush_add(struct Main *bmain, const char *name, short ob_mode);
struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode);
-struct Brush *BKE_brush_copy(struct Brush *brush);
+struct Brush *BKE_brush_copy(struct Main *bmain, struct Brush *brush);
void BKE_brush_make_local(struct Brush *brush);
void BKE_brush_unlink(struct Main *bmain, struct Brush *brush);
void BKE_brush_free(struct Brush *brush);
diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h
index d13a711c589..f78df88c77a 100644
--- a/source/blender/blenkernel/BKE_camera.h
+++ b/source/blender/blenkernel/BKE_camera.h
@@ -52,7 +52,7 @@ struct GPUFXSettings;
void BKE_camera_init(struct Camera *cam);
void *BKE_camera_add(struct Main *bmain, const char *name);
-struct Camera *BKE_camera_copy(struct Camera *cam);
+struct Camera *BKE_camera_copy(struct Main *bmain, struct Camera *cam);
void BKE_camera_make_local(struct Camera *cam);
void BKE_camera_free(struct Camera *ca);
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index ef3d14ce16b..89dbe246910 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -70,8 +70,7 @@ void BKE_curve_free(struct Curve *cu);
void BKE_curve_editfont_free(struct Curve *cu);
void BKE_curve_init(struct Curve *cu);
struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type);
-struct Curve *BKE_curve_copy(struct Curve *cu);
-struct Curve *BKE_curve_copy_ex(struct Main *bmain, struct Curve *cu);
+struct Curve *BKE_curve_copy(struct Main *bmain, struct Curve *cu);
void BKE_curve_make_local(struct Main *bmain, struct Curve *cu);
short BKE_curve_type_get(struct Curve *cu);
void BKE_curve_type_test(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 24e330d927f..6159531d8bd 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -36,6 +36,7 @@ struct bGPdata;
struct bGPDlayer;
struct bGPDframe;
struct bGPDstroke;
+struct Main;
/* ------------ Grease-Pencil API ------------------ */
@@ -53,7 +54,7 @@ struct bGPdata *gpencil_data_addnew(const char name[]);
struct bGPDframe *gpencil_frame_duplicate(struct bGPDframe *src);
struct bGPDlayer *gpencil_layer_duplicate(struct bGPDlayer *src);
-struct bGPdata *gpencil_data_duplicate(struct bGPdata *gpd, bool internal_copy);
+struct bGPdata *gpencil_data_duplicate(struct Main *bmain, struct bGPdata *gpd, bool internal_copy);
void gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe *gpf);
diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h
index ae6e52b613b..4f2c89070cb 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -42,7 +42,7 @@ struct Scene;
void BKE_group_free(struct Group *group);
struct Group *BKE_group_add(struct Main *bmain, const char *name);
-struct Group *BKE_group_copy(struct Group *group);
+struct Group *BKE_group_copy(struct Main *bmain, struct Group *group);
bool BKE_group_object_add(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
bool BKE_group_object_unlink(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
struct Group *BKE_group_object_find(struct Group *group, struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index 86484db3809..f30f9eac4e8 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -51,8 +51,7 @@ extern "C" {
void BKE_key_free(struct Key *sc);
void BKE_key_free_nolib(struct Key *key);
struct Key *BKE_key_add(struct ID *id);
-struct Key *BKE_key_copy(struct Key *key);
-struct Key *BKE_key_copy_ex(struct Main *bmain, struct Key *key);
+struct Key *BKE_key_copy(struct Main *bmain, struct Key *key);
struct Key *BKE_key_copy_nolib(struct Key *key);
void BKE_key_make_local(struct Main *bmain, struct Key *key);
void BKE_key_sort(struct Key *key);
diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h
index d830c19651f..3bdef8eca48 100644
--- a/source/blender/blenkernel/BKE_lamp.h
+++ b/source/blender/blenkernel/BKE_lamp.h
@@ -44,7 +44,7 @@ struct Scene;
void BKE_lamp_init(struct Lamp *la);
struct Lamp *BKE_lamp_add(struct Main *bmain, const char *name) ATTR_WARN_UNUSED_RESULT;
-struct Lamp *BKE_lamp_copy(struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
+struct Lamp *BKE_lamp_copy(struct Main *bmain, struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
struct Lamp *localize_lamp(struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
void BKE_lamp_make_local(struct Lamp *la);
void BKE_lamp_free(struct Lamp *la);
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index a82525225d5..606df9dcec8 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -47,8 +47,7 @@ struct MDeformVert;
void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
void BKE_lattice_init(struct Lattice *lt);
struct Lattice *BKE_lattice_add(struct Main *bmain, const char *name);
-struct Lattice *BKE_lattice_copy(struct Lattice *lt);
-struct Lattice *BKE_lattice_copy_ex(struct Main *bmain, struct Lattice *lt);
+struct Lattice *BKE_lattice_copy(struct Main *bmain, struct Lattice *lt);
void BKE_lattice_free(struct Lattice *lt);
void BKE_lattice_make_local(struct Main *bmain, struct Lattice *lt);
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 37937aa20b3..f3a02019064 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -52,9 +52,8 @@ struct PropertyRNA;
void *BKE_libblock_alloc_notest(short type);
void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BKE_libblock_init_empty(struct ID *id);
-void *BKE_libblock_copy_ex(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+void *BKE_libblock_copy(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void *BKE_libblock_copy_nolib(struct ID *id, const bool do_action) ATTR_NONNULL();
-void *BKE_libblock_copy(struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const bool do_action);
void BKE_libblock_relink(struct ID *id);
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
@@ -83,7 +82,7 @@ void id_fake_user_clear(struct ID *id);
bool id_make_local(struct Main *bmain, struct ID *id, bool test);
bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
-bool id_copy(struct ID *id, struct ID **newid, bool test);
+bool id_copy(struct Main *bmain, struct ID *id, struct ID **newid, bool test);
void id_sort_by_name(struct ListBase *lb, struct ID *id);
bool new_id(struct ListBase *lb, struct ID *id, const char *name);
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index f3d12b5a8cc..97bfd0f3f07 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -123,7 +123,7 @@ void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, const eMask
/* 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 Mask *mask);
+struct Mask *BKE_mask_copy(struct Main *bmain, 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 539cf8a57d7..bcb2db759df 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -54,7 +54,7 @@ void BKE_material_init(struct Material *ma);
void BKE_material_remap_object(struct Object *ob, const unsigned int *remap);
void BKE_material_remap_object_calc(struct Object *ob_dst, struct Object *ob_src, short *remap_src_to_dst);
struct Material *BKE_material_add(struct Main *bmain, const char *name);
-struct Material *BKE_material_copy(struct Material *ma);
+struct Material *BKE_material_copy(struct Main *bmain, struct Material *ma);
struct Material *localize_material(struct Material *ma);
struct Material *give_node_material(struct Material *ma); /* returns node material or self */
void BKE_material_make_local(struct Material *ma);
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index abb1259ca54..42704c1b2db 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -41,8 +41,7 @@ struct MetaElem;
void BKE_mball_free(struct MetaBall *mb);
void BKE_mball_init(struct MetaBall *mb);
struct MetaBall *BKE_mball_add(struct Main *bmain, const char *name);
-struct MetaBall *BKE_mball_copy(struct MetaBall *mb);
-struct MetaBall *BKE_mball_copy_ex(struct Main *bmain, struct MetaBall *mb);
+struct MetaBall *BKE_mball_copy(struct Main *bmain, struct MetaBall *mb);
void BKE_mball_make_local(struct Main *bmain, struct MetaBall *mb);
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 3d05af9a126..d3bb34d7a41 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -87,8 +87,7 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v);
void BKE_mesh_free(struct Mesh *me);
void BKE_mesh_init(struct Mesh *me);
struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
-struct Mesh *BKE_mesh_copy_ex(struct Main *bmain, struct Mesh *me);
-struct Mesh *BKE_mesh_copy(struct Mesh *me);
+struct Mesh *BKE_mesh_copy(struct Main *bmain, struct Mesh *me);
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_node.h b/source/blender/blenkernel/BKE_node.h
index bf198c9b86b..c5d10441ebe 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -336,7 +336,7 @@ struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char
/* copy/free funcs, need to manage ID users */
void ntreeFreeTree(struct bNodeTree *ntree);
struct bNodeTree *ntreeCopyTree_ex(struct bNodeTree *ntree, struct Main *bmain, const bool do_id_user);
-struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree);
+struct bNodeTree *ntreeCopyTree(struct Main *bmain, struct bNodeTree *ntree);
void ntreeSwitchID_ex(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to, const bool do_id_user);
void ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to);
/* node->id user count */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index a1f1bee2642..1f0dc5f1814 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -106,7 +106,7 @@ struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct Scene *scene)
struct Object *BKE_object_lod_matob_get(struct Object *ob, struct Scene *scene);
struct Object *BKE_object_copy_ex(struct Main *bmain, struct Object *ob, bool copy_caches);
-struct Object *BKE_object_copy(struct Object *ob);
+struct Object *BKE_object_copy(struct Main *bmain, struct Object *ob);
void BKE_object_make_local(struct Main *bmain, struct Object *ob);
bool BKE_object_is_libdata(struct Object *ob);
bool BKE_object_obdata_is_libdata(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 5daa94c4302..4f43037682a 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -323,7 +323,7 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P
struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name);
void object_remove_particle_system(struct Scene *scene, struct Object *ob);
struct ParticleSettings *psys_new_settings(const char *name, struct Main *main);
-struct ParticleSettings *BKE_particlesettings_copy(struct ParticleSettings *part);
+struct ParticleSettings *BKE_particlesettings_copy(struct Main *bmain, struct ParticleSettings *part);
void BKE_particlesettings_make_local(struct ParticleSettings *part);
void psys_reset(struct ParticleSystem *psys, int mode);
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index ccb7dc8e015..03af0b7d6c9 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -98,7 +98,7 @@ void BKE_scene_base_flag_from_objects(struct Scene *scene);
void BKE_scene_set_background(struct Main *bmain, struct Scene *sce);
struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name);
-struct Scene *BKE_scene_copy(struct Scene *sce, int type);
+struct Scene *BKE_scene_copy(struct Main *bmain, struct Scene *sce, int type);
void BKE_scene_groups_relink(struct Scene *sce);
struct Object *BKE_scene_camera_find(struct Scene *sc);
diff --git a/source/blender/blenkernel/BKE_speaker.h b/source/blender/blenkernel/BKE_speaker.h
index 5f30df1d6e3..1f633e9854b 100644
--- a/source/blender/blenkernel/BKE_speaker.h
+++ b/source/blender/blenkernel/BKE_speaker.h
@@ -33,7 +33,7 @@ struct Speaker;
void BKE_speaker_init(struct Speaker *spk);
void *BKE_speaker_add(struct Main *bmain, const char *name);
-struct Speaker *BKE_speaker_copy(struct Speaker *spk);
+struct Speaker *BKE_speaker_copy(struct Main *bmain, struct Speaker *spk);
void BKE_speaker_make_local(struct Speaker *spk);
void BKE_speaker_free(struct Speaker *spk);
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 95918b9ca0b..37bd25cf067 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -69,7 +69,7 @@ void colorband_update_sort(struct ColorBand *coba);
void BKE_texture_free(struct Tex *tex);
void BKE_texture_default(struct Tex *tex);
-struct Tex *BKE_texture_copy(struct Tex *tex);
+struct Tex *BKE_texture_copy(struct Main *bmain, struct Tex *tex);
struct Tex *BKE_texture_add(struct Main *bmain, const char *name);
struct Tex *BKE_texture_localize(struct Tex *tex);
void BKE_texture_make_local(struct Tex *tex);
diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h
index 0be61fe0229..197cebc423e 100644
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@ -39,7 +39,7 @@ struct World;
void BKE_world_free(struct World *sc);
void BKE_world_init(struct World *wrld);
struct World *add_world(struct Main *bmian, const char *name);
-struct World *BKE_world_copy(struct World *wrld);
+struct World *BKE_world_copy(struct Main *bmain, struct World *wrld);
struct World *localize_world(struct World *wrld);
void BKE_world_make_local(struct World *wrld);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 9d6b2a05681..5ac80ae1b7c 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -148,7 +148,7 @@ void BKE_action_make_local(bAction *act)
id_clear_lib_data(bmain, &act->id);
}
else if (mlac.is_local && mlac.is_lib) {
- mlac.act_new = BKE_action_copy(act);
+ mlac.act_new = BKE_action_copy(bmain, act);
mlac.act_new->id.us = 0;
BKE_id_lib_local_paths(bmain, act->id.lib, &mlac.act_new->id);
@@ -176,7 +176,7 @@ void BKE_action_free(bAction *act)
/* .................................. */
-bAction *BKE_action_copy(bAction *src)
+bAction *BKE_action_copy(Main *bmain, bAction *src)
{
bAction *dst = NULL;
bActionGroup *dgrp, *sgrp;
@@ -184,7 +184,7 @@ bAction *BKE_action_copy(bAction *src)
if (src == NULL)
return NULL;
- dst = BKE_libblock_copy(&src->id);
+ dst = BKE_libblock_copy(bmain, &src->id);
/* duplicate the lists of groups and markers */
BLI_duplicatelist(&dst->groups, &src->groups);
@@ -214,7 +214,7 @@ bAction *BKE_action_copy(bAction *src)
}
if (ID_IS_LINKED_DATABLOCK(src)) {
- BKE_id_lib_local_paths(G.main, src->id.lib, &dst->id);
+ BKE_id_lib_local_paths(bmain, src->id.lib, &dst->id);
}
return dst;
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 10e7b019505..f478a19235c 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -268,8 +268,8 @@ AnimData *BKE_animdata_copy(AnimData *adt, const bool do_action)
/* make a copy of action - at worst, user has to delete copies... */
if (do_action) {
- dadt->action = BKE_action_copy(adt->action);
- dadt->tmpact = BKE_action_copy(adt->tmpact);
+ dadt->action = BKE_action_copy(G.main, adt->action);
+ dadt->tmpact = BKE_action_copy(G.main, adt->tmpact);
}
else {
id_us_plus((ID *)dadt->action);
@@ -313,11 +313,11 @@ void BKE_animdata_copy_id_action(ID *id)
if (adt) {
if (adt->action) {
id_us_min((ID *)adt->action);
- adt->action = BKE_action_copy(adt->action);
+ adt->action = BKE_action_copy(G.main, adt->action);
}
if (adt->tmpact) {
id_us_min((ID *)adt->tmpact);
- adt->tmpact = BKE_action_copy(adt->tmpact);
+ adt->tmpact = BKE_action_copy(G.main, adt->tmpact);
}
}
}
@@ -341,8 +341,8 @@ void BKE_animdata_merge_copy(ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes a
/* handle actions... */
if (action_mode == ADT_MERGECOPY_SRC_COPY) {
/* make a copy of the actions */
- dst->action = BKE_action_copy(src->action);
- dst->tmpact = BKE_action_copy(src->tmpact);
+ dst->action = BKE_action_copy(G.main, src->action);
+ dst->tmpact = BKE_action_copy(G.main, src->tmpact);
}
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 572490f937c..4ed0196ba9d 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -168,7 +168,7 @@ void BKE_armature_make_local(bArmature *arm)
id_clear_lib_data(bmain, &arm->id);
}
else if (is_local && is_lib) {
- bArmature *arm_new = BKE_armature_copy(arm);
+ bArmature *arm_new = BKE_armature_copy(bmain, arm);
arm_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
@@ -208,13 +208,13 @@ static void copy_bonechildren(Bone *newBone, Bone *oldBone, Bone *actBone, Bone
}
}
-bArmature *BKE_armature_copy(bArmature *arm)
+bArmature *BKE_armature_copy(Main *bmain, bArmature *arm)
{
bArmature *newArm;
Bone *oldBone, *newBone;
Bone *newActBone = NULL;
- newArm = BKE_libblock_copy(&arm->id);
+ newArm = BKE_libblock_copy(bmain, &arm->id);
BLI_duplicatelist(&newArm->bonebase, &arm->bonebase);
/* Duplicate the childrens' lists */
@@ -232,7 +232,7 @@ bArmature *BKE_armature_copy(bArmature *arm)
newArm->sketch = NULL;
if (ID_IS_LINKED_DATABLOCK(arm)) {
- BKE_id_lib_local_paths(G.main, arm->id.lib, &newArm->id);
+ BKE_id_lib_local_paths(bmain, arm->id.lib, &newArm->id);
}
return newArm;
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 6d8dbcc688c..5505d3861d7 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -170,11 +170,11 @@ struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode)
return NULL;
}
-Brush *BKE_brush_copy(Brush *brush)
+Brush *BKE_brush_copy(Main *bmain, Brush *brush)
{
Brush *brushn;
- brushn = BKE_libblock_copy(&brush->id);
+ brushn = BKE_libblock_copy(bmain, &brush->id);
if (brush->mtex.tex)
id_us_plus((ID *)brush->mtex.tex);
@@ -196,7 +196,7 @@ Brush *BKE_brush_copy(Brush *brush)
id_fake_user_set(&brush->id);
if (ID_IS_LINKED_DATABLOCK(brush)) {
- BKE_id_lib_local_paths(G.main, brush->id.lib, &brushn->id);
+ BKE_id_lib_local_paths(bmain, brush->id.lib, &brushn->id);
}
return brushn;
@@ -261,7 +261,7 @@ void BKE_brush_make_local(Brush *brush)
id_fake_user_set(&brush->id);
}
else if (is_local && is_lib) {
- Brush *brush_new = BKE_brush_copy(brush); /* Ensures FAKE_USER is set */
+ Brush *brush_new = BKE_brush_copy(bmain, brush); /* Ensures FAKE_USER is set */
id_us_min(&brush_new->id); /* Remove user added by standard BKE_libblock_copy(). */
/* Remap paths of new ID using old library as base. */
@@ -469,6 +469,7 @@ void BKE_brush_curve_preset(Brush *b, int preset)
curvemapping_changed(b->curve, false);
}
+/* XXX Unused function. */
int BKE_brush_texture_set_nr(Brush *brush, int nr)
{
ID *idtest, *id = NULL;
@@ -477,7 +478,7 @@ int BKE_brush_texture_set_nr(Brush *brush, int nr)
idtest = (ID *)BLI_findlink(&G.main->tex, nr - 1);
if (idtest == NULL) { /* new tex */
- if (id) idtest = (ID *)BKE_texture_copy((Tex *)id);
+ if (id) idtest = (ID *)BKE_texture_copy(G.main, (Tex *)id);
else idtest = (ID *)BKE_texture_add(G.main, "Tex");
id_us_min(idtest);
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 9fd2c2ddd14..41c67ef5365 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -91,16 +91,16 @@ void *BKE_camera_add(Main *bmain, const char *name)
return cam;
}
-Camera *BKE_camera_copy(Camera *cam)
+Camera *BKE_camera_copy(Main *bmain, Camera *cam)
{
Camera *camn;
- camn = BKE_libblock_copy(&cam->id);
+ camn = BKE_libblock_copy(bmain, &cam->id);
id_lib_extern((ID *)camn->dof_ob);
if (ID_IS_LINKED_DATABLOCK(cam)) {
- BKE_id_lib_local_paths(G.main, cam->id.lib, &camn->id);
+ BKE_id_lib_local_paths(bmain, cam->id.lib, &camn->id);
}
return camn;
@@ -134,7 +134,7 @@ void BKE_camera_make_local(Camera *cam)
id_clear_lib_data(bmain, &cam->id);
}
else if (is_local && is_lib) {
- Camera *cam_new = BKE_camera_copy(cam);
+ Camera *cam_new = BKE_camera_copy(bmain, cam);
cam_new->id.us = 0;
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 4dc0f1ccf8c..3a7be948760 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -174,12 +174,12 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
return cu;
}
-Curve *BKE_curve_copy_ex(Main *bmain, Curve *cu)
+Curve *BKE_curve_copy(Main *bmain, Curve *cu)
{
Curve *cun;
int a;
- cun = BKE_libblock_copy_ex(bmain, &cu->id);
+ cun = BKE_libblock_copy(bmain, &cu->id);
BLI_listbase_clear(&cun->nurb);
BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb));
@@ -195,7 +195,7 @@ Curve *BKE_curve_copy_ex(Main *bmain, Curve *cu)
cun->bb = MEM_dupallocN(cu->bb);
if (cu->key) {
- cun->key = BKE_key_copy_ex(bmain, cu->key);
+ cun->key = BKE_key_copy(bmain, cu->key);
cun->key->from = (ID *)cun;
}
@@ -219,11 +219,6 @@ Curve *BKE_curve_copy_ex(Main *bmain, Curve *cu)
return cun;
}
-Curve *BKE_curve_copy(Curve *cu)
-{
- return BKE_curve_copy_ex(G.main, cu);
-}
-
static int extern_local_curve_callback(
void *UNUSED(user_data), struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag)
{
@@ -263,7 +258,7 @@ void BKE_curve_make_local(Main *bmain, Curve *cu)
extern_local_curve(cu);
}
else {
- Curve *cu_new = BKE_curve_copy_ex(bmain, cu);
+ Curve *cu_new = BKE_curve_copy(bmain, cu);
cu_new->id.us = 0;
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index af1bcd0c545..ac4f566dc62 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -49,6 +49,7 @@
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_library.h"
+#include "BKE_main.h"
/* ************************************************** */
@@ -358,7 +359,7 @@ bGPDlayer *gpencil_layer_duplicate(bGPDlayer *src)
}
/* make a copy of a given gpencil datablock */
-bGPdata *gpencil_data_duplicate(bGPdata *src, bool internal_copy)
+bGPdata *gpencil_data_duplicate(Main *bmain, bGPdata *src, bool internal_copy)
{
bGPDlayer *gpl, *gpld;
bGPdata *dst;
@@ -374,7 +375,7 @@ bGPdata *gpencil_data_duplicate(bGPdata *src, bool internal_copy)
}
else {
/* make a copy when others use this */
- dst = BKE_libblock_copy(&src->id);
+ dst = BKE_libblock_copy(bmain, &src->id);
}
/* copy layers */
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index ce7ef1f710a..99a83665db7 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -87,18 +87,18 @@ Group *BKE_group_add(Main *bmain, const char *name)
return group;
}
-Group *BKE_group_copy(Group *group)
+Group *BKE_group_copy(Main *bmain, Group *group)
{
Group *groupn;
- groupn = BKE_libblock_copy(&group->id);
+ groupn = BKE_libblock_copy(bmain, &group->id);
BLI_duplicatelist(&groupn->gobject, &group->gobject);
/* Do not copy group's preview (same behavior as for objects). */
groupn->preview = NULL;
if (ID_IS_LINKED_DATABLOCK(group)) {
- BKE_id_lib_local_paths(G.main, group->id.lib, &groupn->id);
+ BKE_id_lib_local_paths(bmain, group->id.lib, &groupn->id);
}
return groupn;
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index ed8095444a4..2b7968eec1d 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -150,12 +150,12 @@ Key *BKE_key_add(ID *id) /* common function */
return key;
}
-Key *BKE_key_copy_ex(Main *bmain, Key *key)
+Key *BKE_key_copy(Main *bmain, Key *key)
{
Key *keyn;
KeyBlock *kbn, *kb;
- keyn = BKE_libblock_copy_ex(bmain, &key->id);
+ keyn = BKE_libblock_copy(bmain, &key->id);
BLI_duplicatelist(&keyn->block, &key->block);
@@ -177,11 +177,6 @@ Key *BKE_key_copy_ex(Main *bmain, Key *key)
return keyn;
}
-Key *BKE_key_copy(Key *key)
-{
- return BKE_key_copy_ex(G.main, key);
-}
-
Key *BKE_key_copy_nolib(Key *key)
{
Key *keyn;
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 43396834650..7ab71938cf2 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -114,12 +114,12 @@ Lamp *BKE_lamp_add(Main *bmain, const char *name)
return la;
}
-Lamp *BKE_lamp_copy(Lamp *la)
+Lamp *BKE_lamp_copy(Main *bmain, Lamp *la)
{
Lamp *lan;
int a;
- lan = BKE_libblock_copy(&la->id);
+ lan = BKE_libblock_copy(bmain, &la->id);
for (a = 0; a < MAX_MTEX; a++) {
if (lan->mtex[a]) {
@@ -132,13 +132,13 @@ Lamp *BKE_lamp_copy(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
if (la->nodetree)
- lan->nodetree = ntreeCopyTree(la->nodetree);
+ lan->nodetree = ntreeCopyTree(bmain, la->nodetree);
if (la->preview)
lan->preview = BKE_previewimg_copy(la->preview);
if (ID_IS_LINKED_DATABLOCK(la)) {
- BKE_id_lib_local_paths(G.main, la->id.lib, &lan->id);
+ BKE_id_lib_local_paths(bmain, la->id.lib, &lan->id);
}
return lan;
@@ -200,7 +200,7 @@ void BKE_lamp_make_local(Lamp *la)
id_clear_lib_data(bmain, &la->id);
}
else if (is_local && is_lib) {
- Lamp *la_new = BKE_lamp_copy(la);
+ Lamp *la_new = BKE_lamp_copy(bmain, la);
la_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index e85fad55532..88b0418938f 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -277,15 +277,15 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
return lt;
}
-Lattice *BKE_lattice_copy_ex(Main *bmain, Lattice *lt)
+Lattice *BKE_lattice_copy(Main *bmain, Lattice *lt)
{
Lattice *ltn;
- ltn = BKE_libblock_copy_ex(bmain, &lt->id);
+ ltn = BKE_libblock_copy(bmain, &lt->id);
ltn->def = MEM_dupallocN(lt->def);
if (lt->key) {
- ltn->key = BKE_key_copy_ex(bmain, ltn->key);
+ ltn->key = BKE_key_copy(bmain, ltn->key);
ltn->key->from = (ID *)ltn;
}
@@ -304,11 +304,6 @@ Lattice *BKE_lattice_copy_ex(Main *bmain, Lattice *lt)
return ltn;
}
-Lattice *BKE_lattice_copy(Lattice *lt)
-{
- return BKE_lattice_copy_ex(G.main, lt);
-}
-
/** Free (or release) any data used by this lattice (does not free the lattice itself). */
void BKE_lattice_free(Lattice *lt)
{
@@ -358,7 +353,7 @@ void BKE_lattice_make_local(Main *bmain, Lattice *lt)
/* No extern_local_lattice... */
}
else {
- Lattice *lt_new = BKE_lattice_copy_ex(bmain, lt);
+ Lattice *lt_new = BKE_lattice_copy(bmain, lt);
lt_new->id.us = 0;
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index fa63e7a5f84..f85765435f2 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -344,9 +344,11 @@ bool id_make_local(Main *bmain, ID *id, bool test)
* Invokes the appropriate copy method for the block and returns the result in
* newid, unless test. Returns true if the block can be copied.
*/
-bool id_copy(ID *id, ID **newid, bool test)
+bool id_copy(Main *bmain, ID *id, ID **newid, bool test)
{
- if (!test) *newid = NULL;
+ if (!test) {
+ *newid = NULL;
+ }
/* conventions:
* - make shallow copy, only this ID block
@@ -357,83 +359,83 @@ bool id_copy(ID *id, ID **newid, bool test)
case ID_LI:
return false; /* can't be copied from here */
case ID_OB:
- if (!test) *newid = (ID *)BKE_object_copy((Object *)id);
+ if (!test) *newid = (ID *)BKE_object_copy(bmain, (Object *)id);
return true;
case ID_ME:
- if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id);
+ if (!test) *newid = (ID *)BKE_mesh_copy(bmain, (Mesh *)id);
return true;
case ID_CU:
- if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id);
+ if (!test) *newid = (ID *)BKE_curve_copy(bmain, (Curve *)id);
return true;
case ID_MB:
- if (!test) *newid = (ID *)BKE_mball_copy((MetaBall *)id);
+ if (!test) *newid = (ID *)BKE_mball_copy(bmain, (MetaBall *)id);
return true;
case ID_MA:
- if (!test) *newid = (ID *)BKE_material_copy((Material *)id);
+ if (!test) *newid = (ID *)BKE_material_copy(bmain, (Material *)id);
return true;
case ID_TE:
- if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id);
+ if (!test) *newid = (ID *)BKE_texture_copy(bmain, (Tex *)id);
return true;
case ID_IM:
- if (!test) *newid = (ID *)BKE_image_copy(G.main, (Image *)id);
+ if (!test) *newid = (ID *)BKE_image_copy(bmain, (Image *)id);
return true;
case ID_LT:
- if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id);
+ if (!test) *newid = (ID *)BKE_lattice_copy(bmain, (Lattice *)id);
return true;
case ID_LA:
- if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id);
+ if (!test) *newid = (ID *)BKE_lamp_copy(bmain, (Lamp *)id);
return true;
case ID_SPK:
- if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id);
+ if (!test) *newid = (ID *)BKE_speaker_copy(bmain, (Speaker *)id);
return true;
case ID_CA:
- if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id);
+ if (!test) *newid = (ID *)BKE_camera_copy(bmain, (Camera *)id);
return true;
case ID_IP:
return false; /* deprecated */
case ID_KE:
- if (!test) *newid = (ID *)BKE_key_copy((Key *)id);
+ if (!test) *newid = (ID *)BKE_key_copy(bmain, (Key *)id);
return true;
case ID_WO:
- if (!test) *newid = (ID *)BKE_world_copy((World *)id);
+ if (!test) *newid = (ID *)BKE_world_copy(bmain, (World *)id);
return true;
case ID_SCR:
return false; /* can't be copied from here */
case ID_VF:
return false; /* not implemented */
case ID_TXT:
- if (!test) *newid = (ID *)BKE_text_copy(G.main, (Text *)id);
+ if (!test) *newid = (ID *)BKE_text_copy(bmain, (Text *)id);
return true;
case ID_SO:
return false; /* not implemented */
case ID_GR:
- if (!test) *newid = (ID *)BKE_group_copy((Group *)id);
+ if (!test) *newid = (ID *)BKE_group_copy(bmain, (Group *)id);
return true;
case ID_AR:
- if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id);
+ if (!test) *newid = (ID *)BKE_armature_copy(bmain, (bArmature *)id);
return true;
case ID_AC:
- if (!test) *newid = (ID *)BKE_action_copy((bAction *)id);
+ if (!test) *newid = (ID *)BKE_action_copy(bmain, (bAction *)id);
return true;
case ID_NT:
- if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id);
+ if (!test) *newid = (ID *)ntreeCopyTree(bmain, (bNodeTree *)id);
return true;
case ID_BR:
- if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id);
+ if (!test) *newid = (ID *)BKE_brush_copy(bmain, (Brush *)id);
return true;
case ID_PA:
- if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id);
+ if (!test) *newid = (ID *)BKE_particlesettings_copy(bmain, (ParticleSettings *)id);
return true;
case ID_WM:
return false; /* can't be copied from here */
case ID_GD:
- if (!test) *newid = (ID *)gpencil_data_duplicate((bGPdata *)id, false);
+ if (!test) *newid = (ID *)gpencil_data_duplicate(bmain, (bGPdata *)id, false);
return true;
case ID_MSK:
- if (!test) *newid = (ID *)BKE_mask_copy((Mask *)id);
+ if (!test) *newid = (ID *)BKE_mask_copy(bmain, (Mask *)id);
return true;
case ID_LS:
- if (!test) *newid = (ID *)BKE_linestyle_copy(G.main, (FreestyleLineStyle *)id);
+ if (!test) *newid = (ID *)BKE_linestyle_copy(bmain, (FreestyleLineStyle *)id);
return true;
}
@@ -448,7 +450,7 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
if (id) {
/* if property isn't editable, we're going to have an extra block hanging around until we save */
if (RNA_property_editable(ptr, prop)) {
- if (id_copy(id, &newid, false) && newid) {
+ if (id_copy(CTX_data_main(C), id, &newid, false) && newid) {
/* copy animation actions too */
BKE_animdata_copy_id_action(id);
/* us is 1 by convention, but RNA_property_pointer_set
@@ -976,7 +978,7 @@ void BKE_libblock_copy_data(ID *id, const ID *id_from, const bool do_action)
}
/* used everywhere in blenkernel */
-void *BKE_libblock_copy_ex(Main *bmain, ID *id)
+void *BKE_libblock_copy(Main *bmain, ID *id)
{
ID *idn;
size_t idn_len;
@@ -1028,11 +1030,6 @@ void *BKE_libblock_copy_nolib(ID *id, const bool do_action)
return idn;
}
-void *BKE_libblock_copy(ID *id)
-{
- return BKE_libblock_copy_ex(G.main, id);
-}
-
static int id_relink_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **id_pointer, const int cd_flag)
{
ID *id = *id_pointer;
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 2985038bcae..591975b05fa 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -171,7 +171,7 @@ FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, FreestyleLineStyle *l
}
}
if (linestyle->nodetree) {
- new_linestyle->nodetree = ntreeCopyTree(linestyle->nodetree);
+ new_linestyle->nodetree = ntreeCopyTree(bmain, linestyle->nodetree);
}
new_linestyle->r = linestyle->r;
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index dabdb4c81c6..f804a4c3919 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -848,11 +848,11 @@ Mask *BKE_mask_copy_nolib(Mask *mask)
return mask_new;
}
-Mask *BKE_mask_copy(Mask *mask)
+Mask *BKE_mask_copy(Main *bmain, Mask *mask)
{
Mask *mask_new;
- mask_new = BKE_libblock_copy(&mask->id);
+ mask_new = BKE_libblock_copy(bmain, &mask->id);
BLI_listbase_clear(&mask_new->masklayers);
@@ -862,7 +862,7 @@ Mask *BKE_mask_copy(Mask *mask)
id_fake_user_set(&mask->id);
if (ID_IS_LINKED_DATABLOCK(mask)) {
- BKE_id_lib_local_paths(G.main, mask->id.lib, &mask_new->id);
+ BKE_id_lib_local_paths(bmain, mask->id.lib, &mask_new->id);
}
return mask_new;
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 1b6fd300f67..467bf9bf580 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -217,12 +217,12 @@ Material *BKE_material_add(Main *bmain, const char *name)
}
/* XXX keep synced with next function */
-Material *BKE_material_copy(Material *ma)
+Material *BKE_material_copy(Main *bmain, Material *ma)
{
Material *man;
int a;
- man = BKE_libblock_copy(&ma->id);
+ man = BKE_libblock_copy(bmain, &ma->id);
id_lib_extern((ID *)man->group);
@@ -240,13 +240,13 @@ Material *BKE_material_copy(Material *ma)
if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview);
if (ma->nodetree) {
- man->nodetree = ntreeCopyTree(ma->nodetree);
+ man->nodetree = ntreeCopyTree(bmain, ma->nodetree);
}
BLI_listbase_clear(&man->gpumaterial);
if (ID_IS_LINKED_DATABLOCK(ma)) {
- BKE_id_lib_local_paths(G.main, ma->id.lib, &man->id);
+ BKE_id_lib_local_paths(bmain, ma->id.lib, &man->id);
}
return man;
@@ -376,7 +376,7 @@ void BKE_material_make_local(Material *ma)
}
/* Both user and local, so copy. */
else if (is_local && is_lib) {
- Material *ma_new = BKE_material_copy(ma);
+ Material *ma_new = BKE_material_copy(bmain, ma);
ma_new->id.us = 0;
@@ -2161,7 +2161,7 @@ static void convert_tfacematerial(Main *main, Material *ma)
}
/* create a new material */
else {
- mat_new = BKE_material_copy(ma);
+ mat_new = BKE_material_copy(main, ma);
if (mat_new) {
/* rename the material*/
BLI_strncpy(mat_new->id.name, idname, sizeof(mat_new->id.name));
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index c6e6bb86659..0a29b2d53fd 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -102,12 +102,12 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name)
return mb;
}
-MetaBall *BKE_mball_copy_ex(Main *bmain, MetaBall *mb)
+MetaBall *BKE_mball_copy(Main *bmain, MetaBall *mb)
{
MetaBall *mbn;
int a;
- mbn = BKE_libblock_copy_ex(bmain, &mb->id);
+ mbn = BKE_libblock_copy(bmain, &mb->id);
BLI_duplicatelist(&mbn->elems, &mb->elems);
@@ -126,11 +126,6 @@ MetaBall *BKE_mball_copy_ex(Main *bmain, MetaBall *mb)
return mbn;
}
-MetaBall *BKE_mball_copy(MetaBall *mb)
-{
- return BKE_mball_copy_ex(G.main, mb);
-}
-
static int extern_local_mball_callback(
void *UNUSED(user_data), struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag)
{
@@ -167,7 +162,7 @@ void BKE_mball_make_local(Main *bmain, MetaBall *mb)
extern_local_mball(mb);
}
else {
- MetaBall *mb_new = BKE_mball_copy_ex(bmain, mb);
+ MetaBall *mb_new = BKE_mball_copy(bmain, mb);
mb_new->id.us = 0;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index b2ab83a7018..e737696b3af 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -493,7 +493,7 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
return me;
}
-Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
+Mesh *BKE_mesh_copy(Main *bmain, Mesh *me)
{
Mesh *men;
MTFace *tface;
@@ -501,7 +501,7 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
int a, i;
const int do_tessface = ((me->totface != 0) && (me->totpoly == 0)); /* only do tessface if we have no polys */
- men = BKE_libblock_copy_ex(bmain, &me->id);
+ men = BKE_libblock_copy(bmain, &me->id);
men->mat = MEM_dupallocN(me->mat);
for (a = 0; a < men->totcol; a++) {
@@ -549,7 +549,7 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
men->bb = MEM_dupallocN(men->bb);
if (me->key) {
- men->key = BKE_key_copy_ex(bmain, me->key);
+ men->key = BKE_key_copy(bmain, me->key);
men->key->from = (ID *)men;
}
@@ -560,11 +560,6 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
return men;
}
-Mesh *BKE_mesh_copy(Mesh *me)
-{
- return BKE_mesh_copy_ex(G.main, me);
-}
-
BMesh *BKE_mesh_to_bmesh(
Mesh *me, Object *ob,
const bool add_key_index, const struct BMeshCreateParams *params)
@@ -650,7 +645,7 @@ void BKE_mesh_make_local(Main *bmain, Mesh *me)
expand_local_mesh(me);
}
else {
- Mesh *me_new = BKE_mesh_copy_ex(bmain, me);
+ Mesh *me_new = BKE_mesh_copy(bmain, me);
me_new->id.us = 0;
@@ -2338,7 +2333,7 @@ Mesh *BKE_mesh_new_from_object(
BKE_object_free_modifiers(tmpobj);
/* copies the data */
- copycu = tmpobj->data = BKE_curve_copy_ex(bmain, (Curve *) ob->data);
+ copycu = tmpobj->data = BKE_curve_copy(bmain, (Curve *) ob->data);
/* temporarily set edit so we get updates from edit mode, but
* also because for text datablocks copying it while in edit
@@ -2419,7 +2414,7 @@ Mesh *BKE_mesh_new_from_object(
/* copies object and modifiers (but not the data) */
if (cage) {
/* copies the data */
- tmpmesh = BKE_mesh_copy_ex(bmain, ob->data);
+ tmpmesh = BKE_mesh_copy(bmain, ob->data);
/* if not getting the original caged mesh, get final derived mesh */
}
else {
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 992042c8af2..c321bc92a71 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -183,7 +183,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip, const bool use_same_action)
}
else {
/* use a copy of the action instead (user count shouldn't have changed yet) */
- strip_d->act = BKE_action_copy(strip_d->act);
+ strip_d->act = BKE_action_copy(G.main, strip_d->act);
}
}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index cf70159a329..aaba5dff7e4 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1205,7 +1205,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, Main *bmain, bool ski
/* is ntree part of library? */
if (bmain && !skip_database && BLI_findindex(&bmain->nodetree, ntree) >= 0) {
- newtree = BKE_libblock_copy(&ntree->id);
+ newtree = BKE_libblock_copy(bmain, &ntree->id);
}
else {
newtree = BKE_libblock_copy_nolib(&ntree->id, true);
@@ -1300,9 +1300,9 @@ bNodeTree *ntreeCopyTree_ex(bNodeTree *ntree, Main *bmain, const bool do_id_user
{
return ntreeCopyTree_internal(ntree, bmain, false, do_id_user, true, true);
}
-bNodeTree *ntreeCopyTree(bNodeTree *ntree)
+bNodeTree *ntreeCopyTree(Main *bmain, bNodeTree *ntree)
{
- return ntreeCopyTree_ex(ntree, G.main, true);
+ return ntreeCopyTree_ex(ntree, bmain, true);
}
/* use when duplicating scenes */
@@ -1995,11 +1995,11 @@ void ntreeMakeLocal(bNodeTree *ntree, bool id_in_mainlist)
}
else if (local && lib) {
/* this is the mixed case, we copy the tree and assign it to local users */
- bNodeTree *newtree = ntreeCopyTree(ntree);
+ bNodeTree *newtree = ntreeCopyTree(bmain, ntree);
newtree->id.us = 0;
- FOREACH_NODETREE(G.main, tntree, owner_id) {
+ FOREACH_NODETREE(bmain, tntree, owner_id) {
bNode *node;
/* find if group is in tree */
for (node = tntree->nodes.first; node; node = node->next) {
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 623c437fea5..4031afb8a78 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1094,7 +1094,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
ModifierData *md;
int a;
- obn = BKE_libblock_copy_ex(bmain, &ob->id);
+ obn = BKE_libblock_copy(bmain, &ob->id);
if (ob->totcol) {
obn->mat = MEM_dupallocN(ob->mat);
@@ -1181,9 +1181,9 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
}
/* copy objects, will re-initialize cached simulation data */
-Object *BKE_object_copy(Object *ob)
+Object *BKE_object_copy(Main *bmain, Object *ob)
{
- return BKE_object_copy_ex(G.main, ob, false);
+ return BKE_object_copy_ex(bmain, ob, false);
}
static int extern_local_object_callback(
@@ -1223,7 +1223,7 @@ void BKE_object_make_local(Main *bmain, Object *ob)
extern_local_object(ob);
}
else {
- Object *ob_new = BKE_object_copy_ex(bmain, ob, false);
+ Object *ob_new = BKE_object_copy(bmain, ob);
ob_new->id.us = 0;
ob_new->proxy = ob_new->proxy_from = ob_new->proxy_group = NULL;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 4136f866f6a..6e13ce87172 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3304,12 +3304,12 @@ void BKE_particlesettings_rough_curve_init(ParticleSettings *part)
part->roughcurve = cumap;
}
-ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part)
+ParticleSettings *BKE_particlesettings_copy(Main *bmain, ParticleSettings *part)
{
ParticleSettings *partn;
int a;
- partn = BKE_libblock_copy(&part->id);
+ partn = BKE_libblock_copy(bmain, &part->id);
partn->pd = MEM_dupallocN(part->pd);
partn->pd2 = MEM_dupallocN(part->pd2);
partn->effector_weights = MEM_dupallocN(part->effector_weights);
@@ -3333,7 +3333,7 @@ ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part)
BLI_duplicatelist(&partn->dupliweights, &part->dupliweights);
if (ID_IS_LINKED_DATABLOCK(part)) {
- BKE_id_lib_local_paths(G.main, part->id.lib, &partn->id);
+ BKE_id_lib_local_paths(bmain, part->id.lib, &partn->id);
}
return partn;
@@ -3383,7 +3383,7 @@ void BKE_particlesettings_make_local(ParticleSettings *part)
expand_local_particlesettings(part);
}
else if (is_local && is_lib) {
- ParticleSettings *part_new = BKE_particlesettings_copy(part);
+ ParticleSettings *part_new = BKE_particlesettings_copy(bmain, part);
part_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 0e8efca04d0..c071aacc64b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -150,7 +150,7 @@ static void remove_sequencer_fcurves(Scene *sce)
}
}
-Scene *BKE_scene_copy(Scene *sce, int type)
+Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
{
Scene *scen;
SceneRenderLayer *srl, *new_srl;
@@ -161,7 +161,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
if (type == SCE_COPY_EMPTY) {
ListBase rl, rv;
/* XXX. main should become an arg */
- scen = BKE_scene_add(G.main, sce->id.name + 2);
+ scen = BKE_scene_add(bmain, sce->id.name + 2);
rl = scen->r.layers;
rv = scen->r.views;
@@ -182,10 +182,10 @@ Scene *BKE_scene_copy(Scene *sce, int type)
BKE_sound_destroy_scene(scen);
}
else {
- scen = BKE_libblock_copy(&sce->id);
+ scen = BKE_libblock_copy(bmain, &sce->id);
BLI_duplicatelist(&(scen->base), &(sce->base));
- BKE_main_id_clear_newpoins(G.main);
+ BKE_main_id_clear_newpoins(bmain);
id_us_plus((ID *)scen->world);
id_us_plus((ID *)scen->set);
@@ -209,7 +209,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
if (sce->nodetree) {
/* ID's are managed on both copy and switch */
- scen->nodetree = ntreeCopyTree(sce->nodetree);
+ scen->nodetree = ntreeCopyTree(bmain, sce->nodetree);
ntreeSwitchID(scen->nodetree, &sce->id, &scen->id);
}
@@ -237,7 +237,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
for (lineset = new_srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
if (lineset->linestyle) {
id_us_plus((ID *)lineset->linestyle);
- lineset->linestyle = BKE_linestyle_copy(G.main, lineset->linestyle);
+ lineset->linestyle = BKE_linestyle_copy(bmain, lineset->linestyle);
}
}
}
@@ -320,7 +320,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
if (type == SCE_COPY_FULL) {
if (scen->world) {
id_us_plus((ID *)scen->world);
- scen->world = BKE_world_copy(scen->world);
+ scen->world = BKE_world_copy(bmain, scen->world);
BKE_animdata_copy_id_action((ID *)scen->world);
}
@@ -334,7 +334,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
/* grease pencil */
if (scen->gpd) {
if (type == SCE_COPY_FULL) {
- scen->gpd = gpencil_data_duplicate(scen->gpd, false);
+ scen->gpd = gpencil_data_duplicate(bmain, scen->gpd, false);
}
else if (type == SCE_COPY_EMPTY) {
scen->gpd = NULL;
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index 58214e4a8d9..4cce0851ebc 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -66,11 +66,11 @@ void *BKE_speaker_add(Main *bmain, const char *name)
return spk;
}
-Speaker *BKE_speaker_copy(Speaker *spk)
+Speaker *BKE_speaker_copy(Main *bmain, Speaker *spk)
{
Speaker *spkn;
- spkn = BKE_libblock_copy(&spk->id);
+ spkn = BKE_libblock_copy(bmain, &spk->id);
if (spkn->sound)
id_us_plus(&spkn->sound->id);
@@ -118,7 +118,7 @@ void BKE_speaker_make_local(Speaker *spk)
extern_local_speaker(spk);
}
else if (is_local && is_lib) {
- Speaker *spk_new = BKE_speaker_copy(spk);
+ Speaker *spk_new = BKE_speaker_copy(bmain, spk);
spk_new->id.us = 0;
/* Remap paths of new ID using old library as base. */
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 2b713f980d5..6beaba1b41c 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -452,7 +452,7 @@ Text *BKE_text_copy(Main *bmain, Text *ta)
Text *tan;
TextLine *line, *tmp;
- tan = BKE_libblock_copy(&ta->id);
+ tan = BKE_libblock_copy(bmain, &ta->id);
/* file name can be NULL */
if (ta->name) {
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index a8657dd2cb0..877bc0c02b0 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -844,11 +844,11 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot)
/* ------------------------------------------------------------------------- */
-Tex *BKE_texture_copy(Tex *tex)
+Tex *BKE_texture_copy(Main *bmain, Tex *tex)
{
Tex *texn;
- texn = BKE_libblock_copy(&tex->id);
+ texn = BKE_libblock_copy(bmain, &tex->id);
if (BKE_texture_is_image_user(tex)) {
id_us_plus((ID *)texn->ima);
}
@@ -867,11 +867,11 @@ Tex *BKE_texture_copy(Tex *tex)
if (tex->nodetree->execdata) {
ntreeTexEndExecTree(tex->nodetree->execdata);
}
- texn->nodetree = ntreeCopyTree(tex->nodetree);
+ texn->nodetree = ntreeCopyTree(bmain, tex->nodetree);
}
if (ID_IS_LINKED_DATABLOCK(tex)) {
- BKE_id_lib_local_paths(G.main, tex->id.lib, &texn->id);
+ BKE_id_lib_local_paths(bmain, tex->id.lib, &texn->id);
}
return texn;
@@ -1011,7 +1011,7 @@ void BKE_texture_make_local(Tex *tex)
extern_local_texture(tex);
}
else if (is_local && is_lib) {
- Tex *tex_new = BKE_texture_copy(tex);
+ Tex *tex_new = BKE_texture_copy(bmain, tex);
tex_new->id.us = 0;
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index c6ab843b38a..cfd10e7ba35 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -117,12 +117,12 @@ World *add_world(Main *bmain, const char *name)
return wrld;
}
-World *BKE_world_copy(World *wrld)
+World *BKE_world_copy(Main *bmain, World *wrld)
{
World *wrldn;
int a;
- wrldn = BKE_libblock_copy(&wrld->id);
+ wrldn = BKE_libblock_copy(bmain, &wrld->id);
for (a = 0; a < MAX_MTEX; a++) {
if (wrld->mtex[a]) {
@@ -133,7 +133,7 @@ World *BKE_world_copy(World *wrld)
}
if (wrld->nodetree) {
- wrldn->nodetree = ntreeCopyTree(wrld->nodetree);
+ wrldn->nodetree = ntreeCopyTree(bmain, wrld->nodetree);
}
if (wrld->preview)
@@ -142,7 +142,7 @@ World *BKE_world_copy(World *wrld)
BLI_listbase_clear(&wrldn->gpumaterial);
if (ID_IS_LINKED_DATABLOCK(wrld)) {
- BKE_id_lib_local_paths(G.main, wrld->id.lib, &wrldn->id);
+ BKE_id_lib_local_paths(bmain, wrld->id.lib, &wrldn->id);
}
return wrldn;
@@ -202,7 +202,7 @@ void BKE_world_make_local(World *wrld)
id_clear_lib_data(bmain, &wrld->id);
}
else if (is_local && is_lib) {
- World *wrld_new = BKE_world_copy(wrld);
+ World *wrld_new = BKE_world_copy(bmain, wrld);
wrld_new->id.us = 0;
/* Remap paths of new ID using old library as base. */