62
69
static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
66
/* we assume derivedmesh is already built, this strictly does stats now. */
67
DerivedMesh *dm= ob->derivedFinal;
68
int totvert, totedge, totface;
70
stats->totmesh +=totob;
73
totvert = dm->getNumVerts(dm);
74
totedge = dm->getNumEdges(dm);
75
totface = dm->getNumFaces(dm);
77
stats->totvert += totvert*totob;
78
stats->totedge += totedge*totob;
79
stats->totface += totface*totob;
82
stats->totvertsel += totvert;
83
stats->totfacesel += totface;
89
stats->totlamp += totob;
97
stats->totcurve += totob;
100
count_displist(&cu->disp, &tot, &totf);
105
stats->totvert+= tot;
106
stats->totface+= totf;
109
stats->totvertsel += tot;
110
stats->totfacesel += totf;
117
count_displist(&ob->disp, &tot, &totf);
122
stats->totvert += tot;
123
stats->totface += totf;
126
stats->totvertsel += tot;
127
stats->totfacesel += totf;
73
/* we assume derivedmesh is already built, this strictly does stats now. */
74
DerivedMesh *dm = ob->derivedFinal;
75
int totvert, totedge, totface;
77
stats->totmesh += totob;
80
totvert = dm->getNumVerts(dm);
81
totedge = dm->getNumEdges(dm);
82
totface = dm->getNumPolys(dm);
84
stats->totvert += totvert * totob;
85
stats->totedge += totedge * totob;
86
stats->totface += totface * totob;
89
stats->totvertsel += totvert;
90
stats->totfacesel += totface;
96
stats->totlamp += totob;
101
int tot = 0, totf = 0;
103
stats->totcurve += totob;
106
count_displist(&ob->disp, &tot, &totf);
111
stats->totvert += tot;
112
stats->totface += totf;
115
stats->totvertsel += tot;
116
stats->totfacesel += totf;
121
int tot = 0, totf = 0;
123
count_displist(&ob->disp, &tot, &totf);
128
stats->totvert += tot;
129
stats->totface += totf;
132
stats->totvertsel += tot;
133
stats->totfacesel += totf;
134
140
static void stats_object_edit(Object *obedit, SceneStats *stats)
136
if(obedit->type==OB_MESH) {
138
EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
143
for(eve= em->verts.first; eve; eve=eve->next) {
145
if(eve->f & SELECT) stats->totvertsel++;
147
for(eed= em->edges.first; eed; eed=eed->next) {
149
if(eed->f & SELECT) stats->totedgesel++;
151
for(efa= em->faces.first; efa; efa=efa->next) {
153
if(efa->f & SELECT) stats->totfacesel++;
156
EM_validate_selections(em);
142
if (obedit->type == OB_MESH) {
143
BMEditMesh *em = BMEdit_FromObject(obedit);
145
stats->totvert = em->bm->totvert;
146
stats->totvertsel = em->bm->totvertsel;
148
stats->totedge = em->bm->totedge;
149
stats->totedgesel = em->bm->totedgesel;
151
stats->totface = em->bm->totface;
152
stats->totfacesel = em->bm->totfacesel;
158
else if(obedit->type==OB_ARMATURE){
154
else if (obedit->type == OB_ARMATURE) {
159
155
/* Armature Edit */
160
bArmature *arm= obedit->data;
156
bArmature *arm = obedit->data;
163
for(ebo=arm->edbo->first; ebo; ebo=ebo->next){
159
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
164
160
stats->totbone++;
166
if((ebo->flag & BONE_CONNECTED) && ebo->parent)
162
if ((ebo->flag & BONE_CONNECTED) && ebo->parent)
167
163
stats->totvert--;
169
if(ebo->flag & BONE_TIPSEL)
165
if (ebo->flag & BONE_TIPSEL)
170
166
stats->totvertsel++;
171
if(ebo->flag & BONE_ROOTSEL)
167
if (ebo->flag & BONE_ROOTSEL)
172
168
stats->totvertsel++;
174
if(ebo->flag & BONE_SELECTED) stats->totbonesel++;
170
if (ebo->flag & BONE_SELECTED) stats->totbonesel++;
176
172
/* if this is a connected child and it's parent is being moved, remove our root */
177
if((ebo->flag & BONE_CONNECTED)&& (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL))
173
if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL))
178
174
stats->totvertsel--;
183
else if ELEM(obedit->type, OB_CURVE, OB_SURF) { /* OB_FONT has no cu->editnurb */
179
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { /* OB_FONT has no cu->editnurb */
185
Curve *cu= obedit->data;
181
Curve *cu = obedit->data;
186
ListBase *nurbs = curve_editnurbs(cu);
191
for(nu=cu->editnurb->first; nu; nu=nu->next) {
192
if(nu->type == CU_BEZIER) {
197
if(bezt->f1) stats->totvertsel++;
198
if(bezt->f2) stats->totvertsel++;
199
if(bezt->f3) stats->totvertsel++;
188
for (nu = nurbs->first; nu; nu = nu->next) {
189
if (nu->type == CU_BEZIER) {
194
if (bezt->f1) stats->totvertsel++;
195
if (bezt->f2) stats->totvertsel++;
196
if (bezt->f3) stats->totvertsel++;
205
a= nu->pntsu*nu->pntsv;
202
a = nu->pntsu * nu->pntsv;
207
204
stats->totvert++;
208
if(bp->f1 & SELECT) stats->totvertsel++;
205
if (bp->f1 & SELECT) stats->totvertsel++;
214
else if(obedit->type==OB_MBALL) {
211
else if (obedit->type == OB_MBALL) {
215
212
/* MetaBall Edit */
216
MetaBall *mball= obedit->data;
213
MetaBall *mball = obedit->data;
219
for(ml= mball->editelems->first; ml; ml=ml->next) {
216
for (ml = mball->editelems->first; ml; ml = ml->next) {
220
217
stats->totvert++;
221
if(ml->flag & SELECT) stats->totvertsel++;
218
if (ml->flag & SELECT) stats->totvertsel++;
224
else if(obedit->type==OB_LATTICE) {
221
else if (obedit->type == OB_LATTICE) {
225
222
/* Lattice Edit */
226
Lattice *lt= obedit->data;
227
Lattice *editlatt= lt->editlatt;
223
Lattice *lt = obedit->data;
224
Lattice *editlatt = lt->editlatt->latt;
233
a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw;
230
a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
235
232
stats->totvert++;
236
if(bp->f1 & SELECT) stats->totvertsel++;
233
if (bp->f1 & SELECT) stats->totvertsel++;
242
239
static void stats_object_pose(Object *ob, SceneStats *stats)
245
bArmature *arm= ob->data;
242
bArmature *arm = ob->data;
246
243
bPoseChannel *pchan;
248
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
245
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
249
246
stats->totbone++;
250
if(pchan->bone && (pchan->bone->flag & BONE_SELECTED))
251
if(pchan->bone->layer & arm->layer)
247
if (pchan->bone && (pchan->bone->flag & BONE_SELECTED))
248
if (pchan->bone->layer & arm->layer)
252
249
stats->totbonesel++;
257
static void stats_object_paint(Object *ob, SceneStats *stats)
259
if(ob->type == OB_MESH) {
262
stats->totface= me->totface;
263
stats->totvert= me->totvert;
267
254
static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats)
269
if(base->flag & SELECT) stats->totobjsel++;
256
if (base->flag & SELECT) stats->totobjsel++;
271
if(ob->transflag & OB_DUPLIPARTS) {
258
if (ob->transflag & OB_DUPLIPARTS) {
272
259
/* Dupli Particles */
273
260
ParticleSystem *psys;
274
261
ParticleSettings *part;
276
for(psys=ob->particlesystem.first; psys; psys=psys->next){
263
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
279
if(part->draw_as==PART_DRAW_OB && part->dup_ob){
280
int tot=count_particles(psys);
266
if (part->draw_as == PART_DRAW_OB && part->dup_ob) {
267
int tot = count_particles(psys);
281
268
stats_object(part->dup_ob, 0, tot, stats);
283
else if(part->draw_as==PART_DRAW_GR && part->dup_group){
270
else if (part->draw_as == PART_DRAW_GR && part->dup_group) {
285
int tot, totgroup=0, cur=0;
272
int tot, totgroup = 0, cur = 0;
287
for(go= part->dup_group->gobject.first; go; go=go->next)
274
for (go = part->dup_group->gobject.first; go; go = go->next)
290
for(go= part->dup_group->gobject.first; go; go=go->next) {
291
tot=count_particles_mod(psys,totgroup,cur);
277
for (go = part->dup_group->gobject.first; go; go = go->next) {
278
tot = count_particles_mod(psys, totgroup, cur);
292
279
stats_object(go->ob, 0, tot, stats);
298
285
stats_object(ob, base->flag & SELECT, 1, stats);
301
else if(ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS|OB_DUPLIFACES))) {
288
else if (ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS | OB_DUPLIFACES))) {
302
289
/* Dupli Verts/Faces */
303
int tot= count_duplilist(ob->parent);
290
int tot = count_duplilist(ob->parent);
291
stats->totobj += tot;
305
292
stats_object(ob, base->flag & SELECT, tot, stats);
307
else if(ob->transflag & OB_DUPLIFRAMES) {
294
else if (ob->transflag & OB_DUPLIFRAMES) {
308
295
/* Dupli Frames */
309
int tot= count_duplilist(ob);
296
int tot = count_duplilist(ob);
297
stats->totobj += tot;
311
298
stats_object(ob, base->flag & SELECT, tot, stats);
313
else if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
300
else if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
314
301
/* Dupli Group */
315
int tot= count_duplilist(ob);
302
int tot = count_duplilist(ob);
303
stats->totobj += tot;
317
304
stats_object(ob, base->flag & SELECT, tot, stats);
326
313
/* Statistics displayed in info header. Called regularly on scene changes. */
327
314
static void stats_update(Scene *scene)
330
Object *ob= (scene->basact)? scene->basact->object: NULL;
316
SceneStats stats = {0};
317
Object *ob = (scene->basact) ? scene->basact->object : NULL;
333
memset(&stats, 0, sizeof(stats));
337
322
stats_object_edit(scene->obedit, &stats);
339
else if(ob && (ob->mode & OB_MODE_POSE)) {
324
else if (ob && (ob->mode & OB_MODE_POSE)) {
341
326
stats_object_pose(ob, &stats);
343
else if(ob && (ob->flag & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) {
344
/* Sculpt and Paint Mode */
345
stats_object_paint(ob, &stats);
349
for(base= scene->base.first; base; base=base->next)
350
if(scene->lay & base->lay)
330
for (base = scene->base.first; base; base = base->next)
331
if (scene->lay & base->lay)
351
332
stats_dupli_object(base, base->object, &stats);
355
scene->stats= MEM_mallocN(sizeof(SceneStats), "SceneStats");
336
scene->stats = MEM_callocN(sizeof(SceneStats), "SceneStats");
357
*(scene->stats)= stats;
338
*(scene->stats) = stats;
360
341
static void stats_string(Scene *scene)
362
SceneStats *stats= scene->stats;
363
Object *ob= (scene->basact)? scene->basact->object: NULL;
343
SceneStats *stats = scene->stats;
344
Object *ob = (scene->basact) ? scene->basact->object : NULL;
364
345
uintptr_t mem_in_use, mmap_in_use;
368
mem_in_use= MEM_get_memory_in_use();
369
mmap_in_use= MEM_get_mapped_memory_in_use();
349
mem_in_use = MEM_get_memory_in_use();
350
mmap_in_use = MEM_get_mapped_memory_in_use();
371
352
/* get memory statistics */
372
s= memstr + sprintf(memstr, " | Mem:%.2fM", ((mem_in_use-mmap_in_use)>>10)/1024.0);
374
sprintf(s, " (%.2fM)", ((mmap_in_use)>>10)/1024.0);
379
if(ob_get_keyblock(scene->obedit))
380
s+= sprintf(s, "(Key) ");
382
if(scene->obedit->type==OB_MESH) {
383
if(scene->toolsettings->selectmode & SCE_SELECT_VERTEX)
384
s+= sprintf(s, "Ve:%d-%d | Ed:%d-%d | Fa:%d-%d",
385
stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface);
386
else if(scene->toolsettings->selectmode & SCE_SELECT_EDGE)
387
s+= sprintf(s, "Ed:%d-%d | Fa:%d-%d",
388
stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface);
353
s = memstr + sprintf(memstr, " | Mem:%.2fM", (double)((mem_in_use - mmap_in_use) >> 10) / 1024.0);
355
sprintf(s, " (%.2fM)", (double)((mmap_in_use) >> 10) / 1024.0);
359
s += sprintf(s, "%s | ", versionstr);
362
if (ob_get_keyblock(scene->obedit))
363
s += sprintf(s, "(Key) ");
365
if (scene->obedit->type == OB_MESH) {
366
if (scene->toolsettings->selectmode & SCE_SELECT_VERTEX)
367
s += sprintf(s, "Ve:%d-%d | Ed:%d-%d | Fa:%d-%d",
368
stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface);
369
else if (scene->toolsettings->selectmode & SCE_SELECT_EDGE)
370
s += sprintf(s, "Ed:%d-%d | Fa:%d-%d",
371
stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface);
390
s+= sprintf(s, "Fa:%d-%d", stats->totfacesel, stats->totface);
373
s += sprintf(s, "Fa:%d-%d", stats->totfacesel, stats->totface);
392
else if(scene->obedit->type==OB_ARMATURE) {
393
s+= sprintf(s, "Ve:%d-%d | Bo:%d-%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone);
375
else if (scene->obedit->type == OB_ARMATURE) {
376
s += sprintf(s, "Ve:%d-%d | Bo:%d-%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone);
396
s+= sprintf(s, "Ve:%d-%d", stats->totvertsel, stats->totvert);
379
s += sprintf(s, "Ve:%d-%d", stats->totvertsel, stats->totvert);
399
382
strcat(s, memstr);
401
else if(ob && (ob->mode & OB_MODE_POSE)) {
384
else if (ob && (ob->mode & OB_MODE_POSE)) {
402
385
s += sprintf(s, "Bo:%d-%d %s",
403
stats->totbonesel, stats->totbone, memstr);
386
stats->totbonesel, stats->totbone, memstr);
406
389
s += sprintf(s, "Ve:%d | Fa:%d | Ob:%d-%d | La:%d%s",
407
stats->totvert, stats->totface, stats->totobjsel, stats->totobj, stats->totlamp, memstr);
390
stats->totvert, stats->totface, stats->totobjsel, stats->totobj, stats->totlamp, memstr);
411
sprintf(s, " | %s", ob->id.name+2);
394
sprintf(s, " | %s", ob->id.name + 2);
414
397
void ED_info_stats_clear(Scene *scene)
417
400
MEM_freeN(scene->stats);
422
char *ED_info_stats_string(Scene *scene)
405
const char *ED_info_stats_string(Scene *scene)
425
408
stats_update(scene);
426
409
stats_string(scene);