Thanks, M. Igarashi & nlin, for a patch that implements unary minus operator
for Vector3 type. Fix issue 1872.0.6.0-stable
parent
2270b25265
commit
ddf126321c
|
@ -126,6 +126,11 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
return (x == vector.x && x == vector.x && z == vector.z);
|
return (x == vector.x && x == vector.x && z == vector.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector3 operator -(Vector3 vector)
|
||||||
|
{
|
||||||
|
return new Vector3(-vector.x, -vector.y, -vector.z);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Vector & Vector Math
|
#region Vector & Vector Math
|
||||||
|
|
|
@ -29,6 +29,7 @@ using System.Collections.Generic;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Tests.Common;
|
||||||
using OpenSim.Region.ScriptEngine.Common;
|
using OpenSim.Region.ScriptEngine.Common;
|
||||||
|
using vector = OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3;
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.Common.Tests
|
namespace OpenSim.Region.ScriptEngine.Common.Tests
|
||||||
{
|
{
|
||||||
|
@ -39,7 +40,6 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
|
||||||
/// Tests for Vector3
|
/// Tests for Vector3
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
|
|
||||||
public void TestDotProduct()
|
public void TestDotProduct()
|
||||||
{
|
{
|
||||||
// The numbers we test for.
|
// The numbers we test for.
|
||||||
|
@ -54,9 +54,16 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
|
||||||
foreach (KeyValuePair<string, double> ex in expectsSet)
|
foreach (KeyValuePair<string, double> ex in expectsSet)
|
||||||
{
|
{
|
||||||
parts = ex.Key.Split(delim, System.StringSplitOptions.None);
|
parts = ex.Key.Split(delim, System.StringSplitOptions.None);
|
||||||
result = new LSL_Types.Vector3(parts[0]) * new LSL_Types.Vector3(parts[1]);
|
result = new vector(parts[0]) * new vector(parts[1]);
|
||||||
Assert.AreEqual(ex.Value, result);
|
Assert.AreEqual(ex.Value, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestUnaryMinusOperator()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(new vector(-1, -1, -1), - (new vector(1, 1, 1)));
|
||||||
|
Assert.AreEqual(new vector(0, 0, 0), - (new vector(0, 0, 0)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue