本文整理汇总了C++中Float3::makeZero方法的典型用法代码示例。如果您正苦于以下问题:C++ Float3::makeZero方法的具体用法?C++ Float3::makeZero怎么用?C++ Float3::makeZero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Float3
的用法示例。
在下文中一共展示了Float3::makeZero方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSplitAxis
void BoundingVolume::GetSplitAxis(const float *pointsPtr, unsigned int numPoints,
Float3 &splitAxis, float &_min, float &_max)
{
Float3 vMin( FLT_MAX, FLT_MAX, FLT_MAX );
Float3 vMax( -FLT_MAX, -FLT_MAX, -FLT_MAX );
for(unsigned int i = 0; i < numPoints; i +=3 )
for(unsigned int j = 0; j < 3; ++j)
{
vMin.v[j] = min( vMin.v[j], pointsPtr[i+j] );
vMax.v[j] = max( vMax.v[j], pointsPtr[i+j] );
}
unsigned int axis = 0;
if( vMax.v[axis] - vMin.v[axis] < vMax.v[1] - vMin.v[1] )
axis = 1;
if( vMax.v[axis] - vMin.v[axis] < vMax.v[2] - vMin.v[2] )
axis = 2;
splitAxis.makeZero();
splitAxis.v[axis] = 1.0f;
_min = vMin.v[axis];
_max = vMax.v[axis];
}
示例2: OnApplyReaction
void Physics::OnApplyReaction(IBehavior* invokingBehavior, IMessage* message)
{
Physics* pPhysics = (Physics*)invokingBehavior;
MessageT<CollisionContact>* msg = (MessageT<CollisionContact>*)message;
Float3 velocity = pPhysics->m_X[0] - pPhysics->m_OldX[0];
velocity += msg->value.m_ContactNormal * msg->value.m_PenetrationDepth;
float ndotv = DotProduct( msg->value.m_ContactNormal, velocity );
Float3 normalVelocity = msg->value.m_ContactNormal * ndotv;
Float3 tangentialVelocity = velocity - normalVelocity;
Float3 oldTV = tangentialVelocity;
float m_COF = 0.0f;
float m_COR = 0.0f;
float tvMagSq = DotProduct(tangentialVelocity, tangentialVelocity);
if( tvMagSq > 0.0f )
{
float tvMag = sqrt(tvMagSq);
tangentialVelocity *= (1.0f / tvMag);
Float3 tvNorm = tangentialVelocity;
tangentialVelocity *= max( 0.0f, tvMag - msg->value.m_PenetrationDepth*m_COF);
}
else
tangentialVelocity.makeZero();
pPhysics->gameObject->TranslateGlobal( velocity );
pPhysics->m_X[0] = pPhysics->m_OldX[0] + velocity;
pPhysics->m_OldX[0] = pPhysics->m_X[0] - tangentialVelocity - normalVelocity * m_COR;
//pPhysics->m_OldX[0] += (oldTV - tangentialVelocity);
//pPhysics->m_OldX[0] = pPhysics->m_X[0] - tangentialVelocity - normalVelocity;
//pPhysics->m_OldX[0] -= normalVelocity;
}