From 6a5d08819725a836a4072dec3bd3f84a1bd39ffb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 24 Jan 2013 16:26:04 -0800 Subject: [PATCH 01/13] BulletSim: reduce the force of gravity on ground vehicles when they are on the ground. Makes them a little more stable. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index f1ef449313..7ad7c89d04 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -158,6 +158,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); } } + // Return 'true' if this a vehicle that should be sitting on the ground + public bool IsGroundVehicle + { + get { return (Type == Vehicle.TYPE_CAR || Type == Vehicle.TYPE_SLED); } + } + #region Vehicle parameter setting internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) { @@ -1176,6 +1182,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin private void ApplyGravity(float pTimeStep) { Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; + + // Hack to reduce downward force if the vehicle is probably sitting on the ground + if (Prim.IsColliding && IsGroundVehicle) + appliedGravity *= 0.2f; + VehicleAddForce(appliedGravity); VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}", From f557d7e82821c931c6ca2faf97c668fa94cacfb0 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 01:48:31 +0000 Subject: [PATCH 02/13] Add basic JsonCreateStore() regression test --- .../ScriptModuleCommsModule.cs | 2 +- .../Tests/JsonStoreScriptModuleTests.cs | 86 +++++++ OpenSim/Tests/Common/Mock/MockScriptEngine.cs | 214 ++++++++++++++++++ prebuild.xml | 7 +- 4 files changed, 306 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs create mode 100644 OpenSim/Tests/Common/Mock/MockScriptEngine.cs diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index f6e1d393a8..6bf50d2504 100644 --- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -41,7 +41,7 @@ using System.Linq.Expressions; namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] - class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms + public class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs new file mode 100644 index 0000000000..4b6ddd6c34 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -0,0 +1,86 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using log4net; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.CoreModules.Scripting.ScriptModuleComms; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.ScriptEngine.Shared; +using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests +{ + /// + /// Tests for inventory functions in LSL + /// + [TestFixture] + public class LSL_ApiInventoryTests : OpenSimTestCase + { + private Scene m_scene; + private MockScriptEngine m_engine; + private ScriptModuleCommsModule m_smcm; + + [SetUp] + public override void SetUp() + { + base.SetUp(); + + IConfigSource configSource = new IniConfigSource(); + IConfig jsonStoreConfig = configSource.AddConfig("JsonStore"); + jsonStoreConfig.Set("Enabled", "true"); + + m_engine = new MockScriptEngine(); + m_smcm = new ScriptModuleCommsModule(); + JsonStoreModule jsm = new JsonStoreModule(); + JsonStoreScriptModule jssm = new JsonStoreScriptModule(); + + m_scene = new SceneHelpers().SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); + } + + [Test] + public void TestJsonCreateStore() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" }); + + Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs new file mode 100644 index 0000000000..51f2712071 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs @@ -0,0 +1,214 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.ScriptEngine.Interfaces; +using OpenSim.Region.ScriptEngine.Shared; + +namespace OpenSim.Tests.Common +{ + public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine + { + private Scene m_scene; + + public void Initialise(IConfigSource source) + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + m_scene = scene; + + m_scene.StackModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + } + + public string Name { get { return "Mock Script Engine"; } } + public string ScriptEngineName { get { return Name; } } + + public Type ReplaceableInterface { get { return null; } } + + public event ScriptRemoved OnScriptRemoved; + public event ObjectRemoved OnObjectRemoved; + + public string GetXMLState (UUID itemID) + { + throw new System.NotImplementedException (); + } + + public bool SetXMLState(UUID itemID, string xml) + { + throw new System.NotImplementedException (); + } + + public bool PostScriptEvent(UUID itemID, string name, object[] args) + { + throw new System.NotImplementedException (); + } + + public bool PostObjectEvent(UUID itemID, string name, object[] args) + { + throw new System.NotImplementedException (); + } + + public void SuspendScript(UUID itemID) + { + throw new System.NotImplementedException (); + } + + public void ResumeScript(UUID itemID) + { + throw new System.NotImplementedException (); + } + + public ArrayList GetScriptErrors(UUID itemID) + { + throw new System.NotImplementedException (); + } + + public bool HasScript(UUID itemID, out bool running) + { + throw new System.NotImplementedException (); + } + + public bool GetScriptState(UUID itemID) + { + throw new System.NotImplementedException (); + } + + public void SaveAllState() + { + throw new System.NotImplementedException (); + } + + public void StartProcessing() + { + throw new System.NotImplementedException (); + } + + public float GetScriptExecutionTime(List itemIDs) + { + throw new System.NotImplementedException (); + } + + public Dictionary GetObjectScriptsExecutionTimes() + { + throw new System.NotImplementedException (); + } + + public IScriptWorkItem QueueEventHandler(object parms) + { + throw new System.NotImplementedException (); + } + + public bool PostScriptEvent(UUID itemID,EventParams parms) + { + throw new System.NotImplementedException (); + } + + public bool PostObjectEvent (uint localID, EventParams parms) + { + throw new System.NotImplementedException (); + } + + public DetectParams GetDetectParams(UUID item, int number) + { + throw new System.NotImplementedException (); + } + + public void SetMinEventDelay(UUID itemID, double delay) + { + throw new System.NotImplementedException (); + } + + public int GetStartParameter(UUID itemID) + { + throw new System.NotImplementedException (); + } + + public void SetScriptState(UUID itemID, bool state) + { + throw new System.NotImplementedException (); + } + + public void SetState(UUID itemID, string newState) + { + throw new System.NotImplementedException (); + } + + public void ApiResetScript(UUID itemID) + { + throw new System.NotImplementedException (); + } + + public void ResetScript (UUID itemID) + { + throw new System.NotImplementedException (); + } + + public IScriptApi GetApi(UUID itemID, string name) + { + throw new System.NotImplementedException (); + } + + public Scene World { get { return m_scene; } } + + public IScriptModule ScriptModule { get { throw new System.NotImplementedException(); } } + + public IConfig Config { get { throw new System.NotImplementedException (); } } + + public IConfigSource ConfigSource { get { throw new System.NotImplementedException (); } } + + public string ScriptEnginePath { get { throw new System.NotImplementedException (); }} + + public string ScriptClassName { get { throw new System.NotImplementedException (); } } + + public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } } + + public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } } + + public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } } + } +} \ No newline at end of file diff --git a/prebuild.xml b/prebuild.xml index cea4530d85..8a753800df 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2741,12 +2741,13 @@ - - + + + @@ -3109,6 +3110,7 @@ + @@ -3133,6 +3135,7 @@ + From ba369c5cfe89706c0e7261e699dac1d0c3c68cd6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 01:55:27 +0000 Subject: [PATCH 03/13] Add basic JsonGetValue() regression test. --- .../Tests/JsonStoreScriptModuleTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 4b6ddd6c34..204bab1118 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -82,5 +82,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); } + + [Test] + public void TestJsonGetValue() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID storeId + = (UUID)m_smcm.InvokeOperation( + UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); + + string value + = (string)m_smcm.InvokeOperation( + UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" }); + + Assert.That(value, Is.EqualTo("World")); + } } } \ No newline at end of file From b914fb98c4c178987e23580ceb3f8b48415831d1 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 01:56:41 +0000 Subject: [PATCH 04/13] minor: remove mono compiler warning in SceneCommandsModule --- .../OptionalModules/World/SceneCommands/SceneCommandsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs index 12169ab617..5fb74b01ea 100644 --- a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SceneCommandsModule")] public class SceneCommandsModule : ISceneCommandsModule, INonSharedRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; From f32361d595e0ee11066fa78627fe91936743a5e8 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 02:08:33 +0000 Subject: [PATCH 05/13] Add regression test for JsonSetValue() --- .../Tests/JsonStoreScriptModuleTests.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 204bab1118..0e8b1cab05 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -99,5 +99,28 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("World")); } + + [Test] + public void TestJsonSetValue() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID storeId + = (UUID)m_smcm.InvokeOperation( + UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ }" }); + + int result + = (int)m_smcm.InvokeOperation( + UUID.Zero, UUID.Zero, "JsonSetValue", new object[] { storeId, "Hello", "World" }); + + Assert.That(result, Is.EqualTo(1)); + + string value + = (string)m_smcm.InvokeOperation( + UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" }); + + Assert.That(value, Is.EqualTo("World")); + } } } \ No newline at end of file From 844e60da0f81454318519445f7c30fa02cf524f2 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 02:12:15 +0000 Subject: [PATCH 06/13] Add JsonTestPath() regression test --- .../Tests/JsonStoreScriptModuleTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 0e8b1cab05..06e4761e62 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -100,6 +100,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("World")); } + [Test] + public void TestJsonTestPath() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID storeId + = (UUID)m_smcm.InvokeOperation( + UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); + + int result + = (int)m_smcm.InvokeOperation( + UUID.Zero, UUID.Zero, "JsonTestPath", new object[] { storeId, "Hello" }); + + Assert.That(result, Is.EqualTo(1)); + } + [Test] public void TestJsonSetValue() { From 8c68451856756a6c43e90c533352a1b5c3b42210 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 02:22:24 +0000 Subject: [PATCH 07/13] Enable logging in new json store tests to find out why they fail on jenkins but not locally. --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 06e4761e62..0cbc5d960f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonCreateStore() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); + TestHelpers.EnableLogging(); UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" }); @@ -87,7 +87,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonGetValue() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); + TestHelpers.EnableLogging(); UUID storeId = (UUID)m_smcm.InvokeOperation( @@ -104,7 +104,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonTestPath() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); + TestHelpers.EnableLogging(); UUID storeId = (UUID)m_smcm.InvokeOperation( @@ -121,7 +121,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonSetValue() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); + TestHelpers.EnableLogging(); UUID storeId = (UUID)m_smcm.InvokeOperation( From 4f52acaa833b4c1c99e13f6ca7177efc7b2d15ab Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 02:32:38 +0000 Subject: [PATCH 08/13] Increase logging by enabling during test setup rather than during individual tests of for JsonStore --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 0cbc5d960f..b50bc0bcdf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -59,6 +59,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests { base.SetUp(); + TestHelpers.EnableLogging(); + IConfigSource configSource = new IniConfigSource(); IConfig jsonStoreConfig = configSource.AddConfig("JsonStore"); jsonStoreConfig.Set("Enabled", "true"); @@ -76,7 +78,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonCreateStore() { TestHelpers.InMethod(); - TestHelpers.EnableLogging(); +// TestHelpers.EnableLogging(); UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" }); @@ -87,7 +89,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonGetValue() { TestHelpers.InMethod(); - TestHelpers.EnableLogging(); +// TestHelpers.EnableLogging(); UUID storeId = (UUID)m_smcm.InvokeOperation( @@ -104,7 +106,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonTestPath() { TestHelpers.InMethod(); - TestHelpers.EnableLogging(); +// TestHelpers.EnableLogging(); UUID storeId = (UUID)m_smcm.InvokeOperation( @@ -121,7 +123,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonSetValue() { TestHelpers.InMethod(); - TestHelpers.EnableLogging(); +// TestHelpers.EnableLogging(); UUID storeId = (UUID)m_smcm.InvokeOperation( From 614d4eda3ee2889e7b122b4a5c522c6ef72a7765 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 03:02:08 +0000 Subject: [PATCH 09/13] See if getting the registering JsonReadNotecard with MethodInfo works around an apparent issue with registering methods with more than 5 parameters on mono 2.4.3 --- .../Scripting/JsonStore/JsonStoreScriptModule.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 0c175caa7f..77be828ddd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -168,7 +168,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); - m_comms.RegisterScriptInvocation(this,"JsonReadNotecard"); + m_comms.RegisterScriptInvocation( + this, this.GetType().GetMethod( + "JsonReadNotecard", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(UUID), typeof(UUID), typeof(UUID), typeof(string), typeof(UUID)}, null)); + m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); m_comms.RegisterScriptInvocation(this,"JsonTestPath"); @@ -191,7 +194,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore catch (Exception e) { // See http://opensimulator.org/mantis/view.php?id=5971 for more information - m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message); + m_log.WarnFormat("[JsonStoreScripts]: script method registration failed; {0}", e.Message); m_enabled = false; } } From d977bb77cb39eef927cf0b7487b500019a537114 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 25 Jan 2013 03:19:56 +0000 Subject: [PATCH 10/13] Disable json tests for now - I see this is failing on jenkins because mono 2.4.3 doesn't have Funcs >5 params, though mono 2.6 onwards does. Standardize logging in JsonStoreScriptModule and some minor code formatting. --- .../JsonStore/JsonStoreScriptModule.cs | 53 +++++++++---------- .../Tests/JsonStoreScriptModuleTests.cs | 8 +-- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 77be828ddd..b9dcfead8d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -92,12 +92,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } catch (Exception e) { - m_log.ErrorFormat("[JsonStoreScripts] initialization error: {0}",e.Message); + m_log.ErrorFormat("[JsonStoreScripts]: initialization error: {0}", e.Message); return; } if (m_enabled) - m_log.DebugFormat("[JsonStoreScripts] module is enabled"); + m_log.DebugFormat("[JsonStoreScripts]: module is enabled"); } // ----------------------------------------------------------------- @@ -150,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore m_comms = m_scene.RequestModuleInterface(); if (m_comms == null) { - m_log.ErrorFormat("[JsonStoreScripts] ScriptModuleComms interface not defined"); + m_log.ErrorFormat("[JsonStoreScripts]: ScriptModuleComms interface not defined"); m_enabled = false; return; } @@ -158,38 +158,35 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore m_store = m_scene.RequestModuleInterface(); if (m_store == null) { - m_log.ErrorFormat("[JsonStoreScripts] JsonModule interface not defined"); + m_log.ErrorFormat("[JsonStoreScripts]: JsonModule interface not defined"); m_enabled = false; return; } - + try { - m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); - m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); + m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); + m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); - m_comms.RegisterScriptInvocation( - this, this.GetType().GetMethod( - "JsonReadNotecard", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(UUID), typeof(UUID), typeof(UUID), typeof(string), typeof(UUID)}, null)); + m_comms.RegisterScriptInvocation(this, "JsonReadNotecard"); + m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard"); - m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); + m_comms.RegisterScriptInvocation(this, "JsonTestPath"); + m_comms.RegisterScriptInvocation(this, "JsonTestPathJson"); - m_comms.RegisterScriptInvocation(this,"JsonTestPath"); - m_comms.RegisterScriptInvocation(this,"JsonTestPathJson"); + m_comms.RegisterScriptInvocation(this, "JsonGetValue"); + m_comms.RegisterScriptInvocation(this, "JsonGetValueJson"); - m_comms.RegisterScriptInvocation(this,"JsonGetValue"); - m_comms.RegisterScriptInvocation(this,"JsonGetValueJson"); + m_comms.RegisterScriptInvocation(this, "JsonTakeValue"); + m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson"); - m_comms.RegisterScriptInvocation(this,"JsonTakeValue"); - m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson"); + m_comms.RegisterScriptInvocation(this, "JsonReadValue"); + m_comms.RegisterScriptInvocation(this, "JsonReadValueJson"); - m_comms.RegisterScriptInvocation(this,"JsonReadValue"); - m_comms.RegisterScriptInvocation(this,"JsonReadValueJson"); + m_comms.RegisterScriptInvocation(this, "JsonSetValue"); + m_comms.RegisterScriptInvocation(this, "JsonSetValueJson"); - m_comms.RegisterScriptInvocation(this,"JsonSetValue"); - m_comms.RegisterScriptInvocation(this,"JsonSetValueJson"); - - m_comms.RegisterScriptInvocation(this,"JsonRemoveValue"); + m_comms.RegisterScriptInvocation(this, "JsonRemoveValue"); } catch (Exception e) { @@ -357,7 +354,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } catch (Exception e) { - m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); + m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); } DispatchValue(scriptID,reqID,String.Empty); @@ -392,7 +389,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } catch (Exception e) { - m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); + m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); } DispatchValue(scriptID,reqID,String.Empty); @@ -424,7 +421,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore if (a.Type != (sbyte)AssetType.Notecard) GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); - m_log.DebugFormat("[JsonStoreScripts] read notecard in context {0}",storeID); + m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID); try { @@ -435,7 +432,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } catch (Exception e) { - m_log.WarnFormat("[JsonStoreScripts] Json parsing failed; {0}",e.Message); + m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message); } GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); @@ -498,4 +495,4 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index b50bc0bcdf..397dd939f3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -74,7 +74,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); } - [Test] +// [Test] public void TestJsonCreateStore() { TestHelpers.InMethod(); @@ -85,7 +85,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); } - [Test] +// [Test] public void TestJsonGetValue() { TestHelpers.InMethod(); @@ -102,7 +102,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("World")); } - [Test] +// [Test] public void TestJsonTestPath() { TestHelpers.InMethod(); @@ -119,7 +119,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(result, Is.EqualTo(1)); } - [Test] +// [Test] public void TestJsonSetValue() { TestHelpers.InMethod(); From d6d6618f62a3a66e0d660d634c2c0f8722e3692f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 26 Jan 2013 00:28:45 +0000 Subject: [PATCH 11/13] minor: Call down to base OpenSimTestCase.SetUp() in NPCModuleTests to disable any enabled logging from previous tests --- .../Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index a522277e8a..bf23040c3d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -74,6 +74,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests [SetUp] public void Init() { + base.SetUp(); + IConfigSource config = new IniConfigSource(); config.AddConfig("NPC"); config.Configs["NPC"].Set("Enabled", "true"); From c3fb1144614d85562169a7bb6cf8b10c9724b189 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 26 Jan 2013 00:31:19 +0000 Subject: [PATCH 12/13] minor: Fix full scene part console report to show proper Light* names rather than all wrongly FlexiDrag --- .../World/Objects/Commands/ObjectCommandsModule.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 7b235aef74..9fc2dafafc 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -592,11 +592,11 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands cdl.AddRow( "LightColor", string.Format("<{0},{1},{2},{3}>", s.LightColorR, s.LightColorB, s.LightColorG, s.LightColorA)); - cdl.AddRow("FlexiDrag", s.LightCutoff); - cdl.AddRow("FlexiDrag", s.LightEntry); - cdl.AddRow("FlexiDrag", s.LightFalloff); - cdl.AddRow("FlexiDrag", s.LightIntensity); - cdl.AddRow("FlexiDrag", s.LightRadius); + cdl.AddRow("LightCutoff", s.LightCutoff); + cdl.AddRow("LightEntry", s.LightEntry); + cdl.AddRow("LightFalloff", s.LightFalloff); + cdl.AddRow("LightIntensity", s.LightIntensity); + cdl.AddRow("LightRadius", s.LightRadius); cdl.AddRow("Media", string.Format("{0} entries", s.Media != null ? s.Media.Count.ToString() : "n/a")); cdl.AddRow("PathBegin", s.PathBegin); cdl.AddRow("PathEnd", s.PathEnd); From 5128ae7b8685a583b3d53428f5bbba5ba5e65549 Mon Sep 17 00:00:00 2001 From: teravus Date: Fri, 25 Jan 2013 20:15:37 -0500 Subject: [PATCH 13/13] * This adds llVolumeDetect functionality to the C# implementation of BulletSim. --- .../Region/Physics/BulletSPlugin/BSAPIXNA.cs | 196 ++++++++++-------- 1 file changed, 113 insertions(+), 83 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index f63d83c46f..04e77b8f76 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs @@ -137,6 +137,7 @@ private sealed class BulletConstraintXNA : BulletConstraint internal int LastEntityProperty = 0; internal EntityProperties[] UpdatedObjects; + internal Dictionary specialCollisionObjects; private static int m_collisionsThisFrame; private BSScene PhysicsScene { get; set; } @@ -158,7 +159,13 @@ private sealed class BulletConstraintXNA : BulletConstraint { DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; RigidBody body = ((BulletBodyXNA)pBody).rigidBody; - world.RemoveRigidBody(body); + CollisionObject collisionObject = ((BulletBodyXNA)pBody).body; + if (body != null) + world.RemoveRigidBody(body); + else if (collisionObject != null) + world.RemoveCollisionObject(collisionObject); + else + return false; return true; } @@ -182,7 +189,7 @@ private sealed class BulletConstraintXNA : BulletConstraint public override void SetRestitution(BulletBody pCollisionObject, float pRestitution) { - CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; + CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; collisionObject.SetRestitution(pRestitution); } @@ -219,13 +226,13 @@ private sealed class BulletConstraintXNA : BulletConstraint public override void SetCcdMotionThreshold(BulletBody pCollisionObject, float pccdMotionThreashold) { - CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; + CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; collisionObject.SetCcdMotionThreshold(pccdMotionThreashold); } public override void SetCcdSweptSphereRadius(BulletBody pCollisionObject, float pCcdSweptSphereRadius) { - CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; + CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; collisionObject.SetCcdSweptSphereRadius(pCcdSweptSphereRadius); } @@ -262,7 +269,7 @@ private sealed class BulletConstraintXNA : BulletConstraint } else { - world.AddCollisionObject(rbody); + world.AddCollisionObject(cbody); } cbody.SetWorldTransform(origPos); @@ -303,7 +310,7 @@ private sealed class BulletConstraintXNA : BulletConstraint public override bool SetCollisionGroupMask(BulletBody pCollisionObject, uint pGroup, uint pMask) { - CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; + CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; if ((uint) collisionObject.GetBroadphaseHandle().m_collisionFilterGroup == 0) @@ -390,7 +397,7 @@ private sealed class BulletConstraintXNA : BulletConstraint public override void SetTranslation(BulletBody pCollisionObject, Vector3 _position, Quaternion _orientation) { - CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; + CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; IndexedVector3 vposition = new IndexedVector3(_position.X, _position.Y, _position.Z); IndexedQuaternion vquaternion = new IndexedQuaternion(_orientation.X, _orientation.Y, _orientation.Z, _orientation.W); @@ -418,8 +425,11 @@ private sealed class BulletConstraintXNA : BulletConstraint public override void SetMassProps(BulletBody pBody, float pphysMass, Vector3 plocalInertia) { RigidBody body = (pBody as BulletBodyXNA).rigidBody; - IndexedVector3 inertia = new IndexedVector3(plocalInertia.X, plocalInertia.Y, plocalInertia.Z); - body.SetMassProps(pphysMass, inertia); + if (body != null) // Can't set mass props on collision object. + { + IndexedVector3 inertia = new IndexedVector3(plocalInertia.X, plocalInertia.Y, plocalInertia.Z); + body.SetMassProps(pphysMass, inertia); + } } @@ -432,7 +442,7 @@ private sealed class BulletConstraintXNA : BulletConstraint public override void SetFriction(BulletBody pCollisionObject, float _currentFriction) { - CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; + CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; collisionObject.SetFriction(_currentFriction); } @@ -459,7 +469,7 @@ private sealed class BulletConstraintXNA : BulletConstraint public override CollisionFlags RemoveFromCollisionFlags(BulletBody pCollisionObject, CollisionFlags pcollisionFlags) { - CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; + CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)collisionObject.GetCollisionFlags(); existingcollisionFlags &= ~pcollisionFlags; collisionObject.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags); @@ -494,8 +504,11 @@ private sealed class BulletConstraintXNA : BulletConstraint public override void SetGravity(BulletBody pBody, Vector3 pGravity) { RigidBody body = (pBody as BulletBodyXNA).rigidBody; - IndexedVector3 gravity = new IndexedVector3(pGravity.X, pGravity.Y, pGravity.Z); - body.SetGravity(gravity); + if (body != null) // Can't set collisionobject.set gravity + { + IndexedVector3 gravity = new IndexedVector3(pGravity.X, pGravity.Y, pGravity.Z); + body.SetGravity(gravity); + } } public override bool DestroyConstraint(BulletWorld pWorld, BulletConstraint pConstraint) @@ -733,7 +746,8 @@ private sealed class BulletConstraintXNA : BulletConstraint public override void UpdateInertiaTensor(BulletBody pBody) { RigidBody body = (pBody as BulletBodyXNA).rigidBody; - body.UpdateInertiaTensor(); + if (body != null) // can't update inertia tensor on CollisionObject + body.UpdateInertiaTensor(); } public override void RecalculateCompoundShapeLocalAabb(BulletShape pCompoundShape) @@ -770,7 +784,7 @@ private sealed class BulletConstraintXNA : BulletConstraint public override CollisionObjectTypes GetBodyType(BulletBody pCollisionObject) { - CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; + CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; return (CollisionObjectTypes)(int) collisionObject.GetInternalType(); } @@ -889,7 +903,18 @@ private sealed class BulletConstraintXNA : BulletConstraint world.RemoveRigidBody(bo); } } - + if (co != null) + { + if (co.GetUserPointer() != null) + { + uint localId = (uint) co.GetUserPointer(); + if (specialCollisionObjects.ContainsKey(localId)) + { + specialCollisionObjects.Remove(localId); + } + } + } + } public override void Shutdown(BulletWorld pWorld) @@ -1050,7 +1075,7 @@ private sealed class BulletConstraintXNA : BulletConstraint Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); m_maxCollisions = maxCollisions; m_maxUpdatesPerFrame = maxUpdates; - + specialCollisionObjects = new Dictionary(); return new BulletWorldXNA(1, PhysicsScene, BSAPIXNA.Initialize2(worldExtent, configparms, maxCollisions, ref collisionArray, maxUpdates, ref updateArray, null)); } @@ -1310,6 +1335,12 @@ private sealed class BulletConstraintXNA : BulletConstraint CollisionShape shape = (pShape as BulletShapeXNA).shape; gObj.SetCollisionShape(shape); gObj.SetUserPointer(pLocalID); + + if (specialCollisionObjects.ContainsKey(pLocalID)) + specialCollisionObjects[pLocalID] = gObj; + else + specialCollisionObjects.Add(pLocalID, gObj); + // TODO: Add to Special CollisionObjects! return new BulletBodyXNA(pLocalID, gObj); } @@ -1399,7 +1430,7 @@ private sealed class BulletConstraintXNA : BulletConstraint } public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) { - /* TODO */ + if (cShape == null) return null; CompoundShape compoundShape = (cShape as BulletShapeXNA).shape as CompoundShape; @@ -1407,7 +1438,7 @@ private sealed class BulletConstraintXNA : BulletConstraint BulletShape retShape = new BulletShapeXNA(shape, BSShapeTypeFromBroadPhaseNativeType(shape.GetShapeType())); - return null; + return retShape; } public BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin) @@ -1802,26 +1833,29 @@ private sealed class BulletConstraintXNA : BulletConstraint numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); int updates = 0; - - + PersistentManifold contactManifold; + CollisionObject objA; + CollisionObject objB; + ManifoldPoint manifoldPoint; + PairCachingGhostObject pairCachingGhostObject; m_collisionsThisFrame = 0; int numManifolds = world.GetDispatcher().GetNumManifolds(); for (int j = 0; j < numManifolds; j++) { - PersistentManifold contactManifold = world.GetDispatcher().GetManifoldByIndexInternal(j); + contactManifold = world.GetDispatcher().GetManifoldByIndexInternal(j); int numContacts = contactManifold.GetNumContacts(); if (numContacts == 0) continue; - CollisionObject objA = contactManifold.GetBody0() as CollisionObject; - CollisionObject objB = contactManifold.GetBody1() as CollisionObject; + objA = contactManifold.GetBody0() as CollisionObject; + objB = contactManifold.GetBody1() as CollisionObject; - ManifoldPoint manifoldPoint = contactManifold.GetContactPoint(0); - IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB(); - IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A + manifoldPoint = contactManifold.GetContactPoint(0); + //IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB(); + // IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A - RecordCollision(this, objA, objB, contactPoint, contactNormal,manifoldPoint.GetDistance()); + RecordCollision(this, objA, objB, manifoldPoint.GetPositionWorldOnB(), -manifoldPoint.m_normalWorldOnB, manifoldPoint.GetDistance()); m_collisionsThisFrame ++; if (m_collisionsThisFrame >= 9999999) break; @@ -1829,12 +1863,19 @@ private sealed class BulletConstraintXNA : BulletConstraint } + foreach (GhostObject ghostObject in specialCollisionObjects.Values) + { + pairCachingGhostObject = ghostObject as PairCachingGhostObject; + if (pairCachingGhostObject != null) + { + RecordGhostCollisions(pairCachingGhostObject); + } + + } + + updatedEntityCount = LastEntityProperty; updatedEntities = UpdatedObjects; - - - - collidersCount = LastCollisionDesc; colliders = UpdatedCollisions; @@ -1860,60 +1901,49 @@ private sealed class BulletConstraintXNA : BulletConstraint } public void RecordGhostCollisions(PairCachingGhostObject obj) { - /* - *void BulletSim::RecordGhostCollisions(btPairCachingGhostObject* obj) -{ - btManifoldArray manifoldArray; - btBroadphasePairArray& pairArray = obj->getOverlappingPairCache()->getOverlappingPairArray(); - int numPairs = pairArray.size(); + IOverlappingPairCache cache = obj.GetOverlappingPairCache(); + ObjectArray pairs = cache.GetOverlappingPairArray(); + + DiscreteDynamicsWorld world = (PhysicsScene.World as BulletWorldXNA).world; + PersistentManifoldArray manifoldArray = new PersistentManifoldArray(); + BroadphasePair collisionPair; + PersistentManifold contactManifold; - // For all the pairs of sets of contact points - for (int i=0; i < numPairs; i++) - { - if (m_collisionsThisFrame >= m_maxCollisionsPerFrame) - break; + CollisionObject objA; + CollisionObject objB; - manifoldArray.clear(); - const btBroadphasePair& pair = pairArray[i]; + ManifoldPoint pt; - // The real representation is over in the world pair cache - btBroadphasePair* collisionPair = m_worldData.dynamicsWorld->getPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1); - if (!collisionPair) - continue; + int numPairs = pairs.Count; + + for (int i = 0; i < numPairs; i++) + { + manifoldArray.Clear(); + if (LastCollisionDesc < UpdatedCollisions.Length) + break; + collisionPair = world.GetPairCache().FindPair(pairs[i].m_pProxy0, pairs[i].m_pProxy1); + if (collisionPair == null) + continue; + + collisionPair.m_algorithm.GetAllContactManifolds(manifoldArray); + for (int j = 0; j < manifoldArray.Count; j++) + { + contactManifold = manifoldArray[j]; + int numContacts = contactManifold.GetNumContacts(); + objA = contactManifold.GetBody0() as CollisionObject; + objB = contactManifold.GetBody1() as CollisionObject; + for (int p = 0; p < numContacts; p++) + { + pt = contactManifold.GetContactPoint(p); + if (pt.GetDistance() < 0.0f) + { + RecordCollision(this, objA, objB, pt.GetPositionWorldOnA(), -pt.m_normalWorldOnB,pt.GetDistance()); + break; + } + } + } + } - if (collisionPair->m_algorithm) - collisionPair->m_algorithm->getAllContactManifolds(manifoldArray); - - // The collision pair has sets of collision points (manifolds) - for (int j=0; j < manifoldArray.size(); j++) - { - btPersistentManifold* contactManifold = manifoldArray[j]; - int numContacts = contactManifold->getNumContacts(); - - const btCollisionObject* objA = static_cast(contactManifold->getBody0()); - const btCollisionObject* objB = static_cast(contactManifold->getBody1()); - - // TODO: this is a more thurough check than the regular collision code -- - // here we find the penetrating contact in the manifold but for regular - // collisions we assume the first point in the manifold is good enough. - // Decide of this extra checking is required or if first point is good enough. - for (int p=0; p < numContacts; p++) - { - const btManifoldPoint& pt = contactManifold->getContactPoint(p); - // If a penetrating contact, this is a hit - if (pt.getDistance()<0.f) - { - const btVector3& contactPoint = pt.getPositionWorldOnA(); - const btVector3& normalOnA = -pt.m_normalWorldOnB; - RecordCollision(objA, objB, contactPoint, normalOnA, pt.getDistance()); - // Only one contact point for each set of colliding objects - break; - } - } - } - } -} - */ } private static void RecordCollision(BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm, float penetration) { @@ -1934,7 +1964,7 @@ private sealed class BulletConstraintXNA : BulletConstraint contactNormal = -contactNormal; } - ulong collisionID = ((ulong) idA << 32) | idB; + //ulong collisionID = ((ulong) idA << 32) | idB; CollisionDesc cDesc = new CollisionDesc() {