+ vector<Vector3> points;
+ for(vector<LevelOfDetail>::const_iterator i=lods.begin(); i!=lods.end(); ++i)
+ {
+ if(!i->mesh || !i->mesh->is_loaded())
+ continue;
+
+ const VertexArray &vertices = i->mesh->get_vertices();
+
+ int offset = vertices.get_format().offset(VERTEX3);
+ bool three = true;
+ if(offset<0)
+ {
+ offset = vertices.get_format().offset(VERTEX2);
+ three = false;
+ if(offset<0)
+ continue;
+ }
+
+ unsigned n_vertices = vertices.size();
+ points.reserve(points.size()+n_vertices);
+ for(unsigned j=0; j<n_vertices; ++j)
+ {
+ const float *v = vertices[j];
+ points.push_back(Vector3(v[offset], v[offset+1], (three ? v[offset+2] : 0.0f)));
+ }
+ }
+
+ /* Don't touch the bounding sphere if we had no vertices to avoid
+ overwriting a possible hint. */
+ if(points.empty())
+ return;
+
+ bounding_sphere = Geometry::BoundingSphere<float, 3>::from_point_cloud(points.begin(), points.end());