added tests for Vector Math, modified Makefile, added helper include files
This commit is contained in:
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
@@ -1,379 +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
|
||||
/*
|
||||
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
|
||||
|
||||
@@ -1,312 +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
|
||||
/*
|
||||
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
|
||||
|
||||
@@ -1,415 +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
|
||||
/*
|
||||
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
|
||||
|
||||
@@ -1,319 +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
|
||||
/*
|
||||
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
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
@@ -0,0 +1,55 @@
|
||||
/* (C) Copyright
|
||||
Sony Computer Entertainment, Inc.,
|
||||
2001,2002,2003,2004,2005,2006,2007.
|
||||
|
||||
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 _VECTORMATH_VEC_TYPES_H_
|
||||
#define _VECTORMATH_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 /* _VECTORMATH_VEC_TYPES_H_ */
|
||||
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
Reference in New Issue
Block a user