vrshoot

view libs/assimp/assimp/color4.inl @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
6 Copyright (c) 2006-2012, assimp team
8 All rights reserved.
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
14 * Redistributions of source code must retain the above
15 copyright notice, this list of conditions and the
16 following disclaimer.
18 * Redistributions in binary form must reproduce the above
19 copyright notice, this list of conditions and the
20 following disclaimer in the documentation and/or other
21 materials provided with the distribution.
23 * Neither the name of the assimp team, nor the names of its
24 contributors may be used to endorse or promote products
25 derived from this software without specific prior
26 written permission of the assimp team.
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
42 /** @file aiColor4D.inl
43 * @brief Inline implementation of aiColor4t<TReal> operators
44 */
45 #ifndef AI_COLOR4D_INL_INC
46 #define AI_COLOR4D_INL_INC
48 #ifdef __cplusplus
49 #include "color4.h"
51 // ------------------------------------------------------------------------------------------------
52 template <typename TReal>
53 AI_FORCE_INLINE const aiColor4t<TReal>& aiColor4t<TReal>::operator += (const aiColor4t<TReal>& o) {
54 r += o.r; g += o.g; b += o.b; a += o.a;
55 return *this;
56 }
57 // ------------------------------------------------------------------------------------------------
58 template <typename TReal>
59 AI_FORCE_INLINE const aiColor4t<TReal>& aiColor4t<TReal>::operator -= (const aiColor4t<TReal>& o) {
60 r -= o.r; g -= o.g; b -= o.b; a -= o.a;
61 return *this;
62 }
63 // ------------------------------------------------------------------------------------------------
64 template <typename TReal>
65 AI_FORCE_INLINE const aiColor4t<TReal>& aiColor4t<TReal>::operator *= (TReal f) {
66 r *= f; g *= f; b *= f; a *= f;
67 return *this;
68 }
69 // ------------------------------------------------------------------------------------------------
70 template <typename TReal>
71 AI_FORCE_INLINE const aiColor4t<TReal>& aiColor4t<TReal>::operator /= (TReal f) {
72 r /= f; g /= f; b /= f; a /= f;
73 return *this;
74 }
75 // ------------------------------------------------------------------------------------------------
76 template <typename TReal>
77 AI_FORCE_INLINE TReal aiColor4t<TReal>::operator[](unsigned int i) const {
78 return *(&r + i);
79 }
80 // ------------------------------------------------------------------------------------------------
81 template <typename TReal>
82 AI_FORCE_INLINE TReal& aiColor4t<TReal>::operator[](unsigned int i) {
83 return *(&r + i);
84 }
85 // ------------------------------------------------------------------------------------------------
86 template <typename TReal>
87 AI_FORCE_INLINE bool aiColor4t<TReal>::operator== (const aiColor4t<TReal>& other) const {
88 return r == other.r && g == other.g && b == other.b && a == other.a;
89 }
90 // ------------------------------------------------------------------------------------------------
91 template <typename TReal>
92 AI_FORCE_INLINE bool aiColor4t<TReal>::operator!= (const aiColor4t<TReal>& other) const {
93 return r != other.r || g != other.g || b != other.b || a != other.a;
94 }
95 // ------------------------------------------------------------------------------------------------
96 template <typename TReal>
97 AI_FORCE_INLINE aiColor4t<TReal> operator + (const aiColor4t<TReal>& v1, const aiColor4t<TReal>& v2) {
98 return aiColor4t<TReal>( v1.r + v2.r, v1.g + v2.g, v1.b + v2.b, v1.a + v2.a);
99 }
100 // ------------------------------------------------------------------------------------------------
101 template <typename TReal>
102 AI_FORCE_INLINE aiColor4t<TReal> operator - (const aiColor4t<TReal>& v1, const aiColor4t<TReal>& v2) {
103 return aiColor4t<TReal>( v1.r - v2.r, v1.g - v2.g, v1.b - v2.b, v1.a - v2.a);
104 }
105 // ------------------------------------------------------------------------------------------------
106 template <typename TReal>
107 AI_FORCE_INLINE aiColor4t<TReal> operator * (const aiColor4t<TReal>& v1, const aiColor4t<TReal>& v2) {
108 return aiColor4t<TReal>( v1.r * v2.r, v1.g * v2.g, v1.b * v2.b, v1.a * v2.a);
109 }
110 // ------------------------------------------------------------------------------------------------
111 template <typename TReal>
112 AI_FORCE_INLINE aiColor4t<TReal> operator / (const aiColor4t<TReal>& v1, const aiColor4t<TReal>& v2) {
113 return aiColor4t<TReal>( v1.r / v2.r, v1.g / v2.g, v1.b / v2.b, v1.a / v2.a);
114 }
115 // ------------------------------------------------------------------------------------------------
116 template <typename TReal>
117 AI_FORCE_INLINE aiColor4t<TReal> operator * ( TReal f, const aiColor4t<TReal>& v) {
118 return aiColor4t<TReal>( f*v.r, f*v.g, f*v.b, f*v.a);
119 }
120 // ------------------------------------------------------------------------------------------------
121 template <typename TReal>
122 AI_FORCE_INLINE aiColor4t<TReal> operator * ( const aiColor4t<TReal>& v, TReal f) {
123 return aiColor4t<TReal>( f*v.r, f*v.g, f*v.b, f*v.a);
124 }
125 // ------------------------------------------------------------------------------------------------
126 template <typename TReal>
127 AI_FORCE_INLINE aiColor4t<TReal> operator / ( const aiColor4t<TReal>& v, TReal f) {
128 return v * (1/f);
129 }
130 // ------------------------------------------------------------------------------------------------
131 template <typename TReal>
132 AI_FORCE_INLINE aiColor4t<TReal> operator / ( TReal f,const aiColor4t<TReal>& v) {
133 return aiColor4t<TReal>(f,f,f,f)/v;
134 }
135 // ------------------------------------------------------------------------------------------------
136 template <typename TReal>
137 AI_FORCE_INLINE aiColor4t<TReal> operator + ( const aiColor4t<TReal>& v, TReal f) {
138 return aiColor4t<TReal>( f+v.r, f+v.g, f+v.b, f+v.a);
139 }
140 // ------------------------------------------------------------------------------------------------
141 template <typename TReal>
142 AI_FORCE_INLINE aiColor4t<TReal> operator - ( const aiColor4t<TReal>& v, TReal f) {
143 return aiColor4t<TReal>( v.r-f, v.g-f, v.b-f, v.a-f);
144 }
145 // ------------------------------------------------------------------------------------------------
146 template <typename TReal>
147 AI_FORCE_INLINE aiColor4t<TReal> operator + ( TReal f, const aiColor4t<TReal>& v) {
148 return aiColor4t<TReal>( f+v.r, f+v.g, f+v.b, f+v.a);
149 }
150 // ------------------------------------------------------------------------------------------------
151 template <typename TReal>
152 AI_FORCE_INLINE aiColor4t<TReal> operator - ( TReal f, const aiColor4t<TReal>& v) {
153 return aiColor4t<TReal>( f-v.r, f-v.g, f-v.b, f-v.a);
154 }
156 // ------------------------------------------------------------------------------------------------
157 template <typename TReal>
158 inline bool aiColor4t<TReal> :: IsBlack() const {
159 // The alpha component doesn't care here. black is black.
160 static const TReal epsilon = 10e-3f;
161 return fabs( r ) < epsilon && fabs( g ) < epsilon && fabs( b ) < epsilon;
162 }
164 #endif // __cplusplus
165 #endif // AI_VECTOR3D_INL_INC