fix for separate loose parts doing full depsgraph rebuild for every object split off.

This commit is contained in:
2012-07-19 10:23:25 +00:00
parent 4bc46b18d1
commit 9c8edae7d4
5 changed files with 17 additions and 4 deletions

View File

@@ -1213,6 +1213,8 @@ static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op))
/* 2) duplicate base */
newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
DAG_scene_sort(bmain, scene);
newob = newbase->object;
newbase->flag &= ~SELECT;

View File

@@ -1369,6 +1369,8 @@ static int separate_exec(bContext *C, wmOperator *op)
/* 1. duplicate the object and data */
newbase = ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */
DAG_scene_sort(bmain, scene);
ED_base_object_select(newbase, BA_DESELECT);
newob = newbase->object;

View File

@@ -2815,7 +2815,8 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO
CustomData_bmesh_init_pool(&bm_new->ldata, bm_mesh_allocsize_default.totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm_new->pdata, bm_mesh_allocsize_default.totface, BM_FACE);
basenew = ED_object_add_duplicate(bmain, scene, editbase, USER_DUP_MESH); /* 0 = fully linked */
basenew = ED_object_add_duplicate(bmain, scene, editbase, USER_DUP_MESH);
/* DAG_scene_sort(bmain, scene); */ /* normally would call directly after but in this case delay recalc */
assign_matarar(basenew->object, give_matarar(obedit), *give_totcolp(obedit)); /* new in 2.5 */
ED_base_object_select(basenew, BA_DESELECT);
@@ -2968,6 +2969,10 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
if (retval) {
BMEditMesh *em = BMEdit_FromObject(base->object);
/* delay depsgraph recalc until all objects are duplicated */
DAG_scene_sort(bmain, scene);
EDBM_update_generic(C, em, TRUE);
return OPERATOR_FINISHED;

View File

@@ -1854,7 +1854,9 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
/* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */
/* leaves selection of base/object unaltered.
* note: don't call this within a loop since clear_* funcs loop over the entire database. */
* note: don't call this within a loop since clear_* funcs loop over the entire database.
* note: caller must do DAG_scene_sort(bmain, scene);
* this is not done automatic since we may duplicate many objects in a batch */
Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag)
{
Base *basen;
@@ -1874,7 +1876,8 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag
BKE_object_relink(ob);
set_sca_new_poins_ob(ob);
DAG_scene_sort(bmain, scene);
/* DAG_scene_sort(bmain, scene); */ /* caller must do */
if (ob->data) {
ED_render_id_flush_update(bmain, ob->data);
}

View File

@@ -30,6 +30,7 @@
void PyC_ObSpit(const char *name, PyObject *var);
void PyC_LineSpit(void);
void PyC_StackSpit(void);
PyObject * PyC_ExceptionBuffer(void);
PyObject * PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...);
PyObject * PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *format, ...);