Undo: optimize edit-mode undo
- Tag the object data instead of the object when decoding (this avoids duplicating mesh object-data on each undo-step). - Calculate face normals as part of multi-threaded tessellation. This gives ~11% speedup with 1.5x million polygons.
This commit is contained in:
parent
7a4fc9f59d
commit
f9c9e000ca
|
@ -206,7 +206,7 @@ static void armature_undosys_step_decode(struct bContext *C,
|
|||
}
|
||||
undoarm_to_editarm(&elem->data, arm);
|
||||
arm->needs_flush_to_id = 1;
|
||||
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
|
||||
DEG_id_tag_update(&arm->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
/* The first element is always active */
|
||||
|
|
|
@ -267,7 +267,7 @@ static void curve_undosys_step_decode(struct bContext *C,
|
|||
}
|
||||
undocurve_to_editcurve(bmain, &elem->data, obedit->data, &obedit->shapenr);
|
||||
cu->editnurb->needs_flush_to_id = 1;
|
||||
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
|
||||
DEG_id_tag_update(&cu->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
/* The first element is always active */
|
||||
|
|
|
@ -379,7 +379,7 @@ static void font_undosys_step_decode(struct bContext *C,
|
|||
|
||||
Curve *cu = obedit->data;
|
||||
undofont_to_editfont(&us->data, cu);
|
||||
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
|
||||
DEG_id_tag_update(&cu->id, ID_RECALC_GEOMETRY);
|
||||
|
||||
ED_undo_object_set_active_or_warn(
|
||||
CTX_data_scene(C), CTX_data_view_layer(C), obedit, us_p->name, &LOG);
|
||||
|
|
|
@ -240,7 +240,7 @@ static void lattice_undosys_step_decode(struct bContext *C,
|
|||
}
|
||||
undolatt_to_editlatt(&elem->data, lt->editlatt);
|
||||
lt->editlatt->needs_flush_to_id = 1;
|
||||
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
|
||||
DEG_id_tag_update(<->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
/* The first element is always active */
|
||||
|
|
|
@ -681,14 +681,20 @@ static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em, Key *
|
|||
BM_mesh_bm_from_me(bm,
|
||||
&um->me,
|
||||
(&(struct BMeshFromMeshParams){
|
||||
.calc_face_normal = true,
|
||||
/* Handled with tessellation. */
|
||||
.calc_face_normal = false,
|
||||
.active_shapekey = um->shapenr,
|
||||
}));
|
||||
|
||||
em_tmp = BKE_editmesh_create(bm);
|
||||
*em = *em_tmp;
|
||||
|
||||
BKE_editmesh_looptri_calc(em);
|
||||
/* Calculate face normals and tessellation at once since it's multi-threaded.
|
||||
* The vertex normals are stored in the undo-mesh, so this doesn't need to be updated. */
|
||||
BKE_editmesh_looptri_calc_ex(em,
|
||||
&(const struct BMeshCalcTessellation_Params){
|
||||
.face_normals = true,
|
||||
});
|
||||
|
||||
em->selectmode = um->selectmode;
|
||||
bm->selectmode = um->selectmode;
|
||||
|
@ -867,7 +873,7 @@ static void mesh_undosys_step_decode(struct bContext *C,
|
|||
BMEditMesh *em = me->edit_mesh;
|
||||
undomesh_to_editmesh(&elem->data, obedit, em, me->key);
|
||||
em->needs_flush_to_id = 1;
|
||||
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
|
||||
DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
/* The first element is always active */
|
||||
|
|
|
@ -215,7 +215,7 @@ static void mball_undosys_step_decode(struct bContext *C,
|
|||
}
|
||||
undomball_to_editmball(&elem->data, mb);
|
||||
mb->needs_flush_to_id = 1;
|
||||
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
|
||||
DEG_id_tag_update(&mb->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
/* The first element is always active */
|
||||
|
|
Loading…
Reference in New Issue