You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1050 lines
18 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  5. /// Permission is hereby granted, free of charge, to any person obtaining a copy
  6. /// of this software and associated documentation files (the "Software"), to deal
  7. /// in the Software without restriction, including without limitation the rights
  8. /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. /// copies of the Software, and to permit persons to whom the Software is
  10. /// furnished to do so, subject to the following conditions:
  11. ///
  12. /// The above copyright notice and this permission notice shall be included in
  13. /// all copies or substantial portions of the Software.
  14. ///
  15. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. /// THE SOFTWARE.
  22. ///
  23. /// @ref gtc_half_float
  24. /// @file glm/gtc/half_float.inl
  25. /// @date 2009-04-29 / 2012-11-06
  26. /// @author Christophe Riccio
  27. ///////////////////////////////////////////////////////////////////////////////////
  28. namespace glm{
  29. namespace detail
  30. {
  31. #if(GLM_COMPONENT == GLM_COMPONENT_CXX98)
  32. //////////////////////////////////////
  33. // hvec2
  34. GLM_FUNC_QUALIFIER tvec2<half>::size_type tvec2<half>::length() const
  35. {
  36. return 2;
  37. }
  38. GLM_FUNC_QUALIFIER tvec2<half>::size_type tvec2<half>::value_size()
  39. {
  40. return 2;
  41. }
  42. //////////////////////////////////////
  43. // Accesses
  44. GLM_FUNC_QUALIFIER half & tvec2<half>::operator[](tvec2<half>::size_type i)
  45. {
  46. assert(/*i >= tvec2<half>::size_type(0) && */i < tvec2<half>::value_size());
  47. return (&x)[i];
  48. }
  49. GLM_FUNC_QUALIFIER half const & tvec2<half>::operator[](tvec2<half>::size_type i) const
  50. {
  51. assert(/*i >= tvec2<half>::size_type(0) && */i < tvec2<half>::value_size());
  52. return (&x)[i];
  53. }
  54. //////////////////////////////////////
  55. // Implicit basic constructors
  56. GLM_FUNC_QUALIFIER tvec2<half>::tvec2() :
  57. x(half(0.f)),
  58. y(half(0.f))
  59. {}
  60. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  61. (
  62. tvec2<half> const & v
  63. ) :
  64. x(v.x),
  65. y(v.y)
  66. {}
  67. //////////////////////////////////////
  68. // Explicit basic constructors
  69. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  70. (
  71. half const & s
  72. ) :
  73. x(s),
  74. y(s)
  75. {}
  76. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  77. (
  78. half const & s1,
  79. half const & s2
  80. ) :
  81. x(s1),
  82. y(s2)
  83. {}
  84. //////////////////////////////////////
  85. // Swizzle constructors
  86. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  87. (
  88. tref2<half> const & r
  89. ) :
  90. x(r.x),
  91. y(r.y)
  92. {}
  93. //////////////////////////////////////
  94. // Convertion scalar constructors
  95. template <typename U>
  96. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  97. (
  98. U const & x
  99. ) :
  100. x(half(x)),
  101. y(half(x))
  102. {}
  103. template <typename U, typename V>
  104. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  105. (
  106. U const & x,
  107. V const & y
  108. ) :
  109. x(half(x)),
  110. y(half(y))
  111. {}
  112. //////////////////////////////////////
  113. // Convertion vector constructors
  114. template <typename U>
  115. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  116. (
  117. tvec2<U> const & v
  118. ) :
  119. x(half(v.x)),
  120. y(half(v.y))
  121. {}
  122. template <typename U>
  123. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  124. (
  125. tvec3<U> const & v
  126. ) :
  127. x(half(v.x)),
  128. y(half(v.y))
  129. {}
  130. template <typename U>
  131. GLM_FUNC_QUALIFIER tvec2<half>::tvec2
  132. (
  133. tvec4<U> const & v
  134. ) :
  135. x(half(v.x)),
  136. y(half(v.y))
  137. {}
  138. //////////////////////////////////////
  139. // Unary arithmetic operators
  140. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator=
  141. (
  142. tvec2<half> const & v
  143. )
  144. {
  145. this->x = v.x;
  146. this->y = v.y;
  147. return *this;
  148. }
  149. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator+=
  150. (
  151. half const & s
  152. )
  153. {
  154. this->x += s;
  155. this->y += s;
  156. return *this;
  157. }
  158. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator+=
  159. (
  160. tvec2<half> const & v
  161. )
  162. {
  163. this->x += v.x;
  164. this->y += v.y;
  165. return *this;
  166. }
  167. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator-=
  168. (
  169. half const & s
  170. )
  171. {
  172. this->x -= s;
  173. this->y -= s;
  174. return *this;
  175. }
  176. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator-=
  177. (
  178. tvec2<half> const & v
  179. )
  180. {
  181. this->x -= v.x;
  182. this->y -= v.y;
  183. return *this;
  184. }
  185. GLM_FUNC_QUALIFIER tvec2<half>& tvec2<half>::operator*=
  186. (
  187. half const & s
  188. )
  189. {
  190. this->x *= s;
  191. this->y *= s;
  192. return *this;
  193. }
  194. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator*=
  195. (
  196. tvec2<half> const & v
  197. )
  198. {
  199. this->x *= v.x;
  200. this->y *= v.y;
  201. return *this;
  202. }
  203. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator/=
  204. (
  205. half const & s
  206. )
  207. {
  208. this->x /= s;
  209. this->y /= s;
  210. return *this;
  211. }
  212. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator/=
  213. (
  214. tvec2<half> const & v
  215. )
  216. {
  217. this->x /= v.x;
  218. this->y /= v.y;
  219. return *this;
  220. }
  221. GLM_FUNC_QUALIFIER tvec2<half> & tvec2<half>::operator++()
  222. {
  223. ++this->x;
  224. ++this->y;
  225. return *this;
  226. }
  227. GLM_FUNC_QUALIFIER tvec2<half>& tvec2<half>::operator--()
  228. {
  229. --this->x;
  230. --this->y;
  231. return *this;
  232. }
  233. //////////////////////////////////////
  234. // Swizzle operators
  235. GLM_FUNC_QUALIFIER half tvec2<half>::swizzle(comp x) const
  236. {
  237. return (*this)[x];
  238. }
  239. GLM_FUNC_QUALIFIER tvec2<half> tvec2<half>::swizzle(comp x, comp y) const
  240. {
  241. return tvec2<half>(
  242. (*this)[x],
  243. (*this)[y]);
  244. }
  245. GLM_FUNC_QUALIFIER tvec3<half> tvec2<half>::swizzle(comp x, comp y, comp z) const
  246. {
  247. return tvec3<half>(
  248. (*this)[x],
  249. (*this)[y],
  250. (*this)[z]);
  251. }
  252. GLM_FUNC_QUALIFIER tvec4<half> tvec2<half>::swizzle(comp x, comp y, comp z, comp w) const
  253. {
  254. return tvec4<half>(
  255. (*this)[x],
  256. (*this)[y],
  257. (*this)[z],
  258. (*this)[w]);
  259. }
  260. GLM_FUNC_QUALIFIER tref2<half> tvec2<half>::swizzle(comp x, comp y)
  261. {
  262. return tref2<half>(
  263. (*this)[x],
  264. (*this)[y]);
  265. }
  266. //////////////////////////////////////
  267. // hvec3
  268. GLM_FUNC_QUALIFIER tvec3<half>::size_type tvec3<half>::length() const
  269. {
  270. return 3;
  271. }
  272. GLM_FUNC_QUALIFIER tvec3<half>::size_type tvec3<half>::value_size()
  273. {
  274. return 3;
  275. }
  276. //////////////////////////////////////
  277. // Accesses
  278. GLM_FUNC_QUALIFIER half & tvec3<half>::operator[]
  279. (
  280. tvec3<half>::size_type i
  281. )
  282. {
  283. assert(/*i >= tvec3<half>::size_type(0) &&*/ i < tvec3<half>::value_size());
  284. return (&x)[i];
  285. }
  286. GLM_FUNC_QUALIFIER half const & tvec3<half>::operator[]
  287. (
  288. tvec3<half>::size_type i
  289. ) const
  290. {
  291. assert(/*i >= tvec3<half>::size_type(0) &&*/ i < tvec3<half>::value_size());
  292. return (&x)[i];
  293. }
  294. //////////////////////////////////////
  295. // Implicit basic constructors
  296. GLM_FUNC_QUALIFIER tvec3<half>::tvec3() :
  297. x(half(0)),
  298. y(half(0)),
  299. z(half(0))
  300. {}
  301. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  302. (
  303. tvec3<half> const & v
  304. ) :
  305. x(v.x),
  306. y(v.y),
  307. z(v.z)
  308. {}
  309. //////////////////////////////////////
  310. // Explicit basic constructors
  311. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  312. (
  313. half const & s
  314. ) :
  315. x(s),
  316. y(s),
  317. z(s)
  318. {}
  319. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  320. (
  321. half const & s0,
  322. half const & s1,
  323. half const & s2
  324. ) :
  325. x(s0),
  326. y(s1),
  327. z(s2)
  328. {}
  329. //////////////////////////////////////
  330. // Swizzle constructors
  331. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  332. (
  333. tref3<half> const & r
  334. ) :
  335. x(r.x),
  336. y(r.y),
  337. z(r.z)
  338. {}
  339. //////////////////////////////////////
  340. // Convertion scalar constructors
  341. template <typename U>
  342. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  343. (
  344. U const & x
  345. ) :
  346. x(half(x)),
  347. y(half(x)),
  348. z(half(x))
  349. {}
  350. template <typename A, typename B, typename C>
  351. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  352. (
  353. A const & x,
  354. B const & y,
  355. C const & z
  356. ) :
  357. x(half(x)),
  358. y(half(y)),
  359. z(half(z))
  360. {}
  361. //////////////////////////////////////
  362. // Convertion vector constructors
  363. template <typename A, typename B>
  364. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  365. (
  366. tvec2<A> const & v,
  367. B const & s
  368. ) :
  369. x(half(v.x)),
  370. y(half(v.y)),
  371. z(half(s))
  372. {}
  373. template <typename A, typename B>
  374. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  375. (
  376. A const & s,
  377. tvec2<B> const & v
  378. ) :
  379. x(half(s)),
  380. y(half(v.x)),
  381. z(half(v.y))
  382. {}
  383. template <typename U>
  384. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  385. (
  386. tvec3<U> const & v
  387. ) :
  388. x(half(v.x)),
  389. y(half(v.y)),
  390. z(half(v.z))
  391. {}
  392. template <typename U>
  393. GLM_FUNC_QUALIFIER tvec3<half>::tvec3
  394. (
  395. tvec4<U> const & v
  396. ) :
  397. x(half(v.x)),
  398. y(half(v.y)),
  399. z(half(v.z))
  400. {}
  401. //////////////////////////////////////
  402. // Unary arithmetic operators
  403. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator=
  404. (
  405. tvec3<half> const & v
  406. )
  407. {
  408. this->x = v.x;
  409. this->y = v.y;
  410. this->z = v.z;
  411. return *this;
  412. }
  413. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator+=
  414. (
  415. half const & s
  416. )
  417. {
  418. this->x += s;
  419. this->y += s;
  420. this->z += s;
  421. return *this;
  422. }
  423. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator+=
  424. (
  425. tvec3<half> const & v
  426. )
  427. {
  428. this->x += v.x;
  429. this->y += v.y;
  430. this->z += v.z;
  431. return *this;
  432. }
  433. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator-=
  434. (
  435. half const & s
  436. )
  437. {
  438. this->x -= s;
  439. this->y -= s;
  440. this->z -= s;
  441. return *this;
  442. }
  443. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator-=
  444. (
  445. tvec3<half> const & v
  446. )
  447. {
  448. this->x -= v.x;
  449. this->y -= v.y;
  450. this->z -= v.z;
  451. return *this;
  452. }
  453. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator*=
  454. (
  455. half const & s
  456. )
  457. {
  458. this->x *= s;
  459. this->y *= s;
  460. this->z *= s;
  461. return *this;
  462. }
  463. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator*=
  464. (
  465. tvec3<half> const & v
  466. )
  467. {
  468. this->x *= v.x;
  469. this->y *= v.y;
  470. this->z *= v.z;
  471. return *this;
  472. }
  473. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator/=
  474. (
  475. half const & s
  476. )
  477. {
  478. this->x /= s;
  479. this->y /= s;
  480. this->z /= s;
  481. return *this;
  482. }
  483. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator/=
  484. (
  485. tvec3<half> const & v
  486. )
  487. {
  488. this->x /= v.x;
  489. this->y /= v.y;
  490. this->z /= v.z;
  491. return *this;
  492. }
  493. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator++()
  494. {
  495. ++this->x;
  496. ++this->y;
  497. ++this->z;
  498. return *this;
  499. }
  500. GLM_FUNC_QUALIFIER tvec3<half> & tvec3<half>::operator--()
  501. {
  502. --this->x;
  503. --this->y;
  504. --this->z;
  505. return *this;
  506. }
  507. //////////////////////////////////////
  508. // Swizzle operators
  509. GLM_FUNC_QUALIFIER half tvec3<half>::swizzle(comp x) const
  510. {
  511. return (*this)[x];
  512. }
  513. GLM_FUNC_QUALIFIER tvec2<half> tvec3<half>::swizzle(comp x, comp y) const
  514. {
  515. return tvec2<half>(
  516. (*this)[x],
  517. (*this)[y]);
  518. }
  519. GLM_FUNC_QUALIFIER tvec3<half> tvec3<half>::swizzle(comp x, comp y, comp z) const
  520. {
  521. return tvec3<half>(
  522. (*this)[x],
  523. (*this)[y],
  524. (*this)[z]);
  525. }
  526. GLM_FUNC_QUALIFIER tvec4<half> tvec3<half>::swizzle(comp x, comp y, comp z, comp w) const
  527. {
  528. return tvec4<half>(
  529. (*this)[x],
  530. (*this)[y],
  531. (*this)[z],
  532. (*this)[w]);
  533. }
  534. GLM_FUNC_QUALIFIER tref3<half> tvec3<half>::swizzle(comp x, comp y, comp z)
  535. {
  536. return tref3<half>(
  537. (*this)[x],
  538. (*this)[y],
  539. (*this)[z]);
  540. }
  541. //////////////////////////////////////
  542. // hvec4
  543. GLM_FUNC_QUALIFIER tvec4<half>::size_type tvec4<half>::length() const
  544. {
  545. return 4;
  546. }
  547. GLM_FUNC_QUALIFIER tvec4<half>::size_type tvec4<half>::value_size()
  548. {
  549. return 4;
  550. }
  551. //////////////////////////////////////
  552. // Accesses
  553. GLM_FUNC_QUALIFIER half & tvec4<half>::operator[]
  554. (
  555. tvec4<half>::size_type i
  556. )
  557. {
  558. assert(/*i >= tvec4<half>::size_type(0) && */i < tvec4<half>::value_size());
  559. return (&x)[i];
  560. }
  561. GLM_FUNC_QUALIFIER half const & tvec4<half>::operator[]
  562. (
  563. tvec4<half>::size_type i
  564. ) const
  565. {
  566. assert(/*i >= tvec4<half>::size_type(0) && */i < tvec4<half>::value_size());
  567. return (&x)[i];
  568. }
  569. //////////////////////////////////////
  570. // Implicit basic constructors
  571. GLM_FUNC_QUALIFIER tvec4<half>::tvec4() :
  572. x(half(0)),
  573. y(half(0)),
  574. z(half(0)),
  575. w(half(0))
  576. {}
  577. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  578. (
  579. tvec4<half> const & v
  580. ) :
  581. x(v.x),
  582. y(v.y),
  583. z(v.z),
  584. w(v.w)
  585. {}
  586. //////////////////////////////////////
  587. // Explicit basic constructors
  588. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  589. (
  590. half const & s
  591. ) :
  592. x(s),
  593. y(s),
  594. z(s),
  595. w(s)
  596. {}
  597. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  598. (
  599. half const & s1,
  600. half const & s2,
  601. half const & s3,
  602. half const & s4
  603. ) :
  604. x(s1),
  605. y(s2),
  606. z(s3),
  607. w(s4)
  608. {}
  609. //////////////////////////////////////
  610. // Swizzle constructors
  611. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  612. (
  613. tref4<half> const & r
  614. ) :
  615. x(r.x),
  616. y(r.y),
  617. z(r.z),
  618. w(r.w)
  619. {}
  620. //////////////////////////////////////
  621. // Convertion scalar constructors
  622. template <typename U>
  623. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  624. (
  625. U const & x
  626. ) :
  627. x(half(x)),
  628. y(half(x)),
  629. z(half(x)),
  630. w(half(x))
  631. {}
  632. template <typename A, typename B, typename C, typename D>
  633. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  634. (
  635. A const & x,
  636. B const & y,
  637. C const & z,
  638. D const & w
  639. ) :
  640. x(half(x)),
  641. y(half(y)),
  642. z(half(z)),
  643. w(half(w))
  644. {}
  645. //////////////////////////////////////
  646. // Convertion vector constructors
  647. template <typename A, typename B, typename C>
  648. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  649. (
  650. tvec2<A> const & v,
  651. B const & s1,
  652. C const & s2
  653. ) :
  654. x(half(v.x)),
  655. y(half(v.y)),
  656. z(half(s1)),
  657. w(half(s2))
  658. {}
  659. template <typename A, typename B, typename C>
  660. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  661. (
  662. A const & s1,
  663. tvec2<B> const & v,
  664. C const & s2
  665. ) :
  666. x(half(s1)),
  667. y(half(v.x)),
  668. z(half(v.y)),
  669. w(half(s2))
  670. {}
  671. template <typename A, typename B, typename C>
  672. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  673. (
  674. A const & s1,
  675. B const & s2,
  676. tvec2<C> const & v
  677. ) :
  678. x(half(s1)),
  679. y(half(s2)),
  680. z(half(v.x)),
  681. w(half(v.y))
  682. {}
  683. template <typename A, typename B>
  684. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  685. (
  686. tvec3<A> const & v,
  687. B const & s
  688. ) :
  689. x(half(v.x)),
  690. y(half(v.y)),
  691. z(half(v.z)),
  692. w(half(s))
  693. {}
  694. template <typename A, typename B>
  695. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  696. (
  697. A const & s,
  698. tvec3<B> const & v
  699. ) :
  700. x(half(s)),
  701. y(half(v.x)),
  702. z(half(v.y)),
  703. w(half(v.z))
  704. {}
  705. template <typename A, typename B>
  706. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  707. (
  708. tvec2<A> const & v1,
  709. tvec2<B> const & v2
  710. ) :
  711. x(half(v1.x)),
  712. y(half(v1.y)),
  713. z(half(v2.x)),
  714. w(half(v2.y))
  715. {}
  716. template <typename U>
  717. GLM_FUNC_QUALIFIER tvec4<half>::tvec4
  718. (
  719. tvec4<U> const & v
  720. ) :
  721. x(half(v.x)),
  722. y(half(v.y)),
  723. z(half(v.z)),
  724. w(half(v.w))
  725. {}
  726. //////////////////////////////////////
  727. // Unary arithmetic operators
  728. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator=
  729. (
  730. tvec4<half> const & v
  731. )
  732. {
  733. this->x = v.x;
  734. this->y = v.y;
  735. this->z = v.z;
  736. this->w = v.w;
  737. return *this;
  738. }
  739. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator+=
  740. (
  741. half const & s
  742. )
  743. {
  744. this->x += s;
  745. this->y += s;
  746. this->z += s;
  747. this->w += s;
  748. return *this;
  749. }
  750. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator+=
  751. (
  752. tvec4<half> const & v
  753. )
  754. {
  755. this->x += v.x;
  756. this->y += v.y;
  757. this->z += v.z;
  758. this->w += v.w;
  759. return *this;
  760. }
  761. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator-=
  762. (
  763. half const & s
  764. )
  765. {
  766. this->x -= s;
  767. this->y -= s;
  768. this->z -= s;
  769. this->w -= s;
  770. return *this;
  771. }
  772. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator-=
  773. (
  774. tvec4<half> const & v
  775. )
  776. {
  777. this->x -= v.x;
  778. this->y -= v.y;
  779. this->z -= v.z;
  780. this->w -= v.w;
  781. return *this;
  782. }
  783. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator*=
  784. (
  785. half const & s
  786. )
  787. {
  788. this->x *= s;
  789. this->y *= s;
  790. this->z *= s;
  791. this->w *= s;
  792. return *this;
  793. }
  794. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator*=
  795. (
  796. tvec4<half> const & v
  797. )
  798. {
  799. this->x *= v.x;
  800. this->y *= v.y;
  801. this->z *= v.z;
  802. this->w *= v.w;
  803. return *this;
  804. }
  805. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator/=
  806. (
  807. half const & s
  808. )
  809. {
  810. this->x /= s;
  811. this->y /= s;
  812. this->z /= s;
  813. this->w /= s;
  814. return *this;
  815. }
  816. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator/=
  817. (
  818. tvec4<half> const & v
  819. )
  820. {
  821. this->x /= v.x;
  822. this->y /= v.y;
  823. this->z /= v.z;
  824. this->w /= v.w;
  825. return *this;
  826. }
  827. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator++()
  828. {
  829. ++this->x;
  830. ++this->y;
  831. ++this->z;
  832. ++this->w;
  833. return *this;
  834. }
  835. GLM_FUNC_QUALIFIER tvec4<half>& tvec4<half>::operator--()
  836. {
  837. --this->x;
  838. --this->y;
  839. --this->z;
  840. --this->w;
  841. return *this;
  842. }
  843. //////////////////////////////////////
  844. // Swizzle operators
  845. GLM_FUNC_QUALIFIER half tvec4<half>::swizzle(comp x) const
  846. {
  847. return (*this)[x];
  848. }
  849. GLM_FUNC_QUALIFIER tvec2<half> tvec4<half>::swizzle(comp x, comp y) const
  850. {
  851. return tvec2<half>(
  852. (*this)[x],
  853. (*this)[y]);
  854. }
  855. GLM_FUNC_QUALIFIER tvec3<half> tvec4<half>::swizzle(comp x, comp y, comp z) const
  856. {
  857. return tvec3<half>(
  858. (*this)[x],
  859. (*this)[y],
  860. (*this)[z]);
  861. }
  862. GLM_FUNC_QUALIFIER tvec4<half> tvec4<half>::swizzle(comp x, comp y, comp z, comp w) const
  863. {
  864. return tvec4<half>(
  865. (*this)[x],
  866. (*this)[y],
  867. (*this)[z],
  868. (*this)[w]);
  869. }
  870. GLM_FUNC_QUALIFIER tref4<half> tvec4<half>::swizzle(comp x, comp y, comp z, comp w)
  871. {
  872. return tref4<half>(
  873. (*this)[x],
  874. (*this)[y],
  875. (*this)[z],
  876. (*this)[w]);
  877. }
  878. #endif//(GLM_COMPONENT == GLM_COMPONENT_CXX98)
  879. }//namespace detail
  880. GLM_FUNC_QUALIFIER half abs(half const & x)
  881. {
  882. return float(x) >= float(0) ? x : -x;
  883. }
  884. GLM_FUNC_QUALIFIER hvec2 abs(hvec2 const & v)
  885. {
  886. return hvec2(
  887. float(v.x) >= float(0) ? v.x : -v.x,
  888. float(v.y) >= float(0) ? v.y : -v.y);
  889. }
  890. GLM_FUNC_QUALIFIER hvec3 abs(hvec3 const & v)
  891. {
  892. return hvec3(
  893. float(v.x) >= float(0) ? v.x : -v.x,
  894. float(v.y) >= float(0) ? v.y : -v.y,
  895. float(v.z) >= float(0) ? v.z : -v.z);
  896. }
  897. GLM_FUNC_QUALIFIER hvec4 abs(hvec4 const & v)
  898. {
  899. return hvec4(
  900. float(v.x) >= float(0) ? v.x : -v.x,
  901. float(v.y) >= float(0) ? v.y : -v.y,
  902. float(v.z) >= float(0) ? v.z : -v.z,
  903. float(v.w) >= float(0) ? v.w : -v.w);
  904. }
  905. template <>
  906. GLM_FUNC_QUALIFIER glm::half mix
  907. (
  908. glm::half const & x,
  909. glm::half const & y,
  910. bool const & a
  911. )
  912. {
  913. return a ? y : x;
  914. }
  915. }//namespace glm