Cleanup: do not cleanup runtime data twice during ID copying...
More or less same code was being executed twice during ID copying. Makes no sense to add yet another switch-by-ID-type to handle specificaly runtime data during ID copying, we already have BKE_xxx_copy_data() functions for that.
This commit is contained in:
parent
5e3838faa2
commit
eb7f2457e5
|
@ -45,7 +45,7 @@ struct DerivedMesh;
|
|||
#endif
|
||||
|
||||
void BKE_mesh_runtime_reset(struct Mesh *mesh);
|
||||
void BKE_mesh_runtime_reset_on_copy(struct Mesh *mesh);
|
||||
void BKE_mesh_runtime_reset_on_copy(struct Mesh *mesh, const int flag);
|
||||
int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh);
|
||||
void BKE_mesh_runtime_looptri_recalc(struct Mesh *mesh);
|
||||
const struct MLoopTri *BKE_mesh_runtime_looptri_ensure(struct Mesh *mesh);
|
||||
|
|
|
@ -306,7 +306,7 @@ int BKE_object_scenes_users_get(struct Main *bmain, struct Object *ob);
|
|||
struct MovieClip *BKE_object_movieclip_get(struct Scene *scene, struct Object *ob, bool use_default);
|
||||
|
||||
void BKE_object_runtime_reset(struct Object *object);
|
||||
void BKE_object_runtime_reset_on_copy(struct Object *object);
|
||||
void BKE_object_runtime_reset_on_copy(struct Object *object, const int flag);
|
||||
|
||||
void BKE_object_batch_cache_dirty_tag(struct Object *ob);
|
||||
|
||||
|
|
|
@ -511,32 +511,6 @@ static int id_copy_libmanagement_cb(void *user_data, ID *UNUSED(id_self), ID **i
|
|||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
static void id_copy_clear_runtime_pointers(ID *id, int UNUSED(flag))
|
||||
{
|
||||
if (id == NULL) {
|
||||
return;
|
||||
}
|
||||
/* TODO(sergey): We might want to do a deep-copy of all the pointers inside.
|
||||
* This isn't currently needed, and is quite involved change (to cover all
|
||||
* things like batch cache and such). */
|
||||
switch ((ID_Type)GS(id->name)) {
|
||||
case ID_OB:
|
||||
{
|
||||
Object *object = (Object *)id;
|
||||
BKE_object_runtime_reset_on_copy(object);
|
||||
break;
|
||||
}
|
||||
case ID_ME:
|
||||
{
|
||||
Mesh *mesh = (Mesh *)id;
|
||||
BKE_mesh_runtime_reset_on_copy(mesh);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool BKE_id_copy_is_allowed(const ID *id)
|
||||
{
|
||||
#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, /* Not supported */ \
|
||||
|
@ -703,8 +677,6 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
|
|||
(*r_newid)->lib = id->lib;
|
||||
}
|
||||
|
||||
id_copy_clear_runtime_pointers(*r_newid, flag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -525,6 +525,14 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
|
|||
*/
|
||||
void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int flag)
|
||||
{
|
||||
BKE_mesh_runtime_reset_on_copy(me_dst, flag);
|
||||
if ((me_src->id.tag & LIB_TAG_NO_MAIN) == 0) {
|
||||
/* This is a direct copy of a main mesh, so for now it has the same topology. */
|
||||
me_dst->runtime.deformed_only = true;
|
||||
}
|
||||
/* XXX WHAT? Why? Comment, please! And pretty sure this is not valid for regular Mesh copying? */
|
||||
me_dst->runtime.is_original = false;
|
||||
|
||||
const bool do_tessface = ((me_src->totface != 0) && (me_src->totpoly == 0)); /* only do tessface if we have no polys */
|
||||
CustomDataMask mask = CD_MASK_MESH;
|
||||
|
||||
|
@ -551,21 +559,6 @@ void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int
|
|||
|
||||
me_dst->edit_btmesh = NULL;
|
||||
|
||||
/* Call BKE_mesh_runtime_reset? */
|
||||
me_dst->runtime.batch_cache = NULL;
|
||||
me_dst->runtime.looptris.array = NULL;
|
||||
me_dst->runtime.bvh_cache = NULL;
|
||||
me_dst->runtime.shrinkwrap_data = NULL;
|
||||
|
||||
if (me_src->id.tag & LIB_TAG_NO_MAIN) {
|
||||
me_dst->runtime.deformed_only = me_src->runtime.deformed_only;
|
||||
}
|
||||
else {
|
||||
/* This is a direct copy of a main mesh, so for now it has the same topology. */
|
||||
me_dst->runtime.deformed_only = 1;
|
||||
}
|
||||
me_dst->runtime.is_original = false;
|
||||
|
||||
me_dst->mselect = MEM_dupallocN(me_dst->mselect);
|
||||
me_dst->bb = MEM_dupallocN(me_dst->bb);
|
||||
|
||||
|
|
|
@ -54,9 +54,10 @@ void BKE_mesh_runtime_reset(Mesh *mesh)
|
|||
/* Clear all pointers which we don't want to be shared on copying the datablock.
|
||||
* However, keep all the flags which defines what the mesh is (for example, that
|
||||
* it's deformed only, or that its custom data layers are out of date.) */
|
||||
void BKE_mesh_runtime_reset_on_copy(Mesh *mesh)
|
||||
void BKE_mesh_runtime_reset_on_copy(Mesh *mesh, const int UNUSED(flag))
|
||||
{
|
||||
Mesh_Runtime *runtime = &mesh->runtime;
|
||||
|
||||
runtime->edit_data = NULL;
|
||||
runtime->batch_cache = NULL;
|
||||
runtime->subdiv_ccg = NULL;
|
||||
|
|
|
@ -1323,7 +1323,7 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
|
|||
ShaderFxData *fx;
|
||||
|
||||
/* Do not copy runtime data. */
|
||||
BKE_object_runtime_reset(ob_dst);
|
||||
BKE_object_runtime_reset_on_copy(ob_dst, flag);
|
||||
|
||||
/* We never handle usercount here for own data. */
|
||||
const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
|
||||
|
@ -3555,7 +3555,7 @@ void BKE_object_runtime_reset(Object *object)
|
|||
}
|
||||
|
||||
/* Reset all pointers which we don't want to be shared when copying the object. */
|
||||
void BKE_object_runtime_reset_on_copy(Object *object)
|
||||
void BKE_object_runtime_reset_on_copy(Object *object, const int UNUSED(flag))
|
||||
{
|
||||
Object_Runtime *runtime = &object->runtime;
|
||||
runtime->mesh_eval = NULL;
|
||||
|
|
Loading…
Reference in New Issue