diff options
author | dahlia | 2010-07-08 11:10:08 -0700 |
---|---|---|
committer | dahlia | 2010-07-08 11:10:08 -0700 |
commit | d06b75fe3b010347e100a132daa716b6498e5c0b (patch) | |
tree | e4509d9bb350b92d6bd321396ef3e29f42c39fad /OpenSim | |
parent | Switched order of conditionals. (diff) | |
download | opensim-SC_OLD-d06b75fe3b010347e100a132daa716b6498e5c0b.zip opensim-SC_OLD-d06b75fe3b010347e100a132daa716b6498e5c0b.tar.gz opensim-SC_OLD-d06b75fe3b010347e100a132daa716b6498e5c0b.tar.bz2 opensim-SC_OLD-d06b75fe3b010347e100a132daa716b6498e5c0b.tar.xz |
fix a potential division by zero
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 941c761..bb5267c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -259,10 +259,15 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
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 |