aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMike Mazur2008-07-31 09:34:13 +0000
committerMike Mazur2008-07-31 09:34:13 +0000
commitddf126321cd05228a377e49ca23c16c4f0cfe25f (patch)
treede2a13daf95f48bdbd1cffa2f0a37724b0f5c902
parentThanks, sempuki, for a patch that moves all Grid Server's plugins to (diff)
downloadopensim-SC_OLD-ddf126321cd05228a377e49ca23c16c4f0cfe25f.zip
opensim-SC_OLD-ddf126321cd05228a377e49ca23c16c4f0cfe25f.tar.gz
opensim-SC_OLD-ddf126321cd05228a377e49ca23c16c4f0cfe25f.tar.bz2
opensim-SC_OLD-ddf126321cd05228a377e49ca23c16c4f0cfe25f.tar.xz
Thanks, M. Igarashi & nlin, for a patch that implements unary minus operator
for Vector3 type. Fix issue 1872.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs5
-rw-r--r--OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestVector3.cs11
2 files changed, 14 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index 21acac2..4fff717 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -126,6 +126,11 @@ namespace OpenSim.Region.ScriptEngine.Common
126 return (x == vector.x && x == vector.x && z == vector.z); 126 return (x == vector.x && x == vector.x && z == vector.z);
127 } 127 }
128 128
129 public static Vector3 operator -(Vector3 vector)
130 {
131 return new Vector3(-vector.x, -vector.y, -vector.z);
132 }
133
129 #endregion 134 #endregion
130 135
131 #region Vector & Vector Math 136 #region Vector & Vector Math
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestVector3.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestVector3.cs
index cadee93..0a41f92 100644
--- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestVector3.cs
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestVector3.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenSim.Tests.Common; 30using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Common; 31using OpenSim.Region.ScriptEngine.Common;
32using vector = OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3;
32 33
33namespace OpenSim.Region.ScriptEngine.Common.Tests 34namespace OpenSim.Region.ScriptEngine.Common.Tests
34{ 35{
@@ -39,7 +40,6 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
39 /// Tests for Vector3 40 /// Tests for Vector3
40 /// </summary> 41 /// </summary>
41 [Test] 42 [Test]
42
43 public void TestDotProduct() 43 public void TestDotProduct()
44 { 44 {
45 // The numbers we test for. 45 // The numbers we test for.
@@ -54,9 +54,16 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
54 foreach (KeyValuePair<string, double> ex in expectsSet) 54 foreach (KeyValuePair<string, double> ex in expectsSet)
55 { 55 {
56 parts = ex.Key.Split(delim, System.StringSplitOptions.None); 56 parts = ex.Key.Split(delim, System.StringSplitOptions.None);
57 result = new LSL_Types.Vector3(parts[0]) * new LSL_Types.Vector3(parts[1]); 57 result = new vector(parts[0]) * new vector(parts[1]);
58 Assert.AreEqual(ex.Value, result); 58 Assert.AreEqual(ex.Value, result);
59 } 59 }
60 } 60 }
61
62 [Test]
63 public void TestUnaryMinusOperator()
64 {
65 Assert.AreEqual(new vector(-1, -1, -1), - (new vector(1, 1, 1)));
66 Assert.AreEqual(new vector(0, 0, 0), - (new vector(0, 0, 0)));
67 }
61 } 68 }
62} 69}