本文整理汇总了C++中BoundingSphere::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingSphere::isEmpty方法的具体用法?C++ BoundingSphere::isEmpty怎么用?C++ BoundingSphere::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingSphere
的用法示例。
在下文中一共展示了BoundingSphere::isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
void BoundingSphere::merge(const BoundingSphere& sphere)
{
if (sphere.isEmpty())
return;
// Calculate the distance between the two centers.
float vx = center.x - sphere.center.x;
float vy = center.y - sphere.center.y;
float vz = center.z - sphere.center.z;
float d = sqrt(vx * vx + vy * vy + vz * vz);
// If one sphere is contained inside the other, set to the larger sphere.
if (d <= (sphere.radius - radius))
{
center = sphere.center;
radius = sphere.radius;
return;
}
else if (d <= (radius - sphere.radius))
{
return;
}
// Calculate the unit vector between the two centers.
GP_ASSERT(d != 0.0f);
float dI = 1.0f / d;
vx *= dI;
vy *= dI;
vz *= dI;
// Calculate the new radius.
float r = (radius + sphere.radius + d) * 0.5f;
// Calculate the new center.
float scaleFactor = (r - sphere.radius);
vx = vx * scaleFactor + sphere.center.x;
vy = vy * scaleFactor + sphere.center.y;
vz = vz * scaleFactor + sphere.center.z;
// Set the new center and radius.
center.x = vx;
center.y = vy;
center.z = vz;
radius = r;
}