From 50186c9a2d1f677cfb5510706fc97cfb60dcefea Mon Sep 17 00:00:00 2001 From: Geoffrey Bantle Date: Fri, 9 Mar 2007 15:36:21 +0000 Subject: [PATCH] -> Small bug fix for modifiers and info header stats Small but very annoying issue with modifiers meant that G.totvert/totedge/totface were updated to reflect the effects of a subsurf modifier in object mode but all other modifier types were ignored. This was not only inconsistent, but also made it very difficult to keep track of poly budgets. Now in order to obtain accurate counts object_handle_update is called immediatly after adding a modifier and precedes a call to countall() which has been modified to query the final derived mesh directly using dm->getNumVerts/Edges/Faces callbacks. Editmode behaviour is unchanged. --- source/blender/src/buttons_editing.c | 4 +-- source/blender/src/edit.c | 44 +++++++++++++--------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 1ca495d8903..c5fdb564884 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -878,8 +878,9 @@ void do_modifier_panels(unsigned short event) allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWIMAGE, 0); allqueue(REDRAWOOPS, 0); - countall(); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); + object_handle_update(ob); + countall(); break; } } @@ -900,7 +901,6 @@ static void modifiers_add(void *ob_v, int type) } else { BLI_addtail(&ob->modifiers, modifier_new(type)); } - BIF_undo_push("Add modifier"); } diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index 08f72946187..9f73a9674b0 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -73,6 +73,7 @@ #include "BKE_anim.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" +#include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_ipo.h" @@ -509,34 +510,29 @@ static void count_object(Object *ob, int sel, int totob) { Mesh *me; Curve *cu; + DerivedMesh *dm; int tot=0, totf=0, subsurf; - + switch(ob->type) { case OB_MESH: - G.totmesh+=totob; - me= get_mesh(ob); - if(me) { - ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf); - int totvert, totface; - - subsurf= 1; - if (md) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - if(smd->modifier.mode & eModifierMode_Realtime) - subsurf= 1<<(2*smd->levels); + G.totmesh+=totob; + me= get_mesh(ob); + if(me) { + int totvert, totedge, totface; + dm = mesh_get_derived_final(ob, get_viewedit_datamask()); + totvert = dm->getNumVerts(dm); + totedge = dm->getNumEdges(dm); + totface = dm->getNumFaces(dm); + + G.totvert+= totvert*totob; + G.totedge+= totedge*totob; + G.totface+= totface*totob; + if(sel) { + G.totvertsel+= totvert; + G.totfacesel+= totface; + } } - - totvert= subsurf*me->totvert*totob; - totface= subsurf*me->totface*totob; - - G.totvert+= totvert; - G.totface+= totface; - if(sel) { - G.totvertsel+= totvert; - G.totfacesel+= totface; - } - } - break; + break; case OB_LAMP: G.totlamp+=totob;