From cb52e5bd8da01ab2e7976fcd8bfc34e190265ed5 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 16 Mar 2008 22:36:04 +0000 Subject: r_drawradius --- src/core/model.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/core/model.cc') diff --git a/src/core/model.cc b/src/core/model.cc index da179e5..88a1040 100644 --- a/src/core/model.cc +++ b/src/core/model.cc @@ -247,6 +247,11 @@ Model::Model(std::string const & name) : ifs.close(); if (model_face.size()) { + if (model_maxbbox.lengthsquared() > model_minbbox.lengthsquared()) { + model_radius = model_maxbbox.length(); + } else { + model_radius = model_minbbox.length(); + } model_valid = true; } con_debug << " maps/" << name << ".map " << model_face.size() << " polygons\n"; @@ -502,18 +507,17 @@ void Model::make_face(math::Plane3f *face, std::vector & planes Face *mf = new Face(face->normal()*-1, color); for (std::vector::iterator it = vl.begin(); it != vl.end(); it++) { mf->add_vertex(*(*it) * model_scale); - } - add_face(mf); - /* - mf->add_vertex(*(*vn) * model_scale); - mf->add_vertex(*(*v0) * model_scale); - mf->add_vertex(*(*vn1) * model_scale); - add_face(mf); + + // bounding box + for (int i=0; i < 3; i++) { + if (model_maxbbox[i] < (*(*it))[i] * model_scale) + model_maxbbox[i] = (*(*it))[i] * model_scale; - vl.pop_back(); + if (model_minbbox[i] > (*(*it))[i] * model_scale) + model_minbbox[i] = (*(*it))[i] * model_scale; + } } - */ - + add_face(mf); if (color) delete color; } else { con_debug << "Unresolved face!\n"; -- cgit v1.2.3