From 6a86e7f0f9e021498c1df44653a42643bd79dfbf Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 25 Oct 2010 12:39:40 +0000 Subject: corrects model triangle and quad count --- src/model/asefile.cc | 2 +- src/model/mapfile.cc | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/model') diff --git a/src/model/asefile.cc b/src/model/asefile.cc index afe74ea..c9dfe1c 100644 --- a/src/model/asefile.cc +++ b/src/model/asefile.cc @@ -694,7 +694,7 @@ Model *ASEFile::load(const std::string &name) for (FragmentGroup::Fragments::const_iterator fit = asefile.fragmentgroup()->fragments().begin(); fit != asefile.fragmentgroup()->fragments().end(); fit++) { const Fragment *fragment = (*fit); - model->model_tris_count += fragment->structural_size() + fragment->detail_size(); + model->model_tris_count += (fragment->structural_size() + fragment->detail_size()) / 3; } model->add_group(asefile.fragmentgroup()); diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index 32eee8a..47ea354 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -908,8 +908,9 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t count += fragment->add_vertex(quad->v1() - translation, quad->normal(), quad->t1(), false); count += fragment->add_vertex(quad->v2() - translation, quad->normal(), quad->t2(), false); count += fragment->add_vertex(quad->v3() - translation, quad->normal(), quad->t3(), false); - if (count == 4) + if (count == 4) { model->model_quad_count++; + } } } @@ -1427,8 +1428,20 @@ Model * MapFile::load(std::string const &name) // copy fragments, this only copies the original fragment's pointer into the vertex array for (FragmentGroup::Fragments::const_iterator fit = groupsrc->fragments().begin(); fit != groupsrc->fragments().end(); fit++) { + Fragment *fragmentdst = new Fragment(*(*fit)); groupdst->add_fragment(fragmentdst); + + switch (fragmentdst->type()) { + case Fragment::Triangles: + model->model_tris_count += (fragmentdst->structural_size() + fragmentdst->detail_size()) / 3; + model->model_tris_detail_count += fragmentdst->detail_size() / 3; + break; + case Fragment::Quads: + model->model_quad_count += (fragmentdst->structural_size() + fragmentdst->detail_size()) / 4; + model->model_quad_detail_count += fragmentdst->detail_size() / 4; + break; + } } if (groupdst->size()) { -- cgit v1.2.3