2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-08-19 12:35:40 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-08-19 12:35:40 +00:00
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_info/info_stats.c
|
|
|
|
|
* \ingroup spinfo
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-08-19 12:35:40 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
|
#include "DNA_group_types.h"
|
|
|
|
|
#include "DNA_lattice_types.h"
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2009-08-19 12:35:40 +00:00
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2009-08-19 12:35:40 +00:00
|
|
|
#include "BKE_anim.h"
|
2011-11-14 16:05:44 +00:00
|
|
|
#include "BKE_blender.h"
|
2011-09-14 00:37:27 +00:00
|
|
|
#include "BKE_curve.h"
|
2009-08-19 12:35:40 +00:00
|
|
|
#include "BKE_displist.h"
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
|
#include "BKE_key.h"
|
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
#include "BKE_particle.h"
|
2009-08-27 08:54:33 +00:00
|
|
|
#include "BKE_tessmesh.h"
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include "ED_info.h"
|
2009-08-19 12:35:40 +00:00
|
|
|
#include "ED_armature.h"
|
|
|
|
|
#include "ED_mesh.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct SceneStats {
|
|
|
|
|
int totvert, totvertsel;
|
|
|
|
|
int totedge, totedgesel;
|
|
|
|
|
int totface, totfacesel;
|
|
|
|
|
int totbone, totbonesel;
|
2012-04-30 18:37:34 +00:00
|
|
|
int totobj, totobjsel;
|
|
|
|
|
int totlamp, totlampsel;
|
|
|
|
|
int tottri, totmesh, totcurve;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
|
|
|
|
char infostr[512];
|
|
|
|
|
} SceneStats;
|
|
|
|
|
|
|
|
|
|
static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (ob->type) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case OB_MESH:
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
/* we assume derivedmesh is already built, this strictly does stats now. */
|
|
|
|
|
DerivedMesh *dm = ob->derivedFinal;
|
|
|
|
|
int totvert, totedge, totface;
|
|
|
|
|
|
|
|
|
|
stats->totmesh += totob;
|
|
|
|
|
|
|
|
|
|
if (dm) {
|
|
|
|
|
totvert = dm->getNumVerts(dm);
|
|
|
|
|
totedge = dm->getNumEdges(dm);
|
|
|
|
|
totface = dm->getNumPolys(dm);
|
|
|
|
|
|
|
|
|
|
stats->totvert += totvert * totob;
|
|
|
|
|
stats->totedge += totedge * totob;
|
|
|
|
|
stats->totface += totface * totob;
|
|
|
|
|
|
|
|
|
|
if (sel) {
|
|
|
|
|
stats->totvertsel += totvert;
|
|
|
|
|
stats->totfacesel += totface;
|
|
|
|
|
}
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
break;
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
case OB_LAMP:
|
|
|
|
|
stats->totlamp += totob;
|
2012-04-30 18:37:34 +00:00
|
|
|
if (sel) {
|
|
|
|
|
stats->totlampsel += totob;
|
|
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
break;
|
|
|
|
|
case OB_SURF:
|
|
|
|
|
case OB_CURVE:
|
2012-09-08 08:59:47 +00:00
|
|
|
case OB_FONT:
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
int tot = 0, totf = 0;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
stats->totcurve += totob;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (ob->disp.first)
|
2012-05-07 06:58:03 +00:00
|
|
|
BKE_displist_count(&ob->disp, &tot, &totf);
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
tot *= totob;
|
|
|
|
|
totf *= totob;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
stats->totvert += tot;
|
|
|
|
|
stats->totface += totf;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (sel) {
|
|
|
|
|
stats->totvertsel += tot;
|
|
|
|
|
stats->totfacesel += totf;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case OB_MBALL:
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
int tot = 0, totf = 0;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-05-07 06:58:03 +00:00
|
|
|
BKE_displist_count(&ob->disp, &tot, &totf);
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
tot *= totob;
|
|
|
|
|
totf *= totob;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
stats->totvert += tot;
|
|
|
|
|
stats->totface += totf;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (sel) {
|
|
|
|
|
stats->totvertsel += tot;
|
|
|
|
|
stats->totfacesel += totf;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void stats_object_edit(Object *obedit, SceneStats *stats)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
if (obedit->type == OB_MESH) {
|
2012-03-02 12:09:49 +00:00
|
|
|
BMEditMesh *em = BMEdit_FromObject(obedit);
|
2009-08-27 08:54:33 +00:00
|
|
|
|
|
|
|
|
stats->totvert = em->bm->totvert;
|
|
|
|
|
stats->totvertsel = em->bm->totvertsel;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2009-08-27 08:54:33 +00:00
|
|
|
stats->totedge = em->bm->totedge;
|
|
|
|
|
stats->totedgesel = em->bm->totedgesel;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2009-08-27 08:54:33 +00:00
|
|
|
stats->totface = em->bm->totface;
|
|
|
|
|
stats->totfacesel = em->bm->totfacesel;
|
2012-04-30 18:37:34 +00:00
|
|
|
|
|
|
|
|
stats->tottri = em->tottri;
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (obedit->type == OB_ARMATURE) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Armature Edit */
|
2012-03-28 11:53:18 +00:00
|
|
|
bArmature *arm = obedit->data;
|
2009-08-19 12:35:40 +00:00
|
|
|
EditBone *ebo;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totbone++;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((ebo->flag & BONE_CONNECTED) && ebo->parent)
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totvert--;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ebo->flag & BONE_TIPSEL)
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totvertsel++;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ebo->flag & BONE_ROOTSEL)
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totvertsel++;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ebo->flag & BONE_SELECTED) stats->totbonesel++;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
|
|
|
|
/* if this is a connected child and it's parent is being moved, remove our root */
|
2012-03-28 11:53:18 +00:00
|
|
|
if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL))
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totvertsel--;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
stats->totvert += 2;
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 22:35:18 +00:00
|
|
|
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { /* OB_FONT has no cu->editnurb */
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Curve Edit */
|
2012-03-28 11:53:18 +00:00
|
|
|
Curve *cu = obedit->data;
|
2009-08-19 12:35:40 +00:00
|
|
|
Nurb *nu;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
2012-04-28 16:49:00 +00:00
|
|
|
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
for (nu = nurbs->first; nu; nu = nu->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (nu->type == CU_BEZIER) {
|
2012-03-28 11:53:18 +00:00
|
|
|
bezt = nu->bezt;
|
|
|
|
|
a = nu->pntsu;
|
2012-03-24 06:38:07 +00:00
|
|
|
while (a--) {
|
2012-03-28 11:53:18 +00:00
|
|
|
stats->totvert += 3;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (bezt->f1) stats->totvertsel++;
|
|
|
|
|
if (bezt->f2) stats->totvertsel++;
|
|
|
|
|
if (bezt->f3) stats->totvertsel++;
|
2009-08-19 12:35:40 +00:00
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-28 11:53:18 +00:00
|
|
|
bp = nu->bp;
|
|
|
|
|
a = nu->pntsu * nu->pntsv;
|
2012-03-24 06:38:07 +00:00
|
|
|
while (a--) {
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totvert++;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (bp->f1 & SELECT) stats->totvertsel++;
|
2009-08-19 12:35:40 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (obedit->type == OB_MBALL) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* MetaBall Edit */
|
2012-03-28 11:53:18 +00:00
|
|
|
MetaBall *mball = obedit->data;
|
2009-08-19 12:35:40 +00:00
|
|
|
MetaElem *ml;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
for (ml = mball->editelems->first; ml; ml = ml->next) {
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totvert++;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ml->flag & SELECT) stats->totvertsel++;
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (obedit->type == OB_LATTICE) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Lattice Edit */
|
2012-03-28 11:53:18 +00:00
|
|
|
Lattice *lt = obedit->data;
|
|
|
|
|
Lattice *editlatt = lt->editlatt->latt;
|
2009-08-19 12:35:40 +00:00
|
|
|
BPoint *bp;
|
|
|
|
|
int a;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
bp = editlatt->def;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
|
2012-03-24 06:38:07 +00:00
|
|
|
while (a--) {
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totvert++;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (bp->f1 & SELECT) stats->totvertsel++;
|
2009-08-19 12:35:40 +00:00
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void stats_object_pose(Object *ob, SceneStats *stats)
|
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob->pose) {
|
2012-03-28 11:53:18 +00:00
|
|
|
bArmature *arm = ob->data;
|
2009-08-19 12:35:40 +00:00
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totbone++;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pchan->bone && (pchan->bone->flag & BONE_SELECTED))
|
|
|
|
|
if (pchan->bone->layer & arm->layer)
|
2009-08-19 12:35:40 +00:00
|
|
|
stats->totbonesel++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats)
|
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (base->flag & SELECT) stats->totobjsel++;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob->transflag & OB_DUPLIPARTS) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Dupli Particles */
|
|
|
|
|
ParticleSystem *psys;
|
|
|
|
|
ParticleSettings *part;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
|
|
|
|
|
part = psys->part;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (part->draw_as == PART_DRAW_OB && part->dup_ob) {
|
|
|
|
|
int tot = count_particles(psys);
|
2009-08-19 12:35:40 +00:00
|
|
|
stats_object(part->dup_ob, 0, tot, stats);
|
|
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (part->draw_as == PART_DRAW_GR && part->dup_group) {
|
2009-08-19 12:35:40 +00:00
|
|
|
GroupObject *go;
|
2012-03-28 11:53:18 +00:00
|
|
|
int tot, totgroup = 0, cur = 0;
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
for (go = part->dup_group->gobject.first; go; go = go->next)
|
2009-08-19 12:35:40 +00:00
|
|
|
totgroup++;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
for (go = part->dup_group->gobject.first; go; go = go->next) {
|
|
|
|
|
tot = count_particles_mod(psys, totgroup, cur);
|
2009-08-19 12:35:40 +00:00
|
|
|
stats_object(go->ob, 0, tot, stats);
|
|
|
|
|
cur++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stats_object(ob, base->flag & SELECT, 1, stats);
|
|
|
|
|
stats->totobj++;
|
|
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS | OB_DUPLIFACES))) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Dupli Verts/Faces */
|
2012-03-28 11:53:18 +00:00
|
|
|
int tot = count_duplilist(ob->parent);
|
|
|
|
|
stats->totobj += tot;
|
2009-08-19 12:35:40 +00:00
|
|
|
stats_object(ob, base->flag & SELECT, tot, stats);
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ob->transflag & OB_DUPLIFRAMES) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Dupli Frames */
|
2012-03-28 11:53:18 +00:00
|
|
|
int tot = count_duplilist(ob);
|
|
|
|
|
stats->totobj += tot;
|
2009-08-19 12:35:40 +00:00
|
|
|
stats_object(ob, base->flag & SELECT, tot, stats);
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Dupli Group */
|
2012-03-28 11:53:18 +00:00
|
|
|
int tot = count_duplilist(ob);
|
|
|
|
|
stats->totobj += tot;
|
2009-08-19 12:35:40 +00:00
|
|
|
stats_object(ob, base->flag & SELECT, tot, stats);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* No Dupli */
|
|
|
|
|
stats_object(ob, base->flag & SELECT, 1, stats);
|
|
|
|
|
stats->totobj++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Statistics displayed in info header. Called regularly on scene changes. */
|
|
|
|
|
static void stats_update(Scene *scene)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SceneStats stats = {0};
|
|
|
|
|
Object *ob = (scene->basact) ? scene->basact->object : NULL;
|
2009-08-19 12:35:40 +00:00
|
|
|
Base *base;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->obedit) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Edit Mode */
|
|
|
|
|
stats_object_edit(scene->obedit, &stats);
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ob && (ob->mode & OB_MODE_POSE)) {
|
2009-08-19 12:35:40 +00:00
|
|
|
/* Pose Mode */
|
|
|
|
|
stats_object_pose(ob, &stats);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Objects */
|
2012-03-28 11:53:18 +00:00
|
|
|
for (base = scene->base.first; base; base = base->next)
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->lay & base->lay)
|
2009-08-19 12:35:40 +00:00
|
|
|
stats_dupli_object(base, base->object, &stats);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!scene->stats)
|
2012-03-28 11:53:18 +00:00
|
|
|
scene->stats = MEM_callocN(sizeof(SceneStats), "SceneStats");
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
*(scene->stats) = stats;
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void stats_string(Scene *scene)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SceneStats *stats = scene->stats;
|
|
|
|
|
Object *ob = (scene->basact) ? scene->basact->object : NULL;
|
2009-08-19 12:35:40 +00:00
|
|
|
uintptr_t mem_in_use, mmap_in_use;
|
|
|
|
|
char memstr[64];
|
|
|
|
|
char *s;
|
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
mem_in_use = MEM_get_memory_in_use();
|
|
|
|
|
mmap_in_use = MEM_get_mapped_memory_in_use();
|
2009-08-19 12:35:40 +00:00
|
|
|
|
|
|
|
|
/* get memory statistics */
|
2012-03-28 11:53:18 +00:00
|
|
|
s = memstr + sprintf(memstr, " | Mem:%.2fM", (double)((mem_in_use - mmap_in_use) >> 10) / 1024.0);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mmap_in_use)
|
2012-03-28 11:53:18 +00:00
|
|
|
sprintf(s, " (%.2fM)", (double)((mmap_in_use) >> 10) / 1024.0);
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
s = stats->infostr;
|
2011-06-26 17:01:10 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
s += sprintf(s, "%s | ", versionstr);
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->obedit) {
|
|
|
|
|
if (ob_get_keyblock(scene->obedit))
|
2012-03-28 11:53:18 +00:00
|
|
|
s += sprintf(s, "(Key) ");
|
2009-08-19 12:35:40 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (scene->obedit->type == OB_MESH) {
|
2012-04-30 18:37:34 +00:00
|
|
|
s += sprintf(s, "Verts:%d/%d | Edges:%d/%d | Faces:%d/%d | Tris:%d",
|
|
|
|
|
stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface, stats->tottri);
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (scene->obedit->type == OB_ARMATURE) {
|
2012-04-30 18:37:34 +00:00
|
|
|
s += sprintf(s, "Verts:%d/%d | Bones:%d/%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone);
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-04-30 18:37:34 +00:00
|
|
|
s += sprintf(s, "Verts:%d/%d", stats->totvertsel, stats->totvert);
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strcat(s, memstr);
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ob && (ob->mode & OB_MODE_POSE)) {
|
2012-04-30 18:37:34 +00:00
|
|
|
s += sprintf(s, "Bones:%d/%d %s",
|
2012-03-28 11:53:18 +00:00
|
|
|
stats->totbonesel, stats->totbone, memstr);
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-04-30 18:37:34 +00:00
|
|
|
s += sprintf(s, "Verts:%d | Faces:%d | Objects:%d/%d | Lamps:%d/%d%s",
|
|
|
|
|
stats->totvert, stats->totface, stats->totobjsel, stats->totobj, stats->totlampsel, stats->totlamp, memstr);
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob)
|
2012-03-28 11:53:18 +00:00
|
|
|
sprintf(s, " | %s", ob->id.name + 2);
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ED_info_stats_clear(Scene *scene)
|
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->stats) {
|
2009-08-19 12:35:40 +00:00
|
|
|
MEM_freeN(scene->stats);
|
2012-03-28 11:53:18 +00:00
|
|
|
scene->stats = NULL;
|
2009-08-19 12:35:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
const char *ED_info_stats_string(Scene *scene)
|
2009-08-19 12:35:40 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!scene->stats)
|
2009-08-19 12:35:40 +00:00
|
|
|
stats_update(scene);
|
|
|
|
|
stats_string(scene);
|
|
|
|
|
|
|
|
|
|
return scene->stats->infostr;
|
|
|
|
|
}
|
|
|
|
|
|