void ObjectSet::boundingSphere(QVector3D *center, float *radius) { DisplayObject::m.lock(); if (DisplayObject::begin() == DisplayObject::end()) { *center = QVector3D(0,0,0); *radius = 0.0; DisplayObject::m.unlock(); return; } bool hasSelection = any_of(DisplayObject::begin(), DisplayObject::end(), [] (std::pair<const uint, DisplayObject *> &i) { return i.second->hasSelection(); }); DisplayObject *a = DisplayObject::begin()->second, *b; farthestPointFrom(a, &b, hasSelection); farthestPointFrom(b, &a, hasSelection); *center = (a->center() + b->center()) / 2; *radius = (a->center() - b->center()).length() / 2; ritterSphere(center, radius, hasSelection); float maxRadius = 0.0; for (auto i = DisplayObject::begin(); i != DisplayObject::end(); i++) if (i->second->radius() > maxRadius && (!hasSelection || i->second->hasSelection())) maxRadius = i->second->radius(); *radius += 2 * maxRadius; DisplayObject::m.unlock(); }
SE_Result SE_Sphere_CreateFromPoints(SE_Sphere* s, SE_Vector3f* points, int pointNum) { ritterSphere(s, points, pointNum); return SE_VALID; }