Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Core/Math/Headers/MathHelper.h

Diff revisions: vs.
  @@ -104,20 +104,22 @@
104 104 return ((bitMask & bit) == bit);
105 105 }
106 106
107 - template <typename T>
107 + template<typename T>
108 108 inline T squared(T n){
109 109 return n*n;
110 110 }
111 111
112 112 /// Clamps value n between min and max
113 - template <typename T>
113 + template<typename T>
114 114 inline void CLAMP(T& n, T min, T max){
115 115 n = std::min(std::max(n, min), max);
116 116 }
117 - template <typename T>
117 +
118 + template<typename T>
118 119 inline T CLAMPED(const T& n, T min, T max){
119 120 return std::min(std::max(n, min), max);
120 121 }
122 +
121 123 // bit manipulation
122 124 #define ToBit(posn) (1 << posn)
123 125 #define BitSet(arg,posn) (arg |= 1 << posn)
  @@ -133,17 +135,19 @@
133 135 #define BitMaskFlip(arg,mask) ((arg) ^= (mask))
134 136 #define BitMaskCheck(arg,mask) ((arg) & (mask))
135 137
136 - template <typename T>
138 + template<typename T>
137 139 class mat4;
138 - template <typename T>
140 + template<typename T>
139 141 class vec3;
140 - template <typename T>
142 + template<typename T>
141 143 class vec4;
142 - template <typename T>
144 + template<typename T>
143 145 class Quaternion;
144 146
145 147 namespace Util {
146 - inline void replaceStringInPlace( stringImpl& subject, const stringImpl& search, const stringImpl& replace ) {
148 + inline void replaceStringInPlace(stringImpl& subject,
149 + const stringImpl& search,
150 + const stringImpl& replace ) {
147 151 stringAlg::stringSize pos = 0;
148 152 while ( ( pos = subject.find( search, pos ) ) != stringImpl::npos ) {
149 153 subject.replace( pos, search.length(), replace );
  @@ -157,7 +161,10 @@
157 161 *second = temp;
158 162 }
159 163
160 - inline void permute( char* input, U32 startingIndex, U32 stringLength, vectorImpl<stringImpl>& container ) {
164 + inline void permute(char* input,
165 + U32 startingIndex,
166 + U32 stringLength,
167 + vectorImpl<stringImpl>& container ) {
161 168 if ( startingIndex == stringLength - 1 ) {
162 169 container.push_back( input );
163 170 } else {
  @@ -169,7 +176,8 @@
169 176 }
170 177 }
171 178
172 - inline void getPermutations( const stringImpl& inputString, vectorImpl<stringImpl>& permutationContainer ) {
179 + inline void getPermutations(const stringImpl& inputString,
180 + vectorImpl<stringImpl>& permutationContainer ) {
173 181 permutationContainer.clear();
174 182 permute( (char*)inputString.c_str(), 0, (U32)inputString.length() - 1, permutationContainer );
175 183 }
  @@ -218,7 +226,9 @@
218 226 }
219 227
220 228 /// http://stackoverflow.com/questions/53849/how-do-i-tokenize-a-string-in-c
221 - inline void split( const stringImpl& input, const char* delimiter, vectorImpl<stringImpl>& outputVector ) {
229 + inline void split(const stringImpl& input,
230 + const char* delimiter,
231 + vectorImpl<stringImpl>& outputVector ) {
222 232 stringAlg::stringSize delLen = static_cast<stringAlg::stringSize>( strlen( delimiter ) );
223 233 assert( !input.empty() && delLen > 0 );
224 234
  @@ -226,7 +236,9 @@
226 236 while ( end != stringImpl::npos ) {
227 237 end = input.find( delimiter, start );
228 238 // If at end, use length=maxLength. Else use length=end-start.
229 - outputVector.push_back( input.substr( start, ( end == stringImpl::npos ) ? stringImpl::npos : end - start ) );
239 + outputVector.push_back(input.substr(start,
240 + (end == stringImpl::npos) ? stringImpl::npos :
241 + end - start ) );
230 242 // If at end, use start=maxSize. Else use start=end+delimiter.
231 243 start = ( ( end > ( stringImpl::npos - delLen ) ) ? stringImpl::npos : end + delLen );
232 244 }
  @@ -234,12 +246,14 @@
234 246
235 247 /// http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
236 248 inline stringImpl& ltrim( stringImpl& s ) {
237 - s.erase( s.begin(), std::find_if( s.begin(), s.end(), std::not1( std::ptr_fun<int, int>( std::isspace ) ) ) );
249 + s.erase( s.begin(), std::find_if(s.begin(), s.end(),
250 + std::not1( std::ptr_fun<int, int>( std::isspace ) ) ) );
238 251 return s;
239 252 }
240 253
241 254 inline stringImpl& rtrim(stringImpl& s) {
242 - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
255 + s.erase(std::find_if(s.rbegin(), s.rend(),
256 + std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
243 257 return s;
244 258 }
245 259
  @@ -257,12 +271,17 @@
257 271
258 272 /** Ogre3D
259 273 @brief Normalise the selected rotations to be within the +/-180 degree range.
260 - @details The normalise uses a wrap around, so for example a yaw of 360 degrees becomes 0 degrees, and -190 degrees becomes 170.
274 + @details The normalise uses a wrap around,
275 + @details so for example a yaw of 360 degrees becomes 0 degrees, and -190 degrees becomes 170.
261 276 @param normYaw If false, the yaw isn't normalized.
262 277 @param normPitch If false, the pitch isn't normalized.
263 278 @param normRoll If false, the roll isn't normalized.
264 279 */
265 - void normalize(vec3<F32>& inputRotation, bool degrees = false, bool normYaw = true, bool normPitch = true, bool normRoll = true);
280 + void normalize(vec3<F32>& inputRotation,
281 + bool degrees = false,
282 + bool normYaw = true,
283 + bool normPitch = true,
284 + bool normRoll = true);
266 285
267 286 vec4<U8> toByteColor(const vec4<F32>& floatColor);
268 287 vec3<U8> toByteColor(const vec3<F32>& floatColor);