aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authordahlia2010-07-08 10:14:02 -0700
committerdahlia2010-07-08 10:14:02 -0700
commit0116b80795af199c8a68c6ba536c208ea82253d3 (patch)
treec9cb2387cca852fc997b182bcc3c122cb846933b /OpenSim
parentFix scripts in rezzed objects not starting (Mantis #4775) (diff)
downloadopensim-SC_OLD-0116b80795af199c8a68c6ba536c208ea82253d3.zip
opensim-SC_OLD-0116b80795af199c8a68c6ba536c208ea82253d3.tar.gz
opensim-SC_OLD-0116b80795af199c8a68c6ba536c208ea82253d3.tar.bz2
opensim-SC_OLD-0116b80795af199c8a68c6ba536c208ea82253d3.tar.xz
fix a potential division by zero
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs17
1 files changed, 11 insertions, 6 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 1ea52c5..326f327 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -257,12 +257,17 @@ namespace OpenSim.Region.ScriptEngine.Shared
257 public static double Mag(Vector3 v) 257 public static double Mag(Vector3 v)
258 { 258 {
259 return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); 259 return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
260 } 260 }
261 261
262 public static Vector3 Norm(Vector3 vector) 262 public static Vector3 Norm(Vector3 vector)
263 { 263 {
264 double mag = Mag(vector); 264 double mag = Mag(vector);
265 return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag); 265 if (mag > 0.0)
266 {
267 double invMag = 1.0 / mag;
268 return vector * invMag;
269 }
270 return new Vector3(0, 0, 0);
266 } 271 }
267 272
268 #endregion 273 #endregion