本文整理汇总了C++中Vector4::SubtractSet方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector4::SubtractSet方法的具体用法?C++ Vector4::SubtractSet怎么用?C++ Vector4::SubtractSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector4
的用法示例。
在下文中一共展示了Vector4::SubtractSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: matrixSplat
/// Initialize this frustum based on the given transformation matrix.
///
/// @param[in] rInverseViewProjectionTranspose Transpose of the matrix transforming from world space to projected
/// screen space.
void Helium::Simd::Frustum::Set( const Matrix44& rInverseViewProjectionTranspose )
{
// Check whether the input matrix yields an infinite far clip plane.
Vector4 rowDifference;
rowDifference.SubtractSet(
rInverseViewProjectionTranspose.GetRow( 3 ),
rInverseViewProjectionTranspose.GetRow( 2 ) );
m_bInfiniteFarClip =
( Abs( rowDifference.GetElement( 0 ) ) < HELIUM_EPSILON &&
Abs( rowDifference.GetElement( 1 ) ) < HELIUM_EPSILON &&
Abs( rowDifference.GetElement( 2 ) ) < HELIUM_EPSILON );
// Splat the transformation matrix into a struct-of-arrays matrix set.
Matrix44Soa matrixSplat( rInverseViewProjectionTranspose );
// Initialize our pre-transformed clip plane values.
#pragma TODO("Replace these with MemoryZero")
memset( m_planeA, 0, sizeof( m_planeA ) );
memset( m_planeB, 0, sizeof( m_planeB ) );
memset( m_planeC, 0, sizeof( m_planeC ) );
m_planeA[ PLANE_LEFT ] = 1.0f;
m_planeA[ PLANE_RIGHT ] = -1.0f;
m_planeB[ PLANE_BOTTOM ] = 1.0f;
m_planeB[ PLANE_TOP ] = -1.0f;
m_planeC[ PLANE_NEAR ] = 1.0f;
m_planeC[ PLANE_FAR ] = -1.0f;
m_planeD[ PLANE_LEFT ] = 1.0f;
m_planeD[ PLANE_RIGHT ] = 1.0f;
m_planeD[ PLANE_BOTTOM ] = 1.0f;
m_planeD[ PLANE_TOP ] = 1.0f;
m_planeD[ PLANE_NEAR ] = 0.0f;
m_planeD[ PLANE_FAR ] = 1.0f;
// Transform the clip planes into world space.
PlaneSoa planes;
Vector4Soa planeVectors;
for( size_t basePlaneIndex = 0;
basePlaneIndex < PLANE_ARRAY_SIZE;
basePlaneIndex += HELIUM_SIMD_SIZE / sizeof( float32_t ) )
{
float32_t* pPlaneA = m_planeA + basePlaneIndex;
float32_t* pPlaneB = m_planeB + basePlaneIndex;
float32_t* pPlaneC = m_planeC + basePlaneIndex;
float32_t* pPlaneD = m_planeD + basePlaneIndex;
planeVectors.Load( pPlaneA, pPlaneB, pPlaneC, pPlaneD );
matrixSplat.Transform( planeVectors, planeVectors );
planes.m_a = planeVectors.m_x;
planes.m_b = planeVectors.m_y;
planes.m_c = planeVectors.m_z;
planes.m_d = planeVectors.m_w;
planes.Normalize();
planes.Store( pPlaneA, pPlaneB, pPlaneC, pPlaneD );
}
// Set the unused plane entries to values that ensure that tests always pass with them (if an infinite far clip
// plane is used, its plane is also invalid and should be set to always pass as well).
size_t unusedPlaneStart = ( m_bInfiniteFarClip ? PLANE_FAR : PLANE_MAX );
size_t unusedPlaneCount = PLANE_ARRAY_SIZE - unusedPlaneStart;
#pragma TODO("Replace these with MemoryZero")
memset( m_planeA + unusedPlaneStart, 0, sizeof( m_planeA[ 0 ] ) * unusedPlaneCount );
memset( m_planeB + unusedPlaneStart, 0, sizeof( m_planeB[ 0 ] ) * unusedPlaneCount );
memset( m_planeC + unusedPlaneStart, 0, sizeof( m_planeC[ 0 ] ) * unusedPlaneCount );
#pragma TODO("Replace these with ArraySet")
for ( uint32_t i=0; i<unusedPlaneCount; i++ )
{
(m_planeD + unusedPlaneStart)[i] = 1.0f;
}
}