diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmath/v2math.h | 95 |
1 files changed, 86 insertions, 9 deletions
diff --git a/linden/indra/llmath/v2math.h b/linden/indra/llmath/v2math.h index b951786..5a520d2 100644 --- a/linden/indra/llmath/v2math.h +++ b/linden/indra/llmath/v2math.h | |||
@@ -54,18 +54,26 @@ class LLVector2 | |||
54 | LLVector2(const F32 *vec); // Initializes LLVector2 to (vec[0]. vec[1]) | 54 | LLVector2(const F32 *vec); // Initializes LLVector2 to (vec[0]. vec[1]) |
55 | 55 | ||
56 | // Clears LLVector2 to (0, 0). DEPRECATED - prefer zeroVec. | 56 | // Clears LLVector2 to (0, 0). DEPRECATED - prefer zeroVec. |
57 | void clearVec(); | 57 | void clear(); |
58 | void setZero(); | ||
59 | void clearVec(); // deprecated | ||
60 | void zeroVec(); // deprecated | ||
58 | 61 | ||
59 | // Zero LLVector2 to (0, 0) | 62 | void set(F32 x, F32 y); // Sets LLVector2 to (x, y) |
60 | void zeroVec(); | 63 | void set(const LLVector2 &vec); // Sets LLVector2 to vec |
64 | void set(const F32 *vec); // Sets LLVector2 to vec | ||
61 | 65 | ||
62 | void setVec(F32 x, F32 y); // Sets LLVector2 to (x, y) | 66 | void setVec(F32 x, F32 y); // deprecated |
63 | void setVec(const LLVector2 &vec); // Sets LLVector2 to vec | 67 | void setVec(const LLVector2 &vec); // deprecated |
64 | void setVec(const F32 *vec); // Sets LLVector2 to vec | 68 | void setVec(const F32 *vec); // deprecated |
65 | 69 | ||
66 | F32 magVec() const; // Returns magnitude of LLVector2 | 70 | F32 length() const; // Returns magnitude of LLVector2 |
67 | F32 magVecSquared() const; // Returns magnitude squared of LLVector2 | 71 | F32 lengthSquared() const; // Returns magnitude squared of LLVector2 |
68 | F32 normVec(); // Normalizes and returns the magnitude of LLVector2 | 72 | F32 normalize(); // Normalizes and returns the magnitude of LLVector2 |
73 | |||
74 | F32 magVec() const; // deprecated | ||
75 | F32 magVecSquared() const; // deprecated | ||
76 | F32 normVec(); // deprecated | ||
69 | 77 | ||
70 | BOOL abs(); // sets all values to absolute value of original value (first octant), returns TRUE if changed | 78 | BOOL abs(); // sets all values to absolute value of original value (first octant), returns TRUE if changed |
71 | 79 | ||
@@ -132,30 +140,66 @@ inline LLVector2::LLVector2(const F32 *vec) | |||
132 | 140 | ||
133 | // Clear and Assignment Functions | 141 | // Clear and Assignment Functions |
134 | 142 | ||
143 | inline void LLVector2::clear(void) | ||
144 | { | ||
145 | mV[VX] = 0.f; | ||
146 | mV[VY] = 0.f; | ||
147 | } | ||
148 | |||
149 | inline void LLVector2::setZero(void) | ||
150 | { | ||
151 | mV[VX] = 0.f; | ||
152 | mV[VY] = 0.f; | ||
153 | } | ||
154 | |||
155 | // deprecated | ||
135 | inline void LLVector2::clearVec(void) | 156 | inline void LLVector2::clearVec(void) |
136 | { | 157 | { |
137 | mV[VX] = 0.f; | 158 | mV[VX] = 0.f; |
138 | mV[VY] = 0.f; | 159 | mV[VY] = 0.f; |
139 | } | 160 | } |
140 | 161 | ||
162 | // deprecated | ||
141 | inline void LLVector2::zeroVec(void) | 163 | inline void LLVector2::zeroVec(void) |
142 | { | 164 | { |
143 | mV[VX] = 0.f; | 165 | mV[VX] = 0.f; |
144 | mV[VY] = 0.f; | 166 | mV[VY] = 0.f; |
145 | } | 167 | } |
146 | 168 | ||
169 | inline void LLVector2::set(F32 x, F32 y) | ||
170 | { | ||
171 | mV[VX] = x; | ||
172 | mV[VY] = y; | ||
173 | } | ||
174 | |||
175 | inline void LLVector2::set(const LLVector2 &vec) | ||
176 | { | ||
177 | mV[VX] = vec.mV[VX]; | ||
178 | mV[VY] = vec.mV[VY]; | ||
179 | } | ||
180 | |||
181 | inline void LLVector2::set(const F32 *vec) | ||
182 | { | ||
183 | mV[VX] = vec[VX]; | ||
184 | mV[VY] = vec[VY]; | ||
185 | } | ||
186 | |||
187 | |||
188 | // deprecated | ||
147 | inline void LLVector2::setVec(F32 x, F32 y) | 189 | inline void LLVector2::setVec(F32 x, F32 y) |
148 | { | 190 | { |
149 | mV[VX] = x; | 191 | mV[VX] = x; |
150 | mV[VY] = y; | 192 | mV[VY] = y; |
151 | } | 193 | } |
152 | 194 | ||
195 | // deprecated | ||
153 | inline void LLVector2::setVec(const LLVector2 &vec) | 196 | inline void LLVector2::setVec(const LLVector2 &vec) |
154 | { | 197 | { |
155 | mV[VX] = vec.mV[VX]; | 198 | mV[VX] = vec.mV[VX]; |
156 | mV[VY] = vec.mV[VY]; | 199 | mV[VY] = vec.mV[VY]; |
157 | } | 200 | } |
158 | 201 | ||
202 | // deprecated | ||
159 | inline void LLVector2::setVec(const F32 *vec) | 203 | inline void LLVector2::setVec(const F32 *vec) |
160 | { | 204 | { |
161 | mV[VX] = vec[VX]; | 205 | mV[VX] = vec[VX]; |
@@ -164,16 +208,49 @@ inline void LLVector2::setVec(const F32 *vec) | |||
164 | 208 | ||
165 | // LLVector2 Magnitude and Normalization Functions | 209 | // LLVector2 Magnitude and Normalization Functions |
166 | 210 | ||
211 | inline F32 LLVector2::length(void) const | ||
212 | { | ||
213 | return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); | ||
214 | } | ||
215 | |||
216 | inline F32 LLVector2::lengthSquared(void) const | ||
217 | { | ||
218 | return mV[0]*mV[0] + mV[1]*mV[1]; | ||
219 | } | ||
220 | |||
221 | inline F32 LLVector2::normalize(void) | ||
222 | { | ||
223 | F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); | ||
224 | F32 oomag; | ||
225 | |||
226 | if (mag > FP_MAG_THRESHOLD) | ||
227 | { | ||
228 | oomag = 1.f/mag; | ||
229 | mV[0] *= oomag; | ||
230 | mV[1] *= oomag; | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | mV[0] = 0.f; | ||
235 | mV[1] = 0.f; | ||
236 | mag = 0; | ||
237 | } | ||
238 | return (mag); | ||
239 | } | ||
240 | |||
241 | // deprecated | ||
167 | inline F32 LLVector2::magVec(void) const | 242 | inline F32 LLVector2::magVec(void) const |
168 | { | 243 | { |
169 | return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); | 244 | return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); |
170 | } | 245 | } |
171 | 246 | ||
247 | // deprecated | ||
172 | inline F32 LLVector2::magVecSquared(void) const | 248 | inline F32 LLVector2::magVecSquared(void) const |
173 | { | 249 | { |
174 | return mV[0]*mV[0] + mV[1]*mV[1]; | 250 | return mV[0]*mV[0] + mV[1]*mV[1]; |
175 | } | 251 | } |
176 | 252 | ||
253 | // deprecated | ||
177 | inline F32 LLVector2::normVec(void) | 254 | inline F32 LLVector2::normVec(void) |
178 | { | 255 | { |
179 | F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); | 256 | F32 mag = fsqrtf(mV[0]*mV[0] + mV[1]*mV[1]); |