Refactor `BKE_id_copy_ex` to return the new ID pointer.
Note that possibility to pass the new ID pointer as parameter was kept, as this is needed for some rather specific cases (like in depsgraph/COW, when copying into already allocated memory). Part of T71219.
This commit is contained in:
parent
1f50beb9f2
commit
7c9131d11e
|
@ -238,7 +238,10 @@ bool id_single_user(struct bContext *C,
|
|||
struct PropertyRNA *prop);
|
||||
bool BKE_id_copy_is_allowed(const struct ID *id);
|
||||
bool BKE_id_copy(struct Main *bmain, const struct ID *id, struct ID **newid);
|
||||
bool BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag);
|
||||
struct ID *BKE_id_copy_ex(struct Main *bmain,
|
||||
const struct ID *id,
|
||||
struct ID **r_newid,
|
||||
const int flag);
|
||||
struct ID *BKE_id_copy_for_duplicate(struct Main *bmain,
|
||||
struct ID *id,
|
||||
const uint duplicate_flags);
|
||||
|
|
|
@ -342,8 +342,8 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
|
|||
flag;
|
||||
BLI_assert(bmain != NULL);
|
||||
BLI_assert(dadt->action == NULL || dadt->action != dadt->tmpact);
|
||||
BKE_id_copy_ex(bmain, (ID *)dadt->action, (ID **)&dadt->action, id_copy_flag);
|
||||
BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, (ID **)&dadt->tmpact, id_copy_flag);
|
||||
dadt->action = (bAction *)BKE_id_copy_ex(bmain, (ID *)dadt->action, NULL, id_copy_flag);
|
||||
dadt->tmpact = (bAction *)BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, NULL, id_copy_flag);
|
||||
}
|
||||
else if (do_id_user) {
|
||||
id_us_plus((ID *)dadt->action);
|
||||
|
|
|
@ -1071,8 +1071,8 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
|
|||
|
||||
if (modified) {
|
||||
if (vertCos) {
|
||||
Mesh *temp_mesh;
|
||||
BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh, LIB_ID_COPY_LOCALIZE);
|
||||
Mesh *temp_mesh = (Mesh *)BKE_id_copy_ex(
|
||||
NULL, &modified->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
BKE_id_free(NULL, modified);
|
||||
modified = temp_mesh;
|
||||
|
||||
|
@ -1115,8 +1115,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
|
|||
|
||||
if (vertCos) {
|
||||
if (modified) {
|
||||
Mesh *temp_mesh;
|
||||
BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh, LIB_ID_COPY_LOCALIZE);
|
||||
Mesh *temp_mesh = (Mesh *)BKE_id_copy_ex(NULL, &modified->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
BKE_id_free(NULL, modified);
|
||||
modified = temp_mesh;
|
||||
|
||||
|
|
|
@ -660,10 +660,9 @@ static void gpencil_copy_activeframe_to_eval(
|
|||
|
||||
static bGPdata *gpencil_copy_for_eval(bGPdata *gpd)
|
||||
{
|
||||
int flags = LIB_ID_COPY_LOCALIZE;
|
||||
const int flags = LIB_ID_COPY_LOCALIZE;
|
||||
|
||||
bGPdata *result;
|
||||
BKE_id_copy_ex(NULL, &gpd->id, (ID **)&result, flags);
|
||||
bGPdata *result = (bGPdata *)BKE_id_copy_ex(NULL, &gpd->id, NULL, flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -330,8 +330,7 @@ Hair *BKE_hair_copy_for_eval(Hair *hair_src, bool reference)
|
|||
flags |= LIB_ID_COPY_CD_REFERENCE;
|
||||
}
|
||||
|
||||
Hair *result;
|
||||
BKE_id_copy_ex(NULL, &hair_src->id, (ID **)&result, flags);
|
||||
Hair *result = (Hair *)BKE_id_copy_ex(NULL, &hair_src->id, NULL, flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -530,51 +530,55 @@ bool BKE_id_copy_is_allowed(const ID *id)
|
|||
/**
|
||||
* Generic entry point for copying a data-block (new API).
|
||||
*
|
||||
* \note Copy is only affecting given data-block
|
||||
* \note Copy is generally only affecting the given data-block
|
||||
* (no ID used by copied one will be affected, besides usercount).
|
||||
* There is only one exception, if #LIB_ID_COPY_ACTIONS is defined,
|
||||
* actions used by animdata will be duplicated.
|
||||
* There are exceptions though:
|
||||
* - Embedded IDs (root node trees and master collections) are always copied with their owner.
|
||||
* - If #LIB_ID_COPY_ACTIONS is defined, actions used by animdata will be duplicated.
|
||||
* - If #LIB_ID_COPY_SHAPEKEY is defined, shapekeys will be duplicated.
|
||||
* - If #LIB_ID_CREATE_LOCAL is defined, root node trees will be deep-duplicated recursively.
|
||||
*
|
||||
* \note Usercount of new copy is always set to 1.
|
||||
*
|
||||
* \param bmain: Main database, may be NULL only if LIB_ID_CREATE_NO_MAIN is specified.
|
||||
* \param id: Source data-block.
|
||||
* \param r_newid: Pointer to new (copied) ID pointer.
|
||||
* \param flag: Set of copy options, see DNA_ID.h enum for details
|
||||
* (leave to zero for default, full copy).
|
||||
* \return False when copying that ID type is not supported, true otherwise.
|
||||
* \param r_newid: Pointer to new (copied) ID pointer, may be NULL. Used to allow copying into
|
||||
* already allocated memory.
|
||||
* \param flag: Set of copy options, see DNA_ID.h enum for details (leave to zero for default,
|
||||
* full copy).
|
||||
* \return NULL when copying that ID type is not supported, the new copy otherwise.
|
||||
*/
|
||||
bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
|
||||
ID *BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
|
||||
{
|
||||
BLI_assert(r_newid != NULL);
|
||||
ID *newid = (r_newid != NULL) ? *r_newid : NULL;
|
||||
/* Make sure destination pointer is all good. */
|
||||
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0) {
|
||||
*r_newid = NULL;
|
||||
newid = NULL;
|
||||
}
|
||||
else {
|
||||
if (*r_newid != NULL) {
|
||||
if (newid != NULL) {
|
||||
/* Allow some garbage non-initialized memory to go in, and clean it up here. */
|
||||
const size_t size = BKE_libblock_get_alloc_info(GS(id->name), NULL);
|
||||
memset(*r_newid, 0, size);
|
||||
memset(newid, 0, size);
|
||||
}
|
||||
}
|
||||
|
||||
/* Early output is source is NULL. */
|
||||
if (id == NULL) {
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const IDTypeInfo *idtype_info = BKE_idtype_get_info_from_id(id);
|
||||
|
||||
if (idtype_info != NULL) {
|
||||
if ((idtype_info->flags & IDTYPE_FLAGS_NO_COPY) != 0) {
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BKE_libblock_copy_ex(bmain, id, r_newid, flag);
|
||||
BKE_libblock_copy_ex(bmain, id, &newid, flag);
|
||||
|
||||
if (idtype_info->copy_data != NULL) {
|
||||
idtype_info->copy_data(bmain, *r_newid, id, flag);
|
||||
idtype_info->copy_data(bmain, newid, id, flag);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -584,22 +588,26 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
|
|||
/* Update ID refcount, remap pointers to self in new ID. */
|
||||
struct IDCopyLibManagementData data = {
|
||||
.id_src = id,
|
||||
.id_dst = *r_newid,
|
||||
.id_dst = newid,
|
||||
.flag = flag,
|
||||
};
|
||||
BKE_library_foreach_ID_link(bmain, *r_newid, id_copy_libmanagement_cb, &data, IDWALK_NOP);
|
||||
BKE_library_foreach_ID_link(bmain, newid, id_copy_libmanagement_cb, &data, IDWALK_NOP);
|
||||
|
||||
/* Do not make new copy local in case we are copying outside of main...
|
||||
* XXX TODO: is this behavior OK, or should we need own flag to control that? */
|
||||
if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
|
||||
BLI_assert((flag & LIB_ID_COPY_KEEP_LIB) == 0);
|
||||
lib_id_copy_ensure_local(bmain, id, *r_newid);
|
||||
lib_id_copy_ensure_local(bmain, id, newid);
|
||||
}
|
||||
else {
|
||||
(*r_newid)->lib = id->lib;
|
||||
newid->lib = id->lib;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (r_newid != NULL) {
|
||||
*r_newid = newid;
|
||||
}
|
||||
|
||||
return newid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -608,7 +616,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
|
|||
*/
|
||||
bool BKE_id_copy(Main *bmain, const ID *id, ID **newid)
|
||||
{
|
||||
return BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_DEFAULT);
|
||||
return (BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_DEFAULT) != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -729,7 +737,8 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
|
|||
if (RNA_property_editable(ptr, prop)) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
/* copy animation actions too */
|
||||
if (BKE_id_copy_ex(bmain, id, &newid, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS) && newid) {
|
||||
newid = BKE_id_copy_ex(bmain, id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
|
||||
if (newid != NULL) {
|
||||
/* us is 1 by convention with new IDs, but RNA_property_pointer_set
|
||||
* will also increment it, decrement it here. */
|
||||
id_us_min(newid);
|
||||
|
|
|
@ -1013,8 +1013,7 @@ Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference)
|
|||
flags |= LIB_ID_COPY_CD_REFERENCE;
|
||||
}
|
||||
|
||||
Mesh *result;
|
||||
BKE_id_copy_ex(NULL, &source->id, (ID **)&result, flags);
|
||||
Mesh *result = (Mesh *)BKE_id_copy_ex(NULL, &source->id, NULL, flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1010,8 +1010,7 @@ static Object *object_for_curve_to_mesh_create(Object *object)
|
|||
Curve *curve = (Curve *)object->data;
|
||||
|
||||
/* Create object itself. */
|
||||
Object *temp_object;
|
||||
BKE_id_copy_ex(NULL, &object->id, (ID **)&temp_object, LIB_ID_COPY_LOCALIZE);
|
||||
Object *temp_object = (Object *)BKE_id_copy_ex(NULL, &object->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
|
||||
/* Remove all modifiers, since we don't want them to be applied. */
|
||||
BKE_object_free_modifiers(temp_object, LIB_ID_CREATE_NO_USER_REFCOUNT);
|
||||
|
@ -1177,11 +1176,8 @@ static Mesh *mesh_new_from_mesh(Object *object, Mesh *mesh)
|
|||
* add the data to 'mesh' so future calls to this function don't need to re-convert the data. */
|
||||
BKE_mesh_wrapper_ensure_mdata(mesh);
|
||||
|
||||
Mesh *mesh_result = NULL;
|
||||
BKE_id_copy_ex(NULL,
|
||||
&mesh->id,
|
||||
(ID **)&mesh_result,
|
||||
LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT);
|
||||
Mesh *mesh_result = (Mesh *)BKE_id_copy_ex(
|
||||
NULL, &mesh->id, NULL, LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT);
|
||||
/* NOTE: Materials should already be copied. */
|
||||
/* Copy original mesh name. This is because edit meshes might not have one properly set name. */
|
||||
BLI_strncpy(mesh_result->id.name, ((ID *)object->data)->name, sizeof(mesh_result->id.name));
|
||||
|
@ -1407,16 +1403,16 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
|
|||
{
|
||||
Mesh *me = ob_eval->runtime.data_orig ? ob_eval->runtime.data_orig : ob_eval->data;
|
||||
const ModifierTypeInfo *mti = BKE_modifier_get_info(md_eval->type);
|
||||
Mesh *result;
|
||||
Mesh *result = NULL;
|
||||
KeyBlock *kb;
|
||||
ModifierEvalContext mectx = {depsgraph, ob_eval, MOD_APPLY_TO_BASE_MESH};
|
||||
|
||||
if (!(md_eval->mode & eModifierMode_Realtime)) {
|
||||
return NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
|
||||
return NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (build_shapekey_layers && me->key &&
|
||||
|
@ -1428,7 +1424,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
|
|||
int numVerts;
|
||||
float(*deformedVerts)[3] = BKE_mesh_vert_coords_alloc(me, &numVerts);
|
||||
|
||||
BKE_id_copy_ex(NULL, &me->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
result = (Mesh *)BKE_id_copy_ex(NULL, &me->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
mti->deformVerts(md_eval, &mectx, result, deformedVerts, numVerts);
|
||||
BKE_mesh_vert_coords_apply(result, deformedVerts);
|
||||
|
||||
|
@ -1439,8 +1435,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
|
|||
MEM_freeN(deformedVerts);
|
||||
}
|
||||
else {
|
||||
Mesh *mesh_temp;
|
||||
BKE_id_copy_ex(NULL, &me->id, (ID **)&mesh_temp, LIB_ID_COPY_LOCALIZE);
|
||||
Mesh *mesh_temp = (Mesh *)BKE_id_copy_ex(NULL, &me->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
|
||||
if (build_shapekey_layers) {
|
||||
add_shapekey_layers(mesh_temp, me);
|
||||
|
|
|
@ -2328,9 +2328,9 @@ bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
|
|||
|
||||
bNodeTree *ntreeCopyTree_ex(const bNodeTree *ntree, Main *bmain, const bool do_id_user)
|
||||
{
|
||||
bNodeTree *ntree_copy;
|
||||
const int flag = do_id_user ? 0 : LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN;
|
||||
BKE_id_copy_ex(bmain, (ID *)ntree, (ID **)&ntree_copy, flag);
|
||||
|
||||
bNodeTree *ntree_copy = (bNodeTree *)BKE_id_copy_ex(bmain, (ID *)ntree, NULL, flag);
|
||||
return ntree_copy;
|
||||
}
|
||||
bNodeTree *ntreeCopyTree(Main *bmain, const bNodeTree *ntree)
|
||||
|
@ -2981,9 +2981,8 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
|
|||
/* Make full copy outside of Main database.
|
||||
* Note: previews are not copied here.
|
||||
*/
|
||||
bNodeTree *ltree;
|
||||
BKE_id_copy_ex(
|
||||
NULL, &ntree->id, (ID **)<ree, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA));
|
||||
bNodeTree *ltree = (bNodeTree *)BKE_id_copy_ex(
|
||||
NULL, &ntree->id, NULL, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA));
|
||||
|
||||
ltree->id.tag |= LIB_TAG_LOCALIZED;
|
||||
|
||||
|
|
|
@ -942,7 +942,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
|
|||
mesh = final_mesh;
|
||||
}
|
||||
else {
|
||||
BKE_id_copy_ex(NULL, ob->data, (ID **)&mesh, LIB_ID_COPY_LOCALIZE);
|
||||
mesh = (Mesh *)BKE_id_copy_ex(NULL, ob->data, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
BKE_mesh_tessface_ensure(mesh);
|
||||
|
||||
|
@ -990,7 +990,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
|
|||
mesh = final_mesh;
|
||||
}
|
||||
else {
|
||||
BKE_id_copy_ex(NULL, ob->data, (ID **)&mesh, LIB_ID_COPY_LOCALIZE);
|
||||
mesh = (Mesh *)BKE_id_copy_ex(NULL, ob->data, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
|
||||
BKE_mesh_tessface_ensure(mesh);
|
||||
|
|
|
@ -4744,9 +4744,8 @@ static int hair_needs_recalc(ParticleSystem *psys)
|
|||
|
||||
static ParticleSettings *particle_settings_localize(ParticleSettings *particle_settings)
|
||||
{
|
||||
ParticleSettings *particle_settings_local;
|
||||
BKE_id_copy_ex(
|
||||
NULL, (ID *)&particle_settings->id, (ID **)&particle_settings_local, LIB_ID_COPY_LOCALIZE);
|
||||
ParticleSettings *particle_settings_local = (ParticleSettings *)BKE_id_copy_ex(
|
||||
NULL, (ID *)&particle_settings->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
return particle_settings_local;
|
||||
}
|
||||
|
||||
|
|
|
@ -309,8 +309,7 @@ PointCloud *BKE_pointcloud_copy_for_eval(struct PointCloud *pointcloud_src, bool
|
|||
flags |= LIB_ID_COPY_CD_REFERENCE;
|
||||
}
|
||||
|
||||
PointCloud *result;
|
||||
BKE_id_copy_ex(NULL, &pointcloud_src->id, (ID **)&result, flags);
|
||||
PointCloud *result = (PointCloud *)BKE_id_copy_ex(NULL, &pointcloud_src->id, NULL, flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1319,8 +1319,7 @@ Volume *BKE_volume_copy_for_eval(Volume *volume_src, bool reference)
|
|||
flags |= LIB_ID_COPY_CD_REFERENCE;
|
||||
}
|
||||
|
||||
Volume *result;
|
||||
BKE_id_copy_ex(NULL, &volume_src->id, (ID **)&result, flags);
|
||||
Volume *result = (Volume *)BKE_id_copy_ex(NULL, &volume_src->id, NULL, flags);
|
||||
result->filepath[0] = '\0';
|
||||
|
||||
return result;
|
||||
|
|
|
@ -301,8 +301,10 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid)
|
|||
id_for_copy = nested_id_hack_get_discarded_pointers(&id_hack_storage, id);
|
||||
#endif
|
||||
|
||||
bool result = BKE_id_copy_ex(
|
||||
nullptr, (ID *)id_for_copy, &newid, (LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE));
|
||||
bool result = (BKE_id_copy_ex(nullptr,
|
||||
(ID *)id_for_copy,
|
||||
&newid,
|
||||
LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE) != NULL);
|
||||
|
||||
#ifdef NESTED_ID_NASTY_WORKAROUND
|
||||
if (result) {
|
||||
|
@ -328,8 +330,10 @@ bool scene_copy_inplace_no_main(const Scene *scene, Scene *new_scene)
|
|||
id_for_copy = nested_id_hack_get_discarded_pointers(&id_hack_storage, &scene->id);
|
||||
#endif
|
||||
|
||||
bool result = BKE_id_copy_ex(
|
||||
nullptr, id_for_copy, (ID **)&new_scene, LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE);
|
||||
bool result = (BKE_id_copy_ex(nullptr,
|
||||
id_for_copy,
|
||||
(ID **)&new_scene,
|
||||
LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE) != NULL);
|
||||
|
||||
#ifdef NESTED_ID_NASTY_WORKAROUND
|
||||
if (result) {
|
||||
|
|
|
@ -754,7 +754,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
|
|||
return false;
|
||||
}
|
||||
/* don't modify the original vertices */
|
||||
BKE_id_copy_ex(NULL, &mesh->id, (ID **)&mesh, LIB_ID_COPY_LOCALIZE);
|
||||
mesh = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
|
||||
/* BMESH_ONLY, deform dm may not have tessface */
|
||||
BKE_mesh_tessface_ensure(mesh);
|
||||
|
|
|
@ -326,11 +326,11 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world)
|
|||
return sp->worldcopy;
|
||||
}
|
||||
|
||||
ID *id_copy;
|
||||
BKE_id_copy_ex(NULL,
|
||||
&world->id,
|
||||
&id_copy,
|
||||
LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
|
||||
ID *id_copy = BKE_id_copy_ex(NULL,
|
||||
&world->id,
|
||||
NULL,
|
||||
LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE |
|
||||
LIB_ID_COPY_NO_ANIMDATA);
|
||||
sp->worldcopy = (World *)id_copy;
|
||||
BLI_addtail(&sp->pr_main->worlds, sp->worldcopy);
|
||||
return sp->worldcopy;
|
||||
|
@ -348,11 +348,8 @@ static ID *duplicate_ids(ID *id)
|
|||
case ID_TE:
|
||||
case ID_LA:
|
||||
case ID_WO: {
|
||||
ID *id_copy;
|
||||
BKE_id_copy_ex(NULL,
|
||||
id,
|
||||
&id_copy,
|
||||
LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
|
||||
ID *id_copy = BKE_id_copy_ex(
|
||||
NULL, id, NULL, LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
|
||||
return id_copy;
|
||||
}
|
||||
case ID_IM:
|
||||
|
|
|
@ -751,8 +751,8 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
/* add or copy material */
|
||||
if (ma) {
|
||||
Material *new_ma = NULL;
|
||||
BKE_id_copy_ex(bmain, &ma->id, (ID **)&new_ma, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
|
||||
Material *new_ma = (Material *)BKE_id_copy_ex(
|
||||
bmain, &ma->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
|
||||
ma = new_ma;
|
||||
}
|
||||
else {
|
||||
|
@ -873,8 +873,8 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
/* add or copy world */
|
||||
if (wo) {
|
||||
World *new_wo = NULL;
|
||||
BKE_id_copy_ex(bmain, &wo->id, (ID **)&new_wo, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
|
||||
World *new_wo = (World *)BKE_id_copy_ex(
|
||||
bmain, &wo->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
|
||||
wo = new_wo;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -246,7 +246,7 @@ Mesh *bc_get_mesh_copy(BlenderContext &blender_context,
|
|||
tmpmesh = (Mesh *)ob->data;
|
||||
}
|
||||
|
||||
BKE_id_copy_ex(NULL, &tmpmesh->id, (ID **)&tmpmesh, LIB_ID_COPY_LOCALIZE);
|
||||
tmpmesh = (Mesh *)BKE_id_copy_ex(NULL, &tmpmesh->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
|
||||
if (triangulate) {
|
||||
bc_triangulate_mesh(tmpmesh);
|
||||
|
|
|
@ -148,7 +148,7 @@ static Mesh *get_quick_mesh(
|
|||
result = mesh_self;
|
||||
}
|
||||
else {
|
||||
BKE_id_copy_ex(NULL, &mesh_operand_ob->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
result = (Mesh *)BKE_id_copy_ex(NULL, &mesh_operand_ob->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
|
||||
float imat[4][4];
|
||||
float omat[4][4];
|
||||
|
|
|
@ -113,7 +113,7 @@ static void deformVerts(ModifierData *md,
|
|||
else {
|
||||
/* Not possible to use get_mesh() in this case as we'll modify its vertices
|
||||
* and get_mesh() would return 'mesh' directly. */
|
||||
BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&mesh_src, LIB_ID_COPY_LOCALIZE);
|
||||
mesh_src = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
|
||||
/* TODO(sergey): For now it actually duplicates logic from DerivedMesh.c
|
||||
|
|
|
@ -115,7 +115,7 @@ static void deformVerts(ModifierData *md,
|
|||
else {
|
||||
/* Not possible to use get_mesh() in this case as we'll modify its vertices
|
||||
* and get_mesh() would return 'mesh' directly. */
|
||||
BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&mesh_src, LIB_ID_COPY_LOCALIZE);
|
||||
mesh_src = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
|
||||
if (!ob->pd) {
|
||||
|
|
|
@ -198,7 +198,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
(dtmd->data_types & DT_TYPES_AFFECT_MESH)) {
|
||||
/* We need to duplicate data here, otherwise setting custom normals, edges' sharpness, etc.,
|
||||
* could modify org mesh, see T43671. */
|
||||
BKE_id_copy_ex(NULL, &me_mod->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
result = (Mesh *)BKE_id_copy_ex(NULL, &me_mod->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
|
|
|
@ -148,11 +148,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
* flags) and duplicate those too. */
|
||||
if ((me->mvert == mvert) || (me->medge == medge) || (me->mpoly == mpoly)) {
|
||||
/* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */
|
||||
BKE_id_copy_ex(NULL,
|
||||
&mesh->id,
|
||||
(ID **)&mesh,
|
||||
LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
|
||||
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW);
|
||||
mesh = (Mesh *)BKE_id_copy_ex(NULL,
|
||||
&mesh->id,
|
||||
NULL,
|
||||
LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
|
||||
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -515,7 +515,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
|
|||
/* We need to duplicate data here, otherwise setting custom normals
|
||||
* (which may also affect sharp edges) could
|
||||
* modify original mesh, see T43671. */
|
||||
BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
result = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
else {
|
||||
result = mesh;
|
||||
|
|
|
@ -373,7 +373,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||
BKE_mesh_ensure_normals(result);
|
||||
}
|
||||
else if (omd->geometry_mode == MOD_OCEAN_GEOM_DISPLACE) {
|
||||
BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
result = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
|
||||
cfra_for_cache = cfra_scene;
|
||||
|
|
|
@ -126,7 +126,7 @@ static void deformVerts(ModifierData *md,
|
|||
if (mesh) {
|
||||
/* Not possible to use get_mesh() in this case as we'll modify its vertices
|
||||
* and get_mesh() would return 'mesh' directly. */
|
||||
BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&surmd->mesh, LIB_ID_COPY_LOCALIZE);
|
||||
surmd->mesh = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
else {
|
||||
surmd->mesh = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, numVerts, false, false);
|
||||
|
|
|
@ -202,10 +202,10 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob,
|
|||
/* TODO(sybren): after modifier conversion of DM to Mesh is done, check whether
|
||||
* we really need a copy here. Maybe the CoW ob->data can be directly used. */
|
||||
Mesh *mesh_prior_modifiers = BKE_object_get_pre_modified_mesh(ob);
|
||||
BKE_id_copy_ex(NULL,
|
||||
&mesh_prior_modifiers->id,
|
||||
(ID **)&mesh,
|
||||
(LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_CD_REFERENCE));
|
||||
mesh = (Mesh *)BKE_id_copy_ex(NULL,
|
||||
&mesh_prior_modifiers->id,
|
||||
NULL,
|
||||
(LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_CD_REFERENCE));
|
||||
mesh->runtime.deformed_only = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -579,7 +579,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
Mesh *result;
|
||||
BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
result = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
|
||||
const int numVerts = result->totvert;
|
||||
const int numEdges = result->totedge;
|
||||
|
|
Loading…
Reference in New Issue