workaround for tessface not being recalculated when undo is disabled

This commit is contained in:
Campbell Barton 2011-12-11 05:05:37 +00:00
parent 5f6ff0f412
commit 8eab2c66a7
3 changed files with 23 additions and 0 deletions

@ -62,6 +62,10 @@ typedef struct BMEditMesh {
int mirr_free_arrays;
} BMEditMesh;
/* undo triggers editmesh tessface update, this is odd but works OK.
* BMESH_TODO, look into having the update elsewhere. */
#define BMESH_EM_UNDO_RECALC_TESSFACE_WORKAROUND
void BMEdit_RecalcTesselation(BMEditMesh *tm);
BMEditMesh *BMEdit_Create(BMesh *bm);
BMEditMesh *BMEdit_Copy(BMEditMesh *tm);

@ -559,10 +559,14 @@ static void *editbtMesh_to_undoMesh(void *emv, void *obdata)
/*make sure shape keys work*/
me->me.key = obme->key ? copy_key_nolib(obme->key) : NULL;
#ifdef BMESH_EM_UNDO_RECALC_TESSFACE_WORKAROUND
/*we recalc the tesselation here, to avoid seeding calls to
BMEdit_RecalcTesselation throughout the code.*/
BMEdit_RecalcTesselation(em);
#endif
BMO_CallOpf(em->bm, "bmesh_to_mesh mesh=%p notesselation=%i", me, 1);
me->selectmode = em->selectmode;

@ -48,6 +48,8 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
#include "BKE_tessmesh.h" /* BMESH_EM_UNDO_RECALC_TESSFACE_WORKAROUND */
#include "ED_armature.h"
#include "ED_particle.h"
@ -86,6 +88,19 @@ void ED_undo_push(bContext *C, const char *str)
printf("undo push %s\n", str);
if(obedit) {
#ifdef BMESH_EM_UNDO_RECALC_TESSFACE_WORKAROUND
/* undo is causing tessface recalc, so without we need to do explicitly */
if (U.undosteps == 0) {
if (obedit->type == OB_MESH) {
Mesh *me= obedit->data;
BMEdit_RecalcTesselation(me->edit_btmesh);
}
}
#endif /* BMESH_EM_UNDO_RECALC_TESSFACE_WORKAROUND */
if (U.undosteps == 0) return;
if(obedit->type==OB_MESH)