From e720536d5feacf6136b5621c98b72d206e44f64c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 24 Sep 2014 20:36:33 +0300 Subject: [PATCH] Improve bounding sphere handling in Object --- source/object.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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