X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fobject.cpp;fp=source%2Fobject.cpp;h=9aba5466e3e1cf548674b61f2a4b70f156eb8a93;hb=e720536d5feacf6136b5621c98b72d206e44f64c;hp=efd84db89168b85598b278f79147b70214eee493;hpb=e2765175f4a083623c1a9549695140ca902ce0b2;p=libs%2Fgl.git 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