Blame view

3rdparty/boost_1_81_0/boost/qvm/quat_access.hpp 7.1 KB
0b6a182c   Hu Chunming   添加无鉴权注册和注销
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
  #ifndef BOOST_QVM_QUAT_ACCESS_HPP_INCLUDED
  #define BOOST_QVM_QUAT_ACCESS_HPP_INCLUDED
  
  // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
  
  // Distributed under the Boost Software License, Version 1.0. (See accompanying
  // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  
  #include <boost/qvm/config.hpp>
  #include <boost/qvm/quat_traits.hpp>
  #include <boost/qvm/deduce_vec.hpp>
  #include <boost/qvm/static_assert.hpp>
  #include <boost/qvm/enable_if.hpp>
  
  namespace boost { namespace qvm {
  
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type>::type S( Q const & a ) { return quat_traits<Q>::template read_element<0>(a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type>::type X( Q const & a ) { return quat_traits<Q>::template read_element<1>(a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type>::type Y( Q const & a ) { return quat_traits<Q>::template read_element<2>(a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type>::type Z( Q const & a ) { return quat_traits<Q>::template read_element<3>(a); }
  
  namespace
  qvm_detail
      {
      template <int I,class Q>
      struct
      q_element_access
          {
          BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
          void
          operator=( typename quat_traits<Q>::scalar_type s )
              {
              quat_traits<Q>::template write_element<I>(*reinterpret_cast<Q *>(this), s);
              }
  
          BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
          operator typename vec_traits<Q>::scalar_type() const
              {
              return quat_traits<Q>::template read_element<I>(*reinterpret_cast<Q const *>(this));
              }
          };
  
      template <class Q>
      struct
      quat_v_
          {
          template <class R
  #if __cplusplus >= 201103L
              , class = typename enable_if<is_vec<R> >::type
  #endif
          >
          operator R() const
              {
              R r;
              assign(r,*this);
              return r;
              }
  
          private:
  
          quat_v_( quat_v_ const & );
          quat_v_ const & operator=( quat_v_ const & );
          ~quat_v_();
          };
  
      template <class Q,bool WriteElementRef=quat_write_element_ref<Q>::value>
      struct quat_v_write_traits;
  
      template <class Q>
      struct
      quat_v_write_traits<Q,true>
          {
          typedef qvm_detail::quat_v_<Q> this_vector;
          typedef typename quat_traits<Q>::scalar_type scalar_type;
          static int const dim=3;
  
          template <int I>
          BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
          static
          scalar_type &
          write_element( this_vector & q )
              {
              BOOST_QVM_STATIC_ASSERT(I>=0);
              BOOST_QVM_STATIC_ASSERT(I<dim);
              return quat_traits<Q>::template write_element<I+1>( reinterpret_cast<Q &>(q) );
              }
          };
  
      template <class Q>
      struct
      quat_v_write_traits<Q,false>
          {
          typedef qvm_detail::quat_v_<Q> this_vector;
          typedef typename quat_traits<Q>::scalar_type scalar_type;
          static int const dim=3;
  
          template <int I>
          BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
          static
          void
          write_element( this_vector & q, scalar_type s )
              {
              BOOST_QVM_STATIC_ASSERT(I>=0);
              BOOST_QVM_STATIC_ASSERT(I<dim);
              quat_traits<Q>::template write_element<I+1>( reinterpret_cast<Q &>(q), s );
              }
          };
      }
  
  template <class V>
  struct vec_traits;
  
  template <class Q>
  struct
  vec_traits< qvm_detail::quat_v_<Q> >:
      qvm_detail::quat_v_write_traits<Q>
      {
      typedef qvm_detail::quat_v_<Q> this_vector;
      typedef typename quat_traits<Q>::scalar_type scalar_type;
      static int const dim=3;
  
      template <int I>
      BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
      static
      scalar_type
      read_element( this_vector const & q )
          {
          BOOST_QVM_STATIC_ASSERT(I>=0);
          BOOST_QVM_STATIC_ASSERT(I<dim);
          return quat_traits<Q>::template read_element<I+1>( reinterpret_cast<Q const &>(q) );
          }
      };
  
  template <class Q,int D>
  struct
  deduce_vec<qvm_detail::quat_v_<Q>,D>
      {
      typedef vec<typename quat_traits<Q>::scalar_type,D> type;
      };
  
  template <class Q,int D>
  struct
  deduce_vec2<qvm_detail::quat_v_<Q>,qvm_detail::quat_v_<Q>,D>
      {
      typedef vec<typename quat_traits<Q>::scalar_type,D> type;
      };
  
  template <class Q>
  BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
  typename enable_if_c<
      is_quat<Q>::value,
      qvm_detail::quat_v_<Q> const &>::type
  V( Q const & a )
      {
      return reinterpret_cast<qvm_detail::quat_v_<Q> const &>(a);
      }
  
  template <class Q>
  BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
  typename enable_if_c<
      is_quat<Q>::value,
      qvm_detail::quat_v_<Q> &>::type
  V( Q & a )
      {
      return reinterpret_cast<qvm_detail::quat_v_<Q> &>(a);
      }
  
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value && quat_write_element_ref<Q>::value,typename quat_traits<Q>::scalar_type &>::type S( Q & a ) { return quat_traits<Q>::template write_element<0>(a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value && quat_write_element_ref<Q>::value,typename quat_traits<Q>::scalar_type &>::type X( Q & a ) { return quat_traits<Q>::template write_element<1>(a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value && quat_write_element_ref<Q>::value,typename quat_traits<Q>::scalar_type &>::type Y( Q & a ) { return quat_traits<Q>::template write_element<2>(a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value && quat_write_element_ref<Q>::value,typename quat_traits<Q>::scalar_type &>::type Z( Q & a ) { return quat_traits<Q>::template write_element<3>(a); }
  
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value && !quat_write_element_ref<Q>::value,qvm_detail::q_element_access<0,Q> &>::type S( Q & a ) { return *reinterpret_cast<qvm_detail::q_element_access<0, Q> *>(&a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value && !quat_write_element_ref<Q>::value,qvm_detail::q_element_access<1,Q> &>::type X( Q & a ) { return *reinterpret_cast<qvm_detail::q_element_access<1, Q> *>(&a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value && !quat_write_element_ref<Q>::value,qvm_detail::q_element_access<2,Q> &>::type Y( Q & a ) { return *reinterpret_cast<qvm_detail::q_element_access<2, Q> *>(&a); }
  template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value && !quat_write_element_ref<Q>::value,qvm_detail::q_element_access<3,Q> &>::type Z( Q & a ) { return *reinterpret_cast<qvm_detail::q_element_access<3, Q> *>(&a); }
  
  } }
  
  #endif