From: Mikko Rasa Date: Wed, 24 Sep 2014 17:36:33 +0000 (+0300) Subject: Improve bounding sphere handling in Object X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=e720536d5feacf6136b5621c98b72d206e44f64c Improve bounding sphere handling in Object --- diff --git a/source/object.cpp b/source/object.cpp index efd84db8..9aba5466 100644 --- a/source/object.cpp +++ b/source/object.cpp @@ -53,6 +53,8 @@ void Object::set_mesh(unsigned i, const Mesh *m) if(i==0 && m) if(ResourceManager *rm = m->get_manager()) rm->watch_resource(*m, *this); + + update_bounding_sphere(); } void Object::update_bounding_sphere() @@ -61,12 +63,15 @@ void Object::update_bounding_sphere() for(vector >::const_iterator i=meshes.begin(); i!=meshes.end(); ++i) { const VertexArray &vertices = (*i)->get_vertices(); + int offset = vertices.get_format().offset(VERTEX3); + bool three = true; if(offset<0) { - // TODO Handle two-dimensional meshes - bounding_sphere = Geometry::BoundingSphere(); - return; + offset = vertices.get_format().offset(VERTEX2); + three = false; + if(offset<0) + continue; } unsigned n_vertices = vertices.size(); @@ -74,7 +79,7 @@ void Object::update_bounding_sphere() for(unsigned j=0; j