if(i==0 && m)
if(ResourceManager *rm = m->get_manager())
rm->watch_resource(*m, *this);
+
+ update_bounding_sphere();
}
void Object::update_bounding_sphere()
for(vector<RefPtr<const Mesh> >::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<float, 3>();
- return;
+ offset = vertices.get_format().offset(VERTEX2);
+ three = false;
+ if(offset<0)
+ continue;
}
unsigned n_vertices = vertices.size();
for(unsigned j=0; j<n_vertices; ++j)
{
const float *v = vertices[j];
- points.push_back(Vector3(v[offset], v[offset+1], v[offset+2]));
+ points.push_back(Vector3(v[offset], v[offset+1], (three ? v[offset+2] : 0.0f)));
}
}