diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llmath/v4math.h | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/llmath/v4math.h')
-rw-r--r-- | linden/indra/llmath/v4math.h | 127 |
1 files changed, 114 insertions, 13 deletions
diff --git a/linden/indra/llmath/v4math.h b/linden/indra/llmath/v4math.h index 60e30e3..4ef2d32 100644 --- a/linden/indra/llmath/v4math.h +++ b/linden/indra/llmath/v4math.h | |||
@@ -68,17 +68,29 @@ class LLVector4 | |||
68 | 68 | ||
69 | inline BOOL isFinite() const; // checks to see if all values of LLVector3 are finite | 69 | inline BOOL isFinite() const; // checks to see if all values of LLVector3 are finite |
70 | 70 | ||
71 | inline void clearVec(); // Clears LLVector4 to (0, 0, 0, 1) | 71 | inline void clear(); // Clears LLVector4 to (0, 0, 0, 1) |
72 | inline void zeroVec(); // zero LLVector4 to (0, 0, 0, 0) | 72 | inline void clearVec(); // deprecated |
73 | inline void setVec(F32 x, F32 y, F32 z); // Sets LLVector4 to (x, y, z, 1) | 73 | inline void zeroVec(); // deprecated |
74 | inline void setVec(F32 x, F32 y, F32 z, F32 w); // Sets LLVector4 to (x, y, z, w) | 74 | |
75 | inline void setVec(const LLVector4 &vec); // Sets LLVector4 to vec | 75 | inline void set(F32 x, F32 y, F32 z); // Sets LLVector4 to (x, y, z, 1) |
76 | inline void setVec(const LLVector3 &vec, F32 w = 1.f); // Sets LLVector4 to LLVector3 vec | 76 | inline void set(F32 x, F32 y, F32 z, F32 w); // Sets LLVector4 to (x, y, z, w) |
77 | inline void setVec(const F32 *vec); // Sets LLVector4 to vec | 77 | inline void set(const LLVector4 &vec); // Sets LLVector4 to vec |
78 | 78 | inline void set(const LLVector3 &vec, F32 w = 1.f); // Sets LLVector4 to LLVector3 vec | |
79 | F32 magVec() const; // Returns magnitude of LLVector4 | 79 | inline void set(const F32 *vec); // Sets LLVector4 to vec |
80 | F32 magVecSquared() const; // Returns magnitude squared of LLVector4 | 80 | |
81 | F32 normVec(); // Normalizes and returns the magnitude of LLVector4 | 81 | inline void setVec(F32 x, F32 y, F32 z); // deprecated |
82 | inline void setVec(F32 x, F32 y, F32 z, F32 w); // deprecated | ||
83 | inline void setVec(const LLVector4 &vec); // deprecated | ||
84 | inline void setVec(const LLVector3 &vec, F32 w = 1.f); // deprecated | ||
85 | inline void setVec(const F32 *vec); // deprecated | ||
86 | |||
87 | F32 length() const; // Returns magnitude of LLVector4 | ||
88 | F32 lengthSquared() const; // Returns magnitude squared of LLVector4 | ||
89 | F32 normalize(); // Normalizes and returns the magnitude of LLVector4 | ||
90 | |||
91 | F32 magVec() const; // deprecated | ||
92 | F32 magVecSquared() const; // deprecated | ||
93 | F32 normVec(); // deprecated | ||
82 | 94 | ||
83 | // Sets all values to absolute value of their original values | 95 | // Sets all values to absolute value of their original values |
84 | // Returns TRUE if data changed | 96 | // Returns TRUE if data changed |
@@ -192,6 +204,15 @@ inline BOOL LLVector4::isFinite() const | |||
192 | 204 | ||
193 | // Clear and Assignment Functions | 205 | // Clear and Assignment Functions |
194 | 206 | ||
207 | inline void LLVector4::clear(void) | ||
208 | { | ||
209 | mV[VX] = 0.f; | ||
210 | mV[VY] = 0.f; | ||
211 | mV[VZ] = 0.f; | ||
212 | mV[VW] = 1.f; | ||
213 | } | ||
214 | |||
215 | // deprecated | ||
195 | inline void LLVector4::clearVec(void) | 216 | inline void LLVector4::clearVec(void) |
196 | { | 217 | { |
197 | mV[VX] = 0.f; | 218 | mV[VX] = 0.f; |
@@ -200,6 +221,7 @@ inline void LLVector4::clearVec(void) | |||
200 | mV[VW] = 1.f; | 221 | mV[VW] = 1.f; |
201 | } | 222 | } |
202 | 223 | ||
224 | // deprecated | ||
203 | inline void LLVector4::zeroVec(void) | 225 | inline void LLVector4::zeroVec(void) |
204 | { | 226 | { |
205 | mV[VX] = 0.f; | 227 | mV[VX] = 0.f; |
@@ -208,6 +230,48 @@ inline void LLVector4::zeroVec(void) | |||
208 | mV[VW] = 0.f; | 230 | mV[VW] = 0.f; |
209 | } | 231 | } |
210 | 232 | ||
233 | inline void LLVector4::set(F32 x, F32 y, F32 z) | ||
234 | { | ||
235 | mV[VX] = x; | ||
236 | mV[VY] = y; | ||
237 | mV[VZ] = z; | ||
238 | mV[VW] = 1.f; | ||
239 | } | ||
240 | |||
241 | inline void LLVector4::set(F32 x, F32 y, F32 z, F32 w) | ||
242 | { | ||
243 | mV[VX] = x; | ||
244 | mV[VY] = y; | ||
245 | mV[VZ] = z; | ||
246 | mV[VW] = w; | ||
247 | } | ||
248 | |||
249 | inline void LLVector4::set(const LLVector4 &vec) | ||
250 | { | ||
251 | mV[VX] = vec.mV[VX]; | ||
252 | mV[VY] = vec.mV[VY]; | ||
253 | mV[VZ] = vec.mV[VZ]; | ||
254 | mV[VW] = vec.mV[VW]; | ||
255 | } | ||
256 | |||
257 | inline void LLVector4::set(const LLVector3 &vec, F32 w) | ||
258 | { | ||
259 | mV[VX] = vec.mV[VX]; | ||
260 | mV[VY] = vec.mV[VY]; | ||
261 | mV[VZ] = vec.mV[VZ]; | ||
262 | mV[VW] = w; | ||
263 | } | ||
264 | |||
265 | inline void LLVector4::set(const F32 *vec) | ||
266 | { | ||
267 | mV[VX] = vec[VX]; | ||
268 | mV[VY] = vec[VY]; | ||
269 | mV[VZ] = vec[VZ]; | ||
270 | mV[VW] = vec[VW]; | ||
271 | } | ||
272 | |||
273 | |||
274 | // deprecated | ||
211 | inline void LLVector4::setVec(F32 x, F32 y, F32 z) | 275 | inline void LLVector4::setVec(F32 x, F32 y, F32 z) |
212 | { | 276 | { |
213 | mV[VX] = x; | 277 | mV[VX] = x; |
@@ -216,6 +280,7 @@ inline void LLVector4::setVec(F32 x, F32 y, F32 z) | |||
216 | mV[VW] = 1.f; | 280 | mV[VW] = 1.f; |
217 | } | 281 | } |
218 | 282 | ||
283 | // deprecated | ||
219 | inline void LLVector4::setVec(F32 x, F32 y, F32 z, F32 w) | 284 | inline void LLVector4::setVec(F32 x, F32 y, F32 z, F32 w) |
220 | { | 285 | { |
221 | mV[VX] = x; | 286 | mV[VX] = x; |
@@ -224,6 +289,7 @@ inline void LLVector4::setVec(F32 x, F32 y, F32 z, F32 w) | |||
224 | mV[VW] = w; | 289 | mV[VW] = w; |
225 | } | 290 | } |
226 | 291 | ||
292 | // deprecated | ||
227 | inline void LLVector4::setVec(const LLVector4 &vec) | 293 | inline void LLVector4::setVec(const LLVector4 &vec) |
228 | { | 294 | { |
229 | mV[VX] = vec.mV[VX]; | 295 | mV[VX] = vec.mV[VX]; |
@@ -232,6 +298,7 @@ inline void LLVector4::setVec(const LLVector4 &vec) | |||
232 | mV[VW] = vec.mV[VW]; | 298 | mV[VW] = vec.mV[VW]; |
233 | } | 299 | } |
234 | 300 | ||
301 | // deprecated | ||
235 | inline void LLVector4::setVec(const LLVector3 &vec, F32 w) | 302 | inline void LLVector4::setVec(const LLVector3 &vec, F32 w) |
236 | { | 303 | { |
237 | mV[VX] = vec.mV[VX]; | 304 | mV[VX] = vec.mV[VX]; |
@@ -240,6 +307,7 @@ inline void LLVector4::setVec(const LLVector3 &vec, F32 w) | |||
240 | mV[VW] = w; | 307 | mV[VW] = w; |
241 | } | 308 | } |
242 | 309 | ||
310 | // deprecated | ||
243 | inline void LLVector4::setVec(const F32 *vec) | 311 | inline void LLVector4::setVec(const F32 *vec) |
244 | { | 312 | { |
245 | mV[VX] = vec[VX]; | 313 | mV[VX] = vec[VX]; |
@@ -250,6 +318,16 @@ inline void LLVector4::setVec(const F32 *vec) | |||
250 | 318 | ||
251 | // LLVector4 Magnitude and Normalization Functions | 319 | // LLVector4 Magnitude and Normalization Functions |
252 | 320 | ||
321 | inline F32 LLVector4::length(void) const | ||
322 | { | ||
323 | return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); | ||
324 | } | ||
325 | |||
326 | inline F32 LLVector4::lengthSquared(void) const | ||
327 | { | ||
328 | return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; | ||
329 | } | ||
330 | |||
253 | inline F32 LLVector4::magVec(void) const | 331 | inline F32 LLVector4::magVec(void) const |
254 | { | 332 | { |
255 | return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); | 333 | return fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); |
@@ -364,13 +442,13 @@ inline LLVector4 operator-(const LLVector4 &a) | |||
364 | inline F32 dist_vec(const LLVector4 &a, const LLVector4 &b) | 442 | inline F32 dist_vec(const LLVector4 &a, const LLVector4 &b) |
365 | { | 443 | { |
366 | LLVector4 vec = a - b; | 444 | LLVector4 vec = a - b; |
367 | return (vec.magVec()); | 445 | return (vec.length()); |
368 | } | 446 | } |
369 | 447 | ||
370 | inline F32 dist_vec_squared(const LLVector4 &a, const LLVector4 &b) | 448 | inline F32 dist_vec_squared(const LLVector4 &a, const LLVector4 &b) |
371 | { | 449 | { |
372 | LLVector4 vec = a - b; | 450 | LLVector4 vec = a - b; |
373 | return (vec.magVecSquared()); | 451 | return (vec.lengthSquared()); |
374 | } | 452 | } |
375 | 453 | ||
376 | inline LLVector4 lerp(const LLVector4 &a, const LLVector4 &b, F32 u) | 454 | inline LLVector4 lerp(const LLVector4 &a, const LLVector4 &b, F32 u) |
@@ -382,6 +460,29 @@ inline LLVector4 lerp(const LLVector4 &a, const LLVector4 &b, F32 u) | |||
382 | a.mV[VW] + (b.mV[VW] - a.mV[VW]) * u); | 460 | a.mV[VW] + (b.mV[VW] - a.mV[VW]) * u); |
383 | } | 461 | } |
384 | 462 | ||
463 | inline F32 LLVector4::normalize(void) | ||
464 | { | ||
465 | F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); | ||
466 | F32 oomag; | ||
467 | |||
468 | if (mag > FP_MAG_THRESHOLD) | ||
469 | { | ||
470 | oomag = 1.f/mag; | ||
471 | mV[VX] *= oomag; | ||
472 | mV[VY] *= oomag; | ||
473 | mV[VZ] *= oomag; | ||
474 | } | ||
475 | else | ||
476 | { | ||
477 | mV[0] = 0.f; | ||
478 | mV[1] = 0.f; | ||
479 | mV[2] = 0.f; | ||
480 | mag = 0; | ||
481 | } | ||
482 | return (mag); | ||
483 | } | ||
484 | |||
485 | // deprecated | ||
385 | inline F32 LLVector4::normVec(void) | 486 | inline F32 LLVector4::normVec(void) |
386 | { | 487 | { |
387 | F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); | 488 | F32 mag = fsqrtf(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); |