From 2827deffe822378b6cb35dac6c90a21c3fbc0de7 Mon Sep 17 00:00:00 2001 From: Marck Date: Fri, 26 Nov 2010 22:46:48 +0100 Subject: Trigger changed event with CHANGED_TELEPORT when teleporting to another region. --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 660e9a3..8e712b6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -390,19 +390,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } else if (m_stateSource == StateSource.RegionStart) { -// m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); + //m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); PostEvent(new EventParams("changed", - new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, - new DetectParams[0])); + new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, new DetectParams[0])); } - else if (m_stateSource == StateSource.PrimCrossing) + else if (m_stateSource == StateSource.PrimCrossing || m_stateSource == StateSource.Teleporting) { // CHANGED_REGION PostEvent(new EventParams("changed", - new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, - new DetectParams[0])); + new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, new DetectParams[0])); + + // CHANGED_TELEPORT + if (m_stateSource == StateSource.Teleporting) + PostEvent(new EventParams("changed", + new Object[] { new LSL_Types.LSLInteger((int)Changed.TELEPORT) }, new DetectParams[0])); } - } + } else { Start(); -- cgit v1.1 From a8a8fb6e1380c37b64963d0968c5af4f64e6f25e Mon Sep 17 00:00:00 2001 From: Micheil Merlin Date: Sat, 20 Nov 2010 17:04:59 -0600 Subject: llVecNorm nant test --- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index dfc9aa3..1d55b95 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -47,6 +47,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests { private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; + private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; private LSL_Api m_lslApi; [SetUp] @@ -164,5 +165,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail"); Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail"); } + + [Test] + // llVecNorm test. + public void TestllVecNorm() + { + // Check special case for normalizing zero vector. + CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); + // Check various vectors. + CheckllVecNorm(new LSL_Types.Vector3(10.0d, 25.0d, 0.0d), new LSL_Types.Vector3(0.371391d, 0.928477d, 0.0d)); + CheckllVecNorm(new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), new LSL_Types.Vector3(1.0d, 0.0d, 0.0d)); + CheckllVecNorm(new LSL_Types.Vector3(-90.0d, 55.0d, 2.0d), new LSL_Types.Vector3(-0.853128d, 0.521356d, 0.018958d)); + CheckllVecNorm(new LSL_Types.Vector3(255.0d, 255.0d, 255.0d), new LSL_Types.Vector3(0.577350d, 0.577350d, 0.577350d)); + } + + public void CheckllVecNorm(LSL_Types.Vector3 vec, LSL_Types.Vector3 vecNormCheck) + { + // Call LSL function to normalize the vector. + LSL_Types.Vector3 vecNorm = m_lslApi.llVecNorm(vec); + // Check each vector component against expected result. + Assert.AreEqual(vecNorm.x, vecNormCheck.x, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on x component"); + Assert.AreEqual(vecNorm.y, vecNormCheck.y, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on y component"); + Assert.AreEqual(vecNorm.z, vecNormCheck.z, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on z component"); + } } } -- cgit v1.1