• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
2 
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef BOOST_QVM_6D6B1EE2119A11E291554FEE6188709B
7 #define BOOST_QVM_6D6B1EE2119A11E291554FEE6188709B
8 
9 #include <boost/qvm/inline.hpp>
10 #include <boost/qvm/deduce_quat.hpp>
11 #include <boost/qvm/detail/remove_const.hpp>
12 #include <boost/qvm/assert.hpp>
13 
14 namespace
15 boost
16     {
17     namespace
18     qvm
19         {
20         template <class T,int D>
21         struct
22         quat_traits<T[D]>
23             {
24             typedef void scalar_type;
25             };
26         template <class T,int D>
27         struct
28         quat_traits<T[D][4]>
29             {
30             typedef void scalar_type;
31             };
32         template <class T,int D>
33         struct
34         quat_traits<T[4][D]>
35             {
36             typedef void scalar_type;
37             };
38         template <class T>
39         struct
40         quat_traits<T[4][4]>
41             {
42             typedef void scalar_type;
43             };
44         template <class T,int M,int N>
45         struct
46         quat_traits<T[M][N]>
47             {
48             typedef void scalar_type;
49             };
50 
51         template <class T>
52         struct
53         quat_traits<T[4]>
54             {
55             typedef T this_quaternion[4];
56             typedef typename qvm_detail::remove_const<T>::type scalar_type;
57 
58             template <int I>
59             static
60             BOOST_QVM_INLINE_CRITICAL
61             scalar_type
read_elementboost::qvm::quat_traits62             read_element( this_quaternion const & x )
63                 {
64                 BOOST_QVM_STATIC_ASSERT(I>=0);
65                 BOOST_QVM_STATIC_ASSERT(I<4);
66                 return x[I];
67                 }
68 
69             template <int I>
70             static
71             BOOST_QVM_INLINE_CRITICAL
72             scalar_type &
write_elementboost::qvm::quat_traits73             write_element( this_quaternion & x )
74                 {
75                 BOOST_QVM_STATIC_ASSERT(I>=0);
76                 BOOST_QVM_STATIC_ASSERT(I<4);
77                 return x[I];
78                 }
79 
80             static
81             BOOST_QVM_INLINE_CRITICAL
82             scalar_type
read_element_idxboost::qvm::quat_traits83             read_element_idx( int i, this_quaternion const & x )
84                 {
85                 BOOST_QVM_ASSERT(i>=0);
86                 BOOST_QVM_ASSERT(i<4);
87                 return x[i];
88                 }
89 
90             static
91             BOOST_QVM_INLINE_CRITICAL
92             scalar_type &
write_element_idxboost::qvm::quat_traits93             write_element_idx( int i, this_quaternion & x )
94                 {
95                 BOOST_QVM_ASSERT(i>=0);
96                 BOOST_QVM_ASSERT(i<4);
97                 return x[i];
98                 }
99             };
100 
101         template <class T>
102         struct
103         deduce_quat<T[4]>
104             {
105             typedef quat<T> type;
106             };
107 
108         template <class T>
109         struct
110         deduce_quat<T const[4]>
111             {
112             typedef quat<T> type;
113             };
114 
115         template <class T1,class T2>
116         struct
117         deduce_quat2<T1[4],T2[4]>
118             {
119             typedef quat<typename deduce_scalar<T1,T2>::type> type;
120             };
121 
122         template <class T>
123         T (&ptr_qref( T * ptr ))[4]
__anon1a2488760102null124             {
125             return *reinterpret_cast<T (*)[4]>(ptr);
126             }
127         }
128     }
129 
130 #endif
131