Added vectormath library, the open source version. Currently, PowerPC PPU, Cell SPU and a scalar version is available.

An SSE port of vectormath might become available too.
This commit is contained in:
ejcoumans
2007-07-23 23:38:46 +00:00
parent 8a4649d78f
commit f998250c58
73 changed files with 128881 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,379 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_C_H
#define _VECTORMATH_QUAT_AOS_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
{
result->vec128 = quat->vec128;
}
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
{
if (__builtin_constant_p(_x) & __builtin_constant_p(_y) &
__builtin_constant_p(_z) & __builtin_constant_p(_w)) {
result->vec128 = (vec_float4){_x, _y, _z, _w};
} else {
float *pf = (float *)&result->vec128;
pf[0] = _x;
pf[1] = _y;
pf[2] = _z;
pf[3] = _w;
}
}
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
{
result->vec128 = xyz->vec128;
_vmathVfSetElement(result->vec128, _w, 3);
}
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
{
result->vec128 = vec->vec128;
}
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
{
result->vec128 = _vmathVfSplatScalar(scalar);
}
static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 )
{
result->vec128 = vf4;
}
static inline void vmathQMakeIdentity( VmathQuat *result )
{
result->vec128 = _VECTORMATH_UNIT_0001;
}
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
{
VmathQuat tmpQ_0, tmpQ_1;
vmathQSub( &tmpQ_0, quat1, quat0 );
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
vmathQAdd( result, quat0, &tmpQ_1 );
}
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
{
VmathQuat start;
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
vec_uint4 selectMask;
cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 );
cosAngle = vec_splat( cosAngle, 0 );
selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle );
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
start.vec128 = vec_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask );
selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle );
angle = acosf4( cosAngle );
tttt = _vmathVfSplatScalar(t);
oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt );
angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt );
angles = vec_mergeh( angles, oneMinusT );
angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sines = sinf4( angles );
scales = divf4( sines, vec_splat( sines, 0 ) );
scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask );
scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask );
result->vec128 = vec_madd( start.vec128, scale0, vec_madd( unitQuat1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
}
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
{
VmathQuat tmp0, tmp1;
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
}
static inline vec_float4 vmathQGet128( const VmathQuat *quat )
{
return quat->vec128;
}
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
{
result->vec128 = vec_sel( vec->vec128, result->vec128, _VECTORMATH_MASK_0x000F );
}
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
{
result->vec128 = quat->vec128;
}
static inline void vmathQSetX( VmathQuat *result, float _x )
{
_vmathVfSetElement(result->vec128, _x, 0);
}
static inline float vmathQGetX( const VmathQuat *quat )
{
return _vmathVfGetElement(quat->vec128, 0);
}
static inline void vmathQSetY( VmathQuat *result, float _y )
{
_vmathVfSetElement(result->vec128, _y, 1);
}
static inline float vmathQGetY( const VmathQuat *quat )
{
return _vmathVfGetElement(quat->vec128, 1);
}
static inline void vmathQSetZ( VmathQuat *result, float _z )
{
_vmathVfSetElement(result->vec128, _z, 2);
}
static inline float vmathQGetZ( const VmathQuat *quat )
{
return _vmathVfGetElement(quat->vec128, 2);
}
static inline void vmathQSetW( VmathQuat *result, float _w )
{
_vmathVfSetElement(result->vec128, _w, 3);
}
static inline float vmathQGetW( const VmathQuat *quat )
{
return _vmathVfGetElement(quat->vec128, 3);
}
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
{
_vmathVfSetElement(result->vec128, value, idx);
}
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
{
return _vmathVfGetElement(quat->vec128, idx);
}
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
result->vec128 = vec_add( quat0->vec128, quat1->vec128 );
}
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
result->vec128 = vec_sub( quat0->vec128, quat1->vec128 );
}
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
{
result->vec128 = vec_madd( quat->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
}
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
{
result->vec128 = divf4( quat->vec128, _vmathVfSplatScalar(scalar) );
}
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
{
result->vec128 = negatef4( quat->vec128 );
}
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
{
vec_float4 result = _vmathVfDot4( quat0->vec128, quat1->vec128 );
return _vmathVfGetElement(result, 0);
}
static inline float vmathQNorm( const VmathQuat *quat )
{
vec_float4 result = _vmathVfDot4( quat->vec128, quat->vec128 );
return _vmathVfGetElement(result, 0);
}
static inline float vmathQLength( const VmathQuat *quat )
{
return sqrtf( vmathQNorm( quat ) );
}
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
{
vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 );
result->vec128 = vec_madd( quat->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
}
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
{
VmathVector3 crossVec, tmpV3_0;
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 );
cosAngle = vec_splat( cosAngle, 0 );
cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) );
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
crossVec = tmpV3_0;
res = vec_madd( crossVec.vec128, recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F );
result->vec128 = res;
}
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
{
vec_float4 s, c, angle, res;
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
res = vec_sel( vec_madd( unitVec->vec128, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F );
result->vec128 = res;
}
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
{
vec_float4 s, c, angle, res;
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 );
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
result->vec128 = res;
}
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
{
vec_float4 s, c, angle, res;
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 );
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
result->vec128 = res;
}
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
{
vec_float4 s, c, angle, res;
angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 );
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
result->vec128 = res;
}
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
ldata = quat0->vec128;
rdata = quat1->vec128;
tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW );
tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW );
tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW );
tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW );
qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv );
qv = vec_madd( tmp0, tmp1, qv );
qv = vec_nmsub( tmp2, tmp3, qv );
product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
l_wxyz = vec_sld( ldata, ldata, 12 );
r_wxyz = vec_sld( rdata, rdata, 12 );
qw = vec_nmsub( l_wxyz, r_wxyz, product );
xy = vec_madd( l_wxyz, r_wxyz, product );
qw = vec_sub( qw, vec_sld( xy, xy, 8 ) );
result->vec128 = vec_sel( qv, qw, _VECTORMATH_MASK_0x000F );
}
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
{
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
qdata = quat->vec128;
vdata = vec->vec128;
tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW );
tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW );
tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW );
tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW );
wwww = vec_splat( qdata, 3 );
qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
qv = vec_madd( tmp0, tmp1, qv );
qv = vec_nmsub( tmp2, tmp3, qv );
product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product );
qw = vec_add( vec_sld( product, product, 8 ), qw );
tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW );
tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW );
res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
res = vec_madd( wwww, qv, res );
res = vec_madd( tmp0, tmp1, res );
res = vec_nmsub( tmp2, tmp3, res );
result->vec128 = res;
}
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
{
result->vec128 = vec_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) );
}
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
{
unsigned int tmp;
tmp = (unsigned int)-(select1 > 0);
result->vec128 = vec_sel( quat0->vec128, quat1->vec128, _vmathVuiSplatScalar(tmp) );
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathQPrint( const VmathQuat *quat )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = quat->vec128;
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
}
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = quat->vec128;
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,312 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_V_C_H
#define _VECTORMATH_QUAT_AOS_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
{
VmathQuat result;
vmathQMakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
{
VmathQuat result;
vmathQMakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
{
VmathQuat result;
vmathQMakeFromV4(&result, &vec);
return result;
}
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
{
VmathQuat result;
vmathQMakeFromScalar(&result, scalar);
return result;
}
static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 )
{
VmathQuat result;
vmathQMakeFrom128(&result, vf4);
return result;
}
static inline VmathQuat vmathQMakeIdentity_V( )
{
VmathQuat result;
vmathQMakeIdentity(&result);
return result;
}
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQLerp(&result, t, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
{
VmathQuat result;
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
return result;
}
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
{
VmathQuat result;
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
return result;
}
static inline vec_float4 vmathQGet128_V( VmathQuat quat )
{
return vmathQGet128(&quat);
}
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
{
vmathQSetXYZ(result, &vec);
}
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
{
VmathVector3 result;
vmathQGetXYZ(&result, &quat);
return result;
}
static inline void vmathQSetX_V( VmathQuat *result, float _x )
{
vmathQSetX(result, _x);
}
static inline float vmathQGetX_V( VmathQuat quat )
{
return vmathQGetX(&quat);
}
static inline void vmathQSetY_V( VmathQuat *result, float _y )
{
vmathQSetY(result, _y);
}
static inline float vmathQGetY_V( VmathQuat quat )
{
return vmathQGetY(&quat);
}
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
{
vmathQSetZ(result, _z);
}
static inline float vmathQGetZ_V( VmathQuat quat )
{
return vmathQGetZ(&quat);
}
static inline void vmathQSetW_V( VmathQuat *result, float _w )
{
vmathQSetW(result, _w);
}
static inline float vmathQGetW_V( VmathQuat quat )
{
return vmathQGetW(&quat);
}
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
{
vmathQSetElem(result, idx, value);
}
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
{
return vmathQGetElem(&quat, idx);
}
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQAdd(&result, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQSub(&result, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
{
VmathQuat result;
vmathQScalarMul(&result, &quat, scalar);
return result;
}
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
{
VmathQuat result;
vmathQScalarDiv(&result, &quat, scalar);
return result;
}
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
{
VmathQuat result;
vmathQNeg(&result, &quat);
return result;
}
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
{
return vmathQDot(&quat0, &quat1);
}
static inline float vmathQNorm_V( VmathQuat quat )
{
return vmathQNorm(&quat);
}
static inline float vmathQLength_V( VmathQuat quat )
{
return vmathQLength(&quat);
}
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
{
VmathQuat result;
vmathQNormalize(&result, &quat);
return result;
}
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
{
VmathQuat result;
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
return result;
}
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
{
VmathQuat result;
vmathQMakeRotationAxis(&result, radians, &unitVec);
return result;
}
static inline VmathQuat vmathQMakeRotationX_V( float radians )
{
VmathQuat result;
vmathQMakeRotationX(&result, radians);
return result;
}
static inline VmathQuat vmathQMakeRotationY_V( float radians )
{
VmathQuat result;
vmathQMakeRotationY(&result, radians);
return result;
}
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
{
VmathQuat result;
vmathQMakeRotationZ(&result, radians);
return result;
}
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQMul(&result, &quat0, &quat1);
return result;
}
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
{
VmathVector3 result;
vmathQRotate(&result, &quat, &vec);
return result;
}
static inline VmathQuat vmathQConj_V( VmathQuat quat )
{
VmathQuat result;
vmathQConj(&result, &quat);
return result;
}
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
{
VmathQuat result;
vmathQSelect(&result, &quat0, &quat1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathQPrint_V( VmathQuat quat )
{
vmathQPrint(&quat);
}
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
{
vmathQPrints(&quat, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,415 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_SOA_C_H
#define _VECTORMATH_QUAT_SOA_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat )
{
result->x = quat->x;
result->y = quat->y;
result->z = quat->z;
result->w = quat->w;
}
static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
{
result->x = _x;
result->y = _y;
result->z = _z;
result->w = _w;
}
static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w )
{
vmathSoaQSetXYZ( result, xyz );
vmathSoaQSetW( result, _w );
}
static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
result->w = vec->w;
}
static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar )
{
result->x = scalar;
result->y = scalar;
result->z = scalar;
result->w = scalar;
}
static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat )
{
vec_float4 vec128 = quat->vec128;
result->x = vec_splat( vec128, 0 );
result->y = vec_splat( vec128, 1 );
result->z = vec_splat( vec128, 2 );
result->w = vec_splat( vec128, 3 );
}
static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 )
{
vec_float4 tmp0, tmp1, tmp2, tmp3;
tmp0 = vec_mergeh( quat0->vec128, quat2->vec128 );
tmp1 = vec_mergeh( quat1->vec128, quat3->vec128 );
tmp2 = vec_mergel( quat0->vec128, quat2->vec128 );
tmp3 = vec_mergel( quat1->vec128, quat3->vec128 );
result->x = vec_mergeh( tmp0, tmp1 );
result->y = vec_mergel( tmp0, tmp1 );
result->z = vec_mergeh( tmp2, tmp3 );
result->w = vec_mergel( tmp2, tmp3 );
}
static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result )
{
vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) );
}
static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
VmathSoaQuat tmpQ_0, tmpQ_1;
vmathSoaQSub( &tmpQ_0, quat1, quat0 );
vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t );
vmathSoaQAdd( result, quat0, &tmpQ_1 );
}
static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 )
{
VmathSoaQuat start, tmpQ_0, tmpQ_1;
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
vec_uint4 selectMask;
cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 );
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle );
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
vmathSoaQSetX( &start, vec_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) );
vmathSoaQSetY( &start, vec_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) );
vmathSoaQSetZ( &start, vec_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) );
vmathSoaQSetW( &start, vec_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) );
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle );
angle = acosf4( cosAngle );
recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) );
scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
vmathSoaQScalarMul( &tmpQ_0, &start, scale0 );
vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 );
vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 );
}
static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 )
{
VmathSoaQuat tmp0, tmp1;
vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
vmathSoaQSlerp( result, vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), &tmp0, &tmp1 );
}
static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
{
vec_float4 tmp0, tmp1, tmp2, tmp3;
tmp0 = vec_mergeh( quat->x, quat->z );
tmp1 = vec_mergeh( quat->y, quat->w );
tmp2 = vec_mergel( quat->x, quat->z );
tmp3 = vec_mergel( quat->y, quat->w );
vmathQMakeFrom128( result0, vec_mergeh( tmp0, tmp1 ) );
vmathQMakeFrom128( result1, vec_mergel( tmp0, tmp1 ) );
vmathQMakeFrom128( result2, vec_mergeh( tmp2, tmp3 ) );
vmathQMakeFrom128( result3, vec_mergel( tmp2, tmp3 ) );
}
static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
}
static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat )
{
vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z );
}
static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x )
{
result->x = _x;
}
static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat )
{
return quat->x;
}
static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y )
{
result->y = _y;
}
static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat )
{
return quat->y;
}
static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z )
{
result->z = _z;
}
static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat )
{
return quat->z;
}
static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w )
{
result->w = _w;
}
static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat )
{
return quat->w;
}
static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value )
{
*(&result->x + idx) = value;
}
static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx )
{
return *(&quat->x + idx);
}
static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
result->x = vec_add( quat0->x, quat1->x );
result->y = vec_add( quat0->y, quat1->y );
result->z = vec_add( quat0->z, quat1->z );
result->w = vec_add( quat0->w, quat1->w );
}
static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
result->x = vec_sub( quat0->x, quat1->x );
result->y = vec_sub( quat0->y, quat1->y );
result->z = vec_sub( quat0->z, quat1->z );
result->w = vec_sub( quat0->w, quat1->w );
}
static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
{
result->x = vec_madd( quat->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result->y = vec_madd( quat->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result->z = vec_madd( quat->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result->w = vec_madd( quat->w, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
}
static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
{
result->x = divf4( quat->x, scalar );
result->y = divf4( quat->y, scalar );
result->z = divf4( quat->z, scalar );
result->w = divf4( quat->w, scalar );
}
static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat )
{
result->x = negatef4( quat->x );
result->y = negatef4( quat->y );
result->z = negatef4( quat->z );
result->w = negatef4( quat->w );
}
static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
vec_float4 result;
result = vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result = vec_add( result, vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result = vec_add( result, vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result = vec_add( result, vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
return result;
}
static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat )
{
vec_float4 result;
result = vec_madd( quat->x, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result = vec_add( result, vec_madd( quat->y, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result = vec_add( result, vec_madd( quat->z, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result = vec_add( result, vec_madd( quat->w, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
return result;
}
static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat )
{
return sqrtf4( vmathSoaQNorm( quat ) );
}
static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat )
{
vec_float4 lenSqr, lenInv;
lenSqr = vmathSoaQNorm( quat );
lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) );
result->x = vec_madd( quat->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result->y = vec_madd( quat->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result->z = vec_madd( quat->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result->w = vec_madd( quat->w, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
}
static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 )
{
VmathSoaVector3 tmpV3_0, tmpV3_1;
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 );
vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 );
vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
}
static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec )
{
VmathSoaVector3 tmpV3_0;
vec_float4 s, c, angle;
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s );
vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c );
}
static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians )
{
vec_float4 s, c, angle;
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
vmathSoaQMakeFromElems( result, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
}
static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians )
{
vec_float4 s, c, angle;
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
}
static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians )
{
vec_float4 s, c, angle;
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c );
}
static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
vec_float4 tmpX, tmpY, tmpZ, tmpW;
tmpX = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpY = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->y, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpZ = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->z, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpW = vec_sub( vec_sub( vec_sub( vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
}
static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec )
{
vec_float4 tmpX, tmpY, tmpZ, tmpW;
tmpX = vec_sub( vec_add( vec_madd( quat->w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpY = vec_sub( vec_add( vec_madd( quat->w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpZ = vec_sub( vec_add( vec_madd( quat->w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpW = vec_add( vec_add( vec_madd( quat->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result->x = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result->y = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result->z = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
}
static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat )
{
vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w );
}
static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 )
{
result->x = vec_sel( quat0->x, quat1->x, select1 );
result->y = vec_sel( quat0->y, quat1->y, select1 );
result->z = vec_sel( quat0->z, quat1->z, select1 );
result->w = vec_sel( quat0->w, quat1->w, select1 );
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaQPrint( const VmathSoaQuat *quat )
{
VmathQuat vec0, vec1, vec2, vec3;
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
printf("slot 0:\n");
vmathQPrint( &vec0 );
printf("slot 1:\n");
vmathQPrint( &vec1 );
printf("slot 2:\n");
vmathQPrint( &vec2 );
printf("slot 3:\n");
vmathQPrint( &vec3 );
}
static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name )
{
VmathQuat vec0, vec1, vec2, vec3;
printf( "%s:\n", name );
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
printf("slot 0:\n");
vmathQPrint( &vec0 );
printf("slot 1:\n");
vmathQPrint( &vec1 );
printf("slot 2:\n");
vmathQPrint( &vec2 );
printf("slot 3:\n");
vmathQPrint( &vec3 );
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,319 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_SOA_V_C_H
#define _VECTORMATH_QUAT_SOA_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
{
VmathSoaQuat result;
vmathSoaQMakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w )
{
VmathSoaQuat result;
vmathSoaQMakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec )
{
VmathSoaQuat result;
vmathSoaQMakeFromV4(&result, &vec);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar )
{
VmathSoaQuat result;
vmathSoaQMakeFromScalar(&result, scalar);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat )
{
VmathSoaQuat result;
vmathSoaQMakeFromAos(&result, &quat);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 )
{
VmathSoaQuat result;
vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeIdentity_V( )
{
VmathSoaQuat result;
vmathSoaQMakeIdentity(&result);
return result;
}
static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
VmathSoaQuat result;
vmathSoaQLerp(&result, t, &quat0, &quat1);
return result;
}
static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 )
{
VmathSoaQuat result;
vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1);
return result;
}
static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 )
{
VmathSoaQuat result;
vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
return result;
}
static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
{
vmathSoaQGet4Aos(&quat, result0, result1, result2, result3);
}
static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec )
{
vmathSoaQSetXYZ(result, &vec);
}
static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat )
{
VmathSoaVector3 result;
vmathSoaQGetXYZ(&result, &quat);
return result;
}
static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x )
{
vmathSoaQSetX(result, _x);
}
static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat )
{
return vmathSoaQGetX(&quat);
}
static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y )
{
vmathSoaQSetY(result, _y);
}
static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat )
{
return vmathSoaQGetY(&quat);
}
static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z )
{
vmathSoaQSetZ(result, _z);
}
static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat )
{
return vmathSoaQGetZ(&quat);
}
static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w )
{
vmathSoaQSetW(result, _w);
}
static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat )
{
return vmathSoaQGetW(&quat);
}
static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value )
{
vmathSoaQSetElem(result, idx, value);
}
static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx )
{
return vmathSoaQGetElem(&quat, idx);
}
static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
VmathSoaQuat result;
vmathSoaQAdd(&result, &quat0, &quat1);
return result;
}
static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
VmathSoaQuat result;
vmathSoaQSub(&result, &quat0, &quat1);
return result;
}
static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar )
{
VmathSoaQuat result;
vmathSoaQScalarMul(&result, &quat, scalar);
return result;
}
static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar )
{
VmathSoaQuat result;
vmathSoaQScalarDiv(&result, &quat, scalar);
return result;
}
static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat )
{
VmathSoaQuat result;
vmathSoaQNeg(&result, &quat);
return result;
}
static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
return vmathSoaQDot(&quat0, &quat1);
}
static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat )
{
return vmathSoaQNorm(&quat);
}
static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat )
{
return vmathSoaQLength(&quat);
}
static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat )
{
VmathSoaQuat result;
vmathSoaQNormalize(&result, &quat);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 )
{
VmathSoaQuat result;
vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec )
{
VmathSoaQuat result;
vmathSoaQMakeRotationAxis(&result, radians, &unitVec);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians )
{
VmathSoaQuat result;
vmathSoaQMakeRotationX(&result, radians);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians )
{
VmathSoaQuat result;
vmathSoaQMakeRotationY(&result, radians);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians )
{
VmathSoaQuat result;
vmathSoaQMakeRotationZ(&result, radians);
return result;
}
static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
VmathSoaQuat result;
vmathSoaQMul(&result, &quat0, &quat1);
return result;
}
static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaQRotate(&result, &quat, &vec);
return result;
}
static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat )
{
VmathSoaQuat result;
vmathSoaQConj(&result, &quat);
return result;
}
static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 )
{
VmathSoaQuat result;
vmathSoaQSelect(&result, &quat0, &quat1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaQPrint_V( VmathSoaQuat quat )
{
vmathSoaQPrint(&quat);
}
static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name )
{
vmathSoaQPrints(&quat, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,953 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_VEC_AOS_V_C_H
#define _VECTORMATH_VEC_AOS_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Constants
* for permutes words are labeled [x,y,z,w] [a,b,c,d]
*/
#define _VECTORMATH_PERM_X 0x00010203
#define _VECTORMATH_PERM_Y 0x04050607
#define _VECTORMATH_PERM_Z 0x08090a0b
#define _VECTORMATH_PERM_W 0x0c0d0e0f
#define _VECTORMATH_PERM_A 0x10111213
#define _VECTORMATH_PERM_B 0x14151617
#define _VECTORMATH_PERM_C 0x18191a1b
#define _VECTORMATH_PERM_D 0x1c1d1e1f
#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A }
#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W }
#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W }
#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }
#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C }
#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W }
#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W }
#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 }
#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 }
#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 }
#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff }
#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f }
#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f }
#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f }
#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f }
#define _VECTORMATH_SLERP_TOL 0.999f
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z )
{
VmathVector3 result;
vmathV3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt )
{
VmathVector3 result;
vmathV3MakeFromP3(&result, &pnt);
return result;
}
static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar )
{
VmathVector3 result;
vmathV3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 )
{
VmathVector3 result;
vmathV3MakeFrom128(&result, vf4);
return result;
}
static inline VmathVector3 vmathV3MakeXAxis_V( )
{
VmathVector3 result;
vmathV3MakeXAxis(&result);
return result;
}
static inline VmathVector3 vmathV3MakeYAxis_V( )
{
VmathVector3 result;
vmathV3MakeYAxis(&result);
return result;
}
static inline VmathVector3 vmathV3MakeZAxis_V( )
{
VmathVector3 result;
vmathV3MakeZAxis(&result);
return result;
}
static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 )
{
VmathVector3 result;
vmathV3Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline vec_float4 vmathV3Get128_V( VmathVector3 vec )
{
return vmathV3Get128(&vec);
}
static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad )
{
vmathV3StoreXYZ(&vec, quad);
}
static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads )
{
vmathV3LoadXYZArray(vec0, vec1, vec2, vec3, threeQuads);
}
static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads )
{
vmathV3StoreXYZArray(&vec0, &vec1, &vec2, &vec3, threeQuads);
}
static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads )
{
vmathV3StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, &vec4, &vec5, &vec6, &vec7, threeQuads);
}
static inline void vmathV3SetX_V( VmathVector3 *result, float _x )
{
vmathV3SetX(result, _x);
}
static inline float vmathV3GetX_V( VmathVector3 vec )
{
return vmathV3GetX(&vec);
}
static inline void vmathV3SetY_V( VmathVector3 *result, float _y )
{
vmathV3SetY(result, _y);
}
static inline float vmathV3GetY_V( VmathVector3 vec )
{
return vmathV3GetY(&vec);
}
static inline void vmathV3SetZ_V( VmathVector3 *result, float _z )
{
vmathV3SetZ(result, _z);
}
static inline float vmathV3GetZ_V( VmathVector3 vec )
{
return vmathV3GetZ(&vec);
}
static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value )
{
vmathV3SetElem(result, idx, value);
}
static inline float vmathV3GetElem_V( VmathVector3 vec, int idx )
{
return vmathV3GetElem(&vec, idx);
}
static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Add(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathV3AddP3(&result, &vec, &pnt1);
return result;
}
static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar )
{
VmathVector3 result;
vmathV3ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar )
{
VmathVector3 result;
vmathV3ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3Neg(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3RecipPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3SqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3AbsPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV3MaxElem_V( VmathVector3 vec )
{
return vmathV3MaxElem(&vec);
}
static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV3MinElem_V( VmathVector3 vec )
{
return vmathV3MinElem(&vec);
}
static inline float vmathV3Sum_V( VmathVector3 vec )
{
return vmathV3Sum(&vec);
}
static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 )
{
return vmathV3Dot(&vec0, &vec1);
}
static inline float vmathV3LengthSqr_V( VmathVector3 vec )
{
return vmathV3LengthSqr(&vec);
}
static inline float vmathV3Length_V( VmathVector3 vec )
{
return vmathV3Length(&vec);
}
static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3Normalize(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Cross(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 )
{
VmathVector3 result;
vmathV3Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathV3Print_V( VmathVector3 vec )
{
vmathV3Print(&vec);
}
static inline void vmathV3Prints_V( VmathVector3 vec, const char *name )
{
vmathV3Prints(&vec, name);
}
#endif
static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w )
{
VmathVector4 result;
vmathV4MakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w )
{
VmathVector4 result;
vmathV4MakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec )
{
VmathVector4 result;
vmathV4MakeFromV3(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt )
{
VmathVector4 result;
vmathV4MakeFromP3(&result, &pnt);
return result;
}
static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat )
{
VmathVector4 result;
vmathV4MakeFromQ(&result, &quat);
return result;
}
static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar )
{
VmathVector4 result;
vmathV4MakeFromScalar(&result, scalar);
return result;
}
static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 )
{
VmathVector4 result;
vmathV4MakeFrom128(&result, vf4);
return result;
}
static inline VmathVector4 vmathV4MakeXAxis_V( )
{
VmathVector4 result;
vmathV4MakeXAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeYAxis_V( )
{
VmathVector4 result;
vmathV4MakeYAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeZAxis_V( )
{
VmathVector4 result;
vmathV4MakeZAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeWAxis_V( )
{
VmathVector4 result;
vmathV4MakeWAxis(&result);
return result;
}
static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 )
{
VmathVector4 result;
vmathV4Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline vec_float4 vmathV4Get128_V( VmathVector4 vec )
{
return vmathV4Get128(&vec);
}
static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads )
{
vmathV4StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, twoQuads);
}
static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec )
{
vmathV4SetXYZ(result, &vec);
}
static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec )
{
VmathVector3 result;
vmathV4GetXYZ(&result, &vec);
return result;
}
static inline void vmathV4SetX_V( VmathVector4 *result, float _x )
{
vmathV4SetX(result, _x);
}
static inline float vmathV4GetX_V( VmathVector4 vec )
{
return vmathV4GetX(&vec);
}
static inline void vmathV4SetY_V( VmathVector4 *result, float _y )
{
vmathV4SetY(result, _y);
}
static inline float vmathV4GetY_V( VmathVector4 vec )
{
return vmathV4GetY(&vec);
}
static inline void vmathV4SetZ_V( VmathVector4 *result, float _z )
{
vmathV4SetZ(result, _z);
}
static inline float vmathV4GetZ_V( VmathVector4 vec )
{
return vmathV4GetZ(&vec);
}
static inline void vmathV4SetW_V( VmathVector4 *result, float _w )
{
vmathV4SetW(result, _w);
}
static inline float vmathV4GetW_V( VmathVector4 vec )
{
return vmathV4GetW(&vec);
}
static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value )
{
vmathV4SetElem(result, idx, value);
}
static inline float vmathV4GetElem_V( VmathVector4 vec, int idx )
{
return vmathV4GetElem(&vec, idx);
}
static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Add(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar )
{
VmathVector4 result;
vmathV4ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar )
{
VmathVector4 result;
vmathV4ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4Neg(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4RecipPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4SqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4AbsPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV4MaxElem_V( VmathVector4 vec )
{
return vmathV4MaxElem(&vec);
}
static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV4MinElem_V( VmathVector4 vec )
{
return vmathV4MinElem(&vec);
}
static inline float vmathV4Sum_V( VmathVector4 vec )
{
return vmathV4Sum(&vec);
}
static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 )
{
return vmathV4Dot(&vec0, &vec1);
}
static inline float vmathV4LengthSqr_V( VmathVector4 vec )
{
return vmathV4LengthSqr(&vec);
}
static inline float vmathV4Length_V( VmathVector4 vec )
{
return vmathV4Length(&vec);
}
static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4Normalize(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 )
{
VmathVector4 result;
vmathV4Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathV4Print_V( VmathVector4 vec )
{
vmathV4Print(&vec);
}
static inline void vmathV4Prints_V( VmathVector4 vec, const char *name )
{
vmathV4Prints(&vec, name);
}
#endif
static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z )
{
VmathPoint3 result;
vmathP3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec )
{
VmathPoint3 result;
vmathP3MakeFromV3(&result, &vec);
return result;
}
static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar )
{
VmathPoint3 result;
vmathP3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 )
{
VmathPoint3 result;
vmathP3MakeFrom128(&result, vf4);
return result;
}
static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3Lerp(&result, t, &pnt0, &pnt1);
return result;
}
static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt )
{
return vmathP3Get128(&pnt);
}
static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad )
{
vmathP3StoreXYZ(&pnt, quad);
}
static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads )
{
vmathP3LoadXYZArray(pnt0, pnt1, pnt2, pnt3, threeQuads);
}
static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads )
{
vmathP3StoreXYZArray(&pnt0, &pnt1, &pnt2, &pnt3, threeQuads);
}
static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads )
{
vmathP3StoreHalfFloats(&pnt0, &pnt1, &pnt2, &pnt3, &pnt4, &pnt5, &pnt6, &pnt7, threeQuads);
}
static inline void vmathP3SetX_V( VmathPoint3 *result, float _x )
{
vmathP3SetX(result, _x);
}
static inline float vmathP3GetX_V( VmathPoint3 pnt )
{
return vmathP3GetX(&pnt);
}
static inline void vmathP3SetY_V( VmathPoint3 *result, float _y )
{
vmathP3SetY(result, _y);
}
static inline float vmathP3GetY_V( VmathPoint3 pnt )
{
return vmathP3GetY(&pnt);
}
static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z )
{
vmathP3SetZ(result, _z);
}
static inline float vmathP3GetZ_V( VmathPoint3 pnt )
{
return vmathP3GetZ(&pnt);
}
static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value )
{
vmathP3SetElem(result, idx, value);
}
static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx )
{
return vmathP3GetElem(&pnt, idx);
}
static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathVector3 result;
vmathP3Sub(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 )
{
VmathPoint3 result;
vmathP3AddV3(&result, &pnt, &vec1);
return result;
}
static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 )
{
VmathPoint3 result;
vmathP3SubV3(&result, &pnt, &vec1);
return result;
}
static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MulPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3DivPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3RecipPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3SqrtPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3RsqrtPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3AbsPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3CopySignPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MaxPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline float vmathP3MaxElem_V( VmathPoint3 pnt )
{
return vmathP3MaxElem(&pnt);
}
static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MinPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline float vmathP3MinElem_V( VmathPoint3 pnt )
{
return vmathP3MinElem(&pnt);
}
static inline float vmathP3Sum_V( VmathPoint3 pnt )
{
return vmathP3Sum(&pnt);
}
static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal )
{
VmathPoint3 result;
vmathP3Scale(&result, &pnt, scaleVal);
return result;
}
static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec )
{
VmathPoint3 result;
vmathP3NonUniformScale(&result, &pnt, &scaleVec);
return result;
}
static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec )
{
return vmathP3Projection(&pnt, &unitVec);
}
static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt )
{
return vmathP3DistSqrFromOrigin(&pnt);
}
static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt )
{
return vmathP3DistFromOrigin(&pnt);
}
static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
return vmathP3DistSqr(&pnt0, &pnt1);
}
static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
return vmathP3Dist(&pnt0, &pnt1);
}
static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 )
{
VmathPoint3 result;
vmathP3Select(&result, &pnt0, &pnt1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathP3Print_V( VmathPoint3 pnt )
{
vmathP3Print(&pnt);
}
static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name )
{
vmathP3Prints(&pnt, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,958 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_VEC_SOA_V_C_H
#define _VECTORMATH_VEC_SOA_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Constants
* for permutes, words are labeled [x,y,z,w] [a,b,c,d]
*/
#define _VECTORMATH_PERM_X 0x00010203
#define _VECTORMATH_PERM_Y 0x04050607
#define _VECTORMATH_PERM_Z 0x08090a0b
#define _VECTORMATH_PERM_W 0x0c0d0e0f
#define _VECTORMATH_PERM_A 0x10111213
#define _VECTORMATH_PERM_B 0x14151617
#define _VECTORMATH_PERM_C 0x18191a1b
#define _VECTORMATH_PERM_D 0x1c1d1e1f
#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X })
#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X })
#define _VECTORMATH_PERM_ZDWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X })
#define _VECTORMATH_PERM_ZCXA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_A })
#define _VECTORMATH_PERM_XBZD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D })
#define _VECTORMATH_PERM_WDYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B })
#define _VECTORMATH_PERM_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X, _VECTORMATH_PERM_D })
#define _VECTORMATH_PERM_WCYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A })
#define _VECTORMATH_PERM_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B })
#define _VECTORMATH_SLERP_TOL 0.999f
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z )
{
VmathSoaVector3 result;
vmathSoaV3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt )
{
VmathSoaVector3 result;
vmathSoaV3MakeFromP3(&result, &pnt);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar )
{
VmathSoaVector3 result;
vmathSoaV3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3MakeFromAos(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 )
{
VmathSoaVector3 result;
vmathSoaV3MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( )
{
VmathSoaVector3 result;
vmathSoaV3MakeXAxis(&result);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( )
{
VmathSoaVector3 result;
vmathSoaV3MakeYAxis(&result);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( )
{
VmathSoaVector3 result;
vmathSoaV3MakeZAxis(&result);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 )
{
VmathSoaVector3 result;
vmathSoaV3Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 )
{
vmathSoaV3Get4Aos(&vec, result0, result1, result2, result3);
}
static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads )
{
vmathSoaV3LoadXYZArray(vec, threeQuads);
}
static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads )
{
vmathSoaV3StoreXYZArray(&vec, threeQuads);
}
static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads )
{
vmathSoaV3StoreHalfFloats(&vec0, &vec1, threeQuads);
}
static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 _x )
{
vmathSoaV3SetX(result, _x);
}
static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec )
{
return vmathSoaV3GetX(&vec);
}
static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 _y )
{
vmathSoaV3SetY(result, _y);
}
static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec )
{
return vmathSoaV3GetY(&vec);
}
static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 _z )
{
vmathSoaV3SetZ(result, _z);
}
static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec )
{
return vmathSoaV3GetZ(&vec);
}
static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value )
{
vmathSoaV3SetElem(result, idx, value);
}
static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx )
{
return vmathSoaV3GetElem(&vec, idx);
}
static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3Add(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaV3AddP3(&result, &vec, &pnt1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar )
{
VmathSoaVector3 result;
vmathSoaV3ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar )
{
VmathSoaVector3 result;
vmathSoaV3ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3Neg(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3RecipPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3SqrtPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3AbsPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec )
{
return vmathSoaV3MaxElem(&vec);
}
static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec )
{
return vmathSoaV3MinElem(&vec);
}
static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec )
{
return vmathSoaV3Sum(&vec);
}
static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
return vmathSoaV3Dot(&vec0, &vec1);
}
static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec )
{
return vmathSoaV3LengthSqr(&vec);
}
static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec )
{
return vmathSoaV3Length(&vec);
}
static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3Normalize(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3Cross(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 )
{
VmathSoaVector3 result;
vmathSoaV3Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaV3Print_V( VmathSoaVector3 vec )
{
vmathSoaV3Print(&vec);
}
static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name )
{
vmathSoaV3Prints(&vec, name);
}
#endif
static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromV3(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromP3(&result, &pnt);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromQ(&result, &quat);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromScalar(&result, scalar);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromAos(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 )
{
VmathSoaVector4 result;
vmathSoaV4MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( )
{
VmathSoaVector4 result;
vmathSoaV4MakeXAxis(&result);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( )
{
VmathSoaVector4 result;
vmathSoaV4MakeYAxis(&result);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( )
{
VmathSoaVector4 result;
vmathSoaV4MakeZAxis(&result);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( )
{
VmathSoaVector4 result;
vmathSoaV4MakeWAxis(&result);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 )
{
VmathSoaVector4 result;
vmathSoaV4Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 )
{
vmathSoaV4Get4Aos(&vec, result0, result1, result2, result3);
}
static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads )
{
vmathSoaV4StoreHalfFloats(&vec, twoQuads);
}
static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec )
{
vmathSoaV4SetXYZ(result, &vec);
}
static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec )
{
VmathSoaVector3 result;
vmathSoaV4GetXYZ(&result, &vec);
return result;
}
static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 _x )
{
vmathSoaV4SetX(result, _x);
}
static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec )
{
return vmathSoaV4GetX(&vec);
}
static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 _y )
{
vmathSoaV4SetY(result, _y);
}
static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec )
{
return vmathSoaV4GetY(&vec);
}
static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 _z )
{
vmathSoaV4SetZ(result, _z);
}
static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec )
{
return vmathSoaV4GetZ(&vec);
}
static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 _w )
{
vmathSoaV4SetW(result, _w);
}
static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec )
{
return vmathSoaV4GetW(&vec);
}
static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value )
{
vmathSoaV4SetElem(result, idx, value);
}
static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx )
{
return vmathSoaV4GetElem(&vec, idx);
}
static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4Add(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar )
{
VmathSoaVector4 result;
vmathSoaV4ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar )
{
VmathSoaVector4 result;
vmathSoaV4ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4Neg(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4RecipPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4SqrtPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4AbsPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec )
{
return vmathSoaV4MaxElem(&vec);
}
static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec )
{
return vmathSoaV4MinElem(&vec);
}
static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec )
{
return vmathSoaV4Sum(&vec);
}
static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
return vmathSoaV4Dot(&vec0, &vec1);
}
static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec )
{
return vmathSoaV4LengthSqr(&vec);
}
static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec )
{
return vmathSoaV4Length(&vec);
}
static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4Normalize(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 )
{
VmathSoaVector4 result;
vmathSoaV4Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaV4Print_V( VmathSoaVector4 vec )
{
vmathSoaV4Print(&vec);
}
static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name )
{
vmathSoaV4Prints(&vec, name);
}
#endif
static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFromV3(&result, &vec);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFromAos(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFrom4Aos(&result, &pnt0, &pnt1, &pnt2, &pnt3);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3Lerp(&result, t, &pnt0, &pnt1);
return result;
}
static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 )
{
vmathSoaP3Get4Aos(&pnt, result0, result1, result2, result3);
}
static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *vec, const vec_float4 *threeQuads )
{
vmathSoaP3LoadXYZArray(vec, threeQuads);
}
static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 vec, vec_float4 *threeQuads )
{
vmathSoaP3StoreXYZArray(&vec, threeQuads);
}
static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads )
{
vmathSoaP3StoreHalfFloats(&pnt0, &pnt1, threeQuads);
}
static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 _x )
{
vmathSoaP3SetX(result, _x);
}
static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3GetX(&pnt);
}
static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 _y )
{
vmathSoaP3SetY(result, _y);
}
static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3GetY(&pnt);
}
static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 _z )
{
vmathSoaP3SetZ(result, _z);
}
static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3GetZ(&pnt);
}
static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value )
{
vmathSoaP3SetElem(result, idx, value);
}
static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx )
{
return vmathSoaP3GetElem(&pnt, idx);
}
static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaVector3 result;
vmathSoaP3Sub(&result, &pnt0, &pnt1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 )
{
VmathSoaPoint3 result;
vmathSoaP3AddV3(&result, &pnt, &vec1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 )
{
VmathSoaPoint3 result;
vmathSoaP3SubV3(&result, &pnt, &vec1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3MulPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3DivPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3RecipPerElem(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3SqrtPerElem(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3RsqrtPerElem(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3AbsPerElem(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3CopySignPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3MaxPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3MaxElem(&pnt);
}
static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3MinPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3MinElem(&pnt);
}
static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3Sum(&pnt);
}
static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal )
{
VmathSoaPoint3 result;
vmathSoaP3Scale(&result, &pnt, scaleVal);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec )
{
VmathSoaPoint3 result;
vmathSoaP3NonUniformScale(&result, &pnt, &scaleVec);
return result;
}
static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec )
{
return vmathSoaP3Projection(&pnt, &unitVec);
}
static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3DistSqrFromOrigin(&pnt);
}
static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3DistFromOrigin(&pnt);
}
static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
return vmathSoaP3DistSqr(&pnt0, &pnt1);
}
static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
return vmathSoaP3Dist(&pnt0, &pnt1);
}
static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 )
{
VmathSoaPoint3 result;
vmathSoaP3Select(&result, &pnt0, &pnt1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt )
{
vmathSoaP3Print(&pnt);
}
static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name )
{
vmathSoaP3Prints(&pnt, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,261 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _BOOLINVEC_H
#define _BOOLINVEC_H
#include <math.h>
#include <altivec.h>
#include "vec_types.h"
#undef bool
namespace Vectormath {
class floatInVec;
//--------------------------------------------------------------------------------------------------
// boolInVec class
//
class boolInVec
{
private:
vec_uint4 mData;
inline boolInVec(vec_uint4 vec);
public:
inline boolInVec() {}
// matches standard type conversions
//
inline boolInVec(floatInVec vec);
// explicit cast from bool
//
explicit inline boolInVec(bool scalar);
#ifdef _VECTORMATH_NO_SCALAR_CAST
// explicit cast to bool
//
inline bool getAsBool() const;
#else
// implicit cast to bool
//
inline operator bool() const;
#endif
// get vector data
// bool value is splatted across all word slots of vector as 0 (false) or -1 (true)
//
inline vec_uint4 get128() const;
// operators
//
inline const boolInVec operator ! () const;
inline boolInVec& operator = (boolInVec vec);
inline boolInVec& operator &= (boolInVec vec);
inline boolInVec& operator ^= (boolInVec vec);
inline boolInVec& operator |= (boolInVec vec);
// friend functions
//
friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
};
//--------------------------------------------------------------------------------------------------
// boolInVec functions
//
// operators
//
inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
// select between vec0 and vec1 using boolInVec.
// false selects vec0, true selects vec1
//
inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
} // namespace Vectormath
//--------------------------------------------------------------------------------------------------
// boolInVec implementation
//
#include "floatInVec.h"
namespace Vectormath {
inline
boolInVec::boolInVec(vec_uint4 vec)
{
mData = vec;
}
inline
boolInVec::boolInVec(floatInVec vec)
{
*this = (vec != floatInVec(0.0f));
}
inline
boolInVec::boolInVec(bool scalar)
{
#ifdef __GNUC__
if (__builtin_constant_p(scalar))
{
const unsigned int mask = -(int)scalar;
mData = (vec_uint4){mask, mask, mask, mask};
}
else
#endif
{
unsigned int mask = -(int)scalar;
vec_uint4 vec = vec_ld(0, &mask);
mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &mask)), 0);
}
}
#ifdef _VECTORMATH_NO_SCALAR_CAST
inline
bool
boolInVec::getAsBool() const
#else
inline
boolInVec::operator bool() const
#endif
{
return vec_all_gt(mData, ((vec_uint4){0,0,0,0}));
}
inline
vec_uint4
boolInVec::get128() const
{
return mData;
}
inline
const boolInVec
boolInVec::operator ! () const
{
return boolInVec(vec_nor(mData, mData));
}
inline
boolInVec&
boolInVec::operator = (boolInVec vec)
{
mData = vec.mData;
return *this;
}
inline
boolInVec&
boolInVec::operator &= (boolInVec vec)
{
*this = *this & vec;
return *this;
}
inline
boolInVec&
boolInVec::operator ^= (boolInVec vec)
{
*this = *this ^ vec;
return *this;
}
inline
boolInVec&
boolInVec::operator |= (boolInVec vec)
{
*this = *this | vec;
return *this;
}
inline
const boolInVec
operator == (boolInVec vec0, boolInVec vec1)
{
return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator != (boolInVec vec0, boolInVec vec1)
{
return !(vec0 == vec1);
}
inline
const boolInVec
operator & (boolInVec vec0, boolInVec vec1)
{
return boolInVec(vec_and(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator | (boolInVec vec0, boolInVec vec1)
{
return boolInVec(vec_or(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator ^ (boolInVec vec0, boolInVec vec1)
{
return boolInVec(vec_xor(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1)
{
return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
}
} // namespace Vectormath
#endif // boolInVec_h

View File

@@ -0,0 +1,361 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _FLOATINVEC_H
#define _FLOATINVEC_H
#include <math.h>
#include <altivec.h>
#include <stddef.h>
#include "vec_types.h"
#include "simdmath.h"
#undef bool
namespace Vectormath {
class boolInVec;
//--------------------------------------------------------------------------------------------------
// floatInVec class
//
class floatInVec
{
private:
vec_float4 mData;
inline floatInVec(vec_float4 vec);
public:
inline floatInVec() {}
// matches standard type conversions
//
inline floatInVec(boolInVec vec);
// construct from a slot of vec_float4
//
inline floatInVec(vec_float4 vec, int slot);
// explicit cast from float
//
explicit inline floatInVec(float scalar);
#ifdef _VECTORMATH_NO_SCALAR_CAST
// explicit cast to float
//
inline float getAsFloat() const;
#else
// implicit cast to float
//
inline operator float() const;
#endif
// get vector data
// float value is splatted across all word slots of vector
//
inline vec_float4 get128() const;
// operators
//
inline const floatInVec operator ++ (int);
inline const floatInVec operator -- (int);
inline floatInVec& operator ++ ();
inline floatInVec& operator -- ();
inline const floatInVec operator - () const;
inline floatInVec& operator = (floatInVec vec);
inline floatInVec& operator *= (floatInVec vec);
inline floatInVec& operator /= (floatInVec vec);
inline floatInVec& operator += (floatInVec vec);
inline floatInVec& operator -= (floatInVec vec);
// friend functions
//
friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
};
//--------------------------------------------------------------------------------------------------
// floatInVec functions
//
// operators
//
inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
// select between vec0 and vec1 using boolInVec.
// false selects vec0, true selects vec1
//
inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
} // namespace Vectormath
//--------------------------------------------------------------------------------------------------
// floatInVec implementation
//
#include "boolInVec.h"
namespace Vectormath {
inline
floatInVec::floatInVec(vec_float4 vec)
{
mData = vec;
}
inline
floatInVec::floatInVec(boolInVec vec)
{
mData = vec_ctf(vec_sub((vec_uint4){0,0,0,0}, vec.get128()), 0);
}
inline
floatInVec::floatInVec(vec_float4 vec, int slot)
{
#ifdef __GNUC__
if (__builtin_constant_p(slot))
{
mData = vec_splat(vec, slot);
}
else
#endif
{
const vec_uchar16 shiftpattern = vec_lvsl(0, (float *)(size_t)(slot << 2));
mData = vec_splat(vec_perm(vec, vec, shiftpattern), 0);
}
}
inline
floatInVec::floatInVec(float scalar)
{
#ifdef __GNUC__
if (__builtin_constant_p(scalar))
{
mData = (vec_float4){scalar, scalar, scalar, scalar};
}
else
#endif
{
vec_float4 vec = vec_ld(0, &scalar);
mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &scalar)), 0);
}
}
#ifdef _VECTORMATH_NO_SCALAR_CAST
inline
float
floatInVec::getAsFloat() const
#else
inline
floatInVec::operator float() const
#endif
{
return *((float *)&mData);
}
inline
vec_float4
floatInVec::get128() const
{
return mData;
}
inline
const floatInVec
floatInVec::operator ++ (int)
{
vec_float4 olddata = mData;
operator ++();
return floatInVec(olddata);
}
inline
const floatInVec
floatInVec::operator -- (int)
{
vec_float4 olddata = mData;
operator --();
return floatInVec(olddata);
}
inline
floatInVec&
floatInVec::operator ++ ()
{
*this += floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f});
return *this;
}
inline
floatInVec&
floatInVec::operator -- ()
{
*this -= floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f});
return *this;
}
inline
const floatInVec
floatInVec::operator - () const
{
return floatInVec((vec_float4)vec_xor((vec_uint4)mData, (vec_uint4){0x80000000,0x80000000,0x80000000,0x80000000}));
}
inline
floatInVec&
floatInVec::operator = (floatInVec vec)
{
mData = vec.mData;
return *this;
}
inline
floatInVec&
floatInVec::operator *= (floatInVec vec)
{
*this = *this * vec;
return *this;
}
inline
floatInVec&
floatInVec::operator /= (floatInVec vec)
{
*this = *this / vec;
return *this;
}
inline
floatInVec&
floatInVec::operator += (floatInVec vec)
{
*this = *this + vec;
return *this;
}
inline
floatInVec&
floatInVec::operator -= (floatInVec vec)
{
*this = *this - vec;
return *this;
}
inline
const floatInVec
operator * (floatInVec vec0, floatInVec vec1)
{
return floatInVec(vec_madd(vec0.get128(), vec1.get128(), (vec_float4){0,0,0,0}));
}
inline
const floatInVec
operator / (floatInVec num, floatInVec den)
{
return floatInVec(divf4(num.get128(), den.get128()));
}
inline
const floatInVec
operator + (floatInVec vec0, floatInVec vec1)
{
return floatInVec(vec_add(vec0.get128(), vec1.get128()));
}
inline
const floatInVec
operator - (floatInVec vec0, floatInVec vec1)
{
return floatInVec(vec_sub(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator < (floatInVec vec0, floatInVec vec1)
{
return boolInVec((vec_uint4)vec_cmpgt(vec1.get128(), vec0.get128()));
}
inline
const boolInVec
operator <= (floatInVec vec0, floatInVec vec1)
{
return !(vec0 > vec1);
}
inline
const boolInVec
operator > (floatInVec vec0, floatInVec vec1)
{
return boolInVec((vec_uint4)vec_cmpgt(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator >= (floatInVec vec0, floatInVec vec1)
{
return !(vec0 < vec1);
}
inline
const boolInVec
operator == (floatInVec vec0, floatInVec vec1)
{
return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator != (floatInVec vec0, floatInVec vec1)
{
return !(vec0 == vec1);
}
inline
const floatInVec
select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1)
{
return floatInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
}
} // namespace Vectormath
#endif // floatInVec_h

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,536 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_CPP_H
#define _VECTORMATH_QUAT_AOS_CPP_H
//-----------------------------------------------------------------------------
// Definitions
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
namespace Vectormath {
namespace Aos {
inline Quat::Quat( float _x, float _y, float _z, float _w )
{
if (__builtin_constant_p(_x) & __builtin_constant_p(_y) &
__builtin_constant_p(_z) & __builtin_constant_p(_w)) {
mVec128 = (vec_float4){_x, _y, _z, _w};
} else {
float *pf = (float *)&mVec128;
pf[0] = _x;
pf[1] = _y;
pf[2] = _z;
pf[3] = _w;
}
}
inline Quat::Quat( floatInVec _x, floatInVec _y, floatInVec _z, floatInVec _w )
{
vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() );
vec_float4 yw = vec_mergeh( _y.get128(), _w.get128() );
mVec128 = vec_mergeh( xz, yw );
}
inline Quat::Quat( Vector3 xyz, float _w )
{
mVec128 = xyz.get128();
_vmathVfSetElement(mVec128, _w, 3);
}
inline Quat::Quat( Vector3 xyz, floatInVec _w )
{
mVec128 = xyz.get128();
mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3);
}
inline Quat::Quat( Vector4 vec )
{
mVec128 = vec.get128();
}
inline Quat::Quat( float scalar )
{
mVec128 = floatInVec(scalar).get128();
}
inline Quat::Quat( floatInVec scalar )
{
mVec128 = scalar.get128();
}
inline Quat::Quat( vec_float4 vf4 )
{
mVec128 = vf4;
}
inline const Quat Quat::identity( )
{
return Quat( _VECTORMATH_UNIT_0001 );
}
inline const Quat lerp( float t, Quat quat0, Quat quat1 )
{
return lerp( floatInVec(t), quat0, quat1 );
}
inline const Quat lerp( floatInVec t, Quat quat0, Quat quat1 )
{
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
}
inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 )
{
return slerp( floatInVec(t), unitQuat0, unitQuat1 );
}
inline const Quat slerp( floatInVec t, Quat unitQuat0, Quat unitQuat1 )
{
Quat start;
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
vec_uint4 selectMask;
cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() );
cosAngle = vec_splat( cosAngle, 0 );
selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle );
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
start = Quat( vec_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) );
selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle );
angle = acosf4( cosAngle );
tttt = t.get128();
oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt );
angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt );
angles = vec_mergeh( angles, oneMinusT );
angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sines = sinf4( angles );
scales = divf4( sines, vec_splat( sines, 0 ) );
scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask );
scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask );
return Quat( vec_madd( start.get128(), scale0, vec_madd( unitQuat1.get128(), scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) );
}
inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 )
{
return squad( floatInVec(t), unitQuat0, unitQuat1, unitQuat2, unitQuat3 );
}
inline const Quat squad( floatInVec t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 )
{
Quat tmp0, tmp1;
tmp0 = slerp( t, unitQuat0, unitQuat3 );
tmp1 = slerp( t, unitQuat1, unitQuat2 );
return slerp( ( ( floatInVec(2.0f) * t ) * ( floatInVec(1.0f) - t ) ), tmp0, tmp1 );
}
inline vec_float4 Quat::get128( ) const
{
return mVec128;
}
inline Quat & Quat::operator =( Quat quat )
{
mVec128 = quat.mVec128;
return *this;
}
inline Quat & Quat::setXYZ( Vector3 vec )
{
mVec128 = vec_sel( vec.get128(), mVec128, _VECTORMATH_MASK_0x000F );
return *this;
}
inline const Vector3 Quat::getXYZ( ) const
{
return Vector3( mVec128 );
}
inline Quat & Quat::setX( float _x )
{
_vmathVfSetElement(mVec128, _x, 0);
return *this;
}
inline Quat & Quat::setX( floatInVec _x )
{
mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0);
return *this;
}
inline const floatInVec Quat::getX( ) const
{
return floatInVec( mVec128, 0 );
}
inline Quat & Quat::setY( float _y )
{
_vmathVfSetElement(mVec128, _y, 1);
return *this;
}
inline Quat & Quat::setY( floatInVec _y )
{
mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1);
return *this;
}
inline const floatInVec Quat::getY( ) const
{
return floatInVec( mVec128, 1 );
}
inline Quat & Quat::setZ( float _z )
{
_vmathVfSetElement(mVec128, _z, 2);
return *this;
}
inline Quat & Quat::setZ( floatInVec _z )
{
mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2);
return *this;
}
inline const floatInVec Quat::getZ( ) const
{
return floatInVec( mVec128, 2 );
}
inline Quat & Quat::setW( float _w )
{
_vmathVfSetElement(mVec128, _w, 3);
return *this;
}
inline Quat & Quat::setW( floatInVec _w )
{
mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3);
return *this;
}
inline const floatInVec Quat::getW( ) const
{
return floatInVec( mVec128, 3 );
}
inline Quat & Quat::setElem( int idx, float value )
{
_vmathVfSetElement(mVec128, value, idx);
return *this;
}
inline Quat & Quat::setElem( int idx, floatInVec value )
{
mVec128 = _vmathVfInsert(mVec128, value.get128(), idx);
return *this;
}
inline const floatInVec Quat::getElem( int idx ) const
{
return floatInVec( mVec128, idx );
}
inline VecIdx Quat::operator []( int idx )
{
return VecIdx( mVec128, idx );
}
inline const floatInVec Quat::operator []( int idx ) const
{
return floatInVec( mVec128, idx );
}
inline const Quat Quat::operator +( Quat quat ) const
{
return Quat( vec_add( mVec128, quat.mVec128 ) );
}
inline const Quat Quat::operator -( Quat quat ) const
{
return Quat( vec_sub( mVec128, quat.mVec128 ) );
}
inline const Quat Quat::operator *( float scalar ) const
{
return *this * floatInVec(scalar);
}
inline const Quat Quat::operator *( floatInVec scalar ) const
{
return Quat( vec_madd( mVec128, scalar.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
}
inline Quat & Quat::operator +=( Quat quat )
{
*this = *this + quat;
return *this;
}
inline Quat & Quat::operator -=( Quat quat )
{
*this = *this - quat;
return *this;
}
inline Quat & Quat::operator *=( float scalar )
{
*this = *this * scalar;
return *this;
}
inline Quat & Quat::operator *=( floatInVec scalar )
{
*this = *this * scalar;
return *this;
}
inline const Quat Quat::operator /( float scalar ) const
{
return *this / floatInVec(scalar);
}
inline const Quat Quat::operator /( floatInVec scalar ) const
{
return Quat( divf4( mVec128, scalar.get128() ) );
}
inline Quat & Quat::operator /=( float scalar )
{
*this = *this / scalar;
return *this;
}
inline Quat & Quat::operator /=( floatInVec scalar )
{
*this = *this / scalar;
return *this;
}
inline const Quat Quat::operator -( ) const
{
return Quat( negatef4( mVec128 ) );
}
inline const Quat operator *( float scalar, Quat quat )
{
return floatInVec(scalar) * quat;
}
inline const Quat operator *( floatInVec scalar, Quat quat )
{
return quat * scalar;
}
inline const floatInVec dot( Quat quat0, Quat quat1 )
{
return floatInVec( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 );
}
inline const floatInVec norm( Quat quat )
{
return floatInVec( _vmathVfDot4( quat.get128(), quat.get128() ), 0 );
}
inline const floatInVec length( Quat quat )
{
return floatInVec( sqrtf4(_vmathVfDot4( quat.get128(), quat.get128() )), 0 );
}
inline const Quat normalize( Quat quat )
{
vec_float4 dot = _vmathVfDot4( quat.get128(), quat.get128() );
return Quat( vec_madd( quat.get128(), rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
}
inline const Quat Quat::rotation( Vector3 unitVec0, Vector3 unitVec1 )
{
Vector3 crossVec;
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() );
cosAngle = vec_splat( cosAngle, 0 );
cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) );
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
crossVec = cross( unitVec0, unitVec1 );
res = vec_madd( crossVec.get128(), recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F );
return Quat( res );
}
inline const Quat Quat::rotation( float radians, Vector3 unitVec )
{
return rotation( floatInVec(radians), unitVec );
}
inline const Quat Quat::rotation( floatInVec radians, Vector3 unitVec )
{
vec_float4 s, c, angle, res;
angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
res = vec_sel( vec_madd( unitVec.get128(), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F );
return Quat( res );
}
inline const Quat Quat::rotationX( float radians )
{
return rotationX( floatInVec(radians) );
}
inline const Quat Quat::rotationX( floatInVec radians )
{
vec_float4 s, c, angle, res;
angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 );
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
return Quat( res );
}
inline const Quat Quat::rotationY( float radians )
{
return rotationY( floatInVec(radians) );
}
inline const Quat Quat::rotationY( floatInVec radians )
{
vec_float4 s, c, angle, res;
angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 );
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
return Quat( res );
}
inline const Quat Quat::rotationZ( float radians )
{
return rotationZ( floatInVec(radians) );
}
inline const Quat Quat::rotationZ( floatInVec radians )
{
vec_float4 s, c, angle, res;
angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 );
res = vec_sel( res, c, _VECTORMATH_MASK_0x000F );
return Quat( res );
}
inline const Quat Quat::operator *( Quat quat ) const
{
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
ldata = mVec128;
rdata = quat.mVec128;
tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW );
tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW );
tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW );
tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW );
qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv );
qv = vec_madd( tmp0, tmp1, qv );
qv = vec_nmsub( tmp2, tmp3, qv );
product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
l_wxyz = vec_sld( ldata, ldata, 12 );
r_wxyz = vec_sld( rdata, rdata, 12 );
qw = vec_nmsub( l_wxyz, r_wxyz, product );
xy = vec_madd( l_wxyz, r_wxyz, product );
qw = vec_sub( qw, vec_sld( xy, xy, 8 ) );
return Quat( vec_sel( qv, qw, _VECTORMATH_MASK_0x000F ) );
}
inline Quat & Quat::operator *=( Quat quat )
{
*this = *this * quat;
return *this;
}
inline const Vector3 rotate( Quat quat, Vector3 vec )
{
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
qdata = quat.get128();
vdata = vec.get128();
tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW );
tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW );
tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW );
tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW );
wwww = vec_splat( qdata, 3 );
qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
qv = vec_madd( tmp0, tmp1, qv );
qv = vec_nmsub( tmp2, tmp3, qv );
product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product );
qw = vec_add( vec_sld( product, product, 8 ), qw );
tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW );
tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW );
res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
res = vec_madd( wwww, qv, res );
res = vec_madd( tmp0, tmp1, res );
res = vec_nmsub( tmp2, tmp3, res );
return Vector3( res );
}
inline const Quat conj( Quat quat )
{
return Quat( vec_xor( quat.get128(), ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ) );
}
inline const Quat select( Quat quat0, Quat quat1, bool select1 )
{
return select( quat0, quat1, boolInVec(select1) );
}
inline const Quat select( Quat quat0, Quat quat1, boolInVec select1 )
{
return Quat( vec_sel( quat0.get128(), quat1.get128(), select1.get128() ) );
}
#ifdef _VECTORMATH_DEBUG
inline void print( Quat quat )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = quat.get128();
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
}
inline void print( Quat quat, const char * name )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = quat.get128();
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
}
#endif
} // namespace Aos
} // namespace Vectormath
#endif

View File

@@ -0,0 +1,479 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_SOA_CPP_H
#define _VECTORMATH_QUAT_SOA_CPP_H
//-----------------------------------------------------------------------------
// Definitions
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
namespace Vectormath {
namespace Soa {
inline Quat::Quat( const Quat & quat )
{
mX = quat.mX;
mY = quat.mY;
mZ = quat.mZ;
mW = quat.mW;
}
inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
{
mX = _x;
mY = _y;
mZ = _z;
mW = _w;
}
inline Quat::Quat( const Vector3 & xyz, vec_float4 _w )
{
this->setXYZ( xyz );
this->setW( _w );
}
inline Quat::Quat( const Vector4 & vec )
{
mX = vec.getX();
mY = vec.getY();
mZ = vec.getZ();
mW = vec.getW();
}
inline Quat::Quat( vec_float4 scalar )
{
mX = scalar;
mY = scalar;
mZ = scalar;
mW = scalar;
}
inline Quat::Quat( Aos::Quat quat )
{
vec_float4 vec128 = quat.get128();
mX = vec_splat( vec128, 0 );
mY = vec_splat( vec128, 1 );
mZ = vec_splat( vec128, 2 );
mW = vec_splat( vec128, 3 );
}
inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 )
{
vec_float4 tmp0, tmp1, tmp2, tmp3;
tmp0 = vec_mergeh( quat0.get128(), quat2.get128() );
tmp1 = vec_mergeh( quat1.get128(), quat3.get128() );
tmp2 = vec_mergel( quat0.get128(), quat2.get128() );
tmp3 = vec_mergel( quat1.get128(), quat3.get128() );
mX = vec_mergeh( tmp0, tmp1 );
mY = vec_mergel( tmp0, tmp1 );
mZ = vec_mergeh( tmp2, tmp3 );
mW = vec_mergel( tmp2, tmp3 );
}
inline const Quat Quat::identity( )
{
return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) );
}
inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 )
{
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
}
inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 )
{
Quat start;
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
vec_uint4 selectMask;
cosAngle = dot( unitQuat0, unitQuat1 );
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle );
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
start.setX( vec_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) );
start.setY( vec_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) );
start.setZ( vec_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) );
start.setW( vec_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) );
selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle );
angle = acosf4( cosAngle );
recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) );
scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask );
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
}
inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
{
Quat tmp0, tmp1;
tmp0 = slerp( t, unitQuat0, unitQuat3 );
tmp1 = slerp( t, unitQuat1, unitQuat2 );
return slerp( vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), tmp0, tmp1 );
}
inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const
{
vec_float4 tmp0, tmp1, tmp2, tmp3;
tmp0 = vec_mergeh( mX, mZ );
tmp1 = vec_mergeh( mY, mW );
tmp2 = vec_mergel( mX, mZ );
tmp3 = vec_mergel( mY, mW );
result0 = Aos::Quat( vec_mergeh( tmp0, tmp1 ) );
result1 = Aos::Quat( vec_mergel( tmp0, tmp1 ) );
result2 = Aos::Quat( vec_mergeh( tmp2, tmp3 ) );
result3 = Aos::Quat( vec_mergel( tmp2, tmp3 ) );
}
inline Quat & Quat::operator =( const Quat & quat )
{
mX = quat.mX;
mY = quat.mY;
mZ = quat.mZ;
mW = quat.mW;
return *this;
}
inline Quat & Quat::setXYZ( const Vector3 & vec )
{
mX = vec.getX();
mY = vec.getY();
mZ = vec.getZ();
return *this;
}
inline const Vector3 Quat::getXYZ( ) const
{
return Vector3( mX, mY, mZ );
}
inline Quat & Quat::setX( vec_float4 _x )
{
mX = _x;
return *this;
}
inline vec_float4 Quat::getX( ) const
{
return mX;
}
inline Quat & Quat::setY( vec_float4 _y )
{
mY = _y;
return *this;
}
inline vec_float4 Quat::getY( ) const
{
return mY;
}
inline Quat & Quat::setZ( vec_float4 _z )
{
mZ = _z;
return *this;
}
inline vec_float4 Quat::getZ( ) const
{
return mZ;
}
inline Quat & Quat::setW( vec_float4 _w )
{
mW = _w;
return *this;
}
inline vec_float4 Quat::getW( ) const
{
return mW;
}
inline Quat & Quat::setElem( int idx, vec_float4 value )
{
*(&mX + idx) = value;
return *this;
}
inline vec_float4 Quat::getElem( int idx ) const
{
return *(&mX + idx);
}
inline Quat::vec_float4_t & Quat::operator []( int idx )
{
return *(&mX + idx);
}
inline vec_float4 Quat::operator []( int idx ) const
{
return *(&mX + idx);
}
inline const Quat Quat::operator +( const Quat & quat ) const
{
return Quat(
vec_add( mX, quat.mX ),
vec_add( mY, quat.mY ),
vec_add( mZ, quat.mZ ),
vec_add( mW, quat.mW )
);
}
inline const Quat Quat::operator -( const Quat & quat ) const
{
return Quat(
vec_sub( mX, quat.mX ),
vec_sub( mY, quat.mY ),
vec_sub( mZ, quat.mZ ),
vec_sub( mW, quat.mW )
);
}
inline const Quat Quat::operator *( vec_float4 scalar ) const
{
return Quat(
vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
vec_madd( mW, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) )
);
}
inline Quat & Quat::operator +=( const Quat & quat )
{
*this = *this + quat;
return *this;
}
inline Quat & Quat::operator -=( const Quat & quat )
{
*this = *this - quat;
return *this;
}
inline Quat & Quat::operator *=( vec_float4 scalar )
{
*this = *this * scalar;
return *this;
}
inline const Quat Quat::operator /( vec_float4 scalar ) const
{
return Quat(
divf4( mX, scalar ),
divf4( mY, scalar ),
divf4( mZ, scalar ),
divf4( mW, scalar )
);
}
inline Quat & Quat::operator /=( vec_float4 scalar )
{
*this = *this / scalar;
return *this;
}
inline const Quat Quat::operator -( ) const
{
return Quat(
negatef4( mX ),
negatef4( mY ),
negatef4( mZ ),
negatef4( mW )
);
}
inline const Quat operator *( vec_float4 scalar, const Quat & quat )
{
return quat * scalar;
}
inline vec_float4 dot( const Quat & quat0, const Quat & quat1 )
{
vec_float4 result;
result = vec_madd( quat0.getX(), quat1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result = vec_add( result, vec_madd( quat0.getY(), quat1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result = vec_add( result, vec_madd( quat0.getZ(), quat1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result = vec_add( result, vec_madd( quat0.getW(), quat1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
return result;
}
inline vec_float4 norm( const Quat & quat )
{
vec_float4 result;
result = vec_madd( quat.getX(), quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
result = vec_add( result, vec_madd( quat.getY(), quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result = vec_add( result, vec_madd( quat.getZ(), quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
result = vec_add( result, vec_madd( quat.getW(), quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
return result;
}
inline vec_float4 length( const Quat & quat )
{
return sqrtf4( norm( quat ) );
}
inline const Quat normalize( const Quat & quat )
{
vec_float4 lenSqr, lenInv;
lenSqr = norm( quat );
lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) );
return Quat(
vec_madd( quat.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
vec_madd( quat.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
vec_madd( quat.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ),
vec_madd( quat.getW(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) )
);
}
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
{
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 );
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
}
inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec )
{
vec_float4 s, c, angle;
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
return Quat( ( unitVec * s ), c );
}
inline const Quat Quat::rotationX( vec_float4 radians )
{
vec_float4 s, c, angle;
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
return Quat( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
}
inline const Quat Quat::rotationY( vec_float4 radians )
{
vec_float4 s, c, angle;
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c );
}
inline const Quat Quat::rotationZ( vec_float4 radians )
{
vec_float4 s, c, angle;
angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) );
sincosf4( angle, &s, &c );
return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c );
}
inline const Quat Quat::operator *( const Quat & quat ) const
{
return Quat(
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mY, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
vec_sub( vec_add( vec_add( vec_madd( mW, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mZ, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
vec_sub( vec_sub( vec_sub( vec_madd( mW, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) )
);
}
inline Quat & Quat::operator *=( const Quat & quat )
{
*this = *this * quat;
return *this;
}
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
{
vec_float4 tmpX, tmpY, tmpZ, tmpW;
tmpX = vec_sub( vec_add( vec_madd( quat.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpY = vec_sub( vec_add( vec_madd( quat.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpZ = vec_sub( vec_add( vec_madd( quat.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
tmpW = vec_add( vec_add( vec_madd( quat.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) );
return Vector3(
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ),
vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) )
);
}
inline const Quat conj( const Quat & quat )
{
return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() );
}
inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 )
{
return Quat(
vec_sel( quat0.getX(), quat1.getX(), select1 ),
vec_sel( quat0.getY(), quat1.getY(), select1 ),
vec_sel( quat0.getZ(), quat1.getZ(), select1 ),
vec_sel( quat0.getW(), quat1.getW(), select1 )
);
}
#ifdef _VECTORMATH_DEBUG
inline void print( const Quat & quat )
{
Aos::Quat vec0, vec1, vec2, vec3;
quat.get4Aos( vec0, vec1, vec2, vec3 );
printf("slot 0:\n");
print( vec0 );
printf("slot 1:\n");
print( vec1 );
printf("slot 2:\n");
print( vec2 );
printf("slot 3:\n");
print( vec3 );
}
inline void print( const Quat & quat, const char * name )
{
Aos::Quat vec0, vec1, vec2, vec3;
printf( "%s:\n", name );
quat.get4Aos( vec0, vec1, vec2, vec3 );
printf("slot 0:\n");
print( vec0 );
printf("slot 1:\n");
print( vec1 );
printf("slot 2:\n");
print( vec2 );
printf("slot 3:\n");
print( vec3 );
}
#endif
} // namespace Soa
} // namespace Vectormath
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_VECIDX_AOS_H
#define _VECTORMATH_VECIDX_AOS_H
#include "floatInVec.h"
namespace Vectormath {
namespace Aos {
//-----------------------------------------------------------------------------
// VecIdx
// Used in setting elements of Vector3, Vector4, Point3, or Quat with the
// subscripting operator.
//
class VecIdx
{
private:
typedef vec_float4 vec_float4_t;
vec_float4_t &ref __attribute__ ((aligned(16)));
int i __attribute__ ((aligned(16)));
public:
inline VecIdx( vec_float4_t& vec, int idx ): ref(vec) { i = idx; }
// implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined
// in which case, implicitly casts to floatInVec, and one must call
// getAsFloat to convert to float.
//
#ifdef _VECTORMATH_NO_SCALAR_CAST
inline operator floatInVec() const;
inline float getAsFloat() const;
#else
inline operator float() const;
#endif
inline float operator =( float scalar );
inline floatInVec operator =( floatInVec scalar );
inline floatInVec operator =( const VecIdx& scalar );
inline floatInVec operator *=( float scalar );
inline floatInVec operator *=( floatInVec scalar );
inline floatInVec operator /=( float scalar );
inline floatInVec operator /=( floatInVec scalar );
inline floatInVec operator +=( float scalar );
inline floatInVec operator +=( floatInVec scalar );
inline floatInVec operator -=( float scalar );
inline floatInVec operator -=( floatInVec scalar );
};
} // namespace Aos
} // namespace Vectormath
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,368 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_C_H
#define _VECTORMATH_QUAT_AOS_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
{
result->x = quat->x;
result->y = quat->y;
result->z = quat->z;
result->w = quat->w;
}
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
{
result->x = _x;
result->y = _y;
result->z = _z;
result->w = _w;
}
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
{
vmathQSetXYZ( result, xyz );
vmathQSetW( result, _w );
}
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
result->w = vec->w;
}
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
{
result->x = scalar;
result->y = scalar;
result->z = scalar;
result->w = scalar;
}
static inline void vmathQMakeIdentity( VmathQuat *result )
{
vmathQMakeFromElems( result, 0.0f, 0.0f, 0.0f, 1.0f );
}
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
{
VmathQuat tmpQ_0, tmpQ_1;
vmathQSub( &tmpQ_0, quat1, quat0 );
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
vmathQAdd( result, quat0, &tmpQ_1 );
}
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
{
VmathQuat start, tmpQ_0, tmpQ_1;
float recipSinAngle, scale0, scale1, cosAngle, angle;
cosAngle = vmathQDot( unitQuat0, unitQuat1 );
if ( cosAngle < 0.0f ) {
cosAngle = -cosAngle;
vmathQNeg( &start, unitQuat0 );
} else {
vmathQCopy( &start, unitQuat0 );
}
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
angle = acosf( cosAngle );
recipSinAngle = ( 1.0f / sinf( angle ) );
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
} else {
scale0 = ( 1.0f - t );
scale1 = t;
}
vmathQScalarMul( &tmpQ_0, &start, scale0 );
vmathQScalarMul( &tmpQ_1, unitQuat1, scale1 );
vmathQAdd( result, &tmpQ_0, &tmpQ_1 );
}
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
{
VmathQuat tmp0, tmp1;
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
}
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
}
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
{
vmathV3MakeFromElems( result, quat->x, quat->y, quat->z );
}
static inline void vmathQSetX( VmathQuat *result, float _x )
{
result->x = _x;
}
static inline float vmathQGetX( const VmathQuat *quat )
{
return quat->x;
}
static inline void vmathQSetY( VmathQuat *result, float _y )
{
result->y = _y;
}
static inline float vmathQGetY( const VmathQuat *quat )
{
return quat->y;
}
static inline void vmathQSetZ( VmathQuat *result, float _z )
{
result->z = _z;
}
static inline float vmathQGetZ( const VmathQuat *quat )
{
return quat->z;
}
static inline void vmathQSetW( VmathQuat *result, float _w )
{
result->w = _w;
}
static inline float vmathQGetW( const VmathQuat *quat )
{
return quat->w;
}
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
{
*(&result->x + idx) = value;
}
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
{
return *(&quat->x + idx);
}
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
result->x = ( quat0->x + quat1->x );
result->y = ( quat0->y + quat1->y );
result->z = ( quat0->z + quat1->z );
result->w = ( quat0->w + quat1->w );
}
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
result->x = ( quat0->x - quat1->x );
result->y = ( quat0->y - quat1->y );
result->z = ( quat0->z - quat1->z );
result->w = ( quat0->w - quat1->w );
}
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
{
result->x = ( quat->x * scalar );
result->y = ( quat->y * scalar );
result->z = ( quat->z * scalar );
result->w = ( quat->w * scalar );
}
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
{
result->x = ( quat->x / scalar );
result->y = ( quat->y / scalar );
result->z = ( quat->z / scalar );
result->w = ( quat->w / scalar );
}
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
{
result->x = -quat->x;
result->y = -quat->y;
result->z = -quat->z;
result->w = -quat->w;
}
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
{
float result;
result = ( quat0->x * quat1->x );
result = ( result + ( quat0->y * quat1->y ) );
result = ( result + ( quat0->z * quat1->z ) );
result = ( result + ( quat0->w * quat1->w ) );
return result;
}
static inline float vmathQNorm( const VmathQuat *quat )
{
float result;
result = ( quat->x * quat->x );
result = ( result + ( quat->y * quat->y ) );
result = ( result + ( quat->z * quat->z ) );
result = ( result + ( quat->w * quat->w ) );
return result;
}
static inline float vmathQLength( const VmathQuat *quat )
{
return sqrtf( vmathQNorm( quat ) );
}
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
{
float lenSqr, lenInv;
lenSqr = vmathQNorm( quat );
lenInv = ( 1.0f / sqrtf( lenSqr ) );
result->x = ( quat->x * lenInv );
result->y = ( quat->y * lenInv );
result->z = ( quat->z * lenInv );
result->w = ( quat->w * lenInv );
}
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
{
VmathVector3 tmpV3_0, tmpV3_1;
float cosHalfAngleX2, recipCosHalfAngleX2;
cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + vmathV3Dot( unitVec0, unitVec1 ) ) ) );
recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 );
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
vmathQMakeFromV3Scalar( result, &tmpV3_1, ( cosHalfAngleX2 * 0.5f ) );
}
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
{
VmathVector3 tmpV3_0;
float s, c, angle;
angle = ( radians * 0.5f );
s = sinf( angle );
c = cosf( angle );
vmathV3ScalarMul( &tmpV3_0, unitVec, s );
vmathQMakeFromV3Scalar( result, &tmpV3_0, c );
}
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
{
float s, c, angle;
angle = ( radians * 0.5f );
s = sinf( angle );
c = cosf( angle );
vmathQMakeFromElems( result, s, 0.0f, 0.0f, c );
}
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
{
float s, c, angle;
angle = ( radians * 0.5f );
s = sinf( angle );
c = cosf( angle );
vmathQMakeFromElems( result, 0.0f, s, 0.0f, c );
}
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
{
float s, c, angle;
angle = ( radians * 0.5f );
s = sinf( angle );
c = cosf( angle );
vmathQMakeFromElems( result, 0.0f, 0.0f, s, c );
}
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
float tmpX, tmpY, tmpZ, tmpW;
tmpX = ( ( ( ( quat0->w * quat1->x ) + ( quat0->x * quat1->w ) ) + ( quat0->y * quat1->z ) ) - ( quat0->z * quat1->y ) );
tmpY = ( ( ( ( quat0->w * quat1->y ) + ( quat0->y * quat1->w ) ) + ( quat0->z * quat1->x ) ) - ( quat0->x * quat1->z ) );
tmpZ = ( ( ( ( quat0->w * quat1->z ) + ( quat0->z * quat1->w ) ) + ( quat0->x * quat1->y ) ) - ( quat0->y * quat1->x ) );
tmpW = ( ( ( ( quat0->w * quat1->w ) - ( quat0->x * quat1->x ) ) - ( quat0->y * quat1->y ) ) - ( quat0->z * quat1->z ) );
vmathQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
}
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
{
float tmpX, tmpY, tmpZ, tmpW;
tmpX = ( ( ( quat->w * vec->x ) + ( quat->y * vec->z ) ) - ( quat->z * vec->y ) );
tmpY = ( ( ( quat->w * vec->y ) + ( quat->z * vec->x ) ) - ( quat->x * vec->z ) );
tmpZ = ( ( ( quat->w * vec->z ) + ( quat->x * vec->y ) ) - ( quat->y * vec->x ) );
tmpW = ( ( ( quat->x * vec->x ) + ( quat->y * vec->y ) ) + ( quat->z * vec->z ) );
result->x = ( ( ( ( tmpW * quat->x ) + ( tmpX * quat->w ) ) - ( tmpY * quat->z ) ) + ( tmpZ * quat->y ) );
result->y = ( ( ( ( tmpW * quat->y ) + ( tmpY * quat->w ) ) - ( tmpZ * quat->x ) ) + ( tmpX * quat->z ) );
result->z = ( ( ( ( tmpW * quat->z ) + ( tmpZ * quat->w ) ) - ( tmpX * quat->y ) ) + ( tmpY * quat->x ) );
}
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
{
vmathQMakeFromElems( result, -quat->x, -quat->y, -quat->z, quat->w );
}
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
{
result->x = ( select1 )? quat1->x : quat0->x;
result->y = ( select1 )? quat1->y : quat0->y;
result->z = ( select1 )? quat1->z : quat0->z;
result->w = ( select1 )? quat1->w : quat0->w;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathQPrint( const VmathQuat *quat )
{
printf( "( %f %f %f %f )\n", quat->x, quat->y, quat->z, quat->w );
}
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
{
printf( "%s: ( %f %f %f %f )\n", name, quat->x, quat->y, quat->z, quat->w );
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,300 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_V_C_H
#define _VECTORMATH_QUAT_AOS_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
{
VmathQuat result;
vmathQMakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
{
VmathQuat result;
vmathQMakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
{
VmathQuat result;
vmathQMakeFromV4(&result, &vec);
return result;
}
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
{
VmathQuat result;
vmathQMakeFromScalar(&result, scalar);
return result;
}
static inline VmathQuat vmathQMakeIdentity_V( )
{
VmathQuat result;
vmathQMakeIdentity(&result);
return result;
}
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQLerp(&result, t, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
{
VmathQuat result;
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
return result;
}
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
{
VmathQuat result;
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
return result;
}
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
{
vmathQSetXYZ(result, &vec);
}
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
{
VmathVector3 result;
vmathQGetXYZ(&result, &quat);
return result;
}
static inline void vmathQSetX_V( VmathQuat *result, float _x )
{
vmathQSetX(result, _x);
}
static inline float vmathQGetX_V( VmathQuat quat )
{
return vmathQGetX(&quat);
}
static inline void vmathQSetY_V( VmathQuat *result, float _y )
{
vmathQSetY(result, _y);
}
static inline float vmathQGetY_V( VmathQuat quat )
{
return vmathQGetY(&quat);
}
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
{
vmathQSetZ(result, _z);
}
static inline float vmathQGetZ_V( VmathQuat quat )
{
return vmathQGetZ(&quat);
}
static inline void vmathQSetW_V( VmathQuat *result, float _w )
{
vmathQSetW(result, _w);
}
static inline float vmathQGetW_V( VmathQuat quat )
{
return vmathQGetW(&quat);
}
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
{
vmathQSetElem(result, idx, value);
}
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
{
return vmathQGetElem(&quat, idx);
}
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQAdd(&result, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQSub(&result, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
{
VmathQuat result;
vmathQScalarMul(&result, &quat, scalar);
return result;
}
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
{
VmathQuat result;
vmathQScalarDiv(&result, &quat, scalar);
return result;
}
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
{
VmathQuat result;
vmathQNeg(&result, &quat);
return result;
}
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
{
return vmathQDot(&quat0, &quat1);
}
static inline float vmathQNorm_V( VmathQuat quat )
{
return vmathQNorm(&quat);
}
static inline float vmathQLength_V( VmathQuat quat )
{
return vmathQLength(&quat);
}
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
{
VmathQuat result;
vmathQNormalize(&result, &quat);
return result;
}
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
{
VmathQuat result;
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
return result;
}
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
{
VmathQuat result;
vmathQMakeRotationAxis(&result, radians, &unitVec);
return result;
}
static inline VmathQuat vmathQMakeRotationX_V( float radians )
{
VmathQuat result;
vmathQMakeRotationX(&result, radians);
return result;
}
static inline VmathQuat vmathQMakeRotationY_V( float radians )
{
VmathQuat result;
vmathQMakeRotationY(&result, radians);
return result;
}
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
{
VmathQuat result;
vmathQMakeRotationZ(&result, radians);
return result;
}
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQMul(&result, &quat0, &quat1);
return result;
}
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
{
VmathVector3 result;
vmathQRotate(&result, &quat, &vec);
return result;
}
static inline VmathQuat vmathQConj_V( VmathQuat quat )
{
VmathQuat result;
vmathQConj(&result, &quat);
return result;
}
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
{
VmathQuat result;
vmathQSelect(&result, &quat0, &quat1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathQPrint_V( VmathQuat quat )
{
vmathQPrint(&quat);
}
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
{
vmathQPrints(&quat, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,971 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_VEC_AOS_C_H
#define _VECTORMATH_VEC_AOS_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Constants
*/
#define _VECTORMATH_SLERP_TOL 0.999f
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
}
static inline void vmathV3MakeFromElems( VmathVector3 *result, float _x, float _y, float _z )
{
result->x = _x;
result->y = _y;
result->z = _z;
}
static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt )
{
result->x = pnt->x;
result->y = pnt->y;
result->z = pnt->z;
}
static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar )
{
result->x = scalar;
result->y = scalar;
result->z = scalar;
}
static inline void vmathV3MakeXAxis( VmathVector3 *result )
{
vmathV3MakeFromElems( result, 1.0f, 0.0f, 0.0f );
}
static inline void vmathV3MakeYAxis( VmathVector3 *result )
{
vmathV3MakeFromElems( result, 0.0f, 1.0f, 0.0f );
}
static inline void vmathV3MakeZAxis( VmathVector3 *result )
{
vmathV3MakeFromElems( result, 0.0f, 0.0f, 1.0f );
}
static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
VmathVector3 tmpV3_0, tmpV3_1;
vmathV3Sub( &tmpV3_0, vec1, vec0 );
vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t );
vmathV3Add( result, vec0, &tmpV3_1 );
}
static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
{
VmathVector3 tmpV3_0, tmpV3_1;
float recipSinAngle, scale0, scale1, cosAngle, angle;
cosAngle = vmathV3Dot( unitVec0, unitVec1 );
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
angle = acosf( cosAngle );
recipSinAngle = ( 1.0f / sinf( angle ) );
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
} else {
scale0 = ( 1.0f - t );
scale1 = t;
}
vmathV3ScalarMul( &tmpV3_0, unitVec0, scale0 );
vmathV3ScalarMul( &tmpV3_1, unitVec1, scale1 );
vmathV3Add( result, &tmpV3_0, &tmpV3_1 );
}
static inline void vmathV3SetX( VmathVector3 *result, float _x )
{
result->x = _x;
}
static inline float vmathV3GetX( const VmathVector3 *vec )
{
return vec->x;
}
static inline void vmathV3SetY( VmathVector3 *result, float _y )
{
result->y = _y;
}
static inline float vmathV3GetY( const VmathVector3 *vec )
{
return vec->y;
}
static inline void vmathV3SetZ( VmathVector3 *result, float _z )
{
result->z = _z;
}
static inline float vmathV3GetZ( const VmathVector3 *vec )
{
return vec->z;
}
static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value )
{
*(&result->x + idx) = value;
}
static inline float vmathV3GetElem( const VmathVector3 *vec, int idx )
{
return *(&vec->x + idx);
}
static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
result->x = ( vec0->x + vec1->x );
result->y = ( vec0->y + vec1->y );
result->z = ( vec0->z + vec1->z );
}
static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
result->x = ( vec0->x - vec1->x );
result->y = ( vec0->y - vec1->y );
result->z = ( vec0->z - vec1->z );
}
static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt1 )
{
result->x = ( vec->x + pnt1->x );
result->y = ( vec->y + pnt1->y );
result->z = ( vec->z + pnt1->z );
}
static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar )
{
result->x = ( vec->x * scalar );
result->y = ( vec->y * scalar );
result->z = ( vec->z * scalar );
}
static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar )
{
result->x = ( vec->x / scalar );
result->y = ( vec->y / scalar );
result->z = ( vec->z / scalar );
}
static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec )
{
result->x = -vec->x;
result->y = -vec->y;
result->z = -vec->z;
}
static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
result->x = ( vec0->x * vec1->x );
result->y = ( vec0->y * vec1->y );
result->z = ( vec0->z * vec1->z );
}
static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
result->x = ( vec0->x / vec1->x );
result->y = ( vec0->y / vec1->y );
result->z = ( vec0->z / vec1->z );
}
static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec )
{
result->x = ( 1.0f / vec->x );
result->y = ( 1.0f / vec->y );
result->z = ( 1.0f / vec->z );
}
static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec )
{
result->x = sqrtf( vec->x );
result->y = sqrtf( vec->y );
result->z = sqrtf( vec->z );
}
static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec )
{
result->x = ( 1.0f / sqrtf( vec->x ) );
result->y = ( 1.0f / sqrtf( vec->y ) );
result->z = ( 1.0f / sqrtf( vec->z ) );
}
static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec )
{
result->x = fabsf( vec->x );
result->y = fabsf( vec->y );
result->z = fabsf( vec->z );
}
static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
result->x = ( vec1->x < 0.0f )? -fabsf( vec0->x ) : fabsf( vec0->x );
result->y = ( vec1->y < 0.0f )? -fabsf( vec0->y ) : fabsf( vec0->y );
result->z = ( vec1->z < 0.0f )? -fabsf( vec0->z ) : fabsf( vec0->z );
}
static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
result->x = (vec0->x > vec1->x)? vec0->x : vec1->x;
result->y = (vec0->y > vec1->y)? vec0->y : vec1->y;
result->z = (vec0->z > vec1->z)? vec0->z : vec1->z;
}
static inline float vmathV3MaxElem( const VmathVector3 *vec )
{
float result;
result = (vec->x > vec->y)? vec->x : vec->y;
result = (vec->z > result)? vec->z : result;
return result;
}
static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
result->x = (vec0->x < vec1->x)? vec0->x : vec1->x;
result->y = (vec0->y < vec1->y)? vec0->y : vec1->y;
result->z = (vec0->z < vec1->z)? vec0->z : vec1->z;
}
static inline float vmathV3MinElem( const VmathVector3 *vec )
{
float result;
result = (vec->x < vec->y)? vec->x : vec->y;
result = (vec->z < result)? vec->z : result;
return result;
}
static inline float vmathV3Sum( const VmathVector3 *vec )
{
float result;
result = ( vec->x + vec->y );
result = ( result + vec->z );
return result;
}
static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
float result;
result = ( vec0->x * vec1->x );
result = ( result + ( vec0->y * vec1->y ) );
result = ( result + ( vec0->z * vec1->z ) );
return result;
}
static inline float vmathV3LengthSqr( const VmathVector3 *vec )
{
float result;
result = ( vec->x * vec->x );
result = ( result + ( vec->y * vec->y ) );
result = ( result + ( vec->z * vec->z ) );
return result;
}
static inline float vmathV3Length( const VmathVector3 *vec )
{
return sqrtf( vmathV3LengthSqr( vec ) );
}
static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec )
{
float lenSqr, lenInv;
lenSqr = vmathV3LengthSqr( vec );
lenInv = ( 1.0f / sqrtf( lenSqr ) );
result->x = ( vec->x * lenInv );
result->y = ( vec->y * lenInv );
result->z = ( vec->z * lenInv );
}
static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 )
{
float tmpX, tmpY, tmpZ;
tmpX = ( ( vec0->y * vec1->z ) - ( vec0->z * vec1->y ) );
tmpY = ( ( vec0->z * vec1->x ) - ( vec0->x * vec1->z ) );
tmpZ = ( ( vec0->x * vec1->y ) - ( vec0->y * vec1->x ) );
vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ );
}
static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 )
{
result->x = ( select1 )? vec1->x : vec0->x;
result->y = ( select1 )? vec1->y : vec0->y;
result->z = ( select1 )? vec1->z : vec0->z;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathV3Print( const VmathVector3 *vec )
{
printf( "( %f %f %f )\n", vec->x, vec->y, vec->z );
}
static inline void vmathV3Prints( const VmathVector3 *vec, const char *name )
{
printf( "%s: ( %f %f %f )\n", name, vec->x, vec->y, vec->z );
}
#endif
static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
result->w = vec->w;
}
static inline void vmathV4MakeFromElems( VmathVector4 *result, float _x, float _y, float _z, float _w )
{
result->x = _x;
result->y = _y;
result->z = _z;
result->w = _w;
}
static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float _w )
{
vmathV4SetXYZ( result, xyz );
vmathV4SetW( result, _w );
}
static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
result->w = 0.0f;
}
static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt )
{
result->x = pnt->x;
result->y = pnt->y;
result->z = pnt->z;
result->w = 1.0f;
}
static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat )
{
result->x = quat->x;
result->y = quat->y;
result->z = quat->z;
result->w = quat->w;
}
static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar )
{
result->x = scalar;
result->y = scalar;
result->z = scalar;
result->w = scalar;
}
static inline void vmathV4MakeXAxis( VmathVector4 *result )
{
vmathV4MakeFromElems( result, 1.0f, 0.0f, 0.0f, 0.0f );
}
static inline void vmathV4MakeYAxis( VmathVector4 *result )
{
vmathV4MakeFromElems( result, 0.0f, 1.0f, 0.0f, 0.0f );
}
static inline void vmathV4MakeZAxis( VmathVector4 *result )
{
vmathV4MakeFromElems( result, 0.0f, 0.0f, 1.0f, 0.0f );
}
static inline void vmathV4MakeWAxis( VmathVector4 *result )
{
vmathV4MakeFromElems( result, 0.0f, 0.0f, 0.0f, 1.0f );
}
static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
VmathVector4 tmpV4_0, tmpV4_1;
vmathV4Sub( &tmpV4_0, vec1, vec0 );
vmathV4ScalarMul( &tmpV4_1, &tmpV4_0, t );
vmathV4Add( result, vec0, &tmpV4_1 );
}
static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 )
{
VmathVector4 tmpV4_0, tmpV4_1;
float recipSinAngle, scale0, scale1, cosAngle, angle;
cosAngle = vmathV4Dot( unitVec0, unitVec1 );
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
angle = acosf( cosAngle );
recipSinAngle = ( 1.0f / sinf( angle ) );
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
} else {
scale0 = ( 1.0f - t );
scale1 = t;
}
vmathV4ScalarMul( &tmpV4_0, unitVec0, scale0 );
vmathV4ScalarMul( &tmpV4_1, unitVec1, scale1 );
vmathV4Add( result, &tmpV4_0, &tmpV4_1 );
}
static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
}
static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec )
{
vmathV3MakeFromElems( result, vec->x, vec->y, vec->z );
}
static inline void vmathV4SetX( VmathVector4 *result, float _x )
{
result->x = _x;
}
static inline float vmathV4GetX( const VmathVector4 *vec )
{
return vec->x;
}
static inline void vmathV4SetY( VmathVector4 *result, float _y )
{
result->y = _y;
}
static inline float vmathV4GetY( const VmathVector4 *vec )
{
return vec->y;
}
static inline void vmathV4SetZ( VmathVector4 *result, float _z )
{
result->z = _z;
}
static inline float vmathV4GetZ( const VmathVector4 *vec )
{
return vec->z;
}
static inline void vmathV4SetW( VmathVector4 *result, float _w )
{
result->w = _w;
}
static inline float vmathV4GetW( const VmathVector4 *vec )
{
return vec->w;
}
static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value )
{
*(&result->x + idx) = value;
}
static inline float vmathV4GetElem( const VmathVector4 *vec, int idx )
{
return *(&vec->x + idx);
}
static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
result->x = ( vec0->x + vec1->x );
result->y = ( vec0->y + vec1->y );
result->z = ( vec0->z + vec1->z );
result->w = ( vec0->w + vec1->w );
}
static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
result->x = ( vec0->x - vec1->x );
result->y = ( vec0->y - vec1->y );
result->z = ( vec0->z - vec1->z );
result->w = ( vec0->w - vec1->w );
}
static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar )
{
result->x = ( vec->x * scalar );
result->y = ( vec->y * scalar );
result->z = ( vec->z * scalar );
result->w = ( vec->w * scalar );
}
static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar )
{
result->x = ( vec->x / scalar );
result->y = ( vec->y / scalar );
result->z = ( vec->z / scalar );
result->w = ( vec->w / scalar );
}
static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec )
{
result->x = -vec->x;
result->y = -vec->y;
result->z = -vec->z;
result->w = -vec->w;
}
static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
result->x = ( vec0->x * vec1->x );
result->y = ( vec0->y * vec1->y );
result->z = ( vec0->z * vec1->z );
result->w = ( vec0->w * vec1->w );
}
static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
result->x = ( vec0->x / vec1->x );
result->y = ( vec0->y / vec1->y );
result->z = ( vec0->z / vec1->z );
result->w = ( vec0->w / vec1->w );
}
static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec )
{
result->x = ( 1.0f / vec->x );
result->y = ( 1.0f / vec->y );
result->z = ( 1.0f / vec->z );
result->w = ( 1.0f / vec->w );
}
static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec )
{
result->x = sqrtf( vec->x );
result->y = sqrtf( vec->y );
result->z = sqrtf( vec->z );
result->w = sqrtf( vec->w );
}
static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec )
{
result->x = ( 1.0f / sqrtf( vec->x ) );
result->y = ( 1.0f / sqrtf( vec->y ) );
result->z = ( 1.0f / sqrtf( vec->z ) );
result->w = ( 1.0f / sqrtf( vec->w ) );
}
static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec )
{
result->x = fabsf( vec->x );
result->y = fabsf( vec->y );
result->z = fabsf( vec->z );
result->w = fabsf( vec->w );
}
static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
result->x = ( vec1->x < 0.0f )? -fabsf( vec0->x ) : fabsf( vec0->x );
result->y = ( vec1->y < 0.0f )? -fabsf( vec0->y ) : fabsf( vec0->y );
result->z = ( vec1->z < 0.0f )? -fabsf( vec0->z ) : fabsf( vec0->z );
result->w = ( vec1->w < 0.0f )? -fabsf( vec0->w ) : fabsf( vec0->w );
}
static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
result->x = (vec0->x > vec1->x)? vec0->x : vec1->x;
result->y = (vec0->y > vec1->y)? vec0->y : vec1->y;
result->z = (vec0->z > vec1->z)? vec0->z : vec1->z;
result->w = (vec0->w > vec1->w)? vec0->w : vec1->w;
}
static inline float vmathV4MaxElem( const VmathVector4 *vec )
{
float result;
result = (vec->x > vec->y)? vec->x : vec->y;
result = (vec->z > result)? vec->z : result;
result = (vec->w > result)? vec->w : result;
return result;
}
static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
result->x = (vec0->x < vec1->x)? vec0->x : vec1->x;
result->y = (vec0->y < vec1->y)? vec0->y : vec1->y;
result->z = (vec0->z < vec1->z)? vec0->z : vec1->z;
result->w = (vec0->w < vec1->w)? vec0->w : vec1->w;
}
static inline float vmathV4MinElem( const VmathVector4 *vec )
{
float result;
result = (vec->x < vec->y)? vec->x : vec->y;
result = (vec->z < result)? vec->z : result;
result = (vec->w < result)? vec->w : result;
return result;
}
static inline float vmathV4Sum( const VmathVector4 *vec )
{
float result;
result = ( vec->x + vec->y );
result = ( result + vec->z );
result = ( result + vec->w );
return result;
}
static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 )
{
float result;
result = ( vec0->x * vec1->x );
result = ( result + ( vec0->y * vec1->y ) );
result = ( result + ( vec0->z * vec1->z ) );
result = ( result + ( vec0->w * vec1->w ) );
return result;
}
static inline float vmathV4LengthSqr( const VmathVector4 *vec )
{
float result;
result = ( vec->x * vec->x );
result = ( result + ( vec->y * vec->y ) );
result = ( result + ( vec->z * vec->z ) );
result = ( result + ( vec->w * vec->w ) );
return result;
}
static inline float vmathV4Length( const VmathVector4 *vec )
{
return sqrtf( vmathV4LengthSqr( vec ) );
}
static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec )
{
float lenSqr, lenInv;
lenSqr = vmathV4LengthSqr( vec );
lenInv = ( 1.0f / sqrtf( lenSqr ) );
result->x = ( vec->x * lenInv );
result->y = ( vec->y * lenInv );
result->z = ( vec->z * lenInv );
result->w = ( vec->w * lenInv );
}
static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 )
{
result->x = ( select1 )? vec1->x : vec0->x;
result->y = ( select1 )? vec1->y : vec0->y;
result->z = ( select1 )? vec1->z : vec0->z;
result->w = ( select1 )? vec1->w : vec0->w;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathV4Print( const VmathVector4 *vec )
{
printf( "( %f %f %f %f )\n", vec->x, vec->y, vec->z, vec->w );
}
static inline void vmathV4Prints( const VmathVector4 *vec, const char *name )
{
printf( "%s: ( %f %f %f %f )\n", name, vec->x, vec->y, vec->z, vec->w );
}
#endif
static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt )
{
result->x = pnt->x;
result->y = pnt->y;
result->z = pnt->z;
}
static inline void vmathP3MakeFromElems( VmathPoint3 *result, float _x, float _y, float _z )
{
result->x = _x;
result->y = _y;
result->z = _z;
}
static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
}
static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar )
{
result->x = scalar;
result->y = scalar;
result->z = scalar;
}
static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
VmathVector3 tmpV3_0, tmpV3_1;
vmathP3Sub( &tmpV3_0, pnt1, pnt0 );
vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t );
vmathP3AddV3( result, pnt0, &tmpV3_1 );
}
static inline void vmathP3SetX( VmathPoint3 *result, float _x )
{
result->x = _x;
}
static inline float vmathP3GetX( const VmathPoint3 *pnt )
{
return pnt->x;
}
static inline void vmathP3SetY( VmathPoint3 *result, float _y )
{
result->y = _y;
}
static inline float vmathP3GetY( const VmathPoint3 *pnt )
{
return pnt->y;
}
static inline void vmathP3SetZ( VmathPoint3 *result, float _z )
{
result->z = _z;
}
static inline float vmathP3GetZ( const VmathPoint3 *pnt )
{
return pnt->z;
}
static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value )
{
*(&result->x + idx) = value;
}
static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx )
{
return *(&pnt->x + idx);
}
static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
result->x = ( pnt0->x - pnt1->x );
result->y = ( pnt0->y - pnt1->y );
result->z = ( pnt0->z - pnt1->z );
}
static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 )
{
result->x = ( pnt->x + vec1->x );
result->y = ( pnt->y + vec1->y );
result->z = ( pnt->z + vec1->z );
}
static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 )
{
result->x = ( pnt->x - vec1->x );
result->y = ( pnt->y - vec1->y );
result->z = ( pnt->z - vec1->z );
}
static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
result->x = ( pnt0->x * pnt1->x );
result->y = ( pnt0->y * pnt1->y );
result->z = ( pnt0->z * pnt1->z );
}
static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
result->x = ( pnt0->x / pnt1->x );
result->y = ( pnt0->y / pnt1->y );
result->z = ( pnt0->z / pnt1->z );
}
static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt )
{
result->x = ( 1.0f / pnt->x );
result->y = ( 1.0f / pnt->y );
result->z = ( 1.0f / pnt->z );
}
static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt )
{
result->x = sqrtf( pnt->x );
result->y = sqrtf( pnt->y );
result->z = sqrtf( pnt->z );
}
static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt )
{
result->x = ( 1.0f / sqrtf( pnt->x ) );
result->y = ( 1.0f / sqrtf( pnt->y ) );
result->z = ( 1.0f / sqrtf( pnt->z ) );
}
static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt )
{
result->x = fabsf( pnt->x );
result->y = fabsf( pnt->y );
result->z = fabsf( pnt->z );
}
static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
result->x = ( pnt1->x < 0.0f )? -fabsf( pnt0->x ) : fabsf( pnt0->x );
result->y = ( pnt1->y < 0.0f )? -fabsf( pnt0->y ) : fabsf( pnt0->y );
result->z = ( pnt1->z < 0.0f )? -fabsf( pnt0->z ) : fabsf( pnt0->z );
}
static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
result->x = (pnt0->x > pnt1->x)? pnt0->x : pnt1->x;
result->y = (pnt0->y > pnt1->y)? pnt0->y : pnt1->y;
result->z = (pnt0->z > pnt1->z)? pnt0->z : pnt1->z;
}
static inline float vmathP3MaxElem( const VmathPoint3 *pnt )
{
float result;
result = (pnt->x > pnt->y)? pnt->x : pnt->y;
result = (pnt->z > result)? pnt->z : result;
return result;
}
static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
result->x = (pnt0->x < pnt1->x)? pnt0->x : pnt1->x;
result->y = (pnt0->y < pnt1->y)? pnt0->y : pnt1->y;
result->z = (pnt0->z < pnt1->z)? pnt0->z : pnt1->z;
}
static inline float vmathP3MinElem( const VmathPoint3 *pnt )
{
float result;
result = (pnt->x < pnt->y)? pnt->x : pnt->y;
result = (pnt->z < result)? pnt->z : result;
return result;
}
static inline float vmathP3Sum( const VmathPoint3 *pnt )
{
float result;
result = ( pnt->x + pnt->y );
result = ( result + pnt->z );
return result;
}
static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal )
{
VmathPoint3 tmpP3_0;
vmathP3MakeFromScalar( &tmpP3_0, scaleVal );
vmathP3MulPerElem( result, pnt, &tmpP3_0 );
}
static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec )
{
VmathPoint3 tmpP3_0;
vmathP3MakeFromV3( &tmpP3_0, scaleVec );
vmathP3MulPerElem( result, pnt, &tmpP3_0 );
}
static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec )
{
float result;
result = ( pnt->x * unitVec->x );
result = ( result + ( pnt->y * unitVec->y ) );
result = ( result + ( pnt->z * unitVec->z ) );
return result;
}
static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt )
{
VmathVector3 tmpV3_0;
vmathV3MakeFromP3( &tmpV3_0, pnt );
return vmathV3LengthSqr( &tmpV3_0 );
}
static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt )
{
VmathVector3 tmpV3_0;
vmathV3MakeFromP3( &tmpV3_0, pnt );
return vmathV3Length( &tmpV3_0 );
}
static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
VmathVector3 tmpV3_0;
vmathP3Sub( &tmpV3_0, pnt1, pnt0 );
return vmathV3LengthSqr( &tmpV3_0 );
}
static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 )
{
VmathVector3 tmpV3_0;
vmathP3Sub( &tmpV3_0, pnt1, pnt0 );
return vmathV3Length( &tmpV3_0 );
}
static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 )
{
result->x = ( select1 )? pnt1->x : pnt0->x;
result->y = ( select1 )? pnt1->y : pnt0->y;
result->z = ( select1 )? pnt1->z : pnt0->z;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathP3Print( const VmathPoint3 *pnt )
{
printf( "( %f %f %f )\n", pnt->x, pnt->y, pnt->z );
}
static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name )
{
printf( "%s: ( %f %f %f )\n", name, pnt->x, pnt->y, pnt->z );
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,848 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_VEC_AOS_V_C_H
#define _VECTORMATH_VEC_AOS_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Constants
*/
#define _VECTORMATH_SLERP_TOL 0.999f
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z )
{
VmathVector3 result;
vmathV3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt )
{
VmathVector3 result;
vmathV3MakeFromP3(&result, &pnt);
return result;
}
static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar )
{
VmathVector3 result;
vmathV3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathVector3 vmathV3MakeXAxis_V( )
{
VmathVector3 result;
vmathV3MakeXAxis(&result);
return result;
}
static inline VmathVector3 vmathV3MakeYAxis_V( )
{
VmathVector3 result;
vmathV3MakeYAxis(&result);
return result;
}
static inline VmathVector3 vmathV3MakeZAxis_V( )
{
VmathVector3 result;
vmathV3MakeZAxis(&result);
return result;
}
static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 )
{
VmathVector3 result;
vmathV3Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline void vmathV3SetX_V( VmathVector3 *result, float _x )
{
vmathV3SetX(result, _x);
}
static inline float vmathV3GetX_V( VmathVector3 vec )
{
return vmathV3GetX(&vec);
}
static inline void vmathV3SetY_V( VmathVector3 *result, float _y )
{
vmathV3SetY(result, _y);
}
static inline float vmathV3GetY_V( VmathVector3 vec )
{
return vmathV3GetY(&vec);
}
static inline void vmathV3SetZ_V( VmathVector3 *result, float _z )
{
vmathV3SetZ(result, _z);
}
static inline float vmathV3GetZ_V( VmathVector3 vec )
{
return vmathV3GetZ(&vec);
}
static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value )
{
vmathV3SetElem(result, idx, value);
}
static inline float vmathV3GetElem_V( VmathVector3 vec, int idx )
{
return vmathV3GetElem(&vec, idx);
}
static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Add(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathV3AddP3(&result, &vec, &pnt1);
return result;
}
static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar )
{
VmathVector3 result;
vmathV3ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar )
{
VmathVector3 result;
vmathV3ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3Neg(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3RecipPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3SqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3AbsPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV3MaxElem_V( VmathVector3 vec )
{
return vmathV3MaxElem(&vec);
}
static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV3MinElem_V( VmathVector3 vec )
{
return vmathV3MinElem(&vec);
}
static inline float vmathV3Sum_V( VmathVector3 vec )
{
return vmathV3Sum(&vec);
}
static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 )
{
return vmathV3Dot(&vec0, &vec1);
}
static inline float vmathV3LengthSqr_V( VmathVector3 vec )
{
return vmathV3LengthSqr(&vec);
}
static inline float vmathV3Length_V( VmathVector3 vec )
{
return vmathV3Length(&vec);
}
static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3Normalize(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Cross(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 )
{
VmathVector3 result;
vmathV3Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathV3Print_V( VmathVector3 vec )
{
vmathV3Print(&vec);
}
static inline void vmathV3Prints_V( VmathVector3 vec, const char *name )
{
vmathV3Prints(&vec, name);
}
#endif
static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w )
{
VmathVector4 result;
vmathV4MakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w )
{
VmathVector4 result;
vmathV4MakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec )
{
VmathVector4 result;
vmathV4MakeFromV3(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt )
{
VmathVector4 result;
vmathV4MakeFromP3(&result, &pnt);
return result;
}
static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat )
{
VmathVector4 result;
vmathV4MakeFromQ(&result, &quat);
return result;
}
static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar )
{
VmathVector4 result;
vmathV4MakeFromScalar(&result, scalar);
return result;
}
static inline VmathVector4 vmathV4MakeXAxis_V( )
{
VmathVector4 result;
vmathV4MakeXAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeYAxis_V( )
{
VmathVector4 result;
vmathV4MakeYAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeZAxis_V( )
{
VmathVector4 result;
vmathV4MakeZAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeWAxis_V( )
{
VmathVector4 result;
vmathV4MakeWAxis(&result);
return result;
}
static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 )
{
VmathVector4 result;
vmathV4Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec )
{
vmathV4SetXYZ(result, &vec);
}
static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec )
{
VmathVector3 result;
vmathV4GetXYZ(&result, &vec);
return result;
}
static inline void vmathV4SetX_V( VmathVector4 *result, float _x )
{
vmathV4SetX(result, _x);
}
static inline float vmathV4GetX_V( VmathVector4 vec )
{
return vmathV4GetX(&vec);
}
static inline void vmathV4SetY_V( VmathVector4 *result, float _y )
{
vmathV4SetY(result, _y);
}
static inline float vmathV4GetY_V( VmathVector4 vec )
{
return vmathV4GetY(&vec);
}
static inline void vmathV4SetZ_V( VmathVector4 *result, float _z )
{
vmathV4SetZ(result, _z);
}
static inline float vmathV4GetZ_V( VmathVector4 vec )
{
return vmathV4GetZ(&vec);
}
static inline void vmathV4SetW_V( VmathVector4 *result, float _w )
{
vmathV4SetW(result, _w);
}
static inline float vmathV4GetW_V( VmathVector4 vec )
{
return vmathV4GetW(&vec);
}
static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value )
{
vmathV4SetElem(result, idx, value);
}
static inline float vmathV4GetElem_V( VmathVector4 vec, int idx )
{
return vmathV4GetElem(&vec, idx);
}
static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Add(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar )
{
VmathVector4 result;
vmathV4ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar )
{
VmathVector4 result;
vmathV4ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4Neg(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4RecipPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4SqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4AbsPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV4MaxElem_V( VmathVector4 vec )
{
return vmathV4MaxElem(&vec);
}
static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV4MinElem_V( VmathVector4 vec )
{
return vmathV4MinElem(&vec);
}
static inline float vmathV4Sum_V( VmathVector4 vec )
{
return vmathV4Sum(&vec);
}
static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 )
{
return vmathV4Dot(&vec0, &vec1);
}
static inline float vmathV4LengthSqr_V( VmathVector4 vec )
{
return vmathV4LengthSqr(&vec);
}
static inline float vmathV4Length_V( VmathVector4 vec )
{
return vmathV4Length(&vec);
}
static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4Normalize(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 )
{
VmathVector4 result;
vmathV4Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathV4Print_V( VmathVector4 vec )
{
vmathV4Print(&vec);
}
static inline void vmathV4Prints_V( VmathVector4 vec, const char *name )
{
vmathV4Prints(&vec, name);
}
#endif
static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z )
{
VmathPoint3 result;
vmathP3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec )
{
VmathPoint3 result;
vmathP3MakeFromV3(&result, &vec);
return result;
}
static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar )
{
VmathPoint3 result;
vmathP3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3Lerp(&result, t, &pnt0, &pnt1);
return result;
}
static inline void vmathP3SetX_V( VmathPoint3 *result, float _x )
{
vmathP3SetX(result, _x);
}
static inline float vmathP3GetX_V( VmathPoint3 pnt )
{
return vmathP3GetX(&pnt);
}
static inline void vmathP3SetY_V( VmathPoint3 *result, float _y )
{
vmathP3SetY(result, _y);
}
static inline float vmathP3GetY_V( VmathPoint3 pnt )
{
return vmathP3GetY(&pnt);
}
static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z )
{
vmathP3SetZ(result, _z);
}
static inline float vmathP3GetZ_V( VmathPoint3 pnt )
{
return vmathP3GetZ(&pnt);
}
static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value )
{
vmathP3SetElem(result, idx, value);
}
static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx )
{
return vmathP3GetElem(&pnt, idx);
}
static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathVector3 result;
vmathP3Sub(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 )
{
VmathPoint3 result;
vmathP3AddV3(&result, &pnt, &vec1);
return result;
}
static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 )
{
VmathPoint3 result;
vmathP3SubV3(&result, &pnt, &vec1);
return result;
}
static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MulPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3DivPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3RecipPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3SqrtPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3RsqrtPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3AbsPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3CopySignPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MaxPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline float vmathP3MaxElem_V( VmathPoint3 pnt )
{
return vmathP3MaxElem(&pnt);
}
static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MinPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline float vmathP3MinElem_V( VmathPoint3 pnt )
{
return vmathP3MinElem(&pnt);
}
static inline float vmathP3Sum_V( VmathPoint3 pnt )
{
return vmathP3Sum(&pnt);
}
static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal )
{
VmathPoint3 result;
vmathP3Scale(&result, &pnt, scaleVal);
return result;
}
static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec )
{
VmathPoint3 result;
vmathP3NonUniformScale(&result, &pnt, &scaleVec);
return result;
}
static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec )
{
return vmathP3Projection(&pnt, &unitVec);
}
static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt )
{
return vmathP3DistSqrFromOrigin(&pnt);
}
static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt )
{
return vmathP3DistFromOrigin(&pnt);
}
static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
return vmathP3DistSqr(&pnt0, &pnt1);
}
static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
return vmathP3Dist(&pnt0, &pnt1);
}
static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 )
{
VmathPoint3 result;
vmathP3Select(&result, &pnt0, &pnt1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathP3Print_V( VmathPoint3 pnt )
{
vmathP3Print(&pnt);
}
static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name )
{
vmathP3Prints(&pnt, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,432 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_CPP_H
#define _VECTORMATH_QUAT_AOS_CPP_H
//-----------------------------------------------------------------------------
// Definitions
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
namespace Vectormath {
namespace Aos {
inline Quat::Quat( const Quat & quat )
{
mX = quat.mX;
mY = quat.mY;
mZ = quat.mZ;
mW = quat.mW;
}
inline Quat::Quat( float _x, float _y, float _z, float _w )
{
mX = _x;
mY = _y;
mZ = _z;
mW = _w;
}
inline Quat::Quat( const Vector3 & xyz, float _w )
{
this->setXYZ( xyz );
this->setW( _w );
}
inline Quat::Quat( const Vector4 & vec )
{
mX = vec.getX();
mY = vec.getY();
mZ = vec.getZ();
mW = vec.getW();
}
inline Quat::Quat( float scalar )
{
mX = scalar;
mY = scalar;
mZ = scalar;
mW = scalar;
}
inline const Quat Quat::identity( )
{
return Quat( 0.0f, 0.0f, 0.0f, 1.0f );
}
inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 )
{
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
}
inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 )
{
Quat start;
float recipSinAngle, scale0, scale1, cosAngle, angle;
cosAngle = dot( unitQuat0, unitQuat1 );
if ( cosAngle < 0.0f ) {
cosAngle = -cosAngle;
start = ( -unitQuat0 );
} else {
start = unitQuat0;
}
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
angle = acosf( cosAngle );
recipSinAngle = ( 1.0f / sinf( angle ) );
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
} else {
scale0 = ( 1.0f - t );
scale1 = t;
}
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
}
inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
{
Quat tmp0, tmp1;
tmp0 = slerp( t, unitQuat0, unitQuat3 );
tmp1 = slerp( t, unitQuat1, unitQuat2 );
return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 );
}
inline Quat & Quat::operator =( const Quat & quat )
{
mX = quat.mX;
mY = quat.mY;
mZ = quat.mZ;
mW = quat.mW;
return *this;
}
inline Quat & Quat::setXYZ( const Vector3 & vec )
{
mX = vec.getX();
mY = vec.getY();
mZ = vec.getZ();
return *this;
}
inline const Vector3 Quat::getXYZ( ) const
{
return Vector3( mX, mY, mZ );
}
inline Quat & Quat::setX( float _x )
{
mX = _x;
return *this;
}
inline float Quat::getX( ) const
{
return mX;
}
inline Quat & Quat::setY( float _y )
{
mY = _y;
return *this;
}
inline float Quat::getY( ) const
{
return mY;
}
inline Quat & Quat::setZ( float _z )
{
mZ = _z;
return *this;
}
inline float Quat::getZ( ) const
{
return mZ;
}
inline Quat & Quat::setW( float _w )
{
mW = _w;
return *this;
}
inline float Quat::getW( ) const
{
return mW;
}
inline Quat & Quat::setElem( int idx, float value )
{
*(&mX + idx) = value;
return *this;
}
inline float Quat::getElem( int idx ) const
{
return *(&mX + idx);
}
inline float & Quat::operator []( int idx )
{
return *(&mX + idx);
}
inline float Quat::operator []( int idx ) const
{
return *(&mX + idx);
}
inline const Quat Quat::operator +( const Quat & quat ) const
{
return Quat(
( mX + quat.mX ),
( mY + quat.mY ),
( mZ + quat.mZ ),
( mW + quat.mW )
);
}
inline const Quat Quat::operator -( const Quat & quat ) const
{
return Quat(
( mX - quat.mX ),
( mY - quat.mY ),
( mZ - quat.mZ ),
( mW - quat.mW )
);
}
inline const Quat Quat::operator *( float scalar ) const
{
return Quat(
( mX * scalar ),
( mY * scalar ),
( mZ * scalar ),
( mW * scalar )
);
}
inline Quat & Quat::operator +=( const Quat & quat )
{
*this = *this + quat;
return *this;
}
inline Quat & Quat::operator -=( const Quat & quat )
{
*this = *this - quat;
return *this;
}
inline Quat & Quat::operator *=( float scalar )
{
*this = *this * scalar;
return *this;
}
inline const Quat Quat::operator /( float scalar ) const
{
return Quat(
( mX / scalar ),
( mY / scalar ),
( mZ / scalar ),
( mW / scalar )
);
}
inline Quat & Quat::operator /=( float scalar )
{
*this = *this / scalar;
return *this;
}
inline const Quat Quat::operator -( ) const
{
return Quat(
-mX,
-mY,
-mZ,
-mW
);
}
inline const Quat operator *( float scalar, const Quat & quat )
{
return quat * scalar;
}
inline float dot( const Quat & quat0, const Quat & quat1 )
{
float result;
result = ( quat0.getX() * quat1.getX() );
result = ( result + ( quat0.getY() * quat1.getY() ) );
result = ( result + ( quat0.getZ() * quat1.getZ() ) );
result = ( result + ( quat0.getW() * quat1.getW() ) );
return result;
}
inline float norm( const Quat & quat )
{
float result;
result = ( quat.getX() * quat.getX() );
result = ( result + ( quat.getY() * quat.getY() ) );
result = ( result + ( quat.getZ() * quat.getZ() ) );
result = ( result + ( quat.getW() * quat.getW() ) );
return result;
}
inline float length( const Quat & quat )
{
return sqrtf( norm( quat ) );
}
inline const Quat normalize( const Quat & quat )
{
float lenSqr, lenInv;
lenSqr = norm( quat );
lenInv = ( 1.0f / sqrtf( lenSqr ) );
return Quat(
( quat.getX() * lenInv ),
( quat.getY() * lenInv ),
( quat.getZ() * lenInv ),
( quat.getW() * lenInv )
);
}
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
{
float cosHalfAngleX2, recipCosHalfAngleX2;
cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + dot( unitVec0, unitVec1 ) ) ) );
recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 );
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), ( cosHalfAngleX2 * 0.5f ) );
}
inline const Quat Quat::rotation( float radians, const Vector3 & unitVec )
{
float s, c, angle;
angle = ( radians * 0.5f );
s = sinf( angle );
c = cosf( angle );
return Quat( ( unitVec * s ), c );
}
inline const Quat Quat::rotationX( float radians )
{
float s, c, angle;
angle = ( radians * 0.5f );
s = sinf( angle );
c = cosf( angle );
return Quat( s, 0.0f, 0.0f, c );
}
inline const Quat Quat::rotationY( float radians )
{
float s, c, angle;
angle = ( radians * 0.5f );
s = sinf( angle );
c = cosf( angle );
return Quat( 0.0f, s, 0.0f, c );
}
inline const Quat Quat::rotationZ( float radians )
{
float s, c, angle;
angle = ( radians * 0.5f );
s = sinf( angle );
c = cosf( angle );
return Quat( 0.0f, 0.0f, s, c );
}
inline const Quat Quat::operator *( const Quat & quat ) const
{
return Quat(
( ( ( ( mW * quat.mX ) + ( mX * quat.mW ) ) + ( mY * quat.mZ ) ) - ( mZ * quat.mY ) ),
( ( ( ( mW * quat.mY ) + ( mY * quat.mW ) ) + ( mZ * quat.mX ) ) - ( mX * quat.mZ ) ),
( ( ( ( mW * quat.mZ ) + ( mZ * quat.mW ) ) + ( mX * quat.mY ) ) - ( mY * quat.mX ) ),
( ( ( ( mW * quat.mW ) - ( mX * quat.mX ) ) - ( mY * quat.mY ) ) - ( mZ * quat.mZ ) )
);
}
inline Quat & Quat::operator *=( const Quat & quat )
{
*this = *this * quat;
return *this;
}
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
{
float tmpX, tmpY, tmpZ, tmpW;
tmpX = ( ( ( quat.getW() * vec.getX() ) + ( quat.getY() * vec.getZ() ) ) - ( quat.getZ() * vec.getY() ) );
tmpY = ( ( ( quat.getW() * vec.getY() ) + ( quat.getZ() * vec.getX() ) ) - ( quat.getX() * vec.getZ() ) );
tmpZ = ( ( ( quat.getW() * vec.getZ() ) + ( quat.getX() * vec.getY() ) ) - ( quat.getY() * vec.getX() ) );
tmpW = ( ( ( quat.getX() * vec.getX() ) + ( quat.getY() * vec.getY() ) ) + ( quat.getZ() * vec.getZ() ) );
return Vector3(
( ( ( ( tmpW * quat.getX() ) + ( tmpX * quat.getW() ) ) - ( tmpY * quat.getZ() ) ) + ( tmpZ * quat.getY() ) ),
( ( ( ( tmpW * quat.getY() ) + ( tmpY * quat.getW() ) ) - ( tmpZ * quat.getX() ) ) + ( tmpX * quat.getZ() ) ),
( ( ( ( tmpW * quat.getZ() ) + ( tmpZ * quat.getW() ) ) - ( tmpX * quat.getY() ) ) + ( tmpY * quat.getX() ) )
);
}
inline const Quat conj( const Quat & quat )
{
return Quat( -quat.getX(), -quat.getY(), -quat.getZ(), quat.getW() );
}
inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 )
{
return Quat(
( select1 )? quat1.getX() : quat0.getX(),
( select1 )? quat1.getY() : quat0.getY(),
( select1 )? quat1.getZ() : quat0.getZ(),
( select1 )? quat1.getW() : quat0.getW()
);
}
#ifdef _VECTORMATH_DEBUG
inline void print( const Quat & quat )
{
printf( "( %f %f %f %f )\n", quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
}
inline void print( const Quat & quat, const char * name )
{
printf( "%s: ( %f %f %f %f )\n", name, quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
}
#endif
} // namespace Aos
} // namespace Vectormath
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,371 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_C_H
#define _VECTORMATH_QUAT_AOS_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat )
{
result->vec128 = quat->vec128;
}
static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w )
{
result->vec128 = (vec_float4){ _x, _y, _z, _w };
}
static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w )
{
result->vec128 = spu_shuffle( xyz->vec128, spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA );
}
static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec )
{
result->vec128 = vec->vec128;
}
static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar )
{
result->vec128 = spu_splats( scalar );
}
static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 )
{
result->vec128 = vf4;
}
static inline void vmathQMakeIdentity( VmathQuat *result )
{
result->vec128 = _VECTORMATH_UNIT_0001;
}
static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 )
{
VmathQuat tmpQ_0, tmpQ_1;
vmathQSub( &tmpQ_0, quat1, quat0 );
vmathQScalarMul( &tmpQ_1, &tmpQ_0, t );
vmathQAdd( result, quat0, &tmpQ_1 );
}
static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 )
{
VmathQuat start;
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
vec_uint4 selectMask;
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 );
cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx );
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
start.vec128 = spu_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask );
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
angle = acosf4( cosAngle );
tttt = spu_splats(t);
oneMinusT = spu_sub( spu_splats(1.0f), tttt );
angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) );
angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) );
angles = spu_mul( angles, angle );
sines = sinf4( angles );
scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) );
scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask );
scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask );
result->vec128 = spu_madd( start.vec128, scale0, spu_mul( unitQuat1->vec128, scale1 ) );
}
static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 )
{
VmathQuat tmp0, tmp1;
vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 );
}
static inline vec_float4 vmathQGet128( const VmathQuat *quat )
{
return quat->vec128;
}
static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec )
{
result->vec128 = spu_sel( vec->vec128, result->vec128, (vec_uint4)spu_maskb(0x000f) );
}
static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat )
{
result->vec128 = quat->vec128;
}
static inline void vmathQSetX( VmathQuat *result, float _x )
{
result->vec128 = spu_insert( _x, result->vec128, 0 );
}
static inline float vmathQGetX( const VmathQuat *quat )
{
return spu_extract( quat->vec128, 0 );
}
static inline void vmathQSetY( VmathQuat *result, float _y )
{
result->vec128 = spu_insert( _y, result->vec128, 1 );
}
static inline float vmathQGetY( const VmathQuat *quat )
{
return spu_extract( quat->vec128, 1 );
}
static inline void vmathQSetZ( VmathQuat *result, float _z )
{
result->vec128 = spu_insert( _z, result->vec128, 2 );
}
static inline float vmathQGetZ( const VmathQuat *quat )
{
return spu_extract( quat->vec128, 2 );
}
static inline void vmathQSetW( VmathQuat *result, float _w )
{
result->vec128 = spu_insert( _w, result->vec128, 3 );
}
static inline float vmathQGetW( const VmathQuat *quat )
{
return spu_extract( quat->vec128, 3 );
}
static inline void vmathQSetElem( VmathQuat *result, int idx, float value )
{
result->vec128 = spu_insert( value, result->vec128, idx );
}
static inline float vmathQGetElem( const VmathQuat *quat, int idx )
{
return spu_extract( quat->vec128, idx );
}
static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
result->vec128 = spu_add( quat0->vec128, quat1->vec128 );
}
static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
result->vec128 = spu_sub( quat0->vec128, quat1->vec128 );
}
static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar )
{
result->vec128 = spu_mul( quat->vec128, spu_splats(scalar) );
}
static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar )
{
result->vec128 = divf4( quat->vec128, spu_splats(scalar) );
}
static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat )
{
result->vec128 = negatef4( quat->vec128 );
}
static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 )
{
return spu_extract( _vmathVfDot4( quat0->vec128, quat1->vec128 ), 0 );
}
static inline float vmathQNorm( const VmathQuat *quat )
{
return spu_extract( _vmathVfDot4( quat->vec128, quat->vec128 ), 0 );
}
static inline float vmathQLength( const VmathQuat *quat )
{
return sqrtf( vmathQNorm( quat ) );
}
static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat )
{
vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 );
result->vec128 = spu_mul( quat->vec128, rsqrtf4( dot ) );
}
static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 )
{
VmathVector3 crossVec, tmpV3_0;
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 );
cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) );
cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) );
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 );
vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 );
crossVec = tmpV3_0;
res = spu_mul( crossVec.vec128, recipCosHalfAngleX2 );
res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) );
result->vec128 = res;
}
static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec )
{
vec_float4 s, c, angle, res;
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
sincosf4( angle, &s, &c );
res = spu_sel( spu_mul( unitVec->vec128, s ), c, (vec_uint4)spu_maskb(0x000f) );
result->vec128 = res;
}
static inline void vmathQMakeRotationX( VmathQuat *result, float radians )
{
vec_float4 s, c, angle, res;
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
sincosf4( angle, &s, &c );
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) );
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
result->vec128 = res;
}
static inline void vmathQMakeRotationY( VmathQuat *result, float radians )
{
vec_float4 s, c, angle, res;
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
sincosf4( angle, &s, &c );
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) );
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
result->vec128 = res;
}
static inline void vmathQMakeRotationZ( VmathQuat *result, float radians )
{
vec_float4 s, c, angle, res;
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
sincosf4( angle, &s, &c );
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) );
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
result->vec128 = res;
}
static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 )
{
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
ldata = quat0->vec128;
rdata = quat1->vec128;
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW );
tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW );
tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW );
tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW );
qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata );
qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv );
qv = spu_madd( tmp0, tmp1, qv );
qv = spu_nmsub( tmp2, tmp3, qv );
product = spu_mul( ldata, rdata );
l_wxyz = spu_rlqwbyte( ldata, 12 );
r_wxyz = spu_rlqwbyte( rdata, 12 );
qw = spu_nmsub( l_wxyz, r_wxyz, product );
xy = spu_madd( l_wxyz, r_wxyz, product );
qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) );
result->vec128 = spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) );
}
static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec )
{
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
qdata = quat->vec128;
vdata = vec->vec128;
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW );
tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW );
tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW );
tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW );
wwww = spu_shuffle( qdata, qdata, shuffle_wwww );
qv = spu_mul( wwww, vdata );
qv = spu_madd( tmp0, tmp1, qv );
qv = spu_nmsub( tmp2, tmp3, qv );
product = spu_mul( qdata, vdata );
qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product );
qw = spu_add( spu_rlqwbyte( product, 8 ), qw );
tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW );
tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW );
res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata );
res = spu_madd( wwww, qv, res );
res = spu_madd( tmp0, tmp1, res );
res = spu_nmsub( tmp2, tmp3, res );
result->vec128 = res;
}
static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat )
{
result->vec128 = spu_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) );
}
static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 )
{
result->vec128 = spu_sel( quat0->vec128, quat1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) );
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathQPrint( const VmathQuat *quat )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = quat->vec128;
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
}
static inline void vmathQPrints( const VmathQuat *quat, const char *name )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = quat->vec128;
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,312 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_V_C_H
#define _VECTORMATH_QUAT_AOS_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w )
{
VmathQuat result;
vmathQMakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w )
{
VmathQuat result;
vmathQMakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec )
{
VmathQuat result;
vmathQMakeFromV4(&result, &vec);
return result;
}
static inline VmathQuat vmathQMakeFromScalar_V( float scalar )
{
VmathQuat result;
vmathQMakeFromScalar(&result, scalar);
return result;
}
static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 )
{
VmathQuat result;
vmathQMakeFrom128(&result, vf4);
return result;
}
static inline VmathQuat vmathQMakeIdentity_V( )
{
VmathQuat result;
vmathQMakeIdentity(&result);
return result;
}
static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQLerp(&result, t, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 )
{
VmathQuat result;
vmathQSlerp(&result, t, &unitQuat0, &unitQuat1);
return result;
}
static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 )
{
VmathQuat result;
vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
return result;
}
static inline vec_float4 vmathQGet128_V( VmathQuat quat )
{
return vmathQGet128(&quat);
}
static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec )
{
vmathQSetXYZ(result, &vec);
}
static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat )
{
VmathVector3 result;
vmathQGetXYZ(&result, &quat);
return result;
}
static inline void vmathQSetX_V( VmathQuat *result, float _x )
{
vmathQSetX(result, _x);
}
static inline float vmathQGetX_V( VmathQuat quat )
{
return vmathQGetX(&quat);
}
static inline void vmathQSetY_V( VmathQuat *result, float _y )
{
vmathQSetY(result, _y);
}
static inline float vmathQGetY_V( VmathQuat quat )
{
return vmathQGetY(&quat);
}
static inline void vmathQSetZ_V( VmathQuat *result, float _z )
{
vmathQSetZ(result, _z);
}
static inline float vmathQGetZ_V( VmathQuat quat )
{
return vmathQGetZ(&quat);
}
static inline void vmathQSetW_V( VmathQuat *result, float _w )
{
vmathQSetW(result, _w);
}
static inline float vmathQGetW_V( VmathQuat quat )
{
return vmathQGetW(&quat);
}
static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value )
{
vmathQSetElem(result, idx, value);
}
static inline float vmathQGetElem_V( VmathQuat quat, int idx )
{
return vmathQGetElem(&quat, idx);
}
static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQAdd(&result, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQSub(&result, &quat0, &quat1);
return result;
}
static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar )
{
VmathQuat result;
vmathQScalarMul(&result, &quat, scalar);
return result;
}
static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar )
{
VmathQuat result;
vmathQScalarDiv(&result, &quat, scalar);
return result;
}
static inline VmathQuat vmathQNeg_V( VmathQuat quat )
{
VmathQuat result;
vmathQNeg(&result, &quat);
return result;
}
static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 )
{
return vmathQDot(&quat0, &quat1);
}
static inline float vmathQNorm_V( VmathQuat quat )
{
return vmathQNorm(&quat);
}
static inline float vmathQLength_V( VmathQuat quat )
{
return vmathQLength(&quat);
}
static inline VmathQuat vmathQNormalize_V( VmathQuat quat )
{
VmathQuat result;
vmathQNormalize(&result, &quat);
return result;
}
static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 )
{
VmathQuat result;
vmathQMakeRotationArc(&result, &unitVec0, &unitVec1);
return result;
}
static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec )
{
VmathQuat result;
vmathQMakeRotationAxis(&result, radians, &unitVec);
return result;
}
static inline VmathQuat vmathQMakeRotationX_V( float radians )
{
VmathQuat result;
vmathQMakeRotationX(&result, radians);
return result;
}
static inline VmathQuat vmathQMakeRotationY_V( float radians )
{
VmathQuat result;
vmathQMakeRotationY(&result, radians);
return result;
}
static inline VmathQuat vmathQMakeRotationZ_V( float radians )
{
VmathQuat result;
vmathQMakeRotationZ(&result, radians);
return result;
}
static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 )
{
VmathQuat result;
vmathQMul(&result, &quat0, &quat1);
return result;
}
static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec )
{
VmathVector3 result;
vmathQRotate(&result, &quat, &vec);
return result;
}
static inline VmathQuat vmathQConj_V( VmathQuat quat )
{
VmathQuat result;
vmathQConj(&result, &quat);
return result;
}
static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 )
{
VmathQuat result;
vmathQSelect(&result, &quat0, &quat1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathQPrint_V( VmathQuat quat )
{
vmathQPrint(&quat);
}
static inline void vmathQPrints_V( VmathQuat quat, const char *name )
{
vmathQPrints(&quat, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,419 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_SOA_C_H
#define _VECTORMATH_QUAT_SOA_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat )
{
result->x = quat->x;
result->y = quat->y;
result->z = quat->z;
result->w = quat->w;
}
static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
{
result->x = _x;
result->y = _y;
result->z = _z;
result->w = _w;
}
static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w )
{
vmathSoaQSetXYZ( result, xyz );
vmathSoaQSetW( result, _w );
}
static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
result->w = vec->w;
}
static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar )
{
result->x = scalar;
result->y = scalar;
result->z = scalar;
result->w = scalar;
}
static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat )
{
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
vec_float4 vec128 = quat->vec128;
result->x = spu_shuffle( vec128, vec128, shuffle_xxxx );
result->y = spu_shuffle( vec128, vec128, shuffle_yyyy );
result->z = spu_shuffle( vec128, vec128, shuffle_zzzz );
result->w = spu_shuffle( vec128, vec128, shuffle_wwww );
}
static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 )
{
vec_float4 tmp0, tmp1, tmp2, tmp3;
tmp0 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_XAYB );
tmp1 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_XAYB );
tmp2 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_ZCWD );
tmp3 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_ZCWD );
result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB );
result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD );
result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB );
result->w = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD );
}
static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result )
{
vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) );
}
static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
VmathSoaQuat tmpQ_0, tmpQ_1;
vmathSoaQSub( &tmpQ_0, quat1, quat0 );
vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t );
vmathSoaQAdd( result, quat0, &tmpQ_1 );
}
static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 )
{
VmathSoaQuat start, tmpQ_0, tmpQ_1;
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
vec_uint4 selectMask;
cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 );
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
vmathSoaQSetX( &start, spu_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) );
vmathSoaQSetY( &start, spu_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) );
vmathSoaQSetZ( &start, spu_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) );
vmathSoaQSetW( &start, spu_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) );
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
angle = acosf4( cosAngle );
recipSinAngle = recipf4( sinf4( angle ) );
scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask );
scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask );
vmathSoaQScalarMul( &tmpQ_0, &start, scale0 );
vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 );
vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 );
}
static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 )
{
VmathSoaQuat tmp0, tmp1;
vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 );
vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 );
vmathSoaQSlerp( result, spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), &tmp0, &tmp1 );
}
static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
{
vec_float4 tmp0, tmp1, tmp2, tmp3;
tmp0 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_XAYB );
tmp1 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_XAYB );
tmp2 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_ZCWD );
tmp3 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_ZCWD );
vmathQMakeFrom128( result0, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) );
vmathQMakeFrom128( result1, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) );
vmathQMakeFrom128( result2, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) );
vmathQMakeFrom128( result3, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) );
}
static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec )
{
result->x = vec->x;
result->y = vec->y;
result->z = vec->z;
}
static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat )
{
vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z );
}
static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x )
{
result->x = _x;
}
static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat )
{
return quat->x;
}
static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y )
{
result->y = _y;
}
static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat )
{
return quat->y;
}
static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z )
{
result->z = _z;
}
static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat )
{
return quat->z;
}
static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w )
{
result->w = _w;
}
static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat )
{
return quat->w;
}
static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value )
{
*(&result->x + idx) = value;
}
static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx )
{
return *(&quat->x + idx);
}
static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
result->x = spu_add( quat0->x, quat1->x );
result->y = spu_add( quat0->y, quat1->y );
result->z = spu_add( quat0->z, quat1->z );
result->w = spu_add( quat0->w, quat1->w );
}
static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
result->x = spu_sub( quat0->x, quat1->x );
result->y = spu_sub( quat0->y, quat1->y );
result->z = spu_sub( quat0->z, quat1->z );
result->w = spu_sub( quat0->w, quat1->w );
}
static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
{
result->x = spu_mul( quat->x, scalar );
result->y = spu_mul( quat->y, scalar );
result->z = spu_mul( quat->z, scalar );
result->w = spu_mul( quat->w, scalar );
}
static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar )
{
result->x = divf4( quat->x, scalar );
result->y = divf4( quat->y, scalar );
result->z = divf4( quat->z, scalar );
result->w = divf4( quat->w, scalar );
}
static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat )
{
result->x = negatef4( quat->x );
result->y = negatef4( quat->y );
result->z = negatef4( quat->z );
result->w = negatef4( quat->w );
}
static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
vec_float4 result;
result = spu_mul( quat0->x, quat1->x );
result = spu_add( result, spu_mul( quat0->y, quat1->y ) );
result = spu_add( result, spu_mul( quat0->z, quat1->z ) );
result = spu_add( result, spu_mul( quat0->w, quat1->w ) );
return result;
}
static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat )
{
vec_float4 result;
result = spu_mul( quat->x, quat->x );
result = spu_add( result, spu_mul( quat->y, quat->y ) );
result = spu_add( result, spu_mul( quat->z, quat->z ) );
result = spu_add( result, spu_mul( quat->w, quat->w ) );
return result;
}
static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat )
{
return sqrtf4( vmathSoaQNorm( quat ) );
}
static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat )
{
vec_float4 lenSqr, lenInv;
lenSqr = vmathSoaQNorm( quat );
lenInv = rsqrtf4( lenSqr );
result->x = spu_mul( quat->x, lenInv );
result->y = spu_mul( quat->y, lenInv );
result->z = spu_mul( quat->z, lenInv );
result->w = spu_mul( quat->w, lenInv );
}
static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 )
{
VmathSoaVector3 tmpV3_0, tmpV3_1;
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), vmathSoaV3Dot( unitVec0, unitVec1 ) ) ) );
recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 );
vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 );
vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 );
vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) );
}
static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec )
{
VmathSoaVector3 tmpV3_0;
vec_float4 s, c, angle;
angle = spu_mul( radians, spu_splats(0.5f) );
sincosf4( angle, &s, &c );
vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s );
vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c );
}
static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians )
{
vec_float4 s, c, angle;
angle = spu_mul( radians, spu_splats(0.5f) );
sincosf4( angle, &s, &c );
vmathSoaQMakeFromElems( result, s, spu_splats(0.0f), spu_splats(0.0f), c );
}
static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians )
{
vec_float4 s, c, angle;
angle = spu_mul( radians, spu_splats(0.5f) );
sincosf4( angle, &s, &c );
vmathSoaQMakeFromElems( result, spu_splats(0.0f), s, spu_splats(0.0f), c );
}
static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians )
{
vec_float4 s, c, angle;
angle = spu_mul( radians, spu_splats(0.5f) );
sincosf4( angle, &s, &c );
vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), s, c );
}
static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 )
{
vec_float4 tmpX, tmpY, tmpZ, tmpW;
tmpX = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->x ), spu_mul( quat0->x, quat1->w ) ), spu_mul( quat0->y, quat1->z ) ), spu_mul( quat0->z, quat1->y ) );
tmpY = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->y ), spu_mul( quat0->y, quat1->w ) ), spu_mul( quat0->z, quat1->x ) ), spu_mul( quat0->x, quat1->z ) );
tmpZ = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->z ), spu_mul( quat0->z, quat1->w ) ), spu_mul( quat0->x, quat1->y ) ), spu_mul( quat0->y, quat1->x ) );
tmpW = spu_sub( spu_sub( spu_sub( spu_mul( quat0->w, quat1->w ), spu_mul( quat0->x, quat1->x ) ), spu_mul( quat0->y, quat1->y ) ), spu_mul( quat0->z, quat1->z ) );
vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW );
}
static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec )
{
vec_float4 tmpX, tmpY, tmpZ, tmpW;
tmpX = spu_sub( spu_add( spu_mul( quat->w, vec->x ), spu_mul( quat->y, vec->z ) ), spu_mul( quat->z, vec->y ) );
tmpY = spu_sub( spu_add( spu_mul( quat->w, vec->y ), spu_mul( quat->z, vec->x ) ), spu_mul( quat->x, vec->z ) );
tmpZ = spu_sub( spu_add( spu_mul( quat->w, vec->z ), spu_mul( quat->x, vec->y ) ), spu_mul( quat->y, vec->x ) );
tmpW = spu_add( spu_add( spu_mul( quat->x, vec->x ), spu_mul( quat->y, vec->y ) ), spu_mul( quat->z, vec->z ) );
result->x = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->x ), spu_mul( tmpX, quat->w ) ), spu_mul( tmpY, quat->z ) ), spu_mul( tmpZ, quat->y ) );
result->y = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->y ), spu_mul( tmpY, quat->w ) ), spu_mul( tmpZ, quat->x ) ), spu_mul( tmpX, quat->z ) );
result->z = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->z ), spu_mul( tmpZ, quat->w ) ), spu_mul( tmpX, quat->y ) ), spu_mul( tmpY, quat->x ) );
}
static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat )
{
vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w );
}
static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 )
{
result->x = spu_sel( quat0->x, quat1->x, select1 );
result->y = spu_sel( quat0->y, quat1->y, select1 );
result->z = spu_sel( quat0->z, quat1->z, select1 );
result->w = spu_sel( quat0->w, quat1->w, select1 );
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaQPrint( const VmathSoaQuat *quat )
{
VmathQuat vec0, vec1, vec2, vec3;
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
printf("slot 0:\n");
vmathQPrint( &vec0 );
printf("slot 1:\n");
vmathQPrint( &vec1 );
printf("slot 2:\n");
vmathQPrint( &vec2 );
printf("slot 3:\n");
vmathQPrint( &vec3 );
}
static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name )
{
VmathQuat vec0, vec1, vec2, vec3;
printf( "%s:\n", name );
vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 );
printf("slot 0:\n");
vmathQPrint( &vec0 );
printf("slot 1:\n");
vmathQPrint( &vec1 );
printf("slot 2:\n");
vmathQPrint( &vec2 );
printf("slot 3:\n");
vmathQPrint( &vec3 );
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,319 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_SOA_V_C_H
#define _VECTORMATH_QUAT_SOA_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
{
VmathSoaQuat result;
vmathSoaQMakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w )
{
VmathSoaQuat result;
vmathSoaQMakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec )
{
VmathSoaQuat result;
vmathSoaQMakeFromV4(&result, &vec);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar )
{
VmathSoaQuat result;
vmathSoaQMakeFromScalar(&result, scalar);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat )
{
VmathSoaQuat result;
vmathSoaQMakeFromAos(&result, &quat);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 )
{
VmathSoaQuat result;
vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeIdentity_V( )
{
VmathSoaQuat result;
vmathSoaQMakeIdentity(&result);
return result;
}
static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
VmathSoaQuat result;
vmathSoaQLerp(&result, t, &quat0, &quat1);
return result;
}
static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 )
{
VmathSoaQuat result;
vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1);
return result;
}
static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 )
{
VmathSoaQuat result;
vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3);
return result;
}
static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 )
{
vmathSoaQGet4Aos(&quat, result0, result1, result2, result3);
}
static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec )
{
vmathSoaQSetXYZ(result, &vec);
}
static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat )
{
VmathSoaVector3 result;
vmathSoaQGetXYZ(&result, &quat);
return result;
}
static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x )
{
vmathSoaQSetX(result, _x);
}
static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat )
{
return vmathSoaQGetX(&quat);
}
static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y )
{
vmathSoaQSetY(result, _y);
}
static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat )
{
return vmathSoaQGetY(&quat);
}
static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z )
{
vmathSoaQSetZ(result, _z);
}
static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat )
{
return vmathSoaQGetZ(&quat);
}
static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w )
{
vmathSoaQSetW(result, _w);
}
static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat )
{
return vmathSoaQGetW(&quat);
}
static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value )
{
vmathSoaQSetElem(result, idx, value);
}
static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx )
{
return vmathSoaQGetElem(&quat, idx);
}
static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
VmathSoaQuat result;
vmathSoaQAdd(&result, &quat0, &quat1);
return result;
}
static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
VmathSoaQuat result;
vmathSoaQSub(&result, &quat0, &quat1);
return result;
}
static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar )
{
VmathSoaQuat result;
vmathSoaQScalarMul(&result, &quat, scalar);
return result;
}
static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar )
{
VmathSoaQuat result;
vmathSoaQScalarDiv(&result, &quat, scalar);
return result;
}
static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat )
{
VmathSoaQuat result;
vmathSoaQNeg(&result, &quat);
return result;
}
static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
return vmathSoaQDot(&quat0, &quat1);
}
static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat )
{
return vmathSoaQNorm(&quat);
}
static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat )
{
return vmathSoaQLength(&quat);
}
static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat )
{
VmathSoaQuat result;
vmathSoaQNormalize(&result, &quat);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 )
{
VmathSoaQuat result;
vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec )
{
VmathSoaQuat result;
vmathSoaQMakeRotationAxis(&result, radians, &unitVec);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians )
{
VmathSoaQuat result;
vmathSoaQMakeRotationX(&result, radians);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians )
{
VmathSoaQuat result;
vmathSoaQMakeRotationY(&result, radians);
return result;
}
static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians )
{
VmathSoaQuat result;
vmathSoaQMakeRotationZ(&result, radians);
return result;
}
static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 )
{
VmathSoaQuat result;
vmathSoaQMul(&result, &quat0, &quat1);
return result;
}
static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaQRotate(&result, &quat, &vec);
return result;
}
static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat )
{
VmathSoaQuat result;
vmathSoaQConj(&result, &quat);
return result;
}
static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 )
{
VmathSoaQuat result;
vmathSoaQSelect(&result, &quat0, &quat1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaQPrint_V( VmathSoaQuat quat )
{
vmathSoaQPrint(&quat);
}
static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name )
{
vmathSoaQPrints(&quat, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,951 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_VEC_AOS_V_C_H
#define _VECTORMATH_VEC_AOS_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Constants
* for shuffles, words are labeled [x,y,z,w] [a,b,c,d]
*/
#define _VECTORMATH_SHUF_X 0x00010203
#define _VECTORMATH_SHUF_Y 0x04050607
#define _VECTORMATH_SHUF_Z 0x08090a0b
#define _VECTORMATH_SHUF_W 0x0c0d0e0f
#define _VECTORMATH_SHUF_A 0x10111213
#define _VECTORMATH_SHUF_B 0x14151617
#define _VECTORMATH_SHUF_C 0x18191a1b
#define _VECTORMATH_SHUF_D 0x1c1d1e1f
#define _VECTORMATH_SHUF_0 0x80808080
#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A }
#define _VECTORMATH_SHUF_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_W }
#define _VECTORMATH_SHUF_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W }
#define _VECTORMATH_SHUF_WABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C }
#define _VECTORMATH_SHUF_ZWAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B }
#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A }
#define _VECTORMATH_SHUF_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B }
#define _VECTORMATH_SHUF_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C }
#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f }
#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f }
#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f }
#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f }
#define _VECTORMATH_SLERP_TOL 0.999f
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z )
{
VmathVector3 result;
vmathV3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt )
{
VmathVector3 result;
vmathV3MakeFromP3(&result, &pnt);
return result;
}
static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar )
{
VmathVector3 result;
vmathV3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 )
{
VmathVector3 result;
vmathV3MakeFrom128(&result, vf4);
return result;
}
static inline VmathVector3 vmathV3MakeXAxis_V( )
{
VmathVector3 result;
vmathV3MakeXAxis(&result);
return result;
}
static inline VmathVector3 vmathV3MakeYAxis_V( )
{
VmathVector3 result;
vmathV3MakeYAxis(&result);
return result;
}
static inline VmathVector3 vmathV3MakeZAxis_V( )
{
VmathVector3 result;
vmathV3MakeZAxis(&result);
return result;
}
static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 )
{
VmathVector3 result;
vmathV3Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline vec_float4 vmathV3Get128_V( VmathVector3 vec )
{
return vmathV3Get128(&vec);
}
static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad )
{
vmathV3StoreXYZ(&vec, quad);
}
static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads )
{
vmathV3LoadXYZArray(vec0, vec1, vec2, vec3, threeQuads);
}
static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads )
{
vmathV3StoreXYZArray(&vec0, &vec1, &vec2, &vec3, threeQuads);
}
static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads )
{
vmathV3StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, &vec4, &vec5, &vec6, &vec7, threeQuads);
}
static inline void vmathV3SetX_V( VmathVector3 *result, float _x )
{
vmathV3SetX(result, _x);
}
static inline float vmathV3GetX_V( VmathVector3 vec )
{
return vmathV3GetX(&vec);
}
static inline void vmathV3SetY_V( VmathVector3 *result, float _y )
{
vmathV3SetY(result, _y);
}
static inline float vmathV3GetY_V( VmathVector3 vec )
{
return vmathV3GetY(&vec);
}
static inline void vmathV3SetZ_V( VmathVector3 *result, float _z )
{
vmathV3SetZ(result, _z);
}
static inline float vmathV3GetZ_V( VmathVector3 vec )
{
return vmathV3GetZ(&vec);
}
static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value )
{
vmathV3SetElem(result, idx, value);
}
static inline float vmathV3GetElem_V( VmathVector3 vec, int idx )
{
return vmathV3GetElem(&vec, idx);
}
static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Add(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathV3AddP3(&result, &vec, &pnt1);
return result;
}
static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar )
{
VmathVector3 result;
vmathV3ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar )
{
VmathVector3 result;
vmathV3ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3Neg(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3RecipPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3SqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3AbsPerElem(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV3MaxElem_V( VmathVector3 vec )
{
return vmathV3MaxElem(&vec);
}
static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV3MinElem_V( VmathVector3 vec )
{
return vmathV3MinElem(&vec);
}
static inline float vmathV3Sum_V( VmathVector3 vec )
{
return vmathV3Sum(&vec);
}
static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 )
{
return vmathV3Dot(&vec0, &vec1);
}
static inline float vmathV3LengthSqr_V( VmathVector3 vec )
{
return vmathV3LengthSqr(&vec);
}
static inline float vmathV3Length_V( VmathVector3 vec )
{
return vmathV3Length(&vec);
}
static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec )
{
VmathVector3 result;
vmathV3Normalize(&result, &vec);
return result;
}
static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 )
{
VmathVector3 result;
vmathV3Cross(&result, &vec0, &vec1);
return result;
}
static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 )
{
VmathVector3 result;
vmathV3Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathV3Print_V( VmathVector3 vec )
{
vmathV3Print(&vec);
}
static inline void vmathV3Prints_V( VmathVector3 vec, const char *name )
{
vmathV3Prints(&vec, name);
}
#endif
static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w )
{
VmathVector4 result;
vmathV4MakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w )
{
VmathVector4 result;
vmathV4MakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec )
{
VmathVector4 result;
vmathV4MakeFromV3(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt )
{
VmathVector4 result;
vmathV4MakeFromP3(&result, &pnt);
return result;
}
static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat )
{
VmathVector4 result;
vmathV4MakeFromQ(&result, &quat);
return result;
}
static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar )
{
VmathVector4 result;
vmathV4MakeFromScalar(&result, scalar);
return result;
}
static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 )
{
VmathVector4 result;
vmathV4MakeFrom128(&result, vf4);
return result;
}
static inline VmathVector4 vmathV4MakeXAxis_V( )
{
VmathVector4 result;
vmathV4MakeXAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeYAxis_V( )
{
VmathVector4 result;
vmathV4MakeYAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeZAxis_V( )
{
VmathVector4 result;
vmathV4MakeZAxis(&result);
return result;
}
static inline VmathVector4 vmathV4MakeWAxis_V( )
{
VmathVector4 result;
vmathV4MakeWAxis(&result);
return result;
}
static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 )
{
VmathVector4 result;
vmathV4Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline vec_float4 vmathV4Get128_V( VmathVector4 vec )
{
return vmathV4Get128(&vec);
}
static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads )
{
vmathV4StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, twoQuads);
}
static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec )
{
vmathV4SetXYZ(result, &vec);
}
static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec )
{
VmathVector3 result;
vmathV4GetXYZ(&result, &vec);
return result;
}
static inline void vmathV4SetX_V( VmathVector4 *result, float _x )
{
vmathV4SetX(result, _x);
}
static inline float vmathV4GetX_V( VmathVector4 vec )
{
return vmathV4GetX(&vec);
}
static inline void vmathV4SetY_V( VmathVector4 *result, float _y )
{
vmathV4SetY(result, _y);
}
static inline float vmathV4GetY_V( VmathVector4 vec )
{
return vmathV4GetY(&vec);
}
static inline void vmathV4SetZ_V( VmathVector4 *result, float _z )
{
vmathV4SetZ(result, _z);
}
static inline float vmathV4GetZ_V( VmathVector4 vec )
{
return vmathV4GetZ(&vec);
}
static inline void vmathV4SetW_V( VmathVector4 *result, float _w )
{
vmathV4SetW(result, _w);
}
static inline float vmathV4GetW_V( VmathVector4 vec )
{
return vmathV4GetW(&vec);
}
static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value )
{
vmathV4SetElem(result, idx, value);
}
static inline float vmathV4GetElem_V( VmathVector4 vec, int idx )
{
return vmathV4GetElem(&vec, idx);
}
static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Add(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar )
{
VmathVector4 result;
vmathV4ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar )
{
VmathVector4 result;
vmathV4ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4Neg(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4RecipPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4SqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4AbsPerElem(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV4MaxElem_V( VmathVector4 vec )
{
return vmathV4MaxElem(&vec);
}
static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 )
{
VmathVector4 result;
vmathV4MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline float vmathV4MinElem_V( VmathVector4 vec )
{
return vmathV4MinElem(&vec);
}
static inline float vmathV4Sum_V( VmathVector4 vec )
{
return vmathV4Sum(&vec);
}
static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 )
{
return vmathV4Dot(&vec0, &vec1);
}
static inline float vmathV4LengthSqr_V( VmathVector4 vec )
{
return vmathV4LengthSqr(&vec);
}
static inline float vmathV4Length_V( VmathVector4 vec )
{
return vmathV4Length(&vec);
}
static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec )
{
VmathVector4 result;
vmathV4Normalize(&result, &vec);
return result;
}
static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 )
{
VmathVector4 result;
vmathV4Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathV4Print_V( VmathVector4 vec )
{
vmathV4Print(&vec);
}
static inline void vmathV4Prints_V( VmathVector4 vec, const char *name )
{
vmathV4Prints(&vec, name);
}
#endif
static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z )
{
VmathPoint3 result;
vmathP3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec )
{
VmathPoint3 result;
vmathP3MakeFromV3(&result, &vec);
return result;
}
static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar )
{
VmathPoint3 result;
vmathP3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 )
{
VmathPoint3 result;
vmathP3MakeFrom128(&result, vf4);
return result;
}
static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3Lerp(&result, t, &pnt0, &pnt1);
return result;
}
static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt )
{
return vmathP3Get128(&pnt);
}
static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad )
{
vmathP3StoreXYZ(&pnt, quad);
}
static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads )
{
vmathP3LoadXYZArray(pnt0, pnt1, pnt2, pnt3, threeQuads);
}
static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads )
{
vmathP3StoreXYZArray(&pnt0, &pnt1, &pnt2, &pnt3, threeQuads);
}
static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads )
{
vmathP3StoreHalfFloats(&pnt0, &pnt1, &pnt2, &pnt3, &pnt4, &pnt5, &pnt6, &pnt7, threeQuads);
}
static inline void vmathP3SetX_V( VmathPoint3 *result, float _x )
{
vmathP3SetX(result, _x);
}
static inline float vmathP3GetX_V( VmathPoint3 pnt )
{
return vmathP3GetX(&pnt);
}
static inline void vmathP3SetY_V( VmathPoint3 *result, float _y )
{
vmathP3SetY(result, _y);
}
static inline float vmathP3GetY_V( VmathPoint3 pnt )
{
return vmathP3GetY(&pnt);
}
static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z )
{
vmathP3SetZ(result, _z);
}
static inline float vmathP3GetZ_V( VmathPoint3 pnt )
{
return vmathP3GetZ(&pnt);
}
static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value )
{
vmathP3SetElem(result, idx, value);
}
static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx )
{
return vmathP3GetElem(&pnt, idx);
}
static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathVector3 result;
vmathP3Sub(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 )
{
VmathPoint3 result;
vmathP3AddV3(&result, &pnt, &vec1);
return result;
}
static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 )
{
VmathPoint3 result;
vmathP3SubV3(&result, &pnt, &vec1);
return result;
}
static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MulPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3DivPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3RecipPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3SqrtPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3RsqrtPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt )
{
VmathPoint3 result;
vmathP3AbsPerElem(&result, &pnt);
return result;
}
static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3CopySignPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MaxPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline float vmathP3MaxElem_V( VmathPoint3 pnt )
{
return vmathP3MaxElem(&pnt);
}
static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
VmathPoint3 result;
vmathP3MinPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline float vmathP3MinElem_V( VmathPoint3 pnt )
{
return vmathP3MinElem(&pnt);
}
static inline float vmathP3Sum_V( VmathPoint3 pnt )
{
return vmathP3Sum(&pnt);
}
static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal )
{
VmathPoint3 result;
vmathP3Scale(&result, &pnt, scaleVal);
return result;
}
static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec )
{
VmathPoint3 result;
vmathP3NonUniformScale(&result, &pnt, &scaleVec);
return result;
}
static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec )
{
return vmathP3Projection(&pnt, &unitVec);
}
static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt )
{
return vmathP3DistSqrFromOrigin(&pnt);
}
static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt )
{
return vmathP3DistFromOrigin(&pnt);
}
static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
return vmathP3DistSqr(&pnt0, &pnt1);
}
static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 )
{
return vmathP3Dist(&pnt0, &pnt1);
}
static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 )
{
VmathPoint3 result;
vmathP3Select(&result, &pnt0, &pnt1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathP3Print_V( VmathPoint3 pnt )
{
vmathP3Print(&pnt);
}
static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name )
{
vmathP3Prints(&pnt, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,962 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_VEC_SOA_V_C_H
#define _VECTORMATH_VEC_SOA_V_C_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*-----------------------------------------------------------------------------
* Constants
* for shuffles, words are labeled [x,y,z,w] [a,b,c,d]
*/
#define _VECTORMATH_SHUF_X 0x00010203
#define _VECTORMATH_SHUF_Y 0x04050607
#define _VECTORMATH_SHUF_Z 0x08090a0b
#define _VECTORMATH_SHUF_W 0x0c0d0e0f
#define _VECTORMATH_SHUF_A 0x10111213
#define _VECTORMATH_SHUF_B 0x14151617
#define _VECTORMATH_SHUF_C 0x18191a1b
#define _VECTORMATH_SHUF_D 0x1c1d1e1f
#define _VECTORMATH_SHUF_0 0x80808080
#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B })
#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D })
#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 })
#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 })
#define _VECTORMATH_SHUF_ZDW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 })
#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C })
#define _VECTORMATH_SHUF_ZDXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B })
#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D })
#define _VECTORMATH_SHUF_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B })
#define _VECTORMATH_SHUF_YAWC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C })
#define _VECTORMATH_SHUF_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D })
#define _VECTORMATH_SHUF_XYCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D })
#define _VECTORMATH_SLERP_TOL 0.999f
/*-----------------------------------------------------------------------------
* Definitions
*/
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z )
{
VmathSoaVector3 result;
vmathSoaV3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt )
{
VmathSoaVector3 result;
vmathSoaV3MakeFromP3(&result, &pnt);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar )
{
VmathSoaVector3 result;
vmathSoaV3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3MakeFromAos(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 )
{
VmathSoaVector3 result;
vmathSoaV3MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( )
{
VmathSoaVector3 result;
vmathSoaV3MakeXAxis(&result);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( )
{
VmathSoaVector3 result;
vmathSoaV3MakeYAxis(&result);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( )
{
VmathSoaVector3 result;
vmathSoaV3MakeZAxis(&result);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 )
{
VmathSoaVector3 result;
vmathSoaV3Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 )
{
vmathSoaV3Get4Aos(&vec, result0, result1, result2, result3);
}
static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads )
{
vmathSoaV3LoadXYZArray(vec, threeQuads);
}
static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads )
{
vmathSoaV3StoreXYZArray(&vec, threeQuads);
}
static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads )
{
vmathSoaV3StoreHalfFloats(&vec0, &vec1, threeQuads);
}
static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 _x )
{
vmathSoaV3SetX(result, _x);
}
static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec )
{
return vmathSoaV3GetX(&vec);
}
static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 _y )
{
vmathSoaV3SetY(result, _y);
}
static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec )
{
return vmathSoaV3GetY(&vec);
}
static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 _z )
{
vmathSoaV3SetZ(result, _z);
}
static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec )
{
return vmathSoaV3GetZ(&vec);
}
static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value )
{
vmathSoaV3SetElem(result, idx, value);
}
static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx )
{
return vmathSoaV3GetElem(&vec, idx);
}
static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3Add(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaV3AddP3(&result, &vec, &pnt1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar )
{
VmathSoaVector3 result;
vmathSoaV3ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar )
{
VmathSoaVector3 result;
vmathSoaV3ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3Neg(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3RecipPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3SqrtPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3AbsPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec )
{
return vmathSoaV3MaxElem(&vec);
}
static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec )
{
return vmathSoaV3MinElem(&vec);
}
static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec )
{
return vmathSoaV3Sum(&vec);
}
static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
return vmathSoaV3Dot(&vec0, &vec1);
}
static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec )
{
return vmathSoaV3LengthSqr(&vec);
}
static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec )
{
return vmathSoaV3Length(&vec);
}
static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec )
{
VmathSoaVector3 result;
vmathSoaV3Normalize(&result, &vec);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 )
{
VmathSoaVector3 result;
vmathSoaV3Cross(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 )
{
VmathSoaVector3 result;
vmathSoaV3Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaV3Print_V( VmathSoaVector3 vec )
{
vmathSoaV3Print(&vec);
}
static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name )
{
vmathSoaV3Prints(&vec, name);
}
#endif
static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromElems(&result, _x, _y, _z, _w);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromV3Scalar(&result, &xyz, _w);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromV3(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromP3(&result, &pnt);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromQ(&result, &quat);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromScalar(&result, scalar);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4MakeFromAos(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 )
{
VmathSoaVector4 result;
vmathSoaV4MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( )
{
VmathSoaVector4 result;
vmathSoaV4MakeXAxis(&result);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( )
{
VmathSoaVector4 result;
vmathSoaV4MakeYAxis(&result);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( )
{
VmathSoaVector4 result;
vmathSoaV4MakeZAxis(&result);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( )
{
VmathSoaVector4 result;
vmathSoaV4MakeWAxis(&result);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4Lerp(&result, t, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 )
{
VmathSoaVector4 result;
vmathSoaV4Slerp(&result, t, &unitVec0, &unitVec1);
return result;
}
static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 )
{
vmathSoaV4Get4Aos(&vec, result0, result1, result2, result3);
}
static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads )
{
vmathSoaV4StoreHalfFloats(&vec, twoQuads);
}
static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec )
{
vmathSoaV4SetXYZ(result, &vec);
}
static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec )
{
VmathSoaVector3 result;
vmathSoaV4GetXYZ(&result, &vec);
return result;
}
static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 _x )
{
vmathSoaV4SetX(result, _x);
}
static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec )
{
return vmathSoaV4GetX(&vec);
}
static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 _y )
{
vmathSoaV4SetY(result, _y);
}
static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec )
{
return vmathSoaV4GetY(&vec);
}
static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 _z )
{
vmathSoaV4SetZ(result, _z);
}
static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec )
{
return vmathSoaV4GetZ(&vec);
}
static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 _w )
{
vmathSoaV4SetW(result, _w);
}
static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec )
{
return vmathSoaV4GetW(&vec);
}
static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value )
{
vmathSoaV4SetElem(result, idx, value);
}
static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx )
{
return vmathSoaV4GetElem(&vec, idx);
}
static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4Add(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4Sub(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar )
{
VmathSoaVector4 result;
vmathSoaV4ScalarMul(&result, &vec, scalar);
return result;
}
static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar )
{
VmathSoaVector4 result;
vmathSoaV4ScalarDiv(&result, &vec, scalar);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4Neg(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4MulPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4DivPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4RecipPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4SqrtPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4RsqrtPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4AbsPerElem(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4CopySignPerElem(&result, &vec0, &vec1);
return result;
}
static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4MaxPerElem(&result, &vec0, &vec1);
return result;
}
static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec )
{
return vmathSoaV4MaxElem(&vec);
}
static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
VmathSoaVector4 result;
vmathSoaV4MinPerElem(&result, &vec0, &vec1);
return result;
}
static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec )
{
return vmathSoaV4MinElem(&vec);
}
static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec )
{
return vmathSoaV4Sum(&vec);
}
static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 )
{
return vmathSoaV4Dot(&vec0, &vec1);
}
static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec )
{
return vmathSoaV4LengthSqr(&vec);
}
static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec )
{
return vmathSoaV4Length(&vec);
}
static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec )
{
VmathSoaVector4 result;
vmathSoaV4Normalize(&result, &vec);
return result;
}
static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 )
{
VmathSoaVector4 result;
vmathSoaV4Select(&result, &vec0, &vec1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaV4Print_V( VmathSoaVector4 vec )
{
vmathSoaV4Print(&vec);
}
static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name )
{
vmathSoaV4Prints(&vec, name);
}
#endif
static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFromElems(&result, _x, _y, _z);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFromV3(&result, &vec);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFromScalar(&result, scalar);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFromAos(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 )
{
VmathSoaPoint3 result;
vmathSoaP3MakeFrom4Aos(&result, &pnt0, &pnt1, &pnt2, &pnt3);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3Lerp(&result, t, &pnt0, &pnt1);
return result;
}
static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 )
{
vmathSoaP3Get4Aos(&pnt, result0, result1, result2, result3);
}
static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *vec, const vec_float4 *threeQuads )
{
vmathSoaP3LoadXYZArray(vec, threeQuads);
}
static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 vec, vec_float4 *threeQuads )
{
vmathSoaP3StoreXYZArray(&vec, threeQuads);
}
static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads )
{
vmathSoaP3StoreHalfFloats(&pnt0, &pnt1, threeQuads);
}
static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 _x )
{
vmathSoaP3SetX(result, _x);
}
static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3GetX(&pnt);
}
static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 _y )
{
vmathSoaP3SetY(result, _y);
}
static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3GetY(&pnt);
}
static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 _z )
{
vmathSoaP3SetZ(result, _z);
}
static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3GetZ(&pnt);
}
static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value )
{
vmathSoaP3SetElem(result, idx, value);
}
static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx )
{
return vmathSoaP3GetElem(&pnt, idx);
}
static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaVector3 result;
vmathSoaP3Sub(&result, &pnt0, &pnt1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 )
{
VmathSoaPoint3 result;
vmathSoaP3AddV3(&result, &pnt, &vec1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 )
{
VmathSoaPoint3 result;
vmathSoaP3SubV3(&result, &pnt, &vec1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3MulPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3DivPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3RecipPerElem(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3SqrtPerElem(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3RsqrtPerElem(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt )
{
VmathSoaPoint3 result;
vmathSoaP3AbsPerElem(&result, &pnt);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3CopySignPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3MaxPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3MaxElem(&pnt);
}
static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
VmathSoaPoint3 result;
vmathSoaP3MinPerElem(&result, &pnt0, &pnt1);
return result;
}
static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3MinElem(&pnt);
}
static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3Sum(&pnt);
}
static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal )
{
VmathSoaPoint3 result;
vmathSoaP3Scale(&result, &pnt, scaleVal);
return result;
}
static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec )
{
VmathSoaPoint3 result;
vmathSoaP3NonUniformScale(&result, &pnt, &scaleVec);
return result;
}
static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec )
{
return vmathSoaP3Projection(&pnt, &unitVec);
}
static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3DistSqrFromOrigin(&pnt);
}
static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt )
{
return vmathSoaP3DistFromOrigin(&pnt);
}
static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
return vmathSoaP3DistSqr(&pnt0, &pnt1);
}
static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 )
{
return vmathSoaP3Dist(&pnt0, &pnt1);
}
static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 )
{
VmathSoaPoint3 result;
vmathSoaP3Select(&result, &pnt0, &pnt1, select1);
return result;
}
#ifdef _VECTORMATH_DEBUG
static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt )
{
vmathSoaP3Print(&pnt);
}
static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name )
{
vmathSoaP3Prints(&pnt, name);
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,246 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _BOOLINVEC_H
#define _BOOLINVEC_H
#include <spu_intrinsics.h>
namespace Vectormath {
class floatInVec;
//--------------------------------------------------------------------------------------------------
// boolInVec class
//
class boolInVec
{
private:
vec_uint4 mData;
inline boolInVec(vec_uint4 vec);
public:
inline boolInVec() {}
// matches standard type conversions
//
inline boolInVec(floatInVec vec);
// explicit cast from bool
//
explicit inline boolInVec(bool scalar);
#ifdef _VECTORMATH_NO_SCALAR_CAST
// explicit cast to bool
//
inline bool getAsBool() const;
#else
// implicit cast to bool
//
inline operator bool() const;
#endif
// get vector data
// bool value is in the 0 word slot of vector as 0 (false) or -1 (true)
//
inline vec_uint4 get128() const;
// operators
//
inline const boolInVec operator ! () const;
inline boolInVec& operator = (boolInVec vec);
inline boolInVec& operator &= (boolInVec vec);
inline boolInVec& operator ^= (boolInVec vec);
inline boolInVec& operator |= (boolInVec vec);
// friend functions
//
friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
};
//--------------------------------------------------------------------------------------------------
// boolInVec functions
//
// operators
//
inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
// select between vec0 and vec1 using boolInVec.
// false selects vec0, true selects vec1
//
inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
} // namespace Vectormath
//--------------------------------------------------------------------------------------------------
// boolInVec implementation
//
#include "floatInVec.h"
namespace Vectormath {
inline
boolInVec::boolInVec(vec_uint4 vec)
{
mData = vec;
}
inline
boolInVec::boolInVec(floatInVec vec)
{
*this = (vec != floatInVec(0.0f));
}
inline
boolInVec::boolInVec(bool scalar)
{
mData = spu_promote((unsigned int)-scalar, 0);
}
#ifdef _VECTORMATH_NO_SCALAR_CAST
inline
bool
boolInVec::getAsBool() const
#else
inline
boolInVec::operator bool() const
#endif
{
return (bool)spu_extract(mData, 0);
}
inline
vec_uint4
boolInVec::get128() const
{
return mData;
}
inline
const boolInVec
boolInVec::operator ! () const
{
return boolInVec(spu_nor(mData, mData));
}
inline
boolInVec&
boolInVec::operator = (boolInVec vec)
{
mData = vec.mData;
return *this;
}
inline
boolInVec&
boolInVec::operator &= (boolInVec vec)
{
*this = *this & vec;
return *this;
}
inline
boolInVec&
boolInVec::operator ^= (boolInVec vec)
{
*this = *this ^ vec;
return *this;
}
inline
boolInVec&
boolInVec::operator |= (boolInVec vec)
{
*this = *this | vec;
return *this;
}
inline
const boolInVec
operator == (boolInVec vec0, boolInVec vec1)
{
return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator != (boolInVec vec0, boolInVec vec1)
{
return !(vec0 == vec1);
}
inline
const boolInVec
operator & (boolInVec vec0, boolInVec vec1)
{
return boolInVec(spu_and(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator | (boolInVec vec0, boolInVec vec1)
{
return boolInVec(spu_or(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator ^ (boolInVec vec0, boolInVec vec1)
{
return boolInVec(spu_xor(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1)
{
return boolInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
}
} // namespace Vectormath
#endif // boolInVec_h

View File

@@ -0,0 +1,340 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _FLOATINVEC_H
#define _FLOATINVEC_H
#include <math.h>
#include <spu_intrinsics.h>
#include "spu2vmx.h"
#include "simdmath.h"
#undef bool
namespace Vectormath {
class boolInVec;
//--------------------------------------------------------------------------------------------------
// floatInVec class
//
class floatInVec
{
private:
vec_float4 mData;
inline floatInVec(vec_float4 vec);
public:
inline floatInVec() {}
// matches standard type conversions
//
inline floatInVec(boolInVec vec);
// construct from a slot of vec_float4
//
inline floatInVec(vec_float4 vec, int slot);
// explicit cast from float
//
explicit inline floatInVec(float scalar);
#ifdef _VECTORMATH_NO_SCALAR_CAST
// explicit cast to float
//
inline float getAsFloat() const;
#else
// implicit cast to float
//
inline operator float() const;
#endif
// get vector data
// float value is in 0 word slot of vector
//
inline vec_float4 get128() const;
// operators
//
inline const floatInVec operator ++ (int);
inline const floatInVec operator -- (int);
inline floatInVec& operator ++ ();
inline floatInVec& operator -- ();
inline const floatInVec operator - () const;
inline floatInVec& operator = (floatInVec vec);
inline floatInVec& operator *= (floatInVec vec);
inline floatInVec& operator /= (floatInVec vec);
inline floatInVec& operator += (floatInVec vec);
inline floatInVec& operator -= (floatInVec vec);
// friend functions
//
friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
};
//--------------------------------------------------------------------------------------------------
// floatInVec functions
//
// operators
//
inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
// select between vec0 and vec1 using boolInVec.
// false selects vec0, true selects vec1
//
inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
} // namespace Vectormath
//--------------------------------------------------------------------------------------------------
// floatInVec implementation
//
#include "boolInVec.h"
namespace Vectormath {
inline
floatInVec::floatInVec(vec_float4 vec)
{
mData = vec;
}
inline
floatInVec::floatInVec(boolInVec vec)
{
mData = spu_sel(spu_splats(0.0f), spu_splats(1.0f), vec.get128());
}
inline
floatInVec::floatInVec(vec_float4 vec, int slot)
{
mData = spu_promote(spu_extract(vec, slot), 0);
}
inline
floatInVec::floatInVec(float scalar)
{
mData = spu_promote(scalar, 0);
}
#ifdef _VECTORMATH_NO_SCALAR_CAST
inline
float
floatInVec::getAsFloat() const
#else
inline
floatInVec::operator float() const
#endif
{
return spu_extract(mData,0);
}
inline
vec_float4
floatInVec::get128() const
{
return mData;
}
inline
const floatInVec
floatInVec::operator ++ (int)
{
vec_float4 olddata = mData;
operator ++();
return floatInVec(olddata);
}
inline
const floatInVec
floatInVec::operator -- (int)
{
vec_float4 olddata = mData;
operator --();
return floatInVec(olddata);
}
inline
floatInVec&
floatInVec::operator ++ ()
{
*this += floatInVec(1.0f);
return *this;
}
inline
floatInVec&
floatInVec::operator -- ()
{
*this -= floatInVec(1.0f);
return *this;
}
inline
const floatInVec
floatInVec::operator - () const
{
return floatInVec((vec_float4)spu_xor((vec_uint4)mData, spu_splats(0x80000000)));
}
inline
floatInVec&
floatInVec::operator = (floatInVec vec)
{
mData = vec.mData;
return *this;
}
inline
floatInVec&
floatInVec::operator *= (floatInVec vec)
{
*this = *this * vec;
return *this;
}
inline
floatInVec&
floatInVec::operator /= (floatInVec vec)
{
*this = *this / vec;
return *this;
}
inline
floatInVec&
floatInVec::operator += (floatInVec vec)
{
*this = *this + vec;
return *this;
}
inline
floatInVec&
floatInVec::operator -= (floatInVec vec)
{
*this = *this - vec;
return *this;
}
inline
const floatInVec
operator * (floatInVec vec0, floatInVec vec1)
{
return floatInVec(spu_mul(vec0.get128(), vec1.get128()));
}
inline
const floatInVec
operator / (floatInVec num, floatInVec den)
{
return floatInVec(divf4(num.get128(), den.get128()));
}
inline
const floatInVec
operator + (floatInVec vec0, floatInVec vec1)
{
return floatInVec(spu_add(vec0.get128(), vec1.get128()));
}
inline
const floatInVec
operator - (floatInVec vec0, floatInVec vec1)
{
return floatInVec(spu_sub(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator < (floatInVec vec0, floatInVec vec1)
{
return boolInVec(spu_cmpgt(vec1.get128(), vec0.get128()));
}
inline
const boolInVec
operator <= (floatInVec vec0, floatInVec vec1)
{
return !(vec0 > vec1);
}
inline
const boolInVec
operator > (floatInVec vec0, floatInVec vec1)
{
return boolInVec(spu_cmpgt(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator >= (floatInVec vec0, floatInVec vec1)
{
return !(vec0 < vec1);
}
inline
const boolInVec
operator == (floatInVec vec0, floatInVec vec1)
{
return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128()));
}
inline
const boolInVec
operator != (floatInVec vec0, floatInVec vec1)
{
return !(vec0 == vec1);
}
inline
const floatInVec
select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1)
{
return floatInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
}
} // namespace Vectormath
#endif // floatInVec_h

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,417 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_AOS_CPP_H
#define _VECTORMATH_QUAT_AOS_CPP_H
//-----------------------------------------------------------------------------
// Definitions
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
namespace Vectormath {
namespace Aos {
inline Quat::Quat( float _x, float _y, float _z, float _w )
{
mVec128 = (vec_float4){ _x, _y, _z, _w };
}
inline Quat::Quat( Vector3 xyz, float _w )
{
mVec128 = spu_shuffle( xyz.get128(), spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA );
}
inline Quat::Quat( Vector4 vec )
{
mVec128 = vec.get128();
}
inline Quat::Quat( float scalar )
{
mVec128 = spu_splats( scalar );
}
inline Quat::Quat( vec_float4 vf4 )
{
mVec128 = vf4;
}
inline const Quat Quat::identity( )
{
return Quat( _VECTORMATH_UNIT_0001 );
}
inline const Quat lerp( float t, Quat quat0, Quat quat1 )
{
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
}
inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 )
{
Quat start;
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
vec_uint4 selectMask;
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() );
cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx );
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
start = Quat( spu_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) );
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
angle = acosf4( cosAngle );
tttt = spu_splats(t);
oneMinusT = spu_sub( spu_splats(1.0f), tttt );
angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) );
angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) );
angles = spu_mul( angles, angle );
sines = sinf4( angles );
scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) );
scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask );
scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask );
return Quat( spu_madd( start.get128(), scale0, spu_mul( unitQuat1.get128(), scale1 ) ) );
}
inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 )
{
Quat tmp0, tmp1;
tmp0 = slerp( t, unitQuat0, unitQuat3 );
tmp1 = slerp( t, unitQuat1, unitQuat2 );
return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 );
}
inline vec_float4 Quat::get128( ) const
{
return mVec128;
}
inline Quat & Quat::operator =( Quat quat )
{
mVec128 = quat.mVec128;
return *this;
}
inline Quat & Quat::setXYZ( Vector3 vec )
{
mVec128 = spu_sel( vec.get128(), mVec128, (vec_uint4)spu_maskb(0x000f) );
return *this;
}
inline const Vector3 Quat::getXYZ( ) const
{
return Vector3( mVec128 );
}
inline Quat & Quat::setX( float _x )
{
mVec128 = spu_insert( _x, mVec128, 0 );
return *this;
}
inline float Quat::getX( ) const
{
return spu_extract( mVec128, 0 );
}
inline Quat & Quat::setY( float _y )
{
mVec128 = spu_insert( _y, mVec128, 1 );
return *this;
}
inline float Quat::getY( ) const
{
return spu_extract( mVec128, 1 );
}
inline Quat & Quat::setZ( float _z )
{
mVec128 = spu_insert( _z, mVec128, 2 );
return *this;
}
inline float Quat::getZ( ) const
{
return spu_extract( mVec128, 2 );
}
inline Quat & Quat::setW( float _w )
{
mVec128 = spu_insert( _w, mVec128, 3 );
return *this;
}
inline float Quat::getW( ) const
{
return spu_extract( mVec128, 3 );
}
inline Quat & Quat::setElem( int idx, float value )
{
mVec128 = spu_insert( value, mVec128, idx );
return *this;
}
inline float Quat::getElem( int idx ) const
{
return spu_extract( mVec128, idx );
}
inline VecIdx Quat::operator []( int idx )
{
return VecIdx( mVec128, idx );
}
inline float Quat::operator []( int idx ) const
{
return spu_extract( mVec128, idx );
}
inline const Quat Quat::operator +( Quat quat ) const
{
return Quat( spu_add( mVec128, quat.mVec128 ) );
}
inline const Quat Quat::operator -( Quat quat ) const
{
return Quat( spu_sub( mVec128, quat.mVec128 ) );
}
inline const Quat Quat::operator *( float scalar ) const
{
return Quat( spu_mul( mVec128, spu_splats(scalar) ) );
}
inline Quat & Quat::operator +=( Quat quat )
{
*this = *this + quat;
return *this;
}
inline Quat & Quat::operator -=( Quat quat )
{
*this = *this - quat;
return *this;
}
inline Quat & Quat::operator *=( float scalar )
{
*this = *this * scalar;
return *this;
}
inline const Quat Quat::operator /( float scalar ) const
{
return Quat( divf4( mVec128, spu_splats(scalar) ) );
}
inline Quat & Quat::operator /=( float scalar )
{
*this = *this / scalar;
return *this;
}
inline const Quat Quat::operator -( ) const
{
return Quat( negatef4( mVec128 ) );
}
inline const Quat operator *( float scalar, Quat quat )
{
return quat * scalar;
}
inline float dot( Quat quat0, Quat quat1 )
{
return spu_extract( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 );
}
inline float norm( Quat quat )
{
return spu_extract( _vmathVfDot4( quat.get128(), quat.get128() ), 0 );
}
inline float length( Quat quat )
{
return sqrtf( norm( quat ) );
}
inline const Quat normalize( Quat quat )
{
vec_float4 dot = _vmathVfDot4( quat.get128(), quat.get128() );
return Quat( spu_mul( quat.get128(), rsqrtf4( dot ) ) );
}
inline const Quat Quat::rotation( Vector3 unitVec0, Vector3 unitVec1 )
{
Vector3 crossVec;
vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() );
cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) );
cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) );
recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 );
cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 );
crossVec = cross( unitVec0, unitVec1 );
res = spu_mul( crossVec.get128(), recipCosHalfAngleX2 );
res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) );
return Quat( res );
}
inline const Quat Quat::rotation( float radians, Vector3 unitVec )
{
vec_float4 s, c, angle, res;
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
sincosf4( angle, &s, &c );
res = spu_sel( spu_mul( unitVec.get128(), s ), c, (vec_uint4)spu_maskb(0x000f) );
return Quat( res );
}
inline const Quat Quat::rotationX( float radians )
{
vec_float4 s, c, angle, res;
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
sincosf4( angle, &s, &c );
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) );
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
return Quat( res );
}
inline const Quat Quat::rotationY( float radians )
{
vec_float4 s, c, angle, res;
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
sincosf4( angle, &s, &c );
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) );
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
return Quat( res );
}
inline const Quat Quat::rotationZ( float radians )
{
vec_float4 s, c, angle, res;
angle = spu_mul( spu_splats(radians), spu_splats(0.5f) );
sincosf4( angle, &s, &c );
res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) );
res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) );
return Quat( res );
}
inline const Quat Quat::operator *( Quat quat ) const
{
vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
vec_float4 product, l_wxyz, r_wxyz, xy, qw;
ldata = mVec128;
rdata = quat.mVec128;
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW );
tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW );
tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW );
tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW );
qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata );
qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv );
qv = spu_madd( tmp0, tmp1, qv );
qv = spu_nmsub( tmp2, tmp3, qv );
product = spu_mul( ldata, rdata );
l_wxyz = spu_rlqwbyte( ldata, 12 );
r_wxyz = spu_rlqwbyte( rdata, 12 );
qw = spu_nmsub( l_wxyz, r_wxyz, product );
xy = spu_madd( l_wxyz, r_wxyz, product );
qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) );
return Quat( spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) ) );
}
inline Quat & Quat::operator *=( Quat quat )
{
*this = *this * quat;
return *this;
}
inline const Vector3 rotate( Quat quat, Vector3 vec )
{
vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
qdata = quat.get128();
vdata = vec.get128();
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW );
tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW );
tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW );
tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW );
wwww = spu_shuffle( qdata, qdata, shuffle_wwww );
qv = spu_mul( wwww, vdata );
qv = spu_madd( tmp0, tmp1, qv );
qv = spu_nmsub( tmp2, tmp3, qv );
product = spu_mul( qdata, vdata );
qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product );
qw = spu_add( spu_rlqwbyte( product, 8 ), qw );
tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW );
tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW );
res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata );
res = spu_madd( wwww, qv, res );
res = spu_madd( tmp0, tmp1, res );
res = spu_nmsub( tmp2, tmp3, res );
return Vector3( res );
}
inline const Quat conj( Quat quat )
{
return Quat( spu_xor( quat.get128(), ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ) );
}
inline const Quat select( Quat quat0, Quat quat1, bool select1 )
{
return Quat( spu_sel( quat0.get128(), quat1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) );
}
#ifdef _VECTORMATH_DEBUG
inline void print( Quat quat )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = quat.get128();
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
}
inline void print( Quat quat, const char * name )
{
union { vec_float4 v; float s[4]; } tmp;
tmp.v = quat.get128();
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
}
#endif
} // namespace Aos
} // namespace Vectormath
#endif

View File

@@ -0,0 +1,483 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_QUAT_SOA_CPP_H
#define _VECTORMATH_QUAT_SOA_CPP_H
//-----------------------------------------------------------------------------
// Definitions
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
#define _VECTORMATH_INTERNAL_FUNCTIONS
#endif
namespace Vectormath {
namespace Soa {
inline Quat::Quat( const Quat & quat )
{
mX = quat.mX;
mY = quat.mY;
mZ = quat.mZ;
mW = quat.mW;
}
inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w )
{
mX = _x;
mY = _y;
mZ = _z;
mW = _w;
}
inline Quat::Quat( const Vector3 & xyz, vec_float4 _w )
{
this->setXYZ( xyz );
this->setW( _w );
}
inline Quat::Quat( const Vector4 & vec )
{
mX = vec.getX();
mY = vec.getY();
mZ = vec.getZ();
mW = vec.getW();
}
inline Quat::Quat( vec_float4 scalar )
{
mX = scalar;
mY = scalar;
mZ = scalar;
mW = scalar;
}
inline Quat::Quat( Aos::Quat quat )
{
vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203);
vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607);
vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b);
vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f);
vec_float4 vec128 = quat.get128();
mX = spu_shuffle( vec128, vec128, shuffle_xxxx );
mY = spu_shuffle( vec128, vec128, shuffle_yyyy );
mZ = spu_shuffle( vec128, vec128, shuffle_zzzz );
mW = spu_shuffle( vec128, vec128, shuffle_wwww );
}
inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 )
{
vec_float4 tmp0, tmp1, tmp2, tmp3;
tmp0 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_XAYB );
tmp1 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_XAYB );
tmp2 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_ZCWD );
tmp3 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_ZCWD );
mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB );
mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD );
mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB );
mW = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD );
}
inline const Quat Quat::identity( )
{
return Quat( spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) );
}
inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 )
{
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
}
inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 )
{
Quat start;
vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle;
vec_uint4 selectMask;
cosAngle = dot( unitQuat0, unitQuat1 );
selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle );
cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask );
start.setX( spu_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) );
start.setY( spu_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) );
start.setZ( spu_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) );
start.setW( spu_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) );
selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle );
angle = acosf4( cosAngle );
recipSinAngle = recipf4( sinf4( angle ) );
scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask );
scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask );
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
}
inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
{
Quat tmp0, tmp1;
tmp0 = slerp( t, unitQuat0, unitQuat3 );
tmp1 = slerp( t, unitQuat1, unitQuat2 );
return slerp( spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), tmp0, tmp1 );
}
inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const
{
vec_float4 tmp0, tmp1, tmp2, tmp3;
tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB );
tmp1 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_XAYB );
tmp2 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD );
tmp3 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_ZCWD );
result0 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) );
result1 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) );
result2 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) );
result3 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) );
}
inline Quat & Quat::operator =( const Quat & quat )
{
mX = quat.mX;
mY = quat.mY;
mZ = quat.mZ;
mW = quat.mW;
return *this;
}
inline Quat & Quat::setXYZ( const Vector3 & vec )
{
mX = vec.getX();
mY = vec.getY();
mZ = vec.getZ();
return *this;
}
inline const Vector3 Quat::getXYZ( ) const
{
return Vector3( mX, mY, mZ );
}
inline Quat & Quat::setX( vec_float4 _x )
{
mX = _x;
return *this;
}
inline vec_float4 Quat::getX( ) const
{
return mX;
}
inline Quat & Quat::setY( vec_float4 _y )
{
mY = _y;
return *this;
}
inline vec_float4 Quat::getY( ) const
{
return mY;
}
inline Quat & Quat::setZ( vec_float4 _z )
{
mZ = _z;
return *this;
}
inline vec_float4 Quat::getZ( ) const
{
return mZ;
}
inline Quat & Quat::setW( vec_float4 _w )
{
mW = _w;
return *this;
}
inline vec_float4 Quat::getW( ) const
{
return mW;
}
inline Quat & Quat::setElem( int idx, vec_float4 value )
{
*(&mX + idx) = value;
return *this;
}
inline vec_float4 Quat::getElem( int idx ) const
{
return *(&mX + idx);
}
inline Quat::vec_float4_t & Quat::operator []( int idx )
{
return *(&mX + idx);
}
inline vec_float4 Quat::operator []( int idx ) const
{
return *(&mX + idx);
}
inline const Quat Quat::operator +( const Quat & quat ) const
{
return Quat(
spu_add( mX, quat.mX ),
spu_add( mY, quat.mY ),
spu_add( mZ, quat.mZ ),
spu_add( mW, quat.mW )
);
}
inline const Quat Quat::operator -( const Quat & quat ) const
{
return Quat(
spu_sub( mX, quat.mX ),
spu_sub( mY, quat.mY ),
spu_sub( mZ, quat.mZ ),
spu_sub( mW, quat.mW )
);
}
inline const Quat Quat::operator *( vec_float4 scalar ) const
{
return Quat(
spu_mul( mX, scalar ),
spu_mul( mY, scalar ),
spu_mul( mZ, scalar ),
spu_mul( mW, scalar )
);
}
inline Quat & Quat::operator +=( const Quat & quat )
{
*this = *this + quat;
return *this;
}
inline Quat & Quat::operator -=( const Quat & quat )
{
*this = *this - quat;
return *this;
}
inline Quat & Quat::operator *=( vec_float4 scalar )
{
*this = *this * scalar;
return *this;
}
inline const Quat Quat::operator /( vec_float4 scalar ) const
{
return Quat(
divf4( mX, scalar ),
divf4( mY, scalar ),
divf4( mZ, scalar ),
divf4( mW, scalar )
);
}
inline Quat & Quat::operator /=( vec_float4 scalar )
{
*this = *this / scalar;
return *this;
}
inline const Quat Quat::operator -( ) const
{
return Quat(
negatef4( mX ),
negatef4( mY ),
negatef4( mZ ),
negatef4( mW )
);
}
inline const Quat operator *( vec_float4 scalar, const Quat & quat )
{
return quat * scalar;
}
inline vec_float4 dot( const Quat & quat0, const Quat & quat1 )
{
vec_float4 result;
result = spu_mul( quat0.getX(), quat1.getX() );
result = spu_add( result, spu_mul( quat0.getY(), quat1.getY() ) );
result = spu_add( result, spu_mul( quat0.getZ(), quat1.getZ() ) );
result = spu_add( result, spu_mul( quat0.getW(), quat1.getW() ) );
return result;
}
inline vec_float4 norm( const Quat & quat )
{
vec_float4 result;
result = spu_mul( quat.getX(), quat.getX() );
result = spu_add( result, spu_mul( quat.getY(), quat.getY() ) );
result = spu_add( result, spu_mul( quat.getZ(), quat.getZ() ) );
result = spu_add( result, spu_mul( quat.getW(), quat.getW() ) );
return result;
}
inline vec_float4 length( const Quat & quat )
{
return sqrtf4( norm( quat ) );
}
inline const Quat normalize( const Quat & quat )
{
vec_float4 lenSqr, lenInv;
lenSqr = norm( quat );
lenInv = rsqrtf4( lenSqr );
return Quat(
spu_mul( quat.getX(), lenInv ),
spu_mul( quat.getY(), lenInv ),
spu_mul( quat.getZ(), lenInv ),
spu_mul( quat.getW(), lenInv )
);
}
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
{
vec_float4 cosHalfAngleX2, recipCosHalfAngleX2;
cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), dot( unitVec0, unitVec1 ) ) ) );
recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 );
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) );
}
inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec )
{
vec_float4 s, c, angle;
angle = spu_mul( radians, spu_splats(0.5f) );
sincosf4( angle, &s, &c );
return Quat( ( unitVec * s ), c );
}
inline const Quat Quat::rotationX( vec_float4 radians )
{
vec_float4 s, c, angle;
angle = spu_mul( radians, spu_splats(0.5f) );
sincosf4( angle, &s, &c );
return Quat( s, spu_splats(0.0f), spu_splats(0.0f), c );
}
inline const Quat Quat::rotationY( vec_float4 radians )
{
vec_float4 s, c, angle;
angle = spu_mul( radians, spu_splats(0.5f) );
sincosf4( angle, &s, &c );
return Quat( spu_splats(0.0f), s, spu_splats(0.0f), c );
}
inline const Quat Quat::rotationZ( vec_float4 radians )
{
vec_float4 s, c, angle;
angle = spu_mul( radians, spu_splats(0.5f) );
sincosf4( angle, &s, &c );
return Quat( spu_splats(0.0f), spu_splats(0.0f), s, c );
}
inline const Quat Quat::operator *( const Quat & quat ) const
{
return Quat(
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mX ), spu_mul( mX, quat.mW ) ), spu_mul( mY, quat.mZ ) ), spu_mul( mZ, quat.mY ) ),
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mY ), spu_mul( mY, quat.mW ) ), spu_mul( mZ, quat.mX ) ), spu_mul( mX, quat.mZ ) ),
spu_sub( spu_add( spu_add( spu_mul( mW, quat.mZ ), spu_mul( mZ, quat.mW ) ), spu_mul( mX, quat.mY ) ), spu_mul( mY, quat.mX ) ),
spu_sub( spu_sub( spu_sub( spu_mul( mW, quat.mW ), spu_mul( mX, quat.mX ) ), spu_mul( mY, quat.mY ) ), spu_mul( mZ, quat.mZ ) )
);
}
inline Quat & Quat::operator *=( const Quat & quat )
{
*this = *this * quat;
return *this;
}
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
{
vec_float4 tmpX, tmpY, tmpZ, tmpW;
tmpX = spu_sub( spu_add( spu_mul( quat.getW(), vec.getX() ), spu_mul( quat.getY(), vec.getZ() ) ), spu_mul( quat.getZ(), vec.getY() ) );
tmpY = spu_sub( spu_add( spu_mul( quat.getW(), vec.getY() ), spu_mul( quat.getZ(), vec.getX() ) ), spu_mul( quat.getX(), vec.getZ() ) );
tmpZ = spu_sub( spu_add( spu_mul( quat.getW(), vec.getZ() ), spu_mul( quat.getX(), vec.getY() ) ), spu_mul( quat.getY(), vec.getX() ) );
tmpW = spu_add( spu_add( spu_mul( quat.getX(), vec.getX() ), spu_mul( quat.getY(), vec.getY() ) ), spu_mul( quat.getZ(), vec.getZ() ) );
return Vector3(
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getX() ), spu_mul( tmpX, quat.getW() ) ), spu_mul( tmpY, quat.getZ() ) ), spu_mul( tmpZ, quat.getY() ) ),
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getY() ), spu_mul( tmpY, quat.getW() ) ), spu_mul( tmpZ, quat.getX() ) ), spu_mul( tmpX, quat.getZ() ) ),
spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getZ() ), spu_mul( tmpZ, quat.getW() ) ), spu_mul( tmpX, quat.getY() ) ), spu_mul( tmpY, quat.getX() ) )
);
}
inline const Quat conj( const Quat & quat )
{
return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() );
}
inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 )
{
return Quat(
spu_sel( quat0.getX(), quat1.getX(), select1 ),
spu_sel( quat0.getY(), quat1.getY(), select1 ),
spu_sel( quat0.getZ(), quat1.getZ(), select1 ),
spu_sel( quat0.getW(), quat1.getW(), select1 )
);
}
#ifdef _VECTORMATH_DEBUG
inline void print( const Quat & quat )
{
Aos::Quat vec0, vec1, vec2, vec3;
quat.get4Aos( vec0, vec1, vec2, vec3 );
printf("slot 0:\n");
print( vec0 );
printf("slot 1:\n");
print( vec1 );
printf("slot 2:\n");
print( vec2 );
printf("slot 3:\n");
print( vec3 );
}
inline void print( const Quat & quat, const char * name )
{
Aos::Quat vec0, vec1, vec2, vec3;
printf( "%s:\n", name );
quat.get4Aos( vec0, vec1, vec2, vec3 );
printf("slot 0:\n");
print( vec0 );
printf("slot 1:\n");
print( vec1 );
printf("slot 2:\n");
print( vec2 );
printf("slot 3:\n");
print( vec3 );
}
#endif
} // namespace Soa
} // namespace Vectormath
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
/*
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Sony Computer Entertainment Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VECTORMATH_VECIDX_AOS_H
#define _VECTORMATH_VECIDX_AOS_H
#include <spu_intrinsics.h>
namespace Vectormath {
namespace Aos {
//-----------------------------------------------------------------------------
// VecIdx
// Used in setting elements of Vector3, Vector4, Point3, or Quat with the
// subscripting operator.
//
class VecIdx
{
private:
typedef vec_float4 vec_float4_t;
vec_float4_t &ref __attribute__ ((aligned(16)));
int i __attribute__ ((aligned(16)));
public:
inline VecIdx( vec_float4& vec, int idx ): ref(vec) { i = idx; }
inline operator float() const;
inline float operator =( float scalar );
inline float operator =( const VecIdx& scalar );
inline float operator *=( float scalar );
inline float operator /=( float scalar );
inline float operator +=( float scalar );
inline float operator -=( float scalar );
};
} // namespace Aos
} // namespace Vectormath
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/* (C) Copyright
Sony Computer Entertainment, Inc.,
2001,2002,2003,2004,2005,2006.
This file is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This file is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with this file; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* As a special exception, if you include this header file into source files
compiled by GCC, this header file does not by itself cause the resulting
executable to be covered by the GNU General Public License. This exception
does not however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
/* Single token vector data types for the PowerPC SIMD/Vector Multi-media
eXtension */
#ifndef _VEC_TYPES_H_
#define _VEC_TYPES_H_ 1
#define qword __vector unsigned char
#define vec_uchar16 __vector unsigned char
#define vec_char16 __vector signed char
#define vec_bchar16 __vector bool char
#define vec_ushort8 __vector unsigned short
#define vec_short8 __vector signed short
#define vec_bshort8 __vector bool short
#define vec_pixel8 __vector pixel
#define vec_uint4 __vector unsigned int
#define vec_int4 __vector signed int
#define vec_bint4 __vector bool int
#define vec_float4 __vector float
#define vec_ullong2 __vector bool char
#define vec_llong2 __vector bool short
#define vec_double2 __vector bool int
#endif /* _VEC_TYPES_H_ */