├── .gitignore ├── LICENSE ├── README ├── doc └── Vector_Math_Library-Overview.pdf ├── include └── vectormath │ ├── SSE │ └── cpp │ │ ├── boolInVec.h │ │ ├── floatInVec.h │ │ ├── mat_aos.h │ │ ├── quat_aos.h │ │ ├── readme_e.txt │ │ ├── vec_aos.h │ │ ├── vecidx_aos.h │ │ └── vectormath_aos.h │ ├── ppu │ ├── c │ │ ├── mat_aos.h │ │ ├── mat_aos_v.h │ │ ├── mat_soa.h │ │ ├── mat_soa_v.h │ │ ├── quat_aos.h │ │ ├── quat_aos_v.h │ │ ├── quat_soa.h │ │ ├── quat_soa_v.h │ │ ├── vec_aos.h │ │ ├── vec_aos_v.h │ │ ├── vec_soa.h │ │ ├── vec_soa_v.h │ │ ├── vec_types.h │ │ ├── vectormath_aos.h │ │ ├── vectormath_aos_v.h │ │ ├── vectormath_soa.h │ │ └── vectormath_soa_v.h │ └── cpp │ │ ├── boolInVec.h │ │ ├── floatInVec.h │ │ ├── mat_aos.h │ │ ├── mat_soa.h │ │ ├── quat_aos.h │ │ ├── quat_soa.h │ │ ├── vec_aos.h │ │ ├── vec_soa.h │ │ ├── vecidx_aos.h │ │ ├── vectormath_aos.h │ │ └── vectormath_soa.h │ ├── scalar │ ├── c │ │ ├── mat_aos.h │ │ ├── mat_aos_v.h │ │ ├── quat_aos.h │ │ ├── quat_aos_v.h │ │ ├── vec_aos.h │ │ ├── vec_aos_v.h │ │ ├── vectormath_aos.h │ │ └── vectormath_aos_v.h │ └── cpp │ │ ├── boolInVec.h │ │ ├── floatInVec.h │ │ ├── mat_aos.h │ │ ├── quat_aos.h │ │ ├── vec_aos.h │ │ └── vectormath_aos.h │ └── spu │ ├── c │ ├── mat_aos.h │ ├── mat_aos_v.h │ ├── mat_soa.h │ ├── mat_soa_v.h │ ├── quat_aos.h │ ├── quat_aos_v.h │ ├── quat_soa.h │ ├── quat_soa_v.h │ ├── vec_aos.h │ ├── vec_aos_v.h │ ├── vec_soa.h │ ├── vec_soa_v.h │ ├── vectormath_aos.h │ ├── vectormath_aos_v.h │ ├── vectormath_soa.h │ └── vectormath_soa_v.h │ └── cpp │ ├── boolInVec.h │ ├── floatInVec.h │ ├── mat_aos.h │ ├── mat_soa.h │ ├── quat_aos.h │ ├── quat_soa.h │ ├── vec_aos.h │ ├── vec_soa.h │ ├── vecidx_aos.h │ ├── vectormath_aos.h │ └── vectormath_soa.h └── tests ├── .gitattributes ├── 0vs2008.bat ├── Makefile ├── clean.pl ├── compare.pl ├── premake4.exe ├── premake4.lua ├── run_perl_tests.bat ├── run_tests.bat ├── test.h ├── test1_aos_c.c ├── test1_aos_cpp.cpp ├── test1_reference.txt ├── test1_soa_c.c ├── test1_soa_cpp.cpp ├── test2_aos_c.c ├── test2_aos_cpp.cpp ├── test2_reference.txt ├── test2_soa_c.c ├── test2_soa_cpp.cpp ├── test3_aos_c.c ├── test3_aos_cpp.cpp ├── test3_reference.txt ├── test3_soa_c.c ├── test3_soa_cpp.cpp ├── test4_aos_c.c ├── test4_aos_cpp.cpp ├── test4_reference.txt ├── test4_soa_c.c ├── test4_soa_cpp.cpp └── vs2008 ├── test1_aos_SSE_cpp.vcproj ├── test1_aos_scalar_cpp.vcproj ├── test2_aos_SSE_cpp.vcproj ├── test2_aos_scalar_cpp.vcproj ├── test3_aos_SSE_cpp.vcproj ├── test3_aos_scalar_cpp.vcproj ├── test4_aos_SSE_cpp.vcproj ├── test4_aos_scalar_cpp.vcproj └── tests.sln /.gitignore: -------------------------------------------------------------------------------- 1 | test/bin/ 2 | test/vs2008/ 3 | test/vs2010/ 4 | test/vs2005/ 5 | test/lib/ 6 | test/.gitattributes 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Vector Math library for 3-D linear algebra (vector, matrix, quaternion) 2 | SIMD support for x86 SSE, PowerPC (PPU) and the SPU. 3 | Also includes generic multi-platform scalar version. 4 | 5 | Copyright (C) 2006-2011 Sony Computer Entertainment Inc. 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, 9 | with or without modification, are permitted provided that the 10 | following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Sony Computer Entertainment Inc nor the names 17 | of its contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Vector math library 2 | 3 | 4 | * Overview 5 | 6 | The Vector math library provides 3-D/4-D vector operations including 7 | addition, outer product, multiply by a matrix, quaternion etc. 8 | 9 | 10 | * License 11 | 12 | This library is licensed under the terms in the file 'LICENSE' in 13 | this directory. (BSD license) 14 | 15 | * Usage 16 | 17 | See the documents `doc/*.pdf'. 18 | 19 | No shared library, static library nor executable is installed, 20 | because all functions in this library are provided as inline 21 | functions. Copy the appropriate header files into your project. 22 | 23 | * Contacting the project 24 | 25 | Module maintainer: Erwin Coumans 26 | 27 | Feedback and patches: 28 | http://www.bulletphysics.com/Bullet/phpBB2/viewforum.php?f=18 29 | 30 | Main repository URL: 31 | https://github.com/erwincoumans/sce_vectormath 32 | (moved from http://bullet.googlecode.com/svn/trunk/Extras/vectormathlibrary) 33 | 34 | * Example usage: 35 | 36 | See physics effects sample code in https://github.com/erwincoumans/bullet3 37 | 38 | --- 39 | EOF 40 | -------------------------------------------------------------------------------- /doc/Vector_Math_Library-Overview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erwincoumans/sce_vectormath/e02144965bfba3fedb412c7df243d3edc61fd37e/doc/Vector_Math_Library-Overview.pdf -------------------------------------------------------------------------------- /include/vectormath/SSE/cpp/boolInVec.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2010 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _BOOLINVEC_H 31 | #define _BOOLINVEC_H 32 | 33 | #include 34 | 35 | namespace Vectormath { 36 | 37 | class floatInVec; 38 | 39 | //-------------------------------------------------------------------------------------------------- 40 | // boolInVec class 41 | // 42 | 43 | class boolInVec 44 | { 45 | private: 46 | __m128 mData; 47 | 48 | inline boolInVec(__m128 vec); 49 | public: 50 | inline boolInVec() {} 51 | 52 | // matches standard type conversions 53 | // 54 | inline boolInVec(const floatInVec &vec); 55 | 56 | // explicit cast from bool 57 | // 58 | explicit inline boolInVec(bool scalar); 59 | 60 | #ifdef _VECTORMATH_NO_SCALAR_CAST 61 | // explicit cast to bool 62 | // 63 | inline bool getAsBool() const; 64 | #else 65 | // implicit cast to bool 66 | // 67 | inline operator bool() const; 68 | #endif 69 | 70 | // get vector data 71 | // bool value is splatted across all word slots of vector as 0 (false) or -1 (true) 72 | // 73 | inline __m128 get128() const; 74 | 75 | // operators 76 | // 77 | inline const boolInVec operator ! () const; 78 | inline boolInVec& operator = (const boolInVec &vec); 79 | inline boolInVec& operator &= (const boolInVec &vec); 80 | inline boolInVec& operator ^= (const boolInVec &vec); 81 | inline boolInVec& operator |= (const boolInVec &vec); 82 | 83 | // friend functions 84 | // 85 | friend inline const boolInVec operator == (const boolInVec &vec0, const boolInVec &vec1); 86 | friend inline const boolInVec operator != (const boolInVec &vec0, const boolInVec &vec1); 87 | friend inline const boolInVec operator < (const floatInVec &vec0, const floatInVec &vec1); 88 | friend inline const boolInVec operator <= (const floatInVec &vec0, const floatInVec &vec1); 89 | friend inline const boolInVec operator > (const floatInVec &vec0, const floatInVec &vec1); 90 | friend inline const boolInVec operator >= (const floatInVec &vec0, const floatInVec &vec1); 91 | friend inline const boolInVec operator == (const floatInVec &vec0, const floatInVec &vec1); 92 | friend inline const boolInVec operator != (const floatInVec &vec0, const floatInVec &vec1); 93 | friend inline const boolInVec operator & (const boolInVec &vec0, const boolInVec &vec1); 94 | friend inline const boolInVec operator ^ (const boolInVec &vec0, const boolInVec &vec1); 95 | friend inline const boolInVec operator | (const boolInVec &vec0, const boolInVec &vec1); 96 | friend inline const boolInVec select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1); 97 | }; 98 | 99 | //-------------------------------------------------------------------------------------------------- 100 | // boolInVec functions 101 | // 102 | 103 | // operators 104 | // 105 | inline const boolInVec operator == (const boolInVec &vec0, const boolInVec &vec1); 106 | inline const boolInVec operator != (const boolInVec &vec0, const boolInVec &vec1); 107 | inline const boolInVec operator & (const boolInVec &vec0, const boolInVec &vec1); 108 | inline const boolInVec operator ^ (const boolInVec &vec0, const boolInVec &vec1); 109 | inline const boolInVec operator | (const boolInVec &vec0, const boolInVec &vec1); 110 | 111 | // select between vec0 and vec1 using boolInVec. 112 | // false selects vec0, true selects vec1 113 | // 114 | inline const boolInVec select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1); 115 | 116 | } // namespace Vectormath 117 | 118 | //-------------------------------------------------------------------------------------------------- 119 | // boolInVec implementation 120 | // 121 | 122 | #include "floatInVec.h" 123 | 124 | namespace Vectormath { 125 | 126 | inline 127 | boolInVec::boolInVec(__m128 vec) 128 | { 129 | mData = vec; 130 | } 131 | 132 | inline 133 | boolInVec::boolInVec(const floatInVec &vec) 134 | { 135 | *this = (vec != floatInVec(0.0f)); 136 | } 137 | 138 | union boolInVec_converter 139 | { 140 | __m128 m128; 141 | bool b; 142 | float f; 143 | int i; 144 | boolInVec_converter(int i) : i(i) {} 145 | boolInVec_converter(__m128 m128) : m128(m128) {} 146 | boolInVec_converter() {} 147 | }; 148 | 149 | inline 150 | boolInVec::boolInVec(bool scalar) 151 | { 152 | mData = _mm_set1_ps(boolInVec_converter(-(int)scalar).f); 153 | } 154 | 155 | #ifdef _VECTORMATH_NO_SCALAR_CAST 156 | inline 157 | bool 158 | boolInVec::getAsBool() const 159 | #else 160 | inline 161 | boolInVec::operator bool() const 162 | #endif 163 | { 164 | return boolInVec_converter(mData).b; 165 | } 166 | 167 | inline 168 | __m128 169 | boolInVec::get128() const 170 | { 171 | return mData; 172 | } 173 | 174 | inline 175 | const boolInVec 176 | boolInVec::operator ! () const 177 | { 178 | return boolInVec(_mm_andnot_ps(mData, _mm_cmpneq_ps(_mm_setzero_ps(),_mm_setzero_ps()))); 179 | } 180 | 181 | inline 182 | boolInVec& 183 | boolInVec::operator = (const boolInVec &vec) 184 | { 185 | mData = vec.mData; 186 | return *this; 187 | } 188 | 189 | inline 190 | boolInVec& 191 | boolInVec::operator &= (const boolInVec &vec) 192 | { 193 | *this = *this & vec; 194 | return *this; 195 | } 196 | 197 | inline 198 | boolInVec& 199 | boolInVec::operator ^= (const boolInVec &vec) 200 | { 201 | *this = *this ^ vec; 202 | return *this; 203 | } 204 | 205 | inline 206 | boolInVec& 207 | boolInVec::operator |= (const boolInVec &vec) 208 | { 209 | *this = *this | vec; 210 | return *this; 211 | } 212 | 213 | inline 214 | const boolInVec 215 | operator == (const boolInVec &vec0, const boolInVec &vec1) 216 | { 217 | return boolInVec(_mm_cmpeq_ps(vec0.get128(), vec1.get128())); 218 | } 219 | 220 | inline 221 | const boolInVec 222 | operator != (const boolInVec &vec0, const boolInVec &vec1) 223 | { 224 | return boolInVec(_mm_cmpneq_ps(vec0.get128(), vec1.get128())); 225 | } 226 | 227 | inline 228 | const boolInVec 229 | operator & (const boolInVec &vec0, const boolInVec &vec1) 230 | { 231 | return boolInVec(_mm_and_ps(vec0.get128(), vec1.get128())); 232 | } 233 | 234 | inline 235 | const boolInVec 236 | operator | (const boolInVec &vec0, const boolInVec &vec1) 237 | { 238 | return boolInVec(_mm_or_ps(vec0.get128(), vec1.get128())); 239 | } 240 | 241 | inline 242 | const boolInVec 243 | operator ^ (const boolInVec &vec0, const boolInVec &vec1) 244 | { 245 | return boolInVec(_mm_xor_ps(vec0.get128(), vec1.get128())); 246 | } 247 | 248 | inline 249 | const boolInVec 250 | select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1) 251 | { 252 | return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); 253 | } 254 | 255 | } // namespace Vectormath 256 | 257 | #endif // boolInVec_h 258 | -------------------------------------------------------------------------------- /include/vectormath/SSE/cpp/floatInVec.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2010 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _FLOATINVEC_H 31 | #define _FLOATINVEC_H 32 | 33 | #include 34 | #include 35 | 36 | namespace Vectormath { 37 | 38 | class boolInVec; 39 | 40 | //-------------------------------------------------------------------------------------------------- 41 | // floatInVec class 42 | // 43 | 44 | class floatInVec 45 | { 46 | private: 47 | __m128 mData; 48 | 49 | public: 50 | inline floatInVec(__m128 vec); 51 | 52 | inline floatInVec() {} 53 | 54 | // matches standard type conversions 55 | // 56 | inline floatInVec(const boolInVec &vec); 57 | 58 | // construct from a slot of __m128 59 | // 60 | inline floatInVec(__m128 vec, int slot); 61 | 62 | // explicit cast from float 63 | // 64 | explicit inline floatInVec(float scalar); 65 | 66 | #ifdef _VECTORMATH_NO_SCALAR_CAST 67 | // explicit cast to float 68 | // 69 | inline float getAsFloat() const; 70 | #else 71 | // implicit cast to float 72 | // 73 | inline operator float() const; 74 | #endif 75 | 76 | // get vector data 77 | // float value is splatted across all word slots of vector 78 | // 79 | inline __m128 get128() const; 80 | 81 | // operators 82 | // 83 | inline const floatInVec operator ++ (int); 84 | inline const floatInVec operator -- (int); 85 | inline floatInVec& operator ++ (); 86 | inline floatInVec& operator -- (); 87 | inline const floatInVec operator - () const; 88 | inline floatInVec& operator = (const floatInVec &vec); 89 | inline floatInVec& operator *= (const floatInVec &vec); 90 | inline floatInVec& operator /= (const floatInVec &vec); 91 | inline floatInVec& operator += (const floatInVec &vec); 92 | inline floatInVec& operator -= (const floatInVec &vec); 93 | 94 | // friend functions 95 | // 96 | friend inline const floatInVec operator * (const floatInVec &vec0, const floatInVec &vec1); 97 | friend inline const floatInVec operator / (const floatInVec &vec0, const floatInVec &vec1); 98 | friend inline const floatInVec operator + (const floatInVec &vec0, const floatInVec &vec1); 99 | friend inline const floatInVec operator - (const floatInVec &vec0, const floatInVec &vec1); 100 | friend inline const floatInVec select(const floatInVec &vec0, const floatInVec &vec1, boolInVec select_vec1); 101 | }; 102 | 103 | //-------------------------------------------------------------------------------------------------- 104 | // floatInVec functions 105 | // 106 | 107 | // operators 108 | // 109 | inline const floatInVec operator * (const floatInVec &vec0, const floatInVec &vec1); 110 | inline const floatInVec operator / (const floatInVec &vec0, const floatInVec &vec1); 111 | inline const floatInVec operator + (const floatInVec &vec0, const floatInVec &vec1); 112 | inline const floatInVec operator - (const floatInVec &vec0, const floatInVec &vec1); 113 | inline const boolInVec operator < (const floatInVec &vec0, const floatInVec &vec1); 114 | inline const boolInVec operator <= (const floatInVec &vec0, const floatInVec &vec1); 115 | inline const boolInVec operator > (const floatInVec &vec0, const floatInVec &vec1); 116 | inline const boolInVec operator >= (const floatInVec &vec0, const floatInVec &vec1); 117 | inline const boolInVec operator == (const floatInVec &vec0, const floatInVec &vec1); 118 | inline const boolInVec operator != (const floatInVec &vec0, const floatInVec &vec1); 119 | 120 | // select between vec0 and vec1 using boolInVec. 121 | // false selects vec0, true selects vec1 122 | // 123 | inline const floatInVec select(const floatInVec &vec0, const floatInVec &vec1, const boolInVec &select_vec1); 124 | 125 | } // namespace Vectormath 126 | 127 | //-------------------------------------------------------------------------------------------------- 128 | // floatInVec implementation 129 | // 130 | 131 | #include "boolInVec.h" 132 | 133 | namespace Vectormath { 134 | 135 | inline 136 | floatInVec::floatInVec(__m128 vec) 137 | { 138 | mData = vec; 139 | } 140 | 141 | inline 142 | floatInVec::floatInVec(const boolInVec &vec) 143 | { 144 | mData = vec_sel(_mm_setzero_ps(), _mm_set1_ps(1.0f), vec.get128()); 145 | } 146 | 147 | inline 148 | floatInVec::floatInVec(__m128 vec, int slot) 149 | { 150 | SSEFloat v; 151 | v.m128 = vec; 152 | mData = _mm_set1_ps(v.f[slot]); 153 | } 154 | 155 | inline 156 | floatInVec::floatInVec(float scalar) 157 | { 158 | mData = _mm_set1_ps(scalar); 159 | } 160 | 161 | #ifdef _VECTORMATH_NO_SCALAR_CAST 162 | inline 163 | float 164 | floatInVec::getAsFloat() const 165 | #else 166 | inline 167 | floatInVec::operator float() const 168 | #endif 169 | { 170 | return *((float *)&mData); 171 | } 172 | 173 | inline 174 | __m128 175 | floatInVec::get128() const 176 | { 177 | return mData; 178 | } 179 | 180 | inline 181 | const floatInVec 182 | floatInVec::operator ++ (int) 183 | { 184 | __m128 olddata = mData; 185 | operator ++(); 186 | return floatInVec(olddata); 187 | } 188 | 189 | inline 190 | const floatInVec 191 | floatInVec::operator -- (int) 192 | { 193 | __m128 olddata = mData; 194 | operator --(); 195 | return floatInVec(olddata); 196 | } 197 | 198 | inline 199 | floatInVec& 200 | floatInVec::operator ++ () 201 | { 202 | *this += floatInVec(_mm_set1_ps(1.0f)); 203 | return *this; 204 | } 205 | 206 | inline 207 | floatInVec& 208 | floatInVec::operator -- () 209 | { 210 | *this -= floatInVec(_mm_set1_ps(1.0f)); 211 | return *this; 212 | } 213 | 214 | inline 215 | const floatInVec 216 | floatInVec::operator - () const 217 | { 218 | return floatInVec(_mm_sub_ps(_mm_setzero_ps(), mData)); 219 | } 220 | 221 | inline 222 | floatInVec& 223 | floatInVec::operator = (const floatInVec &vec) 224 | { 225 | mData = vec.mData; 226 | return *this; 227 | } 228 | 229 | inline 230 | floatInVec& 231 | floatInVec::operator *= (const floatInVec &vec) 232 | { 233 | *this = *this * vec; 234 | return *this; 235 | } 236 | 237 | inline 238 | floatInVec& 239 | floatInVec::operator /= (const floatInVec &vec) 240 | { 241 | *this = *this / vec; 242 | return *this; 243 | } 244 | 245 | inline 246 | floatInVec& 247 | floatInVec::operator += (const floatInVec &vec) 248 | { 249 | *this = *this + vec; 250 | return *this; 251 | } 252 | 253 | inline 254 | floatInVec& 255 | floatInVec::operator -= (const floatInVec &vec) 256 | { 257 | *this = *this - vec; 258 | return *this; 259 | } 260 | 261 | inline 262 | const floatInVec 263 | operator * (const floatInVec &vec0, const floatInVec &vec1) 264 | { 265 | return floatInVec(_mm_mul_ps(vec0.get128(), vec1.get128())); 266 | } 267 | 268 | inline 269 | const floatInVec 270 | operator / (const floatInVec &num, const floatInVec &den) 271 | { 272 | return floatInVec(_mm_div_ps(num.get128(), den.get128())); 273 | } 274 | 275 | inline 276 | const floatInVec 277 | operator + (const floatInVec &vec0, const floatInVec &vec1) 278 | { 279 | return floatInVec(_mm_add_ps(vec0.get128(), vec1.get128())); 280 | } 281 | 282 | inline 283 | const floatInVec 284 | operator - (const floatInVec &vec0, const floatInVec &vec1) 285 | { 286 | return floatInVec(_mm_sub_ps(vec0.get128(), vec1.get128())); 287 | } 288 | 289 | inline 290 | const boolInVec 291 | operator < (const floatInVec &vec0, const floatInVec &vec1) 292 | { 293 | return boolInVec(_mm_cmpgt_ps(vec1.get128(), vec0.get128())); 294 | } 295 | 296 | inline 297 | const boolInVec 298 | operator <= (const floatInVec &vec0, const floatInVec &vec1) 299 | { 300 | return boolInVec(_mm_cmpge_ps(vec1.get128(), vec0.get128())); 301 | } 302 | 303 | inline 304 | const boolInVec 305 | operator > (const floatInVec &vec0, const floatInVec &vec1) 306 | { 307 | return boolInVec(_mm_cmpgt_ps(vec0.get128(), vec1.get128())); 308 | } 309 | 310 | inline 311 | const boolInVec 312 | operator >= (const floatInVec &vec0, const floatInVec &vec1) 313 | { 314 | return boolInVec(_mm_cmpge_ps(vec0.get128(), vec1.get128())); 315 | } 316 | 317 | inline 318 | const boolInVec 319 | operator == (const floatInVec &vec0, const floatInVec &vec1) 320 | { 321 | return boolInVec(_mm_cmpeq_ps(vec0.get128(), vec1.get128())); 322 | } 323 | 324 | inline 325 | const boolInVec 326 | operator != (const floatInVec &vec0, const floatInVec &vec1) 327 | { 328 | return boolInVec(_mm_cmpneq_ps(vec0.get128(), vec1.get128())); 329 | } 330 | 331 | inline 332 | const floatInVec 333 | select(const floatInVec &vec0, const floatInVec &vec1, const boolInVec &select_vec1) 334 | { 335 | return floatInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); 336 | } 337 | 338 | } // namespace Vectormath 339 | 340 | #endif // floatInVec_h 341 | -------------------------------------------------------------------------------- /include/vectormath/SSE/cpp/readme_e.txt: -------------------------------------------------------------------------------- 1 | This folder contains an SSE implementation of the c++ aos component of the vectormath library as used by PSSG. -------------------------------------------------------------------------------- /include/vectormath/SSE/cpp/vecidx_aos.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2010 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _VECTORMATH_VECIDX_AOS_H 31 | #define _VECTORMATH_VECIDX_AOS_H 32 | 33 | 34 | #include "floatInVec.h" 35 | 36 | namespace Vectormath { 37 | namespace Aos { 38 | 39 | //----------------------------------------------------------------------------- 40 | // VecIdx 41 | // Used in setting elements of Vector3, Vector4, Point3, or Quat with the 42 | // subscripting operator. 43 | // 44 | 45 | VM_ATTRIBUTE_ALIGNED_CLASS16 (class) VecIdx 46 | { 47 | private: 48 | __m128 &ref; 49 | int i; 50 | public: 51 | inline VecIdx( __m128& vec, int idx ): ref(vec) { i = idx; } 52 | 53 | // implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined 54 | // in which case, implicitly casts to floatInVec, and one must call 55 | // getAsFloat to convert to float. 56 | // 57 | #ifdef _VECTORMATH_NO_SCALAR_CAST 58 | inline operator floatInVec() const; 59 | inline float getAsFloat() const; 60 | #else 61 | inline operator float() const; 62 | #endif 63 | 64 | inline float operator =( float scalar ); 65 | inline floatInVec operator =( const floatInVec &scalar ); 66 | inline floatInVec operator =( const VecIdx& scalar ); 67 | inline floatInVec operator *=( float scalar ); 68 | inline floatInVec operator *=( const floatInVec &scalar ); 69 | inline floatInVec operator /=( float scalar ); 70 | inline floatInVec operator /=( const floatInVec &scalar ); 71 | inline floatInVec operator +=( float scalar ); 72 | inline floatInVec operator +=( const floatInVec &scalar ); 73 | inline floatInVec operator -=( float scalar ); 74 | inline floatInVec operator -=( const floatInVec &scalar ); 75 | }; 76 | 77 | } // namespace Aos 78 | } // namespace Vectormath 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /include/vectormath/ppu/c/quat_aos_v.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _VECTORMATH_QUAT_AOS_V_C_H 31 | #define _VECTORMATH_QUAT_AOS_V_C_H 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | /*----------------------------------------------------------------------------- 37 | * Definitions 38 | */ 39 | #ifndef _VECTORMATH_INTERNAL_FUNCTIONS 40 | #define _VECTORMATH_INTERNAL_FUNCTIONS 41 | 42 | #endif 43 | 44 | static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) 45 | { 46 | VmathQuat result; 47 | vmathQMakeFromElems(&result, _x, _y, _z, _w); 48 | return result; 49 | } 50 | 51 | static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) 52 | { 53 | VmathQuat result; 54 | vmathQMakeFromV3Scalar(&result, &xyz, _w); 55 | return result; 56 | } 57 | 58 | static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) 59 | { 60 | VmathQuat result; 61 | vmathQMakeFromV4(&result, &vec); 62 | return result; 63 | } 64 | 65 | static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) 66 | { 67 | VmathQuat result; 68 | vmathQMakeFromScalar(&result, scalar); 69 | return result; 70 | } 71 | 72 | static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ) 73 | { 74 | VmathQuat result; 75 | vmathQMakeFrom128(&result, vf4); 76 | return result; 77 | } 78 | 79 | static inline VmathQuat vmathQMakeIdentity_V( ) 80 | { 81 | VmathQuat result; 82 | vmathQMakeIdentity(&result); 83 | return result; 84 | } 85 | 86 | static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) 87 | { 88 | VmathQuat result; 89 | vmathQLerp(&result, t, &quat0, &quat1); 90 | return result; 91 | } 92 | 93 | static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) 94 | { 95 | VmathQuat result; 96 | vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); 97 | return result; 98 | } 99 | 100 | static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) 101 | { 102 | VmathQuat result; 103 | vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); 104 | return result; 105 | } 106 | 107 | static inline vec_float4 vmathQGet128_V( VmathQuat quat ) 108 | { 109 | return vmathQGet128(&quat); 110 | } 111 | 112 | static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) 113 | { 114 | vmathQSetXYZ(result, &vec); 115 | } 116 | 117 | static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) 118 | { 119 | VmathVector3 result; 120 | vmathQGetXYZ(&result, &quat); 121 | return result; 122 | } 123 | 124 | static inline void vmathQSetX_V( VmathQuat *result, float _x ) 125 | { 126 | vmathQSetX(result, _x); 127 | } 128 | 129 | static inline float vmathQGetX_V( VmathQuat quat ) 130 | { 131 | return vmathQGetX(&quat); 132 | } 133 | 134 | static inline void vmathQSetY_V( VmathQuat *result, float _y ) 135 | { 136 | vmathQSetY(result, _y); 137 | } 138 | 139 | static inline float vmathQGetY_V( VmathQuat quat ) 140 | { 141 | return vmathQGetY(&quat); 142 | } 143 | 144 | static inline void vmathQSetZ_V( VmathQuat *result, float _z ) 145 | { 146 | vmathQSetZ(result, _z); 147 | } 148 | 149 | static inline float vmathQGetZ_V( VmathQuat quat ) 150 | { 151 | return vmathQGetZ(&quat); 152 | } 153 | 154 | static inline void vmathQSetW_V( VmathQuat *result, float _w ) 155 | { 156 | vmathQSetW(result, _w); 157 | } 158 | 159 | static inline float vmathQGetW_V( VmathQuat quat ) 160 | { 161 | return vmathQGetW(&quat); 162 | } 163 | 164 | static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) 165 | { 166 | vmathQSetElem(result, idx, value); 167 | } 168 | 169 | static inline float vmathQGetElem_V( VmathQuat quat, int idx ) 170 | { 171 | return vmathQGetElem(&quat, idx); 172 | } 173 | 174 | static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) 175 | { 176 | VmathQuat result; 177 | vmathQAdd(&result, &quat0, &quat1); 178 | return result; 179 | } 180 | 181 | static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) 182 | { 183 | VmathQuat result; 184 | vmathQSub(&result, &quat0, &quat1); 185 | return result; 186 | } 187 | 188 | static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) 189 | { 190 | VmathQuat result; 191 | vmathQScalarMul(&result, &quat, scalar); 192 | return result; 193 | } 194 | 195 | static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) 196 | { 197 | VmathQuat result; 198 | vmathQScalarDiv(&result, &quat, scalar); 199 | return result; 200 | } 201 | 202 | static inline VmathQuat vmathQNeg_V( VmathQuat quat ) 203 | { 204 | VmathQuat result; 205 | vmathQNeg(&result, &quat); 206 | return result; 207 | } 208 | 209 | static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) 210 | { 211 | return vmathQDot(&quat0, &quat1); 212 | } 213 | 214 | static inline float vmathQNorm_V( VmathQuat quat ) 215 | { 216 | return vmathQNorm(&quat); 217 | } 218 | 219 | static inline float vmathQLength_V( VmathQuat quat ) 220 | { 221 | return vmathQLength(&quat); 222 | } 223 | 224 | static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) 225 | { 226 | VmathQuat result; 227 | vmathQNormalize(&result, &quat); 228 | return result; 229 | } 230 | 231 | static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) 232 | { 233 | VmathQuat result; 234 | vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); 235 | return result; 236 | } 237 | 238 | static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) 239 | { 240 | VmathQuat result; 241 | vmathQMakeRotationAxis(&result, radians, &unitVec); 242 | return result; 243 | } 244 | 245 | static inline VmathQuat vmathQMakeRotationX_V( float radians ) 246 | { 247 | VmathQuat result; 248 | vmathQMakeRotationX(&result, radians); 249 | return result; 250 | } 251 | 252 | static inline VmathQuat vmathQMakeRotationY_V( float radians ) 253 | { 254 | VmathQuat result; 255 | vmathQMakeRotationY(&result, radians); 256 | return result; 257 | } 258 | 259 | static inline VmathQuat vmathQMakeRotationZ_V( float radians ) 260 | { 261 | VmathQuat result; 262 | vmathQMakeRotationZ(&result, radians); 263 | return result; 264 | } 265 | 266 | static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) 267 | { 268 | VmathQuat result; 269 | vmathQMul(&result, &quat0, &quat1); 270 | return result; 271 | } 272 | 273 | static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) 274 | { 275 | VmathVector3 result; 276 | vmathQRotate(&result, &quat, &vec); 277 | return result; 278 | } 279 | 280 | static inline VmathQuat vmathQConj_V( VmathQuat quat ) 281 | { 282 | VmathQuat result; 283 | vmathQConj(&result, &quat); 284 | return result; 285 | } 286 | 287 | static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) 288 | { 289 | VmathQuat result; 290 | vmathQSelect(&result, &quat0, &quat1, select1); 291 | return result; 292 | } 293 | 294 | #ifdef _VECTORMATH_DEBUG 295 | 296 | static inline void vmathQPrint_V( VmathQuat quat ) 297 | { 298 | vmathQPrint(&quat); 299 | } 300 | 301 | static inline void vmathQPrints_V( VmathQuat quat, const char *name ) 302 | { 303 | vmathQPrints(&quat, name); 304 | } 305 | 306 | #endif 307 | 308 | #ifdef __cplusplus 309 | } 310 | #endif /* __cplusplus */ 311 | 312 | #endif 313 | -------------------------------------------------------------------------------- /include/vectormath/ppu/c/quat_soa_v.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _VECTORMATH_QUAT_SOA_V_C_H 31 | #define _VECTORMATH_QUAT_SOA_V_C_H 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | /*----------------------------------------------------------------------------- 37 | * Definitions 38 | */ 39 | #ifndef _VECTORMATH_INTERNAL_FUNCTIONS 40 | #define _VECTORMATH_INTERNAL_FUNCTIONS 41 | 42 | #endif 43 | 44 | static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) 45 | { 46 | VmathSoaQuat result; 47 | vmathSoaQMakeFromElems(&result, _x, _y, _z, _w); 48 | return result; 49 | } 50 | 51 | static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) 52 | { 53 | VmathSoaQuat result; 54 | vmathSoaQMakeFromV3Scalar(&result, &xyz, _w); 55 | return result; 56 | } 57 | 58 | static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ) 59 | { 60 | VmathSoaQuat result; 61 | vmathSoaQMakeFromV4(&result, &vec); 62 | return result; 63 | } 64 | 65 | static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ) 66 | { 67 | VmathSoaQuat result; 68 | vmathSoaQMakeFromScalar(&result, scalar); 69 | return result; 70 | } 71 | 72 | static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ) 73 | { 74 | VmathSoaQuat result; 75 | vmathSoaQMakeFromAos(&result, &quat); 76 | return result; 77 | } 78 | 79 | static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ) 80 | { 81 | VmathSoaQuat result; 82 | vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3); 83 | return result; 84 | } 85 | 86 | static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ) 87 | { 88 | VmathSoaQuat result; 89 | vmathSoaQMakeIdentity(&result); 90 | return result; 91 | } 92 | 93 | static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ) 94 | { 95 | VmathSoaQuat result; 96 | vmathSoaQLerp(&result, t, &quat0, &quat1); 97 | return result; 98 | } 99 | 100 | static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ) 101 | { 102 | VmathSoaQuat result; 103 | vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1); 104 | return result; 105 | } 106 | 107 | static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ) 108 | { 109 | VmathSoaQuat result; 110 | vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); 111 | return result; 112 | } 113 | 114 | static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) 115 | { 116 | vmathSoaQGet4Aos(&quat, result0, result1, result2, result3); 117 | } 118 | 119 | static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ) 120 | { 121 | vmathSoaQSetXYZ(result, &vec); 122 | } 123 | 124 | static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ) 125 | { 126 | VmathSoaVector3 result; 127 | vmathSoaQGetXYZ(&result, &quat); 128 | return result; 129 | } 130 | 131 | static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x ) 132 | { 133 | vmathSoaQSetX(result, _x); 134 | } 135 | 136 | static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ) 137 | { 138 | return vmathSoaQGetX(&quat); 139 | } 140 | 141 | static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y ) 142 | { 143 | vmathSoaQSetY(result, _y); 144 | } 145 | 146 | static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ) 147 | { 148 | return vmathSoaQGetY(&quat); 149 | } 150 | 151 | static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z ) 152 | { 153 | vmathSoaQSetZ(result, _z); 154 | } 155 | 156 | static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ) 157 | { 158 | return vmathSoaQGetZ(&quat); 159 | } 160 | 161 | static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w ) 162 | { 163 | vmathSoaQSetW(result, _w); 164 | } 165 | 166 | static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ) 167 | { 168 | return vmathSoaQGetW(&quat); 169 | } 170 | 171 | static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ) 172 | { 173 | vmathSoaQSetElem(result, idx, value); 174 | } 175 | 176 | static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ) 177 | { 178 | return vmathSoaQGetElem(&quat, idx); 179 | } 180 | 181 | static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) 182 | { 183 | VmathSoaQuat result; 184 | vmathSoaQAdd(&result, &quat0, &quat1); 185 | return result; 186 | } 187 | 188 | static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) 189 | { 190 | VmathSoaQuat result; 191 | vmathSoaQSub(&result, &quat0, &quat1); 192 | return result; 193 | } 194 | 195 | static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ) 196 | { 197 | VmathSoaQuat result; 198 | vmathSoaQScalarMul(&result, &quat, scalar); 199 | return result; 200 | } 201 | 202 | static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ) 203 | { 204 | VmathSoaQuat result; 205 | vmathSoaQScalarDiv(&result, &quat, scalar); 206 | return result; 207 | } 208 | 209 | static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ) 210 | { 211 | VmathSoaQuat result; 212 | vmathSoaQNeg(&result, &quat); 213 | return result; 214 | } 215 | 216 | static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) 217 | { 218 | return vmathSoaQDot(&quat0, &quat1); 219 | } 220 | 221 | static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ) 222 | { 223 | return vmathSoaQNorm(&quat); 224 | } 225 | 226 | static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ) 227 | { 228 | return vmathSoaQLength(&quat); 229 | } 230 | 231 | static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ) 232 | { 233 | VmathSoaQuat result; 234 | vmathSoaQNormalize(&result, &quat); 235 | return result; 236 | } 237 | 238 | static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) 239 | { 240 | VmathSoaQuat result; 241 | vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1); 242 | return result; 243 | } 244 | 245 | static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) 246 | { 247 | VmathSoaQuat result; 248 | vmathSoaQMakeRotationAxis(&result, radians, &unitVec); 249 | return result; 250 | } 251 | 252 | static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ) 253 | { 254 | VmathSoaQuat result; 255 | vmathSoaQMakeRotationX(&result, radians); 256 | return result; 257 | } 258 | 259 | static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ) 260 | { 261 | VmathSoaQuat result; 262 | vmathSoaQMakeRotationY(&result, radians); 263 | return result; 264 | } 265 | 266 | static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ) 267 | { 268 | VmathSoaQuat result; 269 | vmathSoaQMakeRotationZ(&result, radians); 270 | return result; 271 | } 272 | 273 | static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) 274 | { 275 | VmathSoaQuat result; 276 | vmathSoaQMul(&result, &quat0, &quat1); 277 | return result; 278 | } 279 | 280 | static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec ) 281 | { 282 | VmathSoaVector3 result; 283 | vmathSoaQRotate(&result, &quat, &vec); 284 | return result; 285 | } 286 | 287 | static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ) 288 | { 289 | VmathSoaQuat result; 290 | vmathSoaQConj(&result, &quat); 291 | return result; 292 | } 293 | 294 | static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ) 295 | { 296 | VmathSoaQuat result; 297 | vmathSoaQSelect(&result, &quat0, &quat1, select1); 298 | return result; 299 | } 300 | 301 | #ifdef _VECTORMATH_DEBUG 302 | 303 | static inline void vmathSoaQPrint_V( VmathSoaQuat quat ) 304 | { 305 | vmathSoaQPrint(&quat); 306 | } 307 | 308 | static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ) 309 | { 310 | vmathSoaQPrints(&quat, name); 311 | } 312 | 313 | #endif 314 | 315 | #ifdef __cplusplus 316 | } 317 | #endif /* __cplusplus */ 318 | 319 | #endif 320 | -------------------------------------------------------------------------------- /include/vectormath/ppu/c/vec_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* Single token vector data types for the PowerPC SIMD/Vector Multi-media 31 | eXtension */ 32 | 33 | #ifndef _VEC_TYPES_H_ 34 | #define _VEC_TYPES_H_ 1 35 | 36 | #define qword vector unsigned char 37 | 38 | #define vec_uchar16 vector unsigned char 39 | #define vec_char16 vector signed char 40 | #define vec_bchar16 vector bool char 41 | 42 | #define vec_ushort8 vector unsigned short 43 | #define vec_short8 vector signed short 44 | #define vec_bshort8 vector bool short 45 | 46 | #define vec_pixel8 vector pixel 47 | 48 | #define vec_uint4 vector unsigned int 49 | #define vec_int4 vector signed int 50 | #define vec_bint4 vector bool int 51 | 52 | #define vec_float4 vector float 53 | 54 | #define vec_ullong2 vector bool char 55 | #define vec_llong2 vector bool short 56 | 57 | #define vec_double2 vector bool int 58 | 59 | #endif /* _VEC_TYPES_H_ */ 60 | -------------------------------------------------------------------------------- /include/vectormath/ppu/cpp/boolInVec.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _BOOLINVEC_H 31 | #define _BOOLINVEC_H 32 | 33 | #include 34 | #include 35 | #include "../c/vec_types.h" 36 | #undef bool 37 | 38 | namespace Vectormath { 39 | 40 | class floatInVec; 41 | 42 | //-------------------------------------------------------------------------------------------------- 43 | // boolInVec class 44 | // 45 | 46 | class boolInVec 47 | { 48 | private: 49 | vec_uint4 mData; 50 | 51 | inline boolInVec(vec_uint4 vec); 52 | public: 53 | inline boolInVec() {} 54 | 55 | // matches standard type conversions 56 | // 57 | inline boolInVec(floatInVec vec); 58 | 59 | // explicit cast from bool 60 | // 61 | explicit inline boolInVec(bool scalar); 62 | 63 | #ifdef _VECTORMATH_NO_SCALAR_CAST 64 | // explicit cast to bool 65 | // 66 | inline bool getAsBool() const; 67 | #else 68 | // implicit cast to bool 69 | // 70 | inline operator bool() const; 71 | #endif 72 | 73 | // get vector data 74 | // bool value is splatted across all word slots of vector as 0 (false) or -1 (true) 75 | // 76 | inline vec_uint4 get128() const; 77 | 78 | // operators 79 | // 80 | inline const boolInVec operator ! () const; 81 | inline boolInVec& operator = (boolInVec vec); 82 | inline boolInVec& operator &= (boolInVec vec); 83 | inline boolInVec& operator ^= (boolInVec vec); 84 | inline boolInVec& operator |= (boolInVec vec); 85 | 86 | // friend functions 87 | // 88 | friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); 89 | friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); 90 | friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); 91 | friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); 92 | friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); 93 | friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); 94 | friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); 95 | friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); 96 | friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); 97 | friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); 98 | friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); 99 | friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); 100 | }; 101 | 102 | //-------------------------------------------------------------------------------------------------- 103 | // boolInVec functions 104 | // 105 | 106 | // operators 107 | // 108 | inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); 109 | inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); 110 | inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); 111 | inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); 112 | inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); 113 | 114 | // select between vec0 and vec1 using boolInVec. 115 | // false selects vec0, true selects vec1 116 | // 117 | inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); 118 | 119 | } // namespace Vectormath 120 | 121 | //-------------------------------------------------------------------------------------------------- 122 | // boolInVec implementation 123 | // 124 | 125 | #include "floatInVec.h" 126 | 127 | namespace Vectormath { 128 | 129 | inline 130 | boolInVec::boolInVec(vec_uint4 vec) 131 | { 132 | mData = vec; 133 | } 134 | 135 | inline 136 | boolInVec::boolInVec(floatInVec vec) 137 | { 138 | *this = (vec != floatInVec(0.0f)); 139 | } 140 | 141 | inline 142 | boolInVec::boolInVec(bool scalar) 143 | { 144 | #ifdef __GNUC__ 145 | if (__builtin_constant_p(scalar)) 146 | { 147 | const unsigned int mask = -(int)scalar; 148 | mData = (vec_uint4){mask, mask, mask, mask}; 149 | } 150 | else 151 | #endif 152 | { 153 | unsigned int mask = -(int)scalar; 154 | vec_uint4 vec = vec_ld(0, &mask); 155 | mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &mask)), 0); 156 | } 157 | } 158 | 159 | #ifdef _VECTORMATH_NO_SCALAR_CAST 160 | inline 161 | bool 162 | boolInVec::getAsBool() const 163 | #else 164 | inline 165 | boolInVec::operator bool() const 166 | #endif 167 | { 168 | return vec_all_gt(mData, ((vec_uint4){0,0,0,0})); 169 | } 170 | 171 | inline 172 | vec_uint4 173 | boolInVec::get128() const 174 | { 175 | return mData; 176 | } 177 | 178 | inline 179 | const boolInVec 180 | boolInVec::operator ! () const 181 | { 182 | return boolInVec(vec_nor(mData, mData)); 183 | } 184 | 185 | inline 186 | boolInVec& 187 | boolInVec::operator = (boolInVec vec) 188 | { 189 | mData = vec.mData; 190 | return *this; 191 | } 192 | 193 | inline 194 | boolInVec& 195 | boolInVec::operator &= (boolInVec vec) 196 | { 197 | *this = *this & vec; 198 | return *this; 199 | } 200 | 201 | inline 202 | boolInVec& 203 | boolInVec::operator ^= (boolInVec vec) 204 | { 205 | *this = *this ^ vec; 206 | return *this; 207 | } 208 | 209 | inline 210 | boolInVec& 211 | boolInVec::operator |= (boolInVec vec) 212 | { 213 | *this = *this | vec; 214 | return *this; 215 | } 216 | 217 | inline 218 | const boolInVec 219 | operator == (boolInVec vec0, boolInVec vec1) 220 | { 221 | return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128())); 222 | } 223 | 224 | inline 225 | const boolInVec 226 | operator != (boolInVec vec0, boolInVec vec1) 227 | { 228 | return !(vec0 == vec1); 229 | } 230 | 231 | inline 232 | const boolInVec 233 | operator & (boolInVec vec0, boolInVec vec1) 234 | { 235 | return boolInVec(vec_and(vec0.get128(), vec1.get128())); 236 | } 237 | 238 | inline 239 | const boolInVec 240 | operator | (boolInVec vec0, boolInVec vec1) 241 | { 242 | return boolInVec(vec_or(vec0.get128(), vec1.get128())); 243 | } 244 | 245 | inline 246 | const boolInVec 247 | operator ^ (boolInVec vec0, boolInVec vec1) 248 | { 249 | return boolInVec(vec_xor(vec0.get128(), vec1.get128())); 250 | } 251 | 252 | inline 253 | const boolInVec 254 | select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1) 255 | { 256 | return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); 257 | } 258 | 259 | } // namespace Vectormath 260 | 261 | #endif // boolInVec_h 262 | -------------------------------------------------------------------------------- /include/vectormath/ppu/cpp/vecidx_aos.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _VECTORMATH_VECIDX_AOS_H 31 | #define _VECTORMATH_VECIDX_AOS_H 32 | 33 | #include "floatInVec.h" 34 | 35 | namespace Vectormath { 36 | namespace Aos { 37 | 38 | //----------------------------------------------------------------------------- 39 | // VecIdx 40 | // Used in setting elements of Vector3, Vector4, Point3, or Quat with the 41 | // subscripting operator. 42 | // 43 | 44 | class VecIdx 45 | { 46 | private: 47 | typedef vec_float4 vec_float4_t; 48 | vec_float4_t &ref __attribute__ ((aligned(16))); 49 | int i __attribute__ ((aligned(16))); 50 | public: 51 | inline VecIdx( vec_float4_t& vec, int idx ): ref(vec) { i = idx; } 52 | 53 | // implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined 54 | // in which case, implicitly casts to floatInVec, and one must call 55 | // getAsFloat to convert to float. 56 | // 57 | #ifdef _VECTORMATH_NO_SCALAR_CAST 58 | inline operator floatInVec() const; 59 | inline float getAsFloat() const; 60 | #else 61 | inline operator float() const; 62 | #endif 63 | 64 | inline float operator =( float scalar ); 65 | inline floatInVec operator =( floatInVec scalar ); 66 | inline floatInVec operator =( const VecIdx& scalar ); 67 | inline floatInVec operator *=( float scalar ); 68 | inline floatInVec operator *=( floatInVec scalar ); 69 | inline floatInVec operator /=( float scalar ); 70 | inline floatInVec operator /=( floatInVec scalar ); 71 | inline floatInVec operator +=( float scalar ); 72 | inline floatInVec operator +=( floatInVec scalar ); 73 | inline floatInVec operator -=( float scalar ); 74 | inline floatInVec operator -=( floatInVec scalar ); 75 | }; 76 | 77 | } // namespace Aos 78 | } // namespace Vectormath 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /include/vectormath/scalar/c/quat_aos_v.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _VECTORMATH_QUAT_AOS_V_C_H 31 | #define _VECTORMATH_QUAT_AOS_V_C_H 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | /*----------------------------------------------------------------------------- 37 | * Definitions 38 | */ 39 | #ifndef _VECTORMATH_INTERNAL_FUNCTIONS 40 | #define _VECTORMATH_INTERNAL_FUNCTIONS 41 | 42 | #endif 43 | 44 | static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) 45 | { 46 | VmathQuat result; 47 | vmathQMakeFromElems(&result, _x, _y, _z, _w); 48 | return result; 49 | } 50 | 51 | static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) 52 | { 53 | VmathQuat result; 54 | vmathQMakeFromV3Scalar(&result, &xyz, _w); 55 | return result; 56 | } 57 | 58 | static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) 59 | { 60 | VmathQuat result; 61 | vmathQMakeFromV4(&result, &vec); 62 | return result; 63 | } 64 | 65 | static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) 66 | { 67 | VmathQuat result; 68 | vmathQMakeFromScalar(&result, scalar); 69 | return result; 70 | } 71 | 72 | static inline VmathQuat vmathQMakeIdentity_V( ) 73 | { 74 | VmathQuat result; 75 | vmathQMakeIdentity(&result); 76 | return result; 77 | } 78 | 79 | static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) 80 | { 81 | VmathQuat result; 82 | vmathQLerp(&result, t, &quat0, &quat1); 83 | return result; 84 | } 85 | 86 | static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) 87 | { 88 | VmathQuat result; 89 | vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); 90 | return result; 91 | } 92 | 93 | static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) 94 | { 95 | VmathQuat result; 96 | vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); 97 | return result; 98 | } 99 | 100 | static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) 101 | { 102 | vmathQSetXYZ(result, &vec); 103 | } 104 | 105 | static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) 106 | { 107 | VmathVector3 result; 108 | vmathQGetXYZ(&result, &quat); 109 | return result; 110 | } 111 | 112 | static inline void vmathQSetX_V( VmathQuat *result, float _x ) 113 | { 114 | vmathQSetX(result, _x); 115 | } 116 | 117 | static inline float vmathQGetX_V( VmathQuat quat ) 118 | { 119 | return vmathQGetX(&quat); 120 | } 121 | 122 | static inline void vmathQSetY_V( VmathQuat *result, float _y ) 123 | { 124 | vmathQSetY(result, _y); 125 | } 126 | 127 | static inline float vmathQGetY_V( VmathQuat quat ) 128 | { 129 | return vmathQGetY(&quat); 130 | } 131 | 132 | static inline void vmathQSetZ_V( VmathQuat *result, float _z ) 133 | { 134 | vmathQSetZ(result, _z); 135 | } 136 | 137 | static inline float vmathQGetZ_V( VmathQuat quat ) 138 | { 139 | return vmathQGetZ(&quat); 140 | } 141 | 142 | static inline void vmathQSetW_V( VmathQuat *result, float _w ) 143 | { 144 | vmathQSetW(result, _w); 145 | } 146 | 147 | static inline float vmathQGetW_V( VmathQuat quat ) 148 | { 149 | return vmathQGetW(&quat); 150 | } 151 | 152 | static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) 153 | { 154 | vmathQSetElem(result, idx, value); 155 | } 156 | 157 | static inline float vmathQGetElem_V( VmathQuat quat, int idx ) 158 | { 159 | return vmathQGetElem(&quat, idx); 160 | } 161 | 162 | static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) 163 | { 164 | VmathQuat result; 165 | vmathQAdd(&result, &quat0, &quat1); 166 | return result; 167 | } 168 | 169 | static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) 170 | { 171 | VmathQuat result; 172 | vmathQSub(&result, &quat0, &quat1); 173 | return result; 174 | } 175 | 176 | static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) 177 | { 178 | VmathQuat result; 179 | vmathQScalarMul(&result, &quat, scalar); 180 | return result; 181 | } 182 | 183 | static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) 184 | { 185 | VmathQuat result; 186 | vmathQScalarDiv(&result, &quat, scalar); 187 | return result; 188 | } 189 | 190 | static inline VmathQuat vmathQNeg_V( VmathQuat quat ) 191 | { 192 | VmathQuat result; 193 | vmathQNeg(&result, &quat); 194 | return result; 195 | } 196 | 197 | static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) 198 | { 199 | return vmathQDot(&quat0, &quat1); 200 | } 201 | 202 | static inline float vmathQNorm_V( VmathQuat quat ) 203 | { 204 | return vmathQNorm(&quat); 205 | } 206 | 207 | static inline float vmathQLength_V( VmathQuat quat ) 208 | { 209 | return vmathQLength(&quat); 210 | } 211 | 212 | static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) 213 | { 214 | VmathQuat result; 215 | vmathQNormalize(&result, &quat); 216 | return result; 217 | } 218 | 219 | static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) 220 | { 221 | VmathQuat result; 222 | vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); 223 | return result; 224 | } 225 | 226 | static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) 227 | { 228 | VmathQuat result; 229 | vmathQMakeRotationAxis(&result, radians, &unitVec); 230 | return result; 231 | } 232 | 233 | static inline VmathQuat vmathQMakeRotationX_V( float radians ) 234 | { 235 | VmathQuat result; 236 | vmathQMakeRotationX(&result, radians); 237 | return result; 238 | } 239 | 240 | static inline VmathQuat vmathQMakeRotationY_V( float radians ) 241 | { 242 | VmathQuat result; 243 | vmathQMakeRotationY(&result, radians); 244 | return result; 245 | } 246 | 247 | static inline VmathQuat vmathQMakeRotationZ_V( float radians ) 248 | { 249 | VmathQuat result; 250 | vmathQMakeRotationZ(&result, radians); 251 | return result; 252 | } 253 | 254 | static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) 255 | { 256 | VmathQuat result; 257 | vmathQMul(&result, &quat0, &quat1); 258 | return result; 259 | } 260 | 261 | static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) 262 | { 263 | VmathVector3 result; 264 | vmathQRotate(&result, &quat, &vec); 265 | return result; 266 | } 267 | 268 | static inline VmathQuat vmathQConj_V( VmathQuat quat ) 269 | { 270 | VmathQuat result; 271 | vmathQConj(&result, &quat); 272 | return result; 273 | } 274 | 275 | static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) 276 | { 277 | VmathQuat result; 278 | vmathQSelect(&result, &quat0, &quat1, select1); 279 | return result; 280 | } 281 | 282 | #ifdef _VECTORMATH_DEBUG 283 | 284 | static inline void vmathQPrint_V( VmathQuat quat ) 285 | { 286 | vmathQPrint(&quat); 287 | } 288 | 289 | static inline void vmathQPrints_V( VmathQuat quat, const char *name ) 290 | { 291 | vmathQPrints(&quat, name); 292 | } 293 | 294 | #endif 295 | 296 | #ifdef __cplusplus 297 | } 298 | #endif /* __cplusplus */ 299 | 300 | #endif 301 | -------------------------------------------------------------------------------- /include/vectormath/scalar/cpp/boolInVec.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006-2010 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _BOOLINVEC_SCALAR_H 31 | #define _BOOLINVEC_SCALAR_H 32 | 33 | #include 34 | namespace Vectormath { 35 | 36 | class floatInVec; 37 | 38 | //-------------------------------------------------------------------------------------------------- 39 | // boolInVec class 40 | // 41 | 42 | class boolInVec 43 | { 44 | private: 45 | unsigned int mData; 46 | 47 | public: 48 | // Default constructor; does no initialization 49 | // 50 | inline boolInVec( ) { }; 51 | 52 | // Construct from a value converted from float 53 | // 54 | inline boolInVec(floatInVec vec); 55 | 56 | // Explicit cast from bool 57 | // 58 | explicit inline boolInVec(bool scalar); 59 | 60 | // Explicit cast to bool 61 | // 62 | inline bool getAsBool() const; 63 | 64 | #ifndef _VECTORMATH_NO_SCALAR_CAST 65 | // Implicit cast to bool 66 | // 67 | inline operator bool() const; 68 | #endif 69 | 70 | // Boolean negation operator 71 | // 72 | inline const boolInVec operator ! () const; 73 | 74 | // Assignment operator 75 | // 76 | inline boolInVec& operator = (boolInVec vec); 77 | 78 | // Boolean and assignment operator 79 | // 80 | inline boolInVec& operator &= (boolInVec vec); 81 | 82 | // Boolean exclusive or assignment operator 83 | // 84 | inline boolInVec& operator ^= (boolInVec vec); 85 | 86 | // Boolean or assignment operator 87 | // 88 | inline boolInVec& operator |= (boolInVec vec); 89 | 90 | }; 91 | 92 | // Equal operator 93 | // 94 | inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); 95 | 96 | // Not equal operator 97 | // 98 | inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); 99 | 100 | // And operator 101 | // 102 | inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); 103 | 104 | // Exclusive or operator 105 | // 106 | inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); 107 | 108 | // Or operator 109 | // 110 | inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); 111 | 112 | // Conditionally select between two values 113 | // 114 | inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); 115 | 116 | 117 | } // namespace Vectormath 118 | 119 | 120 | //-------------------------------------------------------------------------------------------------- 121 | // boolInVec implementation 122 | // 123 | 124 | #include "floatInVec.h" 125 | 126 | namespace Vectormath { 127 | 128 | inline 129 | boolInVec::boolInVec(floatInVec vec) 130 | { 131 | *this = (vec != floatInVec(0.0f)); 132 | } 133 | 134 | inline 135 | boolInVec::boolInVec(bool scalar) 136 | { 137 | mData = -(int)scalar; 138 | } 139 | 140 | inline 141 | bool 142 | boolInVec::getAsBool() const 143 | { 144 | return (mData > 0); 145 | } 146 | 147 | #ifndef _VECTORMATH_NO_SCALAR_CAST 148 | inline 149 | boolInVec::operator bool() const 150 | { 151 | return getAsBool(); 152 | } 153 | #endif 154 | 155 | inline 156 | const boolInVec 157 | boolInVec::operator ! () const 158 | { 159 | return boolInVec(!mData); 160 | } 161 | 162 | inline 163 | boolInVec& 164 | boolInVec::operator = (boolInVec vec) 165 | { 166 | mData = vec.mData; 167 | return *this; 168 | } 169 | 170 | inline 171 | boolInVec& 172 | boolInVec::operator &= (boolInVec vec) 173 | { 174 | *this = *this & vec; 175 | return *this; 176 | } 177 | 178 | inline 179 | boolInVec& 180 | boolInVec::operator ^= (boolInVec vec) 181 | { 182 | *this = *this ^ vec; 183 | return *this; 184 | } 185 | 186 | inline 187 | boolInVec& 188 | boolInVec::operator |= (boolInVec vec) 189 | { 190 | *this = *this | vec; 191 | return *this; 192 | } 193 | 194 | inline 195 | const boolInVec 196 | operator == (boolInVec vec0, boolInVec vec1) 197 | { 198 | return boolInVec(vec0.getAsBool() == vec1.getAsBool()); 199 | } 200 | 201 | inline 202 | const boolInVec 203 | operator != (boolInVec vec0, boolInVec vec1) 204 | { 205 | return !(vec0 == vec1); 206 | } 207 | 208 | inline 209 | const boolInVec 210 | operator & (boolInVec vec0, boolInVec vec1) 211 | { 212 | return boolInVec(vec0.getAsBool() & vec1.getAsBool()); 213 | } 214 | 215 | inline 216 | const boolInVec 217 | operator | (boolInVec vec0, boolInVec vec1) 218 | { 219 | return boolInVec(vec0.getAsBool() | vec1.getAsBool()); 220 | } 221 | 222 | inline 223 | const boolInVec 224 | operator ^ (boolInVec vec0, boolInVec vec1) 225 | { 226 | return boolInVec(vec0.getAsBool() ^ vec1.getAsBool()); 227 | } 228 | 229 | inline 230 | const boolInVec 231 | select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1) 232 | { 233 | return (select_vec1.getAsBool() == 0) ? vec0 : vec1; 234 | } 235 | 236 | } // namespace Vectormath 237 | 238 | #endif // boolInVec_h 239 | -------------------------------------------------------------------------------- /include/vectormath/scalar/cpp/floatInVec.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006-2010 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _FLOATINVEC__SCALAR_H 31 | #define _FLOATINVEC__SCALAR_H 32 | 33 | #include 34 | namespace Vectormath { 35 | 36 | class boolInVec; 37 | 38 | //-------------------------------------------------------------------------------------------------- 39 | // floatInVec class 40 | // 41 | 42 | // A class representing a scalar float value contained in a vector register 43 | // This class does not support fastmath 44 | class floatInVec 45 | { 46 | private: 47 | float mData; 48 | 49 | public: 50 | // Default constructor; does no initialization 51 | // 52 | inline floatInVec( ) { }; 53 | 54 | // Construct from a value converted from bool 55 | // 56 | inline floatInVec(boolInVec vec); 57 | 58 | // Explicit cast from float 59 | // 60 | explicit inline floatInVec(float scalar); 61 | 62 | // Explicit cast to float 63 | // 64 | inline float getAsFloat() const; 65 | 66 | #ifndef _VECTORMATH_NO_SCALAR_CAST 67 | // Implicit cast to float 68 | // 69 | inline operator float() const; 70 | #endif 71 | 72 | // Post increment (add 1.0f) 73 | // 74 | inline const floatInVec operator ++ (int); 75 | 76 | // Post decrement (subtract 1.0f) 77 | // 78 | inline const floatInVec operator -- (int); 79 | 80 | // Pre increment (add 1.0f) 81 | // 82 | inline floatInVec& operator ++ (); 83 | 84 | // Pre decrement (subtract 1.0f) 85 | // 86 | inline floatInVec& operator -- (); 87 | 88 | // Negation operator 89 | // 90 | inline const floatInVec operator - () const; 91 | 92 | // Assignment operator 93 | // 94 | inline floatInVec& operator = (floatInVec vec); 95 | 96 | // Multiplication assignment operator 97 | // 98 | inline floatInVec& operator *= (floatInVec vec); 99 | 100 | // Division assignment operator 101 | // 102 | inline floatInVec& operator /= (floatInVec vec); 103 | 104 | // Addition assignment operator 105 | // 106 | inline floatInVec& operator += (floatInVec vec); 107 | 108 | // Subtraction assignment operator 109 | // 110 | inline floatInVec& operator -= (floatInVec vec); 111 | 112 | }; 113 | 114 | // Multiplication operator 115 | // 116 | inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); 117 | 118 | // Division operator 119 | // 120 | inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); 121 | 122 | // Addition operator 123 | // 124 | inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); 125 | 126 | // Subtraction operator 127 | // 128 | inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); 129 | 130 | // Less than operator 131 | // 132 | inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); 133 | 134 | // Less than or equal operator 135 | // 136 | inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); 137 | 138 | // Greater than operator 139 | // 140 | inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); 141 | 142 | // Greater than or equal operator 143 | // 144 | inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); 145 | 146 | // Equal operator 147 | // 148 | inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); 149 | 150 | // Not equal operator 151 | // 152 | inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); 153 | 154 | // Conditionally select between two values 155 | // 156 | inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); 157 | 158 | 159 | } // namespace Vectormath 160 | 161 | 162 | //-------------------------------------------------------------------------------------------------- 163 | // floatInVec implementation 164 | // 165 | 166 | #include "boolInVec.h" 167 | 168 | namespace Vectormath { 169 | 170 | inline 171 | floatInVec::floatInVec(boolInVec vec) 172 | { 173 | mData = float(vec.getAsBool()); 174 | } 175 | 176 | inline 177 | floatInVec::floatInVec(float scalar) 178 | { 179 | mData = scalar; 180 | } 181 | 182 | inline 183 | float 184 | floatInVec::getAsFloat() const 185 | { 186 | return mData; 187 | } 188 | 189 | #ifndef _VECTORMATH_NO_SCALAR_CAST 190 | inline 191 | floatInVec::operator float() const 192 | { 193 | return getAsFloat(); 194 | } 195 | #endif 196 | 197 | inline 198 | const floatInVec 199 | floatInVec::operator ++ (int) 200 | { 201 | float olddata = mData; 202 | operator ++(); 203 | return floatInVec(olddata); 204 | } 205 | 206 | inline 207 | const floatInVec 208 | floatInVec::operator -- (int) 209 | { 210 | float olddata = mData; 211 | operator --(); 212 | return floatInVec(olddata); 213 | } 214 | 215 | inline 216 | floatInVec& 217 | floatInVec::operator ++ () 218 | { 219 | *this += floatInVec(1.0f); 220 | return *this; 221 | } 222 | 223 | inline 224 | floatInVec& 225 | floatInVec::operator -- () 226 | { 227 | *this -= floatInVec(1.0f); 228 | return *this; 229 | } 230 | 231 | inline 232 | const floatInVec 233 | floatInVec::operator - () const 234 | { 235 | return floatInVec(-mData); 236 | } 237 | 238 | inline 239 | floatInVec& 240 | floatInVec::operator = (floatInVec vec) 241 | { 242 | mData = vec.mData; 243 | return *this; 244 | } 245 | 246 | inline 247 | floatInVec& 248 | floatInVec::operator *= (floatInVec vec) 249 | { 250 | *this = *this * vec; 251 | return *this; 252 | } 253 | 254 | inline 255 | floatInVec& 256 | floatInVec::operator /= (floatInVec vec) 257 | { 258 | *this = *this / vec; 259 | return *this; 260 | } 261 | 262 | inline 263 | floatInVec& 264 | floatInVec::operator += (floatInVec vec) 265 | { 266 | *this = *this + vec; 267 | return *this; 268 | } 269 | 270 | inline 271 | floatInVec& 272 | floatInVec::operator -= (floatInVec vec) 273 | { 274 | *this = *this - vec; 275 | return *this; 276 | } 277 | 278 | inline 279 | const floatInVec 280 | operator * (floatInVec vec0, floatInVec vec1) 281 | { 282 | return floatInVec(vec0.getAsFloat() * vec1.getAsFloat()); 283 | } 284 | 285 | inline 286 | const floatInVec 287 | operator / (floatInVec num, floatInVec den) 288 | { 289 | return floatInVec(num.getAsFloat() / den.getAsFloat()); 290 | } 291 | 292 | inline 293 | const floatInVec 294 | operator + (floatInVec vec0, floatInVec vec1) 295 | { 296 | return floatInVec(vec0.getAsFloat() + vec1.getAsFloat()); 297 | } 298 | 299 | inline 300 | const floatInVec 301 | operator - (floatInVec vec0, floatInVec vec1) 302 | { 303 | return floatInVec(vec0.getAsFloat() - vec1.getAsFloat()); 304 | } 305 | 306 | inline 307 | const boolInVec 308 | operator < (floatInVec vec0, floatInVec vec1) 309 | { 310 | return boolInVec(vec0.getAsFloat() < vec1.getAsFloat()); 311 | } 312 | 313 | inline 314 | const boolInVec 315 | operator <= (floatInVec vec0, floatInVec vec1) 316 | { 317 | return !(vec0 > vec1); 318 | } 319 | 320 | inline 321 | const boolInVec 322 | operator > (floatInVec vec0, floatInVec vec1) 323 | { 324 | return boolInVec(vec0.getAsFloat() > vec1.getAsFloat()); 325 | } 326 | 327 | inline 328 | const boolInVec 329 | operator >= (floatInVec vec0, floatInVec vec1) 330 | { 331 | return !(vec0 < vec1); 332 | } 333 | 334 | inline 335 | const boolInVec 336 | operator == (floatInVec vec0, floatInVec vec1) 337 | { 338 | return boolInVec(vec0.getAsFloat() == vec1.getAsFloat()); 339 | } 340 | 341 | inline 342 | const boolInVec 343 | operator != (floatInVec vec0, floatInVec vec1) 344 | { 345 | return !(vec0 == vec1); 346 | } 347 | 348 | inline 349 | const floatInVec 350 | select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1) 351 | { 352 | return (select_vec1.getAsBool() == 0) ? vec0 : vec1; 353 | } 354 | 355 | } // namespace Vectormath 356 | 357 | #endif // floatInVec_h 358 | -------------------------------------------------------------------------------- /include/vectormath/spu/c/quat_aos_v.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _VECTORMATH_QUAT_AOS_V_C_H 31 | #define _VECTORMATH_QUAT_AOS_V_C_H 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | /*----------------------------------------------------------------------------- 37 | * Definitions 38 | */ 39 | #ifndef _VECTORMATH_INTERNAL_FUNCTIONS 40 | #define _VECTORMATH_INTERNAL_FUNCTIONS 41 | 42 | #endif 43 | 44 | static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) 45 | { 46 | VmathQuat result; 47 | vmathQMakeFromElems(&result, _x, _y, _z, _w); 48 | return result; 49 | } 50 | 51 | static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) 52 | { 53 | VmathQuat result; 54 | vmathQMakeFromV3Scalar(&result, &xyz, _w); 55 | return result; 56 | } 57 | 58 | static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) 59 | { 60 | VmathQuat result; 61 | vmathQMakeFromV4(&result, &vec); 62 | return result; 63 | } 64 | 65 | static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) 66 | { 67 | VmathQuat result; 68 | vmathQMakeFromScalar(&result, scalar); 69 | return result; 70 | } 71 | 72 | static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ) 73 | { 74 | VmathQuat result; 75 | vmathQMakeFrom128(&result, vf4); 76 | return result; 77 | } 78 | 79 | static inline VmathQuat vmathQMakeIdentity_V( ) 80 | { 81 | VmathQuat result; 82 | vmathQMakeIdentity(&result); 83 | return result; 84 | } 85 | 86 | static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) 87 | { 88 | VmathQuat result; 89 | vmathQLerp(&result, t, &quat0, &quat1); 90 | return result; 91 | } 92 | 93 | static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) 94 | { 95 | VmathQuat result; 96 | vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); 97 | return result; 98 | } 99 | 100 | static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) 101 | { 102 | VmathQuat result; 103 | vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); 104 | return result; 105 | } 106 | 107 | static inline vec_float4 vmathQGet128_V( VmathQuat quat ) 108 | { 109 | return vmathQGet128(&quat); 110 | } 111 | 112 | static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) 113 | { 114 | vmathQSetXYZ(result, &vec); 115 | } 116 | 117 | static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) 118 | { 119 | VmathVector3 result; 120 | vmathQGetXYZ(&result, &quat); 121 | return result; 122 | } 123 | 124 | static inline void vmathQSetX_V( VmathQuat *result, float _x ) 125 | { 126 | vmathQSetX(result, _x); 127 | } 128 | 129 | static inline float vmathQGetX_V( VmathQuat quat ) 130 | { 131 | return vmathQGetX(&quat); 132 | } 133 | 134 | static inline void vmathQSetY_V( VmathQuat *result, float _y ) 135 | { 136 | vmathQSetY(result, _y); 137 | } 138 | 139 | static inline float vmathQGetY_V( VmathQuat quat ) 140 | { 141 | return vmathQGetY(&quat); 142 | } 143 | 144 | static inline void vmathQSetZ_V( VmathQuat *result, float _z ) 145 | { 146 | vmathQSetZ(result, _z); 147 | } 148 | 149 | static inline float vmathQGetZ_V( VmathQuat quat ) 150 | { 151 | return vmathQGetZ(&quat); 152 | } 153 | 154 | static inline void vmathQSetW_V( VmathQuat *result, float _w ) 155 | { 156 | vmathQSetW(result, _w); 157 | } 158 | 159 | static inline float vmathQGetW_V( VmathQuat quat ) 160 | { 161 | return vmathQGetW(&quat); 162 | } 163 | 164 | static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) 165 | { 166 | vmathQSetElem(result, idx, value); 167 | } 168 | 169 | static inline float vmathQGetElem_V( VmathQuat quat, int idx ) 170 | { 171 | return vmathQGetElem(&quat, idx); 172 | } 173 | 174 | static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) 175 | { 176 | VmathQuat result; 177 | vmathQAdd(&result, &quat0, &quat1); 178 | return result; 179 | } 180 | 181 | static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) 182 | { 183 | VmathQuat result; 184 | vmathQSub(&result, &quat0, &quat1); 185 | return result; 186 | } 187 | 188 | static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) 189 | { 190 | VmathQuat result; 191 | vmathQScalarMul(&result, &quat, scalar); 192 | return result; 193 | } 194 | 195 | static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) 196 | { 197 | VmathQuat result; 198 | vmathQScalarDiv(&result, &quat, scalar); 199 | return result; 200 | } 201 | 202 | static inline VmathQuat vmathQNeg_V( VmathQuat quat ) 203 | { 204 | VmathQuat result; 205 | vmathQNeg(&result, &quat); 206 | return result; 207 | } 208 | 209 | static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) 210 | { 211 | return vmathQDot(&quat0, &quat1); 212 | } 213 | 214 | static inline float vmathQNorm_V( VmathQuat quat ) 215 | { 216 | return vmathQNorm(&quat); 217 | } 218 | 219 | static inline float vmathQLength_V( VmathQuat quat ) 220 | { 221 | return vmathQLength(&quat); 222 | } 223 | 224 | static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) 225 | { 226 | VmathQuat result; 227 | vmathQNormalize(&result, &quat); 228 | return result; 229 | } 230 | 231 | static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) 232 | { 233 | VmathQuat result; 234 | vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); 235 | return result; 236 | } 237 | 238 | static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) 239 | { 240 | VmathQuat result; 241 | vmathQMakeRotationAxis(&result, radians, &unitVec); 242 | return result; 243 | } 244 | 245 | static inline VmathQuat vmathQMakeRotationX_V( float radians ) 246 | { 247 | VmathQuat result; 248 | vmathQMakeRotationX(&result, radians); 249 | return result; 250 | } 251 | 252 | static inline VmathQuat vmathQMakeRotationY_V( float radians ) 253 | { 254 | VmathQuat result; 255 | vmathQMakeRotationY(&result, radians); 256 | return result; 257 | } 258 | 259 | static inline VmathQuat vmathQMakeRotationZ_V( float radians ) 260 | { 261 | VmathQuat result; 262 | vmathQMakeRotationZ(&result, radians); 263 | return result; 264 | } 265 | 266 | static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) 267 | { 268 | VmathQuat result; 269 | vmathQMul(&result, &quat0, &quat1); 270 | return result; 271 | } 272 | 273 | static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) 274 | { 275 | VmathVector3 result; 276 | vmathQRotate(&result, &quat, &vec); 277 | return result; 278 | } 279 | 280 | static inline VmathQuat vmathQConj_V( VmathQuat quat ) 281 | { 282 | VmathQuat result; 283 | vmathQConj(&result, &quat); 284 | return result; 285 | } 286 | 287 | static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) 288 | { 289 | VmathQuat result; 290 | vmathQSelect(&result, &quat0, &quat1, select1); 291 | return result; 292 | } 293 | 294 | #ifdef _VECTORMATH_DEBUG 295 | 296 | static inline void vmathQPrint_V( VmathQuat quat ) 297 | { 298 | vmathQPrint(&quat); 299 | } 300 | 301 | static inline void vmathQPrints_V( VmathQuat quat, const char *name ) 302 | { 303 | vmathQPrints(&quat, name); 304 | } 305 | 306 | #endif 307 | 308 | #ifdef __cplusplus 309 | } 310 | #endif /* __cplusplus */ 311 | 312 | #endif 313 | -------------------------------------------------------------------------------- /include/vectormath/spu/c/quat_soa_v.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _VECTORMATH_QUAT_SOA_V_C_H 31 | #define _VECTORMATH_QUAT_SOA_V_C_H 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif /* __cplusplus */ 35 | 36 | /*----------------------------------------------------------------------------- 37 | * Definitions 38 | */ 39 | #ifndef _VECTORMATH_INTERNAL_FUNCTIONS 40 | #define _VECTORMATH_INTERNAL_FUNCTIONS 41 | 42 | #endif 43 | 44 | static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) 45 | { 46 | VmathSoaQuat result; 47 | vmathSoaQMakeFromElems(&result, _x, _y, _z, _w); 48 | return result; 49 | } 50 | 51 | static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) 52 | { 53 | VmathSoaQuat result; 54 | vmathSoaQMakeFromV3Scalar(&result, &xyz, _w); 55 | return result; 56 | } 57 | 58 | static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ) 59 | { 60 | VmathSoaQuat result; 61 | vmathSoaQMakeFromV4(&result, &vec); 62 | return result; 63 | } 64 | 65 | static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ) 66 | { 67 | VmathSoaQuat result; 68 | vmathSoaQMakeFromScalar(&result, scalar); 69 | return result; 70 | } 71 | 72 | static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ) 73 | { 74 | VmathSoaQuat result; 75 | vmathSoaQMakeFromAos(&result, &quat); 76 | return result; 77 | } 78 | 79 | static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ) 80 | { 81 | VmathSoaQuat result; 82 | vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3); 83 | return result; 84 | } 85 | 86 | static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ) 87 | { 88 | VmathSoaQuat result; 89 | vmathSoaQMakeIdentity(&result); 90 | return result; 91 | } 92 | 93 | static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ) 94 | { 95 | VmathSoaQuat result; 96 | vmathSoaQLerp(&result, t, &quat0, &quat1); 97 | return result; 98 | } 99 | 100 | static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ) 101 | { 102 | VmathSoaQuat result; 103 | vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1); 104 | return result; 105 | } 106 | 107 | static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ) 108 | { 109 | VmathSoaQuat result; 110 | vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); 111 | return result; 112 | } 113 | 114 | static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) 115 | { 116 | vmathSoaQGet4Aos(&quat, result0, result1, result2, result3); 117 | } 118 | 119 | static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ) 120 | { 121 | vmathSoaQSetXYZ(result, &vec); 122 | } 123 | 124 | static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ) 125 | { 126 | VmathSoaVector3 result; 127 | vmathSoaQGetXYZ(&result, &quat); 128 | return result; 129 | } 130 | 131 | static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x ) 132 | { 133 | vmathSoaQSetX(result, _x); 134 | } 135 | 136 | static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ) 137 | { 138 | return vmathSoaQGetX(&quat); 139 | } 140 | 141 | static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y ) 142 | { 143 | vmathSoaQSetY(result, _y); 144 | } 145 | 146 | static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ) 147 | { 148 | return vmathSoaQGetY(&quat); 149 | } 150 | 151 | static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z ) 152 | { 153 | vmathSoaQSetZ(result, _z); 154 | } 155 | 156 | static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ) 157 | { 158 | return vmathSoaQGetZ(&quat); 159 | } 160 | 161 | static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w ) 162 | { 163 | vmathSoaQSetW(result, _w); 164 | } 165 | 166 | static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ) 167 | { 168 | return vmathSoaQGetW(&quat); 169 | } 170 | 171 | static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ) 172 | { 173 | vmathSoaQSetElem(result, idx, value); 174 | } 175 | 176 | static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ) 177 | { 178 | return vmathSoaQGetElem(&quat, idx); 179 | } 180 | 181 | static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) 182 | { 183 | VmathSoaQuat result; 184 | vmathSoaQAdd(&result, &quat0, &quat1); 185 | return result; 186 | } 187 | 188 | static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) 189 | { 190 | VmathSoaQuat result; 191 | vmathSoaQSub(&result, &quat0, &quat1); 192 | return result; 193 | } 194 | 195 | static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ) 196 | { 197 | VmathSoaQuat result; 198 | vmathSoaQScalarMul(&result, &quat, scalar); 199 | return result; 200 | } 201 | 202 | static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ) 203 | { 204 | VmathSoaQuat result; 205 | vmathSoaQScalarDiv(&result, &quat, scalar); 206 | return result; 207 | } 208 | 209 | static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ) 210 | { 211 | VmathSoaQuat result; 212 | vmathSoaQNeg(&result, &quat); 213 | return result; 214 | } 215 | 216 | static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) 217 | { 218 | return vmathSoaQDot(&quat0, &quat1); 219 | } 220 | 221 | static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ) 222 | { 223 | return vmathSoaQNorm(&quat); 224 | } 225 | 226 | static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ) 227 | { 228 | return vmathSoaQLength(&quat); 229 | } 230 | 231 | static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ) 232 | { 233 | VmathSoaQuat result; 234 | vmathSoaQNormalize(&result, &quat); 235 | return result; 236 | } 237 | 238 | static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) 239 | { 240 | VmathSoaQuat result; 241 | vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1); 242 | return result; 243 | } 244 | 245 | static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) 246 | { 247 | VmathSoaQuat result; 248 | vmathSoaQMakeRotationAxis(&result, radians, &unitVec); 249 | return result; 250 | } 251 | 252 | static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ) 253 | { 254 | VmathSoaQuat result; 255 | vmathSoaQMakeRotationX(&result, radians); 256 | return result; 257 | } 258 | 259 | static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ) 260 | { 261 | VmathSoaQuat result; 262 | vmathSoaQMakeRotationY(&result, radians); 263 | return result; 264 | } 265 | 266 | static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ) 267 | { 268 | VmathSoaQuat result; 269 | vmathSoaQMakeRotationZ(&result, radians); 270 | return result; 271 | } 272 | 273 | static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) 274 | { 275 | VmathSoaQuat result; 276 | vmathSoaQMul(&result, &quat0, &quat1); 277 | return result; 278 | } 279 | 280 | static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec ) 281 | { 282 | VmathSoaVector3 result; 283 | vmathSoaQRotate(&result, &quat, &vec); 284 | return result; 285 | } 286 | 287 | static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ) 288 | { 289 | VmathSoaQuat result; 290 | vmathSoaQConj(&result, &quat); 291 | return result; 292 | } 293 | 294 | static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ) 295 | { 296 | VmathSoaQuat result; 297 | vmathSoaQSelect(&result, &quat0, &quat1, select1); 298 | return result; 299 | } 300 | 301 | #ifdef _VECTORMATH_DEBUG 302 | 303 | static inline void vmathSoaQPrint_V( VmathSoaQuat quat ) 304 | { 305 | vmathSoaQPrint(&quat); 306 | } 307 | 308 | static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ) 309 | { 310 | vmathSoaQPrints(&quat, name); 311 | } 312 | 313 | #endif 314 | 315 | #ifdef __cplusplus 316 | } 317 | #endif /* __cplusplus */ 318 | 319 | #endif 320 | -------------------------------------------------------------------------------- /include/vectormath/spu/cpp/boolInVec.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _BOOLINVEC_H 31 | #define _BOOLINVEC_H 32 | 33 | #include 34 | 35 | namespace Vectormath { 36 | 37 | class floatInVec; 38 | 39 | //-------------------------------------------------------------------------------------------------- 40 | // boolInVec class 41 | // 42 | 43 | class boolInVec 44 | { 45 | private: 46 | vec_uint4 mData; 47 | 48 | inline boolInVec(vec_uint4 vec); 49 | public: 50 | inline boolInVec() {} 51 | 52 | // matches standard type conversions 53 | // 54 | inline boolInVec(floatInVec vec); 55 | 56 | // explicit cast from bool 57 | // 58 | explicit inline boolInVec(bool scalar); 59 | 60 | #ifdef _VECTORMATH_NO_SCALAR_CAST 61 | // explicit cast to bool 62 | // 63 | inline bool getAsBool() const; 64 | #else 65 | // implicit cast to bool 66 | // 67 | inline operator bool() const; 68 | #endif 69 | 70 | // get vector data 71 | // bool value is in the 0 word slot of vector as 0 (false) or -1 (true) 72 | // 73 | inline vec_uint4 get128() const; 74 | 75 | // operators 76 | // 77 | inline const boolInVec operator ! () const; 78 | inline boolInVec& operator = (boolInVec vec); 79 | inline boolInVec& operator &= (boolInVec vec); 80 | inline boolInVec& operator ^= (boolInVec vec); 81 | inline boolInVec& operator |= (boolInVec vec); 82 | 83 | // friend functions 84 | // 85 | friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); 86 | friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); 87 | friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); 88 | friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); 89 | friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); 90 | friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); 91 | friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); 92 | friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); 93 | friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); 94 | friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); 95 | friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); 96 | friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); 97 | }; 98 | 99 | //-------------------------------------------------------------------------------------------------- 100 | // boolInVec functions 101 | // 102 | 103 | // operators 104 | // 105 | inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); 106 | inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); 107 | inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); 108 | inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); 109 | inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); 110 | 111 | // select between vec0 and vec1 using boolInVec. 112 | // false selects vec0, true selects vec1 113 | // 114 | inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); 115 | 116 | } // namespace Vectormath 117 | 118 | //-------------------------------------------------------------------------------------------------- 119 | // boolInVec implementation 120 | // 121 | 122 | #include "floatInVec.h" 123 | 124 | namespace Vectormath { 125 | 126 | inline 127 | boolInVec::boolInVec(vec_uint4 vec) 128 | { 129 | mData = vec; 130 | } 131 | 132 | inline 133 | boolInVec::boolInVec(floatInVec vec) 134 | { 135 | *this = (vec != floatInVec(0.0f)); 136 | } 137 | 138 | inline 139 | boolInVec::boolInVec(bool scalar) 140 | { 141 | mData = spu_promote((unsigned int)-scalar, 0); 142 | } 143 | 144 | #ifdef _VECTORMATH_NO_SCALAR_CAST 145 | inline 146 | bool 147 | boolInVec::getAsBool() const 148 | #else 149 | inline 150 | boolInVec::operator bool() const 151 | #endif 152 | { 153 | return (bool)spu_extract(mData, 0); 154 | } 155 | 156 | inline 157 | vec_uint4 158 | boolInVec::get128() const 159 | { 160 | return mData; 161 | } 162 | 163 | inline 164 | const boolInVec 165 | boolInVec::operator ! () const 166 | { 167 | return boolInVec(spu_nor(mData, mData)); 168 | } 169 | 170 | inline 171 | boolInVec& 172 | boolInVec::operator = (boolInVec vec) 173 | { 174 | mData = vec.mData; 175 | return *this; 176 | } 177 | 178 | inline 179 | boolInVec& 180 | boolInVec::operator &= (boolInVec vec) 181 | { 182 | *this = *this & vec; 183 | return *this; 184 | } 185 | 186 | inline 187 | boolInVec& 188 | boolInVec::operator ^= (boolInVec vec) 189 | { 190 | *this = *this ^ vec; 191 | return *this; 192 | } 193 | 194 | inline 195 | boolInVec& 196 | boolInVec::operator |= (boolInVec vec) 197 | { 198 | *this = *this | vec; 199 | return *this; 200 | } 201 | 202 | inline 203 | const boolInVec 204 | operator == (boolInVec vec0, boolInVec vec1) 205 | { 206 | return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128())); 207 | } 208 | 209 | inline 210 | const boolInVec 211 | operator != (boolInVec vec0, boolInVec vec1) 212 | { 213 | return !(vec0 == vec1); 214 | } 215 | 216 | inline 217 | const boolInVec 218 | operator & (boolInVec vec0, boolInVec vec1) 219 | { 220 | return boolInVec(spu_and(vec0.get128(), vec1.get128())); 221 | } 222 | 223 | inline 224 | const boolInVec 225 | operator | (boolInVec vec0, boolInVec vec1) 226 | { 227 | return boolInVec(spu_or(vec0.get128(), vec1.get128())); 228 | } 229 | 230 | inline 231 | const boolInVec 232 | operator ^ (boolInVec vec0, boolInVec vec1) 233 | { 234 | return boolInVec(spu_xor(vec0.get128(), vec1.get128())); 235 | } 236 | 237 | inline 238 | const boolInVec 239 | select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1) 240 | { 241 | return boolInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); 242 | } 243 | 244 | } // namespace Vectormath 245 | 246 | #endif // boolInVec_h 247 | -------------------------------------------------------------------------------- /include/vectormath/spu/cpp/floatInVec.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _FLOATINVEC_H 31 | #define _FLOATINVEC_H 32 | 33 | #include 34 | #include 35 | #include 36 | #undef bool 37 | 38 | namespace Vectormath { 39 | 40 | class boolInVec; 41 | 42 | //-------------------------------------------------------------------------------------------------- 43 | // floatInVec class 44 | // 45 | 46 | class floatInVec 47 | { 48 | private: 49 | vec_float4 mData; 50 | 51 | inline floatInVec(vec_float4 vec); 52 | public: 53 | inline floatInVec() {} 54 | 55 | // matches standard type conversions 56 | // 57 | inline floatInVec(boolInVec vec); 58 | 59 | // construct from a slot of vec_float4 60 | // 61 | inline floatInVec(vec_float4 vec, int slot); 62 | 63 | // explicit cast from float 64 | // 65 | explicit inline floatInVec(float scalar); 66 | 67 | #ifdef _VECTORMATH_NO_SCALAR_CAST 68 | // explicit cast to float 69 | // 70 | inline float getAsFloat() const; 71 | #else 72 | // implicit cast to float 73 | // 74 | inline operator float() const; 75 | #endif 76 | 77 | // get vector data 78 | // float value is in 0 word slot of vector 79 | // 80 | inline vec_float4 get128() const; 81 | 82 | // operators 83 | // 84 | inline const floatInVec operator ++ (int); 85 | inline const floatInVec operator -- (int); 86 | inline floatInVec& operator ++ (); 87 | inline floatInVec& operator -- (); 88 | inline const floatInVec operator - () const; 89 | inline floatInVec& operator = (floatInVec vec); 90 | inline floatInVec& operator *= (floatInVec vec); 91 | inline floatInVec& operator /= (floatInVec vec); 92 | inline floatInVec& operator += (floatInVec vec); 93 | inline floatInVec& operator -= (floatInVec vec); 94 | 95 | // friend functions 96 | // 97 | friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); 98 | friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); 99 | friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); 100 | friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); 101 | friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); 102 | }; 103 | 104 | //-------------------------------------------------------------------------------------------------- 105 | // floatInVec functions 106 | // 107 | 108 | // operators 109 | // 110 | inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); 111 | inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); 112 | inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); 113 | inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); 114 | inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); 115 | inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); 116 | inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); 117 | inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); 118 | inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); 119 | inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); 120 | 121 | // select between vec0 and vec1 using boolInVec. 122 | // false selects vec0, true selects vec1 123 | // 124 | inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); 125 | 126 | } // namespace Vectormath 127 | 128 | //-------------------------------------------------------------------------------------------------- 129 | // floatInVec implementation 130 | // 131 | 132 | #include "boolInVec.h" 133 | 134 | namespace Vectormath { 135 | 136 | inline 137 | floatInVec::floatInVec(vec_float4 vec) 138 | { 139 | mData = vec; 140 | } 141 | 142 | inline 143 | floatInVec::floatInVec(boolInVec vec) 144 | { 145 | mData = spu_sel(spu_splats(0.0f), spu_splats(1.0f), vec.get128()); 146 | } 147 | 148 | inline 149 | floatInVec::floatInVec(vec_float4 vec, int slot) 150 | { 151 | mData = spu_promote(spu_extract(vec, slot), 0); 152 | } 153 | 154 | inline 155 | floatInVec::floatInVec(float scalar) 156 | { 157 | mData = spu_promote(scalar, 0); 158 | } 159 | 160 | #ifdef _VECTORMATH_NO_SCALAR_CAST 161 | inline 162 | float 163 | floatInVec::getAsFloat() const 164 | #else 165 | inline 166 | floatInVec::operator float() const 167 | #endif 168 | { 169 | return spu_extract(mData,0); 170 | } 171 | 172 | inline 173 | vec_float4 174 | floatInVec::get128() const 175 | { 176 | return mData; 177 | } 178 | 179 | inline 180 | const floatInVec 181 | floatInVec::operator ++ (int) 182 | { 183 | vec_float4 olddata = mData; 184 | operator ++(); 185 | return floatInVec(olddata); 186 | } 187 | 188 | inline 189 | const floatInVec 190 | floatInVec::operator -- (int) 191 | { 192 | vec_float4 olddata = mData; 193 | operator --(); 194 | return floatInVec(olddata); 195 | } 196 | 197 | inline 198 | floatInVec& 199 | floatInVec::operator ++ () 200 | { 201 | *this += floatInVec(1.0f); 202 | return *this; 203 | } 204 | 205 | inline 206 | floatInVec& 207 | floatInVec::operator -- () 208 | { 209 | *this -= floatInVec(1.0f); 210 | return *this; 211 | } 212 | 213 | inline 214 | const floatInVec 215 | floatInVec::operator - () const 216 | { 217 | return floatInVec((vec_float4)spu_xor((vec_uint4)mData, spu_splats(0x80000000))); 218 | } 219 | 220 | inline 221 | floatInVec& 222 | floatInVec::operator = (floatInVec vec) 223 | { 224 | mData = vec.mData; 225 | return *this; 226 | } 227 | 228 | inline 229 | floatInVec& 230 | floatInVec::operator *= (floatInVec vec) 231 | { 232 | *this = *this * vec; 233 | return *this; 234 | } 235 | 236 | inline 237 | floatInVec& 238 | floatInVec::operator /= (floatInVec vec) 239 | { 240 | *this = *this / vec; 241 | return *this; 242 | } 243 | 244 | inline 245 | floatInVec& 246 | floatInVec::operator += (floatInVec vec) 247 | { 248 | *this = *this + vec; 249 | return *this; 250 | } 251 | 252 | inline 253 | floatInVec& 254 | floatInVec::operator -= (floatInVec vec) 255 | { 256 | *this = *this - vec; 257 | return *this; 258 | } 259 | 260 | inline 261 | const floatInVec 262 | operator * (floatInVec vec0, floatInVec vec1) 263 | { 264 | return floatInVec(spu_mul(vec0.get128(), vec1.get128())); 265 | } 266 | 267 | inline 268 | const floatInVec 269 | operator / (floatInVec num, floatInVec den) 270 | { 271 | return floatInVec(divf4(num.get128(), den.get128())); 272 | } 273 | 274 | inline 275 | const floatInVec 276 | operator + (floatInVec vec0, floatInVec vec1) 277 | { 278 | return floatInVec(spu_add(vec0.get128(), vec1.get128())); 279 | } 280 | 281 | inline 282 | const floatInVec 283 | operator - (floatInVec vec0, floatInVec vec1) 284 | { 285 | return floatInVec(spu_sub(vec0.get128(), vec1.get128())); 286 | } 287 | 288 | inline 289 | const boolInVec 290 | operator < (floatInVec vec0, floatInVec vec1) 291 | { 292 | return boolInVec(spu_cmpgt(vec1.get128(), vec0.get128())); 293 | } 294 | 295 | inline 296 | const boolInVec 297 | operator <= (floatInVec vec0, floatInVec vec1) 298 | { 299 | return !(vec0 > vec1); 300 | } 301 | 302 | inline 303 | const boolInVec 304 | operator > (floatInVec vec0, floatInVec vec1) 305 | { 306 | return boolInVec(spu_cmpgt(vec0.get128(), vec1.get128())); 307 | } 308 | 309 | inline 310 | const boolInVec 311 | operator >= (floatInVec vec0, floatInVec vec1) 312 | { 313 | return !(vec0 < vec1); 314 | } 315 | 316 | inline 317 | const boolInVec 318 | operator == (floatInVec vec0, floatInVec vec1) 319 | { 320 | return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128())); 321 | } 322 | 323 | inline 324 | const boolInVec 325 | operator != (floatInVec vec0, floatInVec vec1) 326 | { 327 | return !(vec0 == vec1); 328 | } 329 | 330 | inline 331 | const floatInVec 332 | select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1) 333 | { 334 | return floatInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); 335 | } 336 | 337 | } // namespace Vectormath 338 | 339 | #endif // floatInVec_h 340 | -------------------------------------------------------------------------------- /include/vectormath/spu/cpp/vecidx_aos.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, 6 | with or without modification, are permitted provided that the 7 | following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Sony Computer Entertainment Inc nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _VECTORMATH_VECIDX_AOS_H 31 | #define _VECTORMATH_VECIDX_AOS_H 32 | 33 | #include 34 | 35 | namespace Vectormath { 36 | namespace Aos { 37 | 38 | //----------------------------------------------------------------------------- 39 | // VecIdx 40 | // Used in setting elements of Vector3, Vector4, Point3, or Quat with the 41 | // subscripting operator. 42 | // 43 | 44 | class VecIdx 45 | { 46 | private: 47 | typedef vec_float4 vec_float4_t; 48 | vec_float4_t &ref __attribute__ ((aligned(16))); 49 | int i __attribute__ ((aligned(16))); 50 | public: 51 | inline VecIdx( vec_float4& vec, int idx ): ref(vec) { i = idx; } 52 | inline operator float() const; 53 | inline float operator =( float scalar ); 54 | inline float operator =( const VecIdx& scalar ); 55 | inline float operator *=( float scalar ); 56 | inline float operator /=( float scalar ); 57 | inline float operator +=( float scalar ); 58 | inline float operator -=( float scalar ); 59 | }; 60 | 61 | } // namespace Aos 62 | } // namespace Vectormath 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /tests/.gitattributes: -------------------------------------------------------------------------------- 1 | *.txt text 2 | *.bat eol=crlf 3 | *.vcproj eol=crlf 4 | *.sln eol=crlf 5 | *.filters eol=crlf 6 | *.user eol=crlf 7 | *.vcxproj eol=crlf 8 | *.sh eol=lf 9 | *.jpg -text -------------------------------------------------------------------------------- /tests/0vs2008.bat: -------------------------------------------------------------------------------- 1 | rmdir /s /q vc2008 2 | rmdir /s /q build 3 | premake4 clean 4 | 5 | premake4 vs2008 6 | 7 | rename build vs2008 8 | pause -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for vector math library testsuite. 2 | # 3 | # Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, 7 | # with or without modification, are permitted provided that the 8 | # following conditions are met: 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # * Neither the name of the Sony Computer Entertainment Inc nor the names 15 | # of its contributors may be used to endorse or promote products derived 16 | # from this software without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | # POSSIBILITY OF SUCH DAMAGE. 29 | 30 | topdir = .. 31 | 32 | ARCH = scalar 33 | 34 | TESTS_all = \ 35 | test1_aos_c.elf \ 36 | test1_soa_c.elf \ 37 | test2_aos_c.elf \ 38 | test2_soa_c.elf \ 39 | test3_aos_c.elf \ 40 | test3_soa_c.elf \ 41 | test4_aos_c.elf \ 42 | test4_soa_c.elf \ 43 | test1_aos_cpp.elf \ 44 | test1_soa_cpp.elf \ 45 | test2_aos_cpp.elf \ 46 | test2_soa_cpp.elf \ 47 | test3_aos_cpp.elf \ 48 | test3_soa_cpp.elf \ 49 | test4_aos_cpp.elf \ 50 | test4_soa_cpp.elf 51 | 52 | TESTS_ppu = $(TESTS_all) 53 | ARCH_CFLAGS_ppu = -maltivec -mabi=altivec -I$(SIMDMATH_DIR)/common 54 | ARCH_LDFLAGS_ppu = -L$(SIMDMATH_DIR)/ppu -lsimdmath -static 55 | 56 | CROSS_spu = spu- 57 | TESTS_spu = $(TESTS_all) 58 | ARCH_CFLAGS_spu = -I$(SIMDMATH_DIR)/common 59 | ARCH_LDFLAGS_spu = -L$(SIMDMATH_DIR)/spu -lsimdmath 60 | 61 | TESTS_SSE = \ 62 | test1_aos_cpp.elf \ 63 | test2_aos_cpp.elf \ 64 | test3_aos_cpp.elf \ 65 | test4_aos_cpp.elf 66 | ARCH_CFLAGS_SSE = -msse 67 | 68 | TESTS_scalar = \ 69 | test1_aos_c.elf \ 70 | test2_aos_c.elf \ 71 | test3_aos_c.elf \ 72 | test4_aos_c.elf \ 73 | test1_aos_cpp.elf \ 74 | test2_aos_cpp.elf \ 75 | test3_aos_cpp.elf \ 76 | test4_aos_cpp.elf 77 | 78 | TESTS = $(TESTS_$(ARCH)) 79 | ARCH_CFLAGS = $(ARCH_CFLAGS_$(ARCH)) 80 | ARCH_LDFLAGS = $(ARCH_LDFLAGS_$(ARCH)) 81 | 82 | SIMDMATH_DIR = $(topdir)/../simdmathlibrary 83 | 84 | RESULTS = $(TESTS:.elf=.$(ARCH).out) 85 | DIFFS = $(RESULTS:.out=.cmp) 86 | 87 | CROSS = $(CROSS_$(ARCH)) 88 | CC = $(CROSS)gcc 89 | CXX = $(CROSS)g++ 90 | LD = $(CC) 91 | LDXX = $(CXX) 92 | 93 | CFLAGS = -O2 -W -Wall -D_VECTORMATH_DEBUG $(ARCH_CFLAGS) 94 | LDFLAGS = -lm $(ARCH_LDFLAGS) 95 | 96 | C_INCLUDES = -I$(topdir)/include/vectormath/c 97 | CXX_INCLUDES = -I$(topdir)/include/vectormath/cpp 98 | 99 | PERL = perl 100 | 101 | all: $(TESTS) 102 | 103 | check: $(DIFFS) 104 | 105 | clean: 106 | -rm -f *.elf 107 | 108 | distclean: clean 109 | -rm -f *.out *.cmp *~ 110 | 111 | %_c.elf: %_c.c 112 | $(CC) $(CFLAGS) $(C_INCLUDES) -o $@ $< $(LDFLAGS) 113 | 114 | %_cpp.elf: %_cpp.cpp 115 | $(CXX) $(CFLAGS) $(CXX_INCLUDES) -o $@ $< $(LDFLAGS) 116 | 117 | %.$(ARCH).out: %.elf 118 | ./$< > $@ 119 | 120 | test1_%.cmp: test1_%.out 121 | $(PERL) ./clean.pl < $< > $<.tmp 122 | $(PERL) ./compare.pl $<.tmp test1_reference.txt | tee $@ 123 | rm $<.tmp 124 | 125 | test2_%.cmp: test2_%.out 126 | $(PERL) ./clean.pl < $< > $<.tmp 127 | $(PERL) ./compare.pl $<.tmp test2_reference.txt | tee $@ 128 | rm $<.tmp 129 | 130 | test3_%.cmp: test3_%.out 131 | $(PERL) ./clean.pl < $< > $<.tmp 132 | $(PERL) ./compare.pl $<.tmp test3_reference.txt | tee $@ 133 | rm $<.tmp 134 | 135 | test4_%.cmp: test4_%.out 136 | $(PERL) ./clean.pl < $< > $<.tmp 137 | $(PERL) ./compare.pl $<.tmp test4_reference.txt | tee $@ 138 | rm $<.tmp 139 | -------------------------------------------------------------------------------- /tests/clean.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, 8 | # with or without modification, are permitted provided that the 9 | # following conditions are met: 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # * Neither the name of the Sony Computer Entertainment Inc nor the names 16 | # of its contributors may be used to endorse or promote products derived 17 | # from this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | # POSSIBILITY OF SUCH DAMAGE. 30 | # 31 | 32 | $lineno = 0; 33 | 34 | sub getLine 35 | { 36 | local( $line ); 37 | 38 | $line = ; 39 | 40 | while( $line =~ m/^lv2\([^\)]*\)\:$/ ) 41 | { 42 | $line = ; 43 | } 44 | 45 | $line =~ s/^lv2\([^\)]*\)\: //; 46 | 47 | return $line; 48 | } 49 | 50 | while(($line = ) !~ m/__begin__/) 51 | { 52 | } 53 | 54 | $countSlotLines = 0; 55 | 56 | while( $line = &getLine ) 57 | { 58 | $lineno++; 59 | 60 | if ( $line =~ m/__end__/ ) 61 | { 62 | exit; 63 | } 64 | 65 | # if soa print, only save first slot 66 | 67 | if ( $line =~ m/^slot ([1-3])/ ) 68 | { 69 | while ( $line =~ m/^slot [1-3]/ ) 70 | { 71 | # skip all lines for this slot 72 | 73 | for ( $i = 0; $i < $slotLines; $i++ ) 74 | { 75 | $line = &getLine; 76 | } 77 | 78 | # get next line 79 | 80 | $line = &getLine; 81 | } 82 | 83 | # stop counting slot lines 84 | 85 | $countSlotLines = 0; 86 | } 87 | elsif ( $countSlotLines ) 88 | { 89 | $slotLines++; 90 | } 91 | 92 | if ( $line =~ m/^slot 0\:(.?)/ ) 93 | { 94 | $countSlotLines = 1; 95 | 96 | if ( $1 eq ' ' ) 97 | { 98 | $line =~ s/^slot 0\: //; 99 | $slotLines = 0; 100 | } 101 | else 102 | { 103 | $line = &getLine; 104 | $slotLines = 1; 105 | } 106 | } 107 | 108 | print $line; 109 | } 110 | -------------------------------------------------------------------------------- /tests/compare.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, 8 | # with or without modification, are permitted provided that the 9 | # following conditions are met: 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # * Neither the name of the Sony Computer Entertainment Inc nor the names 16 | # of its contributors may be used to endorse or promote products derived 17 | # from this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | # POSSIBILITY OF SUCH DAMAGE. 30 | # 31 | 32 | $file1 = $ARGV[0]; 33 | $file2 = $ARGV[1]; 34 | 35 | if (!open(FILE1, "<$file1")) 36 | { 37 | print "Couldn't open $file1\n"; 38 | exit; 39 | } 40 | 41 | if (!open(FILE2, "<$file2")) 42 | { 43 | print "Couldn't open $file2\n"; 44 | exit; 45 | } 46 | 47 | print "Comparing $file1 $file2\n"; 48 | 49 | $lineno1 = 0; 50 | $lineno2 = 0; 51 | 52 | while(($line1 = ) && ($line2 = )) 53 | { 54 | $lineno1++; 55 | $lineno2++; 56 | 57 | if ( $line1 =~ m/\:$/ ) 58 | { 59 | $line1 = ; 60 | $lineno1++; 61 | } 62 | 63 | if ( $line2 =~ m/\:$/ ) 64 | { 65 | $line2 = ; 66 | $lineno2++; 67 | } 68 | 69 | $line1 =~ s/^.*\: //g; 70 | $line2 =~ s/^.*\: //g; 71 | 72 | @words1 = split(/ /,$line1); 73 | @words2 = split(/ /,$line2); 74 | 75 | for ($i = 0; $i < @words1; $i++) 76 | { 77 | $word1 = $words1[$i]; 78 | $word2 = $words2[$i]; 79 | 80 | $word1 =~ s/\s//g; 81 | $word2 =~ s/\s//g; 82 | 83 | if ( $word1 ne $word2 ) 84 | { 85 | $error = abs($word1 - $word2); 86 | 87 | $limit = abs(1e-4 * $word1); 88 | 89 | if ( $error > $limit && !( abs($word1) < 1e-4 && $error < 1e-4 ) ) 90 | { 91 | print "$lineno1: $word1 $lineno2: $word2\n"; 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /tests/premake4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erwincoumans/sce_vectormath/e02144965bfba3fedb412c7df243d3edc61fd37e/tests/premake4.exe -------------------------------------------------------------------------------- /tests/premake4.lua: -------------------------------------------------------------------------------- 1 | solution "tests" 2 | 3 | configurations {"Release", "Debug"} 4 | configuration "Release" 5 | flags { "Optimize", "StaticRuntime", "NoRTTI", "NoExceptions"} 6 | configuration "Debug" 7 | flags { "Symbols", "StaticRuntime" , "NoRTTI", "NoExceptions"} 8 | platforms {"x32", "x64"} 9 | 10 | configuration "x64" 11 | targetsuffix "_64" 12 | configuration {"x64", "debug"} 13 | targetsuffix "_x64_debug" 14 | configuration {"x64", "release"} 15 | targetsuffix "_x64" 16 | configuration {"x32", "debug"} 17 | targetsuffix "_debug" 18 | 19 | 20 | language "C++" 21 | location "build" 22 | targetdir "bin" 23 | 24 | project "test1_aos_scalar_cpp" 25 | kind "ConsoleApp" 26 | targetdir "bin" 27 | includedirs {"../include/vectormath/scalar/cpp" } 28 | files { "test1_aos_cpp.cpp" } 29 | 30 | project "test2_aos_scalar_cpp" 31 | kind "ConsoleApp" 32 | targetdir "bin" 33 | includedirs {"../include/vectormath/scalar/cpp" } 34 | files { "test2_aos_cpp.cpp" } 35 | 36 | project "test3_aos_scalar_cpp" 37 | kind "ConsoleApp" 38 | targetdir "bin" 39 | includedirs {"../include/vectormath/scalar/cpp" } 40 | files { "test3_aos_cpp.cpp" } 41 | 42 | project "test4_aos_scalar_cpp" 43 | kind "ConsoleApp" 44 | targetdir "bin" 45 | includedirs {"../include/vectormath/scalar/cpp" } 46 | files { "test4_aos_cpp.cpp" } 47 | 48 | project "test1_aos_SSE_cpp" 49 | kind "ConsoleApp" 50 | targetdir "bin" 51 | includedirs {"../include/vectormath/SSE/cpp" } 52 | files { "test1_aos_cpp.cpp" } 53 | 54 | project "test2_aos_SSE_cpp" 55 | kind "ConsoleApp" 56 | targetdir "bin" 57 | includedirs {"../include/vectormath/SSE/cpp" } 58 | files { "test2_aos_cpp.cpp" } 59 | 60 | project "test3_aos_SSE_cpp" 61 | kind "ConsoleApp" 62 | targetdir "bin" 63 | includedirs {"../include/vectormath/SSE/cpp" } 64 | files { "test3_aos_cpp.cpp" } 65 | 66 | project "test4_aos_SSE_cpp" 67 | kind "ConsoleApp" 68 | targetdir "bin" 69 | includedirs {"../include/vectormath/SSE/cpp" } 70 | files { "test4_aos_cpp.cpp" } 71 | -------------------------------------------------------------------------------- /tests/run_perl_tests.bat: -------------------------------------------------------------------------------- 1 | bin/test1_aos_scalar_cpp_debug.exe >result_test1_aos_scalar_cpp_debug.txt 2 | perl compare.pl test1_reference.txt result_test1_aos_scalar_cpp_debug.txt >diff_test1_aos_scalar_cpp_debug.txt 3 | 4 | bin/test2_aos_scalar_cpp_debug.exe >result_test2_aos_scalar_cpp_debug.txt 5 | perl compare.pl test2_reference.txt result_test2_aos_scalar_cpp_debug.txt >diff_test2_aos_scalar_cpp_debug.txt 6 | 7 | bin/test3_aos_scalar_cpp_debug.exe >result_test3_aos_scalar_cpp_debug.txt 8 | perl compare.pl test3_reference.txt result_test3_aos_scalar_cpp_debug.txt >diff_test3_aos_scalar_cpp_debug.txt 9 | 10 | bin/test4_aos_scalar_cpp_debug.exe >result_test4_aos_scalar_cpp_debug.txt 11 | perl compare.pl test4_reference.txt result_test4_aos_scalar_cpp_debug.txt >diff_test4_aos_scalar_cpp_debug.txt 12 | 13 | bin/test1_aos_SSE_cpp_debug.exe >result_test1_aos_SSE_cpp_debug.txt 14 | perl compare.pl test1_reference.txt result_test1_aos_SSE_cpp_debug.txt >diff_test1_aos_SSE_cpp_debug.txt 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/run_tests.bat: -------------------------------------------------------------------------------- 1 | cd bin 2 | test1_aos_scalar_cpp.exe 3 | test2_aos_scalar_cpp.exe 4 | test3_aos_scalar_cpp.exe 5 | test4_aos_scalar_cpp.exe 6 | 7 | test1_aos_SSE_cpp.exe 8 | test2_aos_SSE_cpp.exe 9 | test3_aos_SSE_cpp.exe 10 | test4_aos_SSE_cpp.exe 11 | pause 12 | -------------------------------------------------------------------------------- /tests/vs2008/test1_aos_SSE_cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 57 | 60 | 64 | 67 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 111 | 114 | 117 | 120 | 123 | 127 | 141 | 144 | 148 | 151 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 195 | 198 | 201 | 204 | 207 | 210 | 225 | 228 | 232 | 235 | 246 | 249 | 252 | 255 | 258 | 261 | 264 | 267 | 270 | 271 | 278 | 281 | 284 | 287 | 290 | 294 | 309 | 312 | 316 | 319 | 330 | 333 | 336 | 339 | 342 | 345 | 348 | 351 | 354 | 355 | 356 | 357 | 358 | 359 | 362 | 363 | 364 | 365 | 366 | 367 | -------------------------------------------------------------------------------- /tests/vs2008/test1_aos_scalar_cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 57 | 60 | 64 | 67 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 111 | 114 | 117 | 120 | 123 | 127 | 141 | 144 | 148 | 151 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 195 | 198 | 201 | 204 | 207 | 210 | 225 | 228 | 232 | 235 | 246 | 249 | 252 | 255 | 258 | 261 | 264 | 267 | 270 | 271 | 278 | 281 | 284 | 287 | 290 | 294 | 309 | 312 | 316 | 319 | 330 | 333 | 336 | 339 | 342 | 345 | 348 | 351 | 354 | 355 | 356 | 357 | 358 | 359 | 362 | 363 | 364 | 365 | 366 | 367 | -------------------------------------------------------------------------------- /tests/vs2008/test2_aos_SSE_cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 57 | 60 | 64 | 67 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 111 | 114 | 117 | 120 | 123 | 127 | 141 | 144 | 148 | 151 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 195 | 198 | 201 | 204 | 207 | 210 | 225 | 228 | 232 | 235 | 246 | 249 | 252 | 255 | 258 | 261 | 264 | 267 | 270 | 271 | 278 | 281 | 284 | 287 | 290 | 294 | 309 | 312 | 316 | 319 | 330 | 333 | 336 | 339 | 342 | 345 | 348 | 351 | 354 | 355 | 356 | 357 | 358 | 359 | 362 | 363 | 364 | 365 | 366 | 367 | -------------------------------------------------------------------------------- /tests/vs2008/test2_aos_scalar_cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 57 | 60 | 64 | 67 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 111 | 114 | 117 | 120 | 123 | 127 | 141 | 144 | 148 | 151 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 195 | 198 | 201 | 204 | 207 | 210 | 225 | 228 | 232 | 235 | 246 | 249 | 252 | 255 | 258 | 261 | 264 | 267 | 270 | 271 | 278 | 281 | 284 | 287 | 290 | 294 | 309 | 312 | 316 | 319 | 330 | 333 | 336 | 339 | 342 | 345 | 348 | 351 | 354 | 355 | 356 | 357 | 358 | 359 | 362 | 363 | 364 | 365 | 366 | 367 | -------------------------------------------------------------------------------- /tests/vs2008/test3_aos_SSE_cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 57 | 60 | 64 | 67 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 111 | 114 | 117 | 120 | 123 | 127 | 141 | 144 | 148 | 151 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 195 | 198 | 201 | 204 | 207 | 210 | 225 | 228 | 232 | 235 | 246 | 249 | 252 | 255 | 258 | 261 | 264 | 267 | 270 | 271 | 278 | 281 | 284 | 287 | 290 | 294 | 309 | 312 | 316 | 319 | 330 | 333 | 336 | 339 | 342 | 345 | 348 | 351 | 354 | 355 | 356 | 357 | 358 | 359 | 362 | 363 | 364 | 365 | 366 | 367 | -------------------------------------------------------------------------------- /tests/vs2008/test3_aos_scalar_cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 57 | 60 | 64 | 67 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 111 | 114 | 117 | 120 | 123 | 127 | 141 | 144 | 148 | 151 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 195 | 198 | 201 | 204 | 207 | 210 | 225 | 228 | 232 | 235 | 246 | 249 | 252 | 255 | 258 | 261 | 264 | 267 | 270 | 271 | 278 | 281 | 284 | 287 | 290 | 294 | 309 | 312 | 316 | 319 | 330 | 333 | 336 | 339 | 342 | 345 | 348 | 351 | 354 | 355 | 356 | 357 | 358 | 359 | 362 | 363 | 364 | 365 | 366 | 367 | -------------------------------------------------------------------------------- /tests/vs2008/test4_aos_SSE_cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 57 | 60 | 64 | 67 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 111 | 114 | 117 | 120 | 123 | 127 | 141 | 144 | 148 | 151 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 195 | 198 | 201 | 204 | 207 | 210 | 225 | 228 | 232 | 235 | 246 | 249 | 252 | 255 | 258 | 261 | 264 | 267 | 270 | 271 | 278 | 281 | 284 | 287 | 290 | 294 | 309 | 312 | 316 | 319 | 330 | 333 | 336 | 339 | 342 | 345 | 348 | 351 | 354 | 355 | 356 | 357 | 358 | 359 | 362 | 363 | 364 | 365 | 366 | 367 | -------------------------------------------------------------------------------- /tests/vs2008/test4_aos_scalar_cpp.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 57 | 60 | 64 | 67 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 111 | 114 | 117 | 120 | 123 | 127 | 141 | 144 | 148 | 151 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 195 | 198 | 201 | 204 | 207 | 210 | 225 | 228 | 232 | 235 | 246 | 249 | 252 | 255 | 258 | 261 | 264 | 267 | 270 | 271 | 278 | 281 | 284 | 287 | 290 | 294 | 309 | 312 | 316 | 319 | 330 | 333 | 336 | 339 | 342 | 345 | 348 | 351 | 354 | 355 | 356 | 357 | 358 | 359 | 362 | 363 | 364 | 365 | 366 | 367 | -------------------------------------------------------------------------------- /tests/vs2008/tests.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test1_aos_scalar_cpp", "test1_aos_scalar_cpp.vcproj", "{202A37D3-7F29-4A43-B1A0-8D83A015DC71}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test2_aos_scalar_cpp", "test2_aos_scalar_cpp.vcproj", "{F9277FAF-063F-8B40-A68D-7903DEDCFA5E}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test3_aos_scalar_cpp", "test3_aos_scalar_cpp.vcproj", "{19A09F90-E26D-984A-A311-0242DF5FCD4B}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test4_aos_scalar_cpp", "test4_aos_scalar_cpp.vcproj", "{93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test1_aos_SSE_cpp", "test1_aos_SSE_cpp.vcproj", "{BB929EEA-67F4-544F-A1B8-DC567A411E06}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test2_aos_SSE_cpp", "test2_aos_SSE_cpp.vcproj", "{80C480CF-0CAD-B544-BE4D-3E8742B00370}" 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test3_aos_SSE_cpp", "test3_aos_SSE_cpp.vcproj", "{58588E63-E74F-4F4A-A3B5-C83FF972E77E}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test4_aos_SSE_cpp", "test4_aos_SSE_cpp.vcproj", "{0F44CD47-4C9C-8E48-A820-C4E6B7B91496}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Release|Win32 = Release|Win32 23 | Release|x64 = Release|x64 24 | Debug|Win32 = Debug|Win32 25 | Debug|x64 = Debug|x64 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {202A37D3-7F29-4A43-B1A0-8D83A015DC71}.Release|Win32.ActiveCfg = Release|Win32 29 | {202A37D3-7F29-4A43-B1A0-8D83A015DC71}.Release|Win32.Build.0 = Release|Win32 30 | {202A37D3-7F29-4A43-B1A0-8D83A015DC71}.Release|x64.ActiveCfg = Release|x64 31 | {202A37D3-7F29-4A43-B1A0-8D83A015DC71}.Release|x64.Build.0 = Release|x64 32 | {202A37D3-7F29-4A43-B1A0-8D83A015DC71}.Debug|Win32.ActiveCfg = Debug|Win32 33 | {202A37D3-7F29-4A43-B1A0-8D83A015DC71}.Debug|Win32.Build.0 = Debug|Win32 34 | {202A37D3-7F29-4A43-B1A0-8D83A015DC71}.Debug|x64.ActiveCfg = Debug|x64 35 | {202A37D3-7F29-4A43-B1A0-8D83A015DC71}.Debug|x64.Build.0 = Debug|x64 36 | {F9277FAF-063F-8B40-A68D-7903DEDCFA5E}.Release|Win32.ActiveCfg = Release|Win32 37 | {F9277FAF-063F-8B40-A68D-7903DEDCFA5E}.Release|Win32.Build.0 = Release|Win32 38 | {F9277FAF-063F-8B40-A68D-7903DEDCFA5E}.Release|x64.ActiveCfg = Release|x64 39 | {F9277FAF-063F-8B40-A68D-7903DEDCFA5E}.Release|x64.Build.0 = Release|x64 40 | {F9277FAF-063F-8B40-A68D-7903DEDCFA5E}.Debug|Win32.ActiveCfg = Debug|Win32 41 | {F9277FAF-063F-8B40-A68D-7903DEDCFA5E}.Debug|Win32.Build.0 = Debug|Win32 42 | {F9277FAF-063F-8B40-A68D-7903DEDCFA5E}.Debug|x64.ActiveCfg = Debug|x64 43 | {F9277FAF-063F-8B40-A68D-7903DEDCFA5E}.Debug|x64.Build.0 = Debug|x64 44 | {19A09F90-E26D-984A-A311-0242DF5FCD4B}.Release|Win32.ActiveCfg = Release|Win32 45 | {19A09F90-E26D-984A-A311-0242DF5FCD4B}.Release|Win32.Build.0 = Release|Win32 46 | {19A09F90-E26D-984A-A311-0242DF5FCD4B}.Release|x64.ActiveCfg = Release|x64 47 | {19A09F90-E26D-984A-A311-0242DF5FCD4B}.Release|x64.Build.0 = Release|x64 48 | {19A09F90-E26D-984A-A311-0242DF5FCD4B}.Debug|Win32.ActiveCfg = Debug|Win32 49 | {19A09F90-E26D-984A-A311-0242DF5FCD4B}.Debug|Win32.Build.0 = Debug|Win32 50 | {19A09F90-E26D-984A-A311-0242DF5FCD4B}.Debug|x64.ActiveCfg = Debug|x64 51 | {19A09F90-E26D-984A-A311-0242DF5FCD4B}.Debug|x64.Build.0 = Debug|x64 52 | {93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}.Release|Win32.ActiveCfg = Release|Win32 53 | {93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}.Release|Win32.Build.0 = Release|Win32 54 | {93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}.Release|x64.ActiveCfg = Release|x64 55 | {93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}.Release|x64.Build.0 = Release|x64 56 | {93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}.Debug|Win32.ActiveCfg = Debug|Win32 57 | {93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}.Debug|Win32.Build.0 = Debug|Win32 58 | {93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}.Debug|x64.ActiveCfg = Debug|x64 59 | {93C2BF8C-16EC-A341-8EE8-841E9A7BCF75}.Debug|x64.Build.0 = Debug|x64 60 | {BB929EEA-67F4-544F-A1B8-DC567A411E06}.Release|Win32.ActiveCfg = Release|Win32 61 | {BB929EEA-67F4-544F-A1B8-DC567A411E06}.Release|Win32.Build.0 = Release|Win32 62 | {BB929EEA-67F4-544F-A1B8-DC567A411E06}.Release|x64.ActiveCfg = Release|x64 63 | {BB929EEA-67F4-544F-A1B8-DC567A411E06}.Release|x64.Build.0 = Release|x64 64 | {BB929EEA-67F4-544F-A1B8-DC567A411E06}.Debug|Win32.ActiveCfg = Debug|Win32 65 | {BB929EEA-67F4-544F-A1B8-DC567A411E06}.Debug|Win32.Build.0 = Debug|Win32 66 | {BB929EEA-67F4-544F-A1B8-DC567A411E06}.Debug|x64.ActiveCfg = Debug|x64 67 | {BB929EEA-67F4-544F-A1B8-DC567A411E06}.Debug|x64.Build.0 = Debug|x64 68 | {80C480CF-0CAD-B544-BE4D-3E8742B00370}.Release|Win32.ActiveCfg = Release|Win32 69 | {80C480CF-0CAD-B544-BE4D-3E8742B00370}.Release|Win32.Build.0 = Release|Win32 70 | {80C480CF-0CAD-B544-BE4D-3E8742B00370}.Release|x64.ActiveCfg = Release|x64 71 | {80C480CF-0CAD-B544-BE4D-3E8742B00370}.Release|x64.Build.0 = Release|x64 72 | {80C480CF-0CAD-B544-BE4D-3E8742B00370}.Debug|Win32.ActiveCfg = Debug|Win32 73 | {80C480CF-0CAD-B544-BE4D-3E8742B00370}.Debug|Win32.Build.0 = Debug|Win32 74 | {80C480CF-0CAD-B544-BE4D-3E8742B00370}.Debug|x64.ActiveCfg = Debug|x64 75 | {80C480CF-0CAD-B544-BE4D-3E8742B00370}.Debug|x64.Build.0 = Debug|x64 76 | {58588E63-E74F-4F4A-A3B5-C83FF972E77E}.Release|Win32.ActiveCfg = Release|Win32 77 | {58588E63-E74F-4F4A-A3B5-C83FF972E77E}.Release|Win32.Build.0 = Release|Win32 78 | {58588E63-E74F-4F4A-A3B5-C83FF972E77E}.Release|x64.ActiveCfg = Release|x64 79 | {58588E63-E74F-4F4A-A3B5-C83FF972E77E}.Release|x64.Build.0 = Release|x64 80 | {58588E63-E74F-4F4A-A3B5-C83FF972E77E}.Debug|Win32.ActiveCfg = Debug|Win32 81 | {58588E63-E74F-4F4A-A3B5-C83FF972E77E}.Debug|Win32.Build.0 = Debug|Win32 82 | {58588E63-E74F-4F4A-A3B5-C83FF972E77E}.Debug|x64.ActiveCfg = Debug|x64 83 | {58588E63-E74F-4F4A-A3B5-C83FF972E77E}.Debug|x64.Build.0 = Debug|x64 84 | {0F44CD47-4C9C-8E48-A820-C4E6B7B91496}.Release|Win32.ActiveCfg = Release|Win32 85 | {0F44CD47-4C9C-8E48-A820-C4E6B7B91496}.Release|Win32.Build.0 = Release|Win32 86 | {0F44CD47-4C9C-8E48-A820-C4E6B7B91496}.Release|x64.ActiveCfg = Release|x64 87 | {0F44CD47-4C9C-8E48-A820-C4E6B7B91496}.Release|x64.Build.0 = Release|x64 88 | {0F44CD47-4C9C-8E48-A820-C4E6B7B91496}.Debug|Win32.ActiveCfg = Debug|Win32 89 | {0F44CD47-4C9C-8E48-A820-C4E6B7B91496}.Debug|Win32.Build.0 = Debug|Win32 90 | {0F44CD47-4C9C-8E48-A820-C4E6B7B91496}.Debug|x64.ActiveCfg = Debug|x64 91 | {0F44CD47-4C9C-8E48-A820-C4E6B7B91496}.Debug|x64.Build.0 = Debug|x64 92 | EndGlobalSection 93 | GlobalSection(SolutionProperties) = preSolution 94 | HideSolutionNode = FALSE 95 | EndGlobalSection 96 | EndGlobal 97 | --------------------------------------------------------------------------------