本文整理汇总了C++中BoundingSphere::SetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingSphere::SetCenter方法的具体用法?C++ BoundingSphere::SetCenter怎么用?C++ BoundingSphere::SetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingSphere
的用法示例。
在下文中一共展示了BoundingSphere::SetCenter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Sqrt
//----------------------------------------------------------------------------
// @ ::Merge()
// ---------------------------------------------------------------------------
// Merge two spheres together to create a new one
//-----------------------------------------------------------------------------
void
Merge( BoundingSphere& result,
const BoundingSphere& s0, const BoundingSphere& s1 )
{
// get differences between them
Vector3 diff = s1.mCenter - s0.mCenter;
float distsq = diff.Dot(diff);
float radiusdiff = s1.mRadius - s0.mRadius;
// if one sphere inside other
if ( distsq <= radiusdiff*radiusdiff )
{
if ( s0.mRadius > s1.mRadius )
result = s0;
else
result = s1;
return;
}
// build new sphere
float dist = Sqrt( distsq );
float radius = 0.5f*( s0.mRadius + s1.mRadius + dist );
Vector3 center = s0.mCenter;
if (!gfx::IsZero( dist ))
center += ((radius-s0.mRadius)/dist)*diff;
result.SetRadius( radius );
result.SetCenter( center );
} // End of ::Merge()