本文整理汇总了C++中Bound::GetMaxRadius方法的典型用法代码示例。如果您正苦于以下问题:C++ Bound::GetMaxRadius方法的具体用法?C++ Bound::GetMaxRadius怎么用?C++ Bound::GetMaxRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bound
的用法示例。
在下文中一共展示了Bound::GetMaxRadius方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Merge
VOID Bound::Merge( const Bound& Other )
{
Sphere OtherSphere;
OtherSphere.Center = Other.GetCenter();
OtherSphere.Radius = Other.GetMaxRadius();
if( m_Type == Bound::No_Bound )
{
SetSphere( OtherSphere );
return;
}
Sphere ThisSphere;
if( m_Type != Bound::Sphere_Bound )
{
// convert this bound into a sphere
ThisSphere.Center = GetCenter();
ThisSphere.Radius = GetMaxRadius();
}
else
{
ThisSphere = GetSphere();
}
XMVECTOR vThisCenter = XMLoadFloat3( &ThisSphere.Center );
XMVECTOR vOtherCenter = XMLoadFloat3( &OtherSphere.Center );
XMVECTOR vThisToOther = XMVectorSubtract( vOtherCenter, vThisCenter );
XMVECTOR vDistance = XMVector3LengthEst( vThisToOther );
FLOAT fCombinedDiameter = XMVectorGetX( vDistance ) + ThisSphere.Radius + OtherSphere.Radius;
if( fCombinedDiameter <= ( ThisSphere.Radius * 2 ) )
{
SetSphere( ThisSphere );
return;
}
if( fCombinedDiameter <= ( OtherSphere.Radius * 2 ) )
{
SetSphere( OtherSphere );
return;
}
XMVECTOR vDirectionNorm = XMVector3Normalize( vThisToOther );
XMVECTOR vRadius = XMVectorSet( ThisSphere.Radius, OtherSphere.Radius, 0, 0 );
XMVECTOR vThisRadius = XMVectorSplatX( vRadius );
XMVECTOR vOtherRadius = XMVectorSplatY( vRadius );
XMVECTOR vCombinedDiameter = vThisRadius + vDistance + vOtherRadius;
XMVECTOR vMaxDiameter = XMVectorMax( vCombinedDiameter, vThisRadius * 2 );
vMaxDiameter = XMVectorMax( vMaxDiameter, vOtherRadius * 2 );
XMVECTOR vMaxRadius = vMaxDiameter * 0.5f;
ThisSphere.Radius = XMVectorGetX( vMaxRadius );
vMaxRadius -= vThisRadius;
XMVECTOR vCombinedCenter = vThisCenter + vMaxRadius * vDirectionNorm;
XMStoreFloat3( &ThisSphere.Center, vCombinedCenter );
SetSphere( ThisSphere );
}