1/// @ref core 2/// @file glm/detail/type_tvec4.inl 3 4namespace glm{ 5namespace detail 6{ 7 template <typename T> 8 struct is_int 9 { 10 enum test {value = 0}; 11 }; 12 13 template <> 14 struct is_int<uint32> 15 { 16 enum test {value = ~0}; 17 }; 18 19 template <> 20 struct is_int<int32> 21 { 22 enum test {value = ~0}; 23 }; 24 25 template <> 26 struct is_int<uint64> 27 { 28 enum test {value = ~0}; 29 }; 30 31 template <> 32 struct is_int<int64> 33 { 34 enum test {value = ~0}; 35 }; 36 37 template <typename T, precision P, bool Aligned> 38 struct compute_vec4_add 39 { 40 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 41 { 42 return tvec4<T, P>(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); 43 } 44 }; 45 46 template <typename T, precision P, bool Aligned> 47 struct compute_vec4_sub 48 { 49 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 50 { 51 return tvec4<T, P>(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); 52 } 53 }; 54 55 template <typename T, precision P, bool Aligned> 56 struct compute_vec4_mul 57 { 58 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 59 { 60 return tvec4<T, P>(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); 61 } 62 }; 63 64 template <typename T, precision P, bool Aligned> 65 struct compute_vec4_div 66 { 67 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 68 { 69 return tvec4<T, P>(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w); 70 } 71 }; 72 73 template <typename T, precision P, bool Aligned> 74 struct compute_vec4_mod 75 { 76 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 77 { 78 return tvec4<T, P>(a.x % b.x, a.y % b.y, a.z % b.z, a.w % b.w); 79 } 80 }; 81 82 template <typename T, precision P, int IsInt, std::size_t Size, bool Aligned> 83 struct compute_vec4_and 84 { 85 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 86 { 87 return tvec4<T, P>(a.x & b.x, a.y & b.y, a.z & b.z, a.w & b.w); 88 } 89 }; 90 91 template <typename T, precision P, int IsInt, std::size_t Size, bool Aligned> 92 struct compute_vec4_or 93 { 94 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 95 { 96 return tvec4<T, P>(a.x | b.x, a.y | b.y, a.z | b.z, a.w | b.w); 97 } 98 }; 99 100 template <typename T, precision P, int IsInt, std::size_t Size, bool Aligned> 101 struct compute_vec4_xor 102 { 103 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 104 { 105 return tvec4<T, P>(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w); 106 } 107 }; 108 109 template <typename T, precision P, int IsInt, std::size_t Size, bool Aligned> 110 struct compute_vec4_shift_left 111 { 112 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 113 { 114 return tvec4<T, P>(a.x << b.x, a.y << b.y, a.z << b.z, a.w << b.w); 115 } 116 }; 117 118 template <typename T, precision P, int IsInt, std::size_t Size, bool Aligned> 119 struct compute_vec4_shift_right 120 { 121 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & a, tvec4<T, P> const & b) 122 { 123 return tvec4<T, P>(a.x >> b.x, a.y >> b.y, a.z >> b.z, a.w >> b.w); 124 } 125 }; 126 127 template <typename T, precision P, int IsInt, std::size_t Size, bool Aligned> 128 struct compute_vec4_equal 129 { 130 GLM_FUNC_QUALIFIER static bool call(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 131 { 132 return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w); 133 } 134 }; 135 136 template <typename T, precision P, int IsInt, std::size_t Size, bool Aligned> 137 struct compute_vec4_nequal 138 { 139 GLM_FUNC_QUALIFIER static bool call(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 140 { 141 return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w); 142 } 143 }; 144 145 template <typename T, precision P, int IsInt, std::size_t Size, bool Aligned> 146 struct compute_vec4_bitwise_not 147 { 148 GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const & v) 149 { 150 return tvec4<T, P>(~v.x, ~v.y, ~v.z, ~v.w); 151 } 152 }; 153}//namespace detail 154 155 // -- Implicit basic constructors -- 156 157# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) 158 template <typename T, precision P> 159 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4() 160# ifndef GLM_FORCE_NO_CTOR_INIT 161 : x(0), y(0), z(0), w(0) 162# endif 163 {} 164# endif//!GLM_HAS_DEFAULTED_FUNCTIONS 165 166# if !GLM_HAS_DEFAULTED_FUNCTIONS 167 template <typename T, precision P> 168 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(tvec4<T, P> const & v) 169 : x(v.x), y(v.y), z(v.z), w(v.w) 170 {} 171# endif//!GLM_HAS_DEFAULTED_FUNCTIONS 172 173 template <typename T, precision P> 174 template <precision Q> 175 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(tvec4<T, Q> const & v) 176 : x(v.x), y(v.y), z(v.z), w(v.w) 177 {} 178 179 // -- Explicit basic constructors -- 180 181 template <typename T, precision P> 182 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(ctor) 183 {} 184 185 template <typename T, precision P> 186 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(T scalar) 187 : x(scalar), y(scalar), z(scalar), w(scalar) 188 {} 189 190 template <typename T, precision P> 191 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(T a, T b, T c, T d) 192 : x(a), y(b), z(c), w(d) 193 {} 194 195 // -- Conversion scalar constructors -- 196 197 template <typename T, precision P> 198 template <typename A, typename B, typename C, typename D> 199 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<T, P>::tvec4(A a, B b, C c, D d) : 200 x(static_cast<T>(a)), 201 y(static_cast<T>(b)), 202 z(static_cast<T>(c)), 203 w(static_cast<T>(d)) 204 {} 205 206 template <typename T, precision P> 207 template <typename A, typename B, typename C, typename D> 208 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec1<A, P> const & a, tvec1<B, P> const & b, tvec1<C, P> const & c, tvec1<D, P> const & d) : 209 x(static_cast<T>(a.x)), 210 y(static_cast<T>(b.x)), 211 z(static_cast<T>(c.x)), 212 w(static_cast<T>(d.x)) 213 {} 214 215 // -- Conversion vector constructors -- 216 217 template <typename T, precision P> 218 template <typename A, typename B, typename C, precision Q> 219 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec2<A, Q> const & a, B b, C c) : 220 x(static_cast<T>(a.x)), 221 y(static_cast<T>(a.y)), 222 z(static_cast<T>(b)), 223 w(static_cast<T>(c)) 224 {} 225 226 template <typename T, precision P> 227 template <typename A, typename B, typename C, precision Q> 228 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec2<A, Q> const & a, tvec1<B, Q> const & b, tvec1<C, Q> const & c) : 229 x(static_cast<T>(a.x)), 230 y(static_cast<T>(a.y)), 231 z(static_cast<T>(b.x)), 232 w(static_cast<T>(c.x)) 233 {} 234 235 template <typename T, precision P> 236 template <typename A, typename B, typename C, precision Q> 237 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(A s1, tvec2<B, Q> const & v, C s2) : 238 x(static_cast<T>(s1)), 239 y(static_cast<T>(v.x)), 240 z(static_cast<T>(v.y)), 241 w(static_cast<T>(s2)) 242 {} 243 244 template <typename T, precision P> 245 template <typename A, typename B, typename C, precision Q> 246 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec1<A, Q> const & a, tvec2<B, Q> const & b, tvec1<C, Q> const & c) : 247 x(static_cast<T>(a.x)), 248 y(static_cast<T>(b.x)), 249 z(static_cast<T>(b.y)), 250 w(static_cast<T>(c.x)) 251 {} 252 253 template <typename T, precision P> 254 template <typename A, typename B, typename C, precision Q> 255 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(A s1, B s2, tvec2<C, Q> const & v) : 256 x(static_cast<T>(s1)), 257 y(static_cast<T>(s2)), 258 z(static_cast<T>(v.x)), 259 w(static_cast<T>(v.y)) 260 {} 261 262 template <typename T, precision P> 263 template <typename A, typename B, typename C, precision Q> 264 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec1<A, Q> const & a, tvec1<B, Q> const & b, tvec2<C, Q> const & c) : 265 x(static_cast<T>(a.x)), 266 y(static_cast<T>(b.x)), 267 z(static_cast<T>(c.x)), 268 w(static_cast<T>(c.y)) 269 {} 270 271 template <typename T, precision P> 272 template <typename A, typename B, precision Q> 273 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec3<A, Q> const & a, B b) : 274 x(static_cast<T>(a.x)), 275 y(static_cast<T>(a.y)), 276 z(static_cast<T>(a.z)), 277 w(static_cast<T>(b)) 278 {} 279 280 template <typename T, precision P> 281 template <typename A, typename B, precision Q> 282 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec3<A, Q> const & a, tvec1<B, Q> const & b) : 283 x(static_cast<T>(a.x)), 284 y(static_cast<T>(a.y)), 285 z(static_cast<T>(a.z)), 286 w(static_cast<T>(b.x)) 287 {} 288 289 template <typename T, precision P> 290 template <typename A, typename B, precision Q> 291 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(A a, tvec3<B, Q> const & b) : 292 x(static_cast<T>(a)), 293 y(static_cast<T>(b.x)), 294 z(static_cast<T>(b.y)), 295 w(static_cast<T>(b.z)) 296 {} 297 298 template <typename T, precision P> 299 template <typename A, typename B, precision Q> 300 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec1<A, Q> const & a, tvec3<B, Q> const & b) : 301 x(static_cast<T>(a.x)), 302 y(static_cast<T>(b.x)), 303 z(static_cast<T>(b.y)), 304 w(static_cast<T>(b.z)) 305 {} 306 307 template <typename T, precision P> 308 template <typename A, typename B, precision Q> 309 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec2<A, Q> const & a, tvec2<B, Q> const & b) : 310 x(static_cast<T>(a.x)), 311 y(static_cast<T>(a.y)), 312 z(static_cast<T>(b.x)), 313 w(static_cast<T>(b.y)) 314 {} 315 316 template <typename T, precision P> 317 template <typename U, precision Q> 318 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec4<T, P>::tvec4(tvec4<U, Q> const & v) : 319 x(static_cast<T>(v.x)), 320 y(static_cast<T>(v.y)), 321 z(static_cast<T>(v.z)), 322 w(static_cast<T>(v.w)) 323 {} 324 325 // -- Component accesses -- 326 327 template <typename T, precision P> 328 GLM_FUNC_QUALIFIER T & tvec4<T, P>::operator[](typename tvec4<T, P>::length_type i) 329 { 330 assert(i >= 0 && i < this->length()); 331 return (&x)[i]; 332 } 333 334 template <typename T, precision P> 335 GLM_FUNC_QUALIFIER T const & tvec4<T, P>::operator[](typename tvec4<T, P>::length_type i) const 336 { 337 assert(i >= 0 && i < this->length()); 338 return (&x)[i]; 339 } 340 341 // -- Unary arithmetic operators -- 342 343# if !GLM_HAS_DEFAULTED_FUNCTIONS 344 template <typename T, precision P> 345 GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator=(tvec4<T, P> const & v) 346 { 347 this->x = v.x; 348 this->y = v.y; 349 this->z = v.z; 350 this->w = v.w; 351 return *this; 352 } 353# endif//!GLM_HAS_DEFAULTED_FUNCTIONS 354 355 template <typename T, precision P> 356 template <typename U> 357 GLM_FUNC_QUALIFIER tvec4<T, P>& tvec4<T, P>::operator=(tvec4<U, P> const & v) 358 { 359 this->x = static_cast<T>(v.x); 360 this->y = static_cast<T>(v.y); 361 this->z = static_cast<T>(v.z); 362 this->w = static_cast<T>(v.w); 363 return *this; 364 } 365 366 template <typename T, precision P> 367 template <typename U> 368 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator+=(U scalar) 369 { 370 return (*this = detail::compute_vec4_add<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 371 } 372 373 template <typename T, precision P> 374 template <typename U> 375 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator+=(tvec1<U, P> const & v) 376 { 377 return (*this = detail::compute_vec4_add<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v.x))); 378 } 379 380 template <typename T, precision P> 381 template <typename U> 382 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator+=(tvec4<U, P> const & v) 383 { 384 return (*this = detail::compute_vec4_add<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 385 } 386 387 template <typename T, precision P> 388 template <typename U> 389 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator-=(U scalar) 390 { 391 return (*this = detail::compute_vec4_sub<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 392 } 393 394 template <typename T, precision P> 395 template <typename U> 396 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator-=(tvec1<U, P> const & v) 397 { 398 return (*this = detail::compute_vec4_sub<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v.x))); 399 } 400 401 template <typename T, precision P> 402 template <typename U> 403 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator-=(tvec4<U, P> const & v) 404 { 405 return (*this = detail::compute_vec4_sub<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 406 } 407 408 template <typename T, precision P> 409 template <typename U> 410 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator*=(U scalar) 411 { 412 return (*this = detail::compute_vec4_mul<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 413 } 414 415 template <typename T, precision P> 416 template <typename U> 417 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator*=(tvec1<U, P> const & v) 418 { 419 return (*this = detail::compute_vec4_mul<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v.x))); 420 } 421 422 template <typename T, precision P> 423 template <typename U> 424 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator*=(tvec4<U, P> const & v) 425 { 426 return (*this = detail::compute_vec4_mul<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 427 } 428 429 template <typename T, precision P> 430 template <typename U> 431 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator/=(U scalar) 432 { 433 return (*this = detail::compute_vec4_div<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 434 } 435 436 template <typename T, precision P> 437 template <typename U> 438 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator/=(tvec1<U, P> const & v) 439 { 440 return (*this = detail::compute_vec4_div<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v.x))); 441 } 442 443 template <typename T, precision P> 444 template <typename U> 445 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator/=(tvec4<U, P> const & v) 446 { 447 return (*this = detail::compute_vec4_div<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 448 } 449 450 // -- Increment and decrement operators -- 451 452 template <typename T, precision P> 453 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator++() 454 { 455 ++this->x; 456 ++this->y; 457 ++this->z; 458 ++this->w; 459 return *this; 460 } 461 462 template <typename T, precision P> 463 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator--() 464 { 465 --this->x; 466 --this->y; 467 --this->z; 468 --this->w; 469 return *this; 470 } 471 472 template <typename T, precision P> 473 GLM_FUNC_QUALIFIER tvec4<T, P> tvec4<T, P>::operator++(int) 474 { 475 tvec4<T, P> Result(*this); 476 ++*this; 477 return Result; 478 } 479 480 template <typename T, precision P> 481 GLM_FUNC_QUALIFIER tvec4<T, P> tvec4<T, P>::operator--(int) 482 { 483 tvec4<T, P> Result(*this); 484 --*this; 485 return Result; 486 } 487 488 // -- Unary bit operators -- 489 490 template <typename T, precision P> 491 template <typename U> 492 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator%=(U scalar) 493 { 494 return (*this = detail::compute_vec4_mod<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 495 } 496 497 template <typename T, precision P> 498 template <typename U> 499 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator%=(tvec1<U, P> const& v) 500 { 501 return (*this = detail::compute_vec4_mod<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 502 } 503 504 template <typename T, precision P> 505 template <typename U> 506 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator%=(tvec4<U, P> const& v) 507 { 508 return (*this = detail::compute_vec4_mod<T, P, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 509 } 510 511 template <typename T, precision P> 512 template <typename U> 513 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator&=(U scalar) 514 { 515 return (*this = detail::compute_vec4_and<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 516 } 517 518 template <typename T, precision P> 519 template <typename U> 520 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator&=(tvec1<U, P> const & v) 521 { 522 return (*this = detail::compute_vec4_and<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 523 } 524 525 template <typename T, precision P> 526 template <typename U> 527 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator&=(tvec4<U, P> const & v) 528 { 529 return (*this = detail::compute_vec4_and<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 530 } 531 532 template <typename T, precision P> 533 template <typename U> 534 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator|=(U scalar) 535 { 536 return (*this = detail::compute_vec4_or<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 537 } 538 539 template <typename T, precision P> 540 template <typename U> 541 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator|=(tvec1<U, P> const & v) 542 { 543 return (*this = detail::compute_vec4_or<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 544 } 545 546 template <typename T, precision P> 547 template <typename U> 548 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator|=(tvec4<U, P> const & v) 549 { 550 return (*this = detail::compute_vec4_or<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 551 } 552 553 template <typename T, precision P> 554 template <typename U> 555 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator^=(U scalar) 556 { 557 return (*this = detail::compute_vec4_xor<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 558 } 559 560 template <typename T, precision P> 561 template <typename U> 562 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator^=(tvec1<U, P> const & v) 563 { 564 return (*this = detail::compute_vec4_xor<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 565 } 566 567 template <typename T, precision P> 568 template <typename U> 569 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator^=(tvec4<U, P> const & v) 570 { 571 return (*this = detail::compute_vec4_xor<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 572 } 573 574 template <typename T, precision P> 575 template <typename U> 576 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator<<=(U scalar) 577 { 578 return (*this = detail::compute_vec4_shift_left<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 579 } 580 581 template <typename T, precision P> 582 template <typename U> 583 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator<<=(tvec1<U, P> const & v) 584 { 585 return (*this = detail::compute_vec4_shift_left<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 586 } 587 588 template <typename T, precision P> 589 template <typename U> 590 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator<<=(tvec4<U, P> const & v) 591 { 592 return (*this = detail::compute_vec4_shift_left<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 593 } 594 595 template <typename T, precision P> 596 template <typename U> 597 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator>>=(U scalar) 598 { 599 return (*this = detail::compute_vec4_shift_right<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(scalar))); 600 } 601 602 template <typename T, precision P> 603 template <typename U> 604 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator>>=(tvec1<U, P> const & v) 605 { 606 return (*this = detail::compute_vec4_shift_right<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 607 } 608 609 template <typename T, precision P> 610 template <typename U> 611 GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator>>=(tvec4<U, P> const & v) 612 { 613 return (*this = detail::compute_vec4_shift_right<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(*this, tvec4<T, P>(v))); 614 } 615 616 // -- Unary constant operators -- 617 618 template <typename T, precision P> 619 GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v) 620 { 621 return v; 622 } 623 624 template <typename T, precision P> 625 GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v) 626 { 627 return tvec4<T, P>(0) -= v; 628 } 629 630 // -- Binary arithmetic operators -- 631 632 template <typename T, precision P> 633 GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v, T scalar) 634 { 635 return tvec4<T, P>(v) += scalar; 636 } 637 638 template <typename T, precision P> 639 GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 640 { 641 return tvec4<T, P>(v1) += v2; 642 } 643 644 template <typename T, precision P> 645 GLM_FUNC_QUALIFIER tvec4<T, P> operator+(T scalar, tvec4<T, P> const & v) 646 { 647 return tvec4<T, P>(v) += scalar; 648 } 649 650 template <typename T, precision P> 651 GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 652 { 653 return tvec4<T, P>(v2) += v1; 654 } 655 656 template <typename T, precision P> 657 GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 658 { 659 return tvec4<T, P>(v1) += v2; 660 } 661 662 template <typename T, precision P> 663 GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v, T scalar) 664 { 665 return tvec4<T, P>(v) -= scalar; 666 } 667 668 template <typename T, precision P> 669 GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 670 { 671 return tvec4<T, P>(v1) -= v2; 672 } 673 674 template <typename T, precision P> 675 GLM_FUNC_QUALIFIER tvec4<T, P> operator-(T scalar, tvec4<T, P> const & v) 676 { 677 return tvec4<T, P>(scalar) -= v; 678 } 679 680 template <typename T, precision P> 681 GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 682 { 683 return tvec4<T, P>(v1.x) -= v2; 684 } 685 686 template <typename T, precision P> 687 GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 688 { 689 return tvec4<T, P>(v1) -= v2; 690 } 691 692 template <typename T, precision P> 693 GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v, T scalar) 694 { 695 return tvec4<T, P>(v) *= scalar; 696 } 697 698 template <typename T, precision P> 699 GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 700 { 701 return tvec4<T, P>(v1) *= v2; 702 } 703 704 template <typename T, precision P> 705 GLM_FUNC_QUALIFIER tvec4<T, P> operator*(T scalar, tvec4<T, P> const & v) 706 { 707 return tvec4<T, P>(v) *= scalar; 708 } 709 710 template <typename T, precision P> 711 GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 712 { 713 return tvec4<T, P>(v2) *= v1; 714 } 715 716 template <typename T, precision P> 717 GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 718 { 719 return tvec4<T, P>(v1) *= v2; 720 } 721 722 template <typename T, precision P> 723 GLM_FUNC_QUALIFIER tvec4<T, P> operator/(tvec4<T, P> const & v, T scalar) 724 { 725 return tvec4<T, P>(v) /= scalar; 726 } 727 728 template <typename T, precision P> 729 GLM_FUNC_QUALIFIER tvec4<T, P> operator/(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 730 { 731 return tvec4<T, P>(v1) /= v2; 732 } 733 734 template <typename T, precision P> 735 GLM_FUNC_QUALIFIER tvec4<T, P> operator/(T scalar, tvec4<T, P> const & v) 736 { 737 return tvec4<T, P>(scalar) /= v; 738 } 739 740 template <typename T, precision P> 741 GLM_FUNC_QUALIFIER tvec4<T, P> operator/(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 742 { 743 return tvec4<T, P>(v1.x) /= v2; 744 } 745 746 template <typename T, precision P> 747 GLM_FUNC_QUALIFIER tvec4<T, P> operator/(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 748 { 749 return tvec4<T, P>(v1) /= v2; 750 } 751 752 // -- Binary bit operators -- 753 754 template <typename T, precision P> 755 GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec4<T, P> const & v, T scalar) 756 { 757 return tvec4<T, P>(v) %= scalar; 758 } 759 760 template <typename T, precision P> 761 GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 762 { 763 return tvec4<T, P>(v1) %= v2.x; 764 } 765 766 template <typename T, precision P> 767 GLM_FUNC_QUALIFIER tvec4<T, P> operator%(T scalar, tvec4<T, P> const & v) 768 { 769 return tvec4<T, P>(scalar) %= v; 770 } 771 772 template <typename T, precision P> 773 GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec1<T, P> const & scalar, tvec4<T, P> const & v) 774 { 775 return tvec4<T, P>(scalar.x) %= v; 776 } 777 778 template <typename T, precision P> 779 GLM_FUNC_QUALIFIER tvec4<T, P> operator%(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 780 { 781 return tvec4<T, P>(v1) %= v2; 782 } 783 784 template <typename T, precision P> 785 GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec4<T, P> const & v, T scalar) 786 { 787 return tvec4<T, P>(v) &= scalar; 788 } 789 790 template <typename T, precision P> 791 GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec4<T, P> const & v, tvec1<T, P> const & scalar) 792 { 793 return tvec4<T, P>(v) &= scalar; 794 } 795 796 template <typename T, precision P> 797 GLM_FUNC_QUALIFIER tvec4<T, P> operator&(T scalar, tvec4<T, P> const & v) 798 { 799 return tvec4<T, P>(scalar) &= v; 800 } 801 802 template <typename T, precision P> 803 GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 804 { 805 return tvec4<T, P>(v1.x) &= v2; 806 } 807 808 template <typename T, precision P> 809 GLM_FUNC_QUALIFIER tvec4<T, P> operator&(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 810 { 811 return tvec4<T, P>(v1) &= v2; 812 } 813 814 template <typename T, precision P> 815 GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec4<T, P> const & v, T scalar) 816 { 817 return tvec4<T, P>(v) |= scalar; 818 } 819 820 template <typename T, precision P> 821 GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 822 { 823 return tvec4<T, P>(v1) |= v2.x; 824 } 825 826 template <typename T, precision P> 827 GLM_FUNC_QUALIFIER tvec4<T, P> operator|(T scalar, tvec4<T, P> const & v) 828 { 829 return tvec4<T, P>(scalar) |= v; 830 } 831 832 template <typename T, precision P> 833 GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 834 { 835 return tvec4<T, P>(v1.x) |= v2; 836 } 837 838 template <typename T, precision P> 839 GLM_FUNC_QUALIFIER tvec4<T, P> operator|(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 840 { 841 return tvec4<T, P>(v1) |= v2; 842 } 843 844 template <typename T, precision P> 845 GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec4<T, P> const & v, T scalar) 846 { 847 return tvec4<T, P>(v) ^= scalar; 848 } 849 850 template <typename T, precision P> 851 GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 852 { 853 return tvec4<T, P>(v1) ^= v2.x; 854 } 855 856 template <typename T, precision P> 857 GLM_FUNC_QUALIFIER tvec4<T, P> operator^(T scalar, tvec4<T, P> const & v) 858 { 859 return tvec4<T, P>(scalar) ^= v; 860 } 861 862 template <typename T, precision P> 863 GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 864 { 865 return tvec4<T, P>(v1.x) ^= v2; 866 } 867 868 template <typename T, precision P> 869 GLM_FUNC_QUALIFIER tvec4<T, P> operator^(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 870 { 871 return tvec4<T, P>(v1) ^= v2; 872 } 873 874 template <typename T, precision P> 875 GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(tvec4<T, P> const & v, T scalar) 876 { 877 return tvec4<T, P>(v) <<= scalar; 878 } 879 880 template <typename T, precision P> 881 GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 882 { 883 return tvec4<T, P>(v1) <<= v2.x; 884 } 885 886 template <typename T, precision P> 887 GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(T scalar, tvec4<T, P> const & v) 888 { 889 return tvec4<T, P>(scalar) <<= v; 890 } 891 892 template <typename T, precision P> 893 GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 894 { 895 return tvec4<T, P>(v1.x) <<= v2; 896 } 897 898 template <typename T, precision P> 899 GLM_FUNC_QUALIFIER tvec4<T, P> operator<<(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 900 { 901 return tvec4<T, P>(v1) <<= v2; 902 } 903 904 template <typename T, precision P> 905 GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(tvec4<T, P> const & v, T scalar) 906 { 907 return tvec4<T, P>(v) >>= scalar; 908 } 909 910 template <typename T, precision P> 911 GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(tvec4<T, P> const & v1, tvec1<T, P> const & v2) 912 { 913 return tvec4<T, P>(v1) >>= v2.x; 914 } 915 916 template <typename T, precision P> 917 GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(T scalar, tvec4<T, P> const & v) 918 { 919 return tvec4<T, P>(scalar) >>= v; 920 } 921 922 template <typename T, precision P> 923 GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(tvec1<T, P> const & v1, tvec4<T, P> const & v2) 924 { 925 return tvec4<T, P>(v1.x) >>= v2; 926 } 927 928 template <typename T, precision P> 929 GLM_FUNC_QUALIFIER tvec4<T, P> operator>>(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 930 { 931 return tvec4<T, P>(v1) >>= v2; 932 } 933 934 template <typename T, precision P> 935 GLM_FUNC_QUALIFIER tvec4<T, P> operator~(tvec4<T, P> const & v) 936 { 937 return detail::compute_vec4_bitwise_not<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(v); 938 } 939 940 // -- Boolean operators -- 941 942 template <typename T, precision P> 943 GLM_FUNC_QUALIFIER bool operator==(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 944 { 945 return detail::compute_vec4_equal<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(v1, v2); 946 } 947 948 template <typename T, precision P> 949 GLM_FUNC_QUALIFIER bool operator!=(tvec4<T, P> const & v1, tvec4<T, P> const & v2) 950 { 951 return detail::compute_vec4_nequal<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(v1, v2); 952 } 953 954 template <precision P> 955 GLM_FUNC_QUALIFIER tvec4<bool, P> operator&&(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2) 956 { 957 return tvec4<bool, P>(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z, v1.w && v2.w); 958 } 959 960 template <precision P> 961 GLM_FUNC_QUALIFIER tvec4<bool, P> operator||(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2) 962 { 963 return tvec4<bool, P>(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z, v1.w || v2.w); 964 } 965}//namespace glm 966 967#if GLM_ARCH != GLM_ARCH_PURE && GLM_HAS_ALIGNED_TYPE 968# include "type_vec4_simd.inl" 969#endif 970