diff options
Diffstat (limited to '')
10 files changed, 526 insertions, 121 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index f6e1d39..6bf50d2 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; | |||
41 | namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms | 41 | namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms |
42 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] |
44 | class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms | 44 | public class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms |
45 | { | 45 | { |
46 | private static readonly ILog m_log = | 46 | private static readonly ILog m_log = |
47 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 7b235ae..9fc2daf 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 | |||
592 | cdl.AddRow( | 592 | cdl.AddRow( |
593 | "LightColor", | 593 | "LightColor", |
594 | string.Format("<{0},{1},{2},{3}>", s.LightColorR, s.LightColorB, s.LightColorG, s.LightColorA)); | 594 | string.Format("<{0},{1},{2},{3}>", s.LightColorR, s.LightColorB, s.LightColorG, s.LightColorA)); |
595 | cdl.AddRow("FlexiDrag", s.LightCutoff); | 595 | cdl.AddRow("LightCutoff", s.LightCutoff); |
596 | cdl.AddRow("FlexiDrag", s.LightEntry); | 596 | cdl.AddRow("LightEntry", s.LightEntry); |
597 | cdl.AddRow("FlexiDrag", s.LightFalloff); | 597 | cdl.AddRow("LightFalloff", s.LightFalloff); |
598 | cdl.AddRow("FlexiDrag", s.LightIntensity); | 598 | cdl.AddRow("LightIntensity", s.LightIntensity); |
599 | cdl.AddRow("FlexiDrag", s.LightRadius); | 599 | cdl.AddRow("LightRadius", s.LightRadius); |
600 | cdl.AddRow("Media", string.Format("{0} entries", s.Media != null ? s.Media.Count.ToString() : "n/a")); | 600 | cdl.AddRow("Media", string.Format("{0} entries", s.Media != null ? s.Media.Count.ToString() : "n/a")); |
601 | cdl.AddRow("PathBegin", s.PathBegin); | 601 | cdl.AddRow("PathBegin", s.PathBegin); |
602 | cdl.AddRow("PathEnd", s.PathEnd); | 602 | cdl.AddRow("PathEnd", s.PathEnd); |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 0c175ca..b9dcfea 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 | |||
92 | } | 92 | } |
93 | catch (Exception e) | 93 | catch (Exception e) |
94 | { | 94 | { |
95 | m_log.ErrorFormat("[JsonStoreScripts] initialization error: {0}",e.Message); | 95 | m_log.ErrorFormat("[JsonStoreScripts]: initialization error: {0}", e.Message); |
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | 98 | ||
99 | if (m_enabled) | 99 | if (m_enabled) |
100 | m_log.DebugFormat("[JsonStoreScripts] module is enabled"); | 100 | m_log.DebugFormat("[JsonStoreScripts]: module is enabled"); |
101 | } | 101 | } |
102 | 102 | ||
103 | // ----------------------------------------------------------------- | 103 | // ----------------------------------------------------------------- |
@@ -150,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
150 | m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>(); | 150 | m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>(); |
151 | if (m_comms == null) | 151 | if (m_comms == null) |
152 | { | 152 | { |
153 | m_log.ErrorFormat("[JsonStoreScripts] ScriptModuleComms interface not defined"); | 153 | m_log.ErrorFormat("[JsonStoreScripts]: ScriptModuleComms interface not defined"); |
154 | m_enabled = false; | 154 | m_enabled = false; |
155 | return; | 155 | return; |
156 | } | 156 | } |
@@ -158,40 +158,40 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
158 | m_store = m_scene.RequestModuleInterface<IJsonStoreModule>(); | 158 | m_store = m_scene.RequestModuleInterface<IJsonStoreModule>(); |
159 | if (m_store == null) | 159 | if (m_store == null) |
160 | { | 160 | { |
161 | m_log.ErrorFormat("[JsonStoreScripts] JsonModule interface not defined"); | 161 | m_log.ErrorFormat("[JsonStoreScripts]: JsonModule interface not defined"); |
162 | m_enabled = false; | 162 | m_enabled = false; |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | 165 | ||
166 | try | 166 | try |
167 | { | 167 | { |
168 | m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); | 168 | m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); |
169 | m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); | 169 | m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); |
170 | 170 | ||
171 | m_comms.RegisterScriptInvocation(this,"JsonReadNotecard"); | 171 | m_comms.RegisterScriptInvocation(this, "JsonReadNotecard"); |
172 | m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); | 172 | m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard"); |
173 | 173 | ||
174 | m_comms.RegisterScriptInvocation(this,"JsonTestPath"); | 174 | m_comms.RegisterScriptInvocation(this, "JsonTestPath"); |
175 | m_comms.RegisterScriptInvocation(this,"JsonTestPathJson"); | 175 | m_comms.RegisterScriptInvocation(this, "JsonTestPathJson"); |
176 | 176 | ||
177 | m_comms.RegisterScriptInvocation(this,"JsonGetValue"); | 177 | m_comms.RegisterScriptInvocation(this, "JsonGetValue"); |
178 | m_comms.RegisterScriptInvocation(this,"JsonGetValueJson"); | 178 | m_comms.RegisterScriptInvocation(this, "JsonGetValueJson"); |
179 | 179 | ||
180 | m_comms.RegisterScriptInvocation(this,"JsonTakeValue"); | 180 | m_comms.RegisterScriptInvocation(this, "JsonTakeValue"); |
181 | m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson"); | 181 | m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson"); |
182 | 182 | ||
183 | m_comms.RegisterScriptInvocation(this,"JsonReadValue"); | 183 | m_comms.RegisterScriptInvocation(this, "JsonReadValue"); |
184 | m_comms.RegisterScriptInvocation(this,"JsonReadValueJson"); | 184 | m_comms.RegisterScriptInvocation(this, "JsonReadValueJson"); |
185 | 185 | ||
186 | m_comms.RegisterScriptInvocation(this,"JsonSetValue"); | 186 | m_comms.RegisterScriptInvocation(this, "JsonSetValue"); |
187 | m_comms.RegisterScriptInvocation(this,"JsonSetValueJson"); | 187 | m_comms.RegisterScriptInvocation(this, "JsonSetValueJson"); |
188 | 188 | ||
189 | m_comms.RegisterScriptInvocation(this,"JsonRemoveValue"); | 189 | m_comms.RegisterScriptInvocation(this, "JsonRemoveValue"); |
190 | } | 190 | } |
191 | catch (Exception e) | 191 | catch (Exception e) |
192 | { | 192 | { |
193 | // See http://opensimulator.org/mantis/view.php?id=5971 for more information | 193 | // See http://opensimulator.org/mantis/view.php?id=5971 for more information |
194 | m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message); | 194 | m_log.WarnFormat("[JsonStoreScripts]: script method registration failed; {0}", e.Message); |
195 | m_enabled = false; | 195 | m_enabled = false; |
196 | } | 196 | } |
197 | } | 197 | } |
@@ -354,7 +354,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
354 | } | 354 | } |
355 | catch (Exception e) | 355 | catch (Exception e) |
356 | { | 356 | { |
357 | m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); | 357 | m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); |
358 | } | 358 | } |
359 | 359 | ||
360 | DispatchValue(scriptID,reqID,String.Empty); | 360 | DispatchValue(scriptID,reqID,String.Empty); |
@@ -389,7 +389,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
389 | } | 389 | } |
390 | catch (Exception e) | 390 | catch (Exception e) |
391 | { | 391 | { |
392 | m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); | 392 | m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); |
393 | } | 393 | } |
394 | 394 | ||
395 | DispatchValue(scriptID,reqID,String.Empty); | 395 | DispatchValue(scriptID,reqID,String.Empty); |
@@ -421,7 +421,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
421 | if (a.Type != (sbyte)AssetType.Notecard) | 421 | if (a.Type != (sbyte)AssetType.Notecard) |
422 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); | 422 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); |
423 | 423 | ||
424 | m_log.DebugFormat("[JsonStoreScripts] read notecard in context {0}",storeID); | 424 | m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID); |
425 | 425 | ||
426 | try | 426 | try |
427 | { | 427 | { |
@@ -432,7 +432,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
432 | } | 432 | } |
433 | catch (Exception e) | 433 | catch (Exception e) |
434 | { | 434 | { |
435 | m_log.WarnFormat("[JsonStoreScripts] Json parsing failed; {0}",e.Message); | 435 | m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message); |
436 | } | 436 | } |
437 | 437 | ||
438 | GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); | 438 | GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); |
@@ -495,4 +495,4 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
495 | m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); | 495 | m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | } | 498 | } \ 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 new file mode 100644 index 0000000..397dd93 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | |||
@@ -0,0 +1,145 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.Scripting.ScriptModuleComms; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.ScriptEngine.Shared; | ||
40 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using OpenSim.Tests.Common; | ||
43 | using OpenSim.Tests.Common.Mock; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// Tests for inventory functions in LSL | ||
49 | /// </summary> | ||
50 | [TestFixture] | ||
51 | public class LSL_ApiInventoryTests : OpenSimTestCase | ||
52 | { | ||
53 | private Scene m_scene; | ||
54 | private MockScriptEngine m_engine; | ||
55 | private ScriptModuleCommsModule m_smcm; | ||
56 | |||
57 | [SetUp] | ||
58 | public override void SetUp() | ||
59 | { | ||
60 | base.SetUp(); | ||
61 | |||
62 | TestHelpers.EnableLogging(); | ||
63 | |||
64 | IConfigSource configSource = new IniConfigSource(); | ||
65 | IConfig jsonStoreConfig = configSource.AddConfig("JsonStore"); | ||
66 | jsonStoreConfig.Set("Enabled", "true"); | ||
67 | |||
68 | m_engine = new MockScriptEngine(); | ||
69 | m_smcm = new ScriptModuleCommsModule(); | ||
70 | JsonStoreModule jsm = new JsonStoreModule(); | ||
71 | JsonStoreScriptModule jssm = new JsonStoreScriptModule(); | ||
72 | |||
73 | m_scene = new SceneHelpers().SetupScene(); | ||
74 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); | ||
75 | } | ||
76 | |||
77 | // [Test] | ||
78 | public void TestJsonCreateStore() | ||
79 | { | ||
80 | TestHelpers.InMethod(); | ||
81 | // TestHelpers.EnableLogging(); | ||
82 | |||
83 | UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" }); | ||
84 | |||
85 | Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); | ||
86 | } | ||
87 | |||
88 | // [Test] | ||
89 | public void TestJsonGetValue() | ||
90 | { | ||
91 | TestHelpers.InMethod(); | ||
92 | // TestHelpers.EnableLogging(); | ||
93 | |||
94 | UUID storeId | ||
95 | = (UUID)m_smcm.InvokeOperation( | ||
96 | UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); | ||
97 | |||
98 | string value | ||
99 | = (string)m_smcm.InvokeOperation( | ||
100 | UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" }); | ||
101 | |||
102 | Assert.That(value, Is.EqualTo("World")); | ||
103 | } | ||
104 | |||
105 | // [Test] | ||
106 | public void TestJsonTestPath() | ||
107 | { | ||
108 | TestHelpers.InMethod(); | ||
109 | // TestHelpers.EnableLogging(); | ||
110 | |||
111 | UUID storeId | ||
112 | = (UUID)m_smcm.InvokeOperation( | ||
113 | UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); | ||
114 | |||
115 | int result | ||
116 | = (int)m_smcm.InvokeOperation( | ||
117 | UUID.Zero, UUID.Zero, "JsonTestPath", new object[] { storeId, "Hello" }); | ||
118 | |||
119 | Assert.That(result, Is.EqualTo(1)); | ||
120 | } | ||
121 | |||
122 | // [Test] | ||
123 | public void TestJsonSetValue() | ||
124 | { | ||
125 | TestHelpers.InMethod(); | ||
126 | // TestHelpers.EnableLogging(); | ||
127 | |||
128 | UUID storeId | ||
129 | = (UUID)m_smcm.InvokeOperation( | ||
130 | UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ }" }); | ||
131 | |||
132 | int result | ||
133 | = (int)m_smcm.InvokeOperation( | ||
134 | UUID.Zero, UUID.Zero, "JsonSetValue", new object[] { storeId, "Hello", "World" }); | ||
135 | |||
136 | Assert.That(result, Is.EqualTo(1)); | ||
137 | |||
138 | string value | ||
139 | = (string)m_smcm.InvokeOperation( | ||
140 | UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" }); | ||
141 | |||
142 | Assert.That(value, Is.EqualTo("World")); | ||
143 | } | ||
144 | } | ||
145 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 365fd78..34362af 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 | |||
74 | [SetUp] | 74 | [SetUp] |
75 | public void Init() | 75 | public void Init() |
76 | { | 76 | { |
77 | base.SetUp(); | ||
78 | |||
77 | IConfigSource config = new IniConfigSource(); | 79 | IConfigSource config = new IniConfigSource(); |
78 | config.AddConfig("NPC"); | 80 | config.AddConfig("NPC"); |
79 | config.Configs["NPC"].Set("Enabled", "true"); | 81 | config.Configs["NPC"].Set("Enabled", "true"); |
diff --git a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs index 12169ab..5fb74b0 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 | |||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SceneCommandsModule")] | 48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SceneCommandsModule")] |
49 | public class SceneCommandsModule : ISceneCommandsModule, INonSharedRegionModule | 49 | public class SceneCommandsModule : ISceneCommandsModule, INonSharedRegionModule |
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private Scene m_scene; | 53 | private Scene m_scene; |
54 | 54 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index f63d83c..04e77b8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | |||
@@ -137,6 +137,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
137 | internal int LastEntityProperty = 0; | 137 | internal int LastEntityProperty = 0; |
138 | 138 | ||
139 | internal EntityProperties[] UpdatedObjects; | 139 | internal EntityProperties[] UpdatedObjects; |
140 | internal Dictionary<uint, GhostObject> specialCollisionObjects; | ||
140 | 141 | ||
141 | private static int m_collisionsThisFrame; | 142 | private static int m_collisionsThisFrame; |
142 | private BSScene PhysicsScene { get; set; } | 143 | private BSScene PhysicsScene { get; set; } |
@@ -158,7 +159,13 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
158 | { | 159 | { |
159 | DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; | 160 | DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world; |
160 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | 161 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
161 | world.RemoveRigidBody(body); | 162 | CollisionObject collisionObject = ((BulletBodyXNA)pBody).body; |
163 | if (body != null) | ||
164 | world.RemoveRigidBody(body); | ||
165 | else if (collisionObject != null) | ||
166 | world.RemoveCollisionObject(collisionObject); | ||
167 | else | ||
168 | return false; | ||
162 | return true; | 169 | return true; |
163 | } | 170 | } |
164 | 171 | ||
@@ -182,7 +189,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
182 | 189 | ||
183 | public override void SetRestitution(BulletBody pCollisionObject, float pRestitution) | 190 | public override void SetRestitution(BulletBody pCollisionObject, float pRestitution) |
184 | { | 191 | { |
185 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; | 192 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; |
186 | collisionObject.SetRestitution(pRestitution); | 193 | collisionObject.SetRestitution(pRestitution); |
187 | } | 194 | } |
188 | 195 | ||
@@ -219,13 +226,13 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
219 | 226 | ||
220 | public override void SetCcdMotionThreshold(BulletBody pCollisionObject, float pccdMotionThreashold) | 227 | public override void SetCcdMotionThreshold(BulletBody pCollisionObject, float pccdMotionThreashold) |
221 | { | 228 | { |
222 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; | 229 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; |
223 | collisionObject.SetCcdMotionThreshold(pccdMotionThreashold); | 230 | collisionObject.SetCcdMotionThreshold(pccdMotionThreashold); |
224 | } | 231 | } |
225 | 232 | ||
226 | public override void SetCcdSweptSphereRadius(BulletBody pCollisionObject, float pCcdSweptSphereRadius) | 233 | public override void SetCcdSweptSphereRadius(BulletBody pCollisionObject, float pCcdSweptSphereRadius) |
227 | { | 234 | { |
228 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; | 235 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; |
229 | collisionObject.SetCcdSweptSphereRadius(pCcdSweptSphereRadius); | 236 | collisionObject.SetCcdSweptSphereRadius(pCcdSweptSphereRadius); |
230 | } | 237 | } |
231 | 238 | ||
@@ -262,7 +269,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
262 | } | 269 | } |
263 | else | 270 | else |
264 | { | 271 | { |
265 | world.AddCollisionObject(rbody); | 272 | world.AddCollisionObject(cbody); |
266 | } | 273 | } |
267 | cbody.SetWorldTransform(origPos); | 274 | cbody.SetWorldTransform(origPos); |
268 | 275 | ||
@@ -303,7 +310,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
303 | 310 | ||
304 | public override bool SetCollisionGroupMask(BulletBody pCollisionObject, uint pGroup, uint pMask) | 311 | public override bool SetCollisionGroupMask(BulletBody pCollisionObject, uint pGroup, uint pMask) |
305 | { | 312 | { |
306 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; | 313 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; |
307 | collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; | 314 | collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; |
308 | collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; | 315 | collisionObject.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; |
309 | if ((uint) collisionObject.GetBroadphaseHandle().m_collisionFilterGroup == 0) | 316 | if ((uint) collisionObject.GetBroadphaseHandle().m_collisionFilterGroup == 0) |
@@ -390,7 +397,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
390 | 397 | ||
391 | public override void SetTranslation(BulletBody pCollisionObject, Vector3 _position, Quaternion _orientation) | 398 | public override void SetTranslation(BulletBody pCollisionObject, Vector3 _position, Quaternion _orientation) |
392 | { | 399 | { |
393 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; | 400 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; |
394 | IndexedVector3 vposition = new IndexedVector3(_position.X, _position.Y, _position.Z); | 401 | IndexedVector3 vposition = new IndexedVector3(_position.X, _position.Y, _position.Z); |
395 | IndexedQuaternion vquaternion = new IndexedQuaternion(_orientation.X, _orientation.Y, _orientation.Z, | 402 | IndexedQuaternion vquaternion = new IndexedQuaternion(_orientation.X, _orientation.Y, _orientation.Z, |
396 | _orientation.W); | 403 | _orientation.W); |
@@ -418,8 +425,11 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
418 | public override void SetMassProps(BulletBody pBody, float pphysMass, Vector3 plocalInertia) | 425 | public override void SetMassProps(BulletBody pBody, float pphysMass, Vector3 plocalInertia) |
419 | { | 426 | { |
420 | RigidBody body = (pBody as BulletBodyXNA).rigidBody; | 427 | RigidBody body = (pBody as BulletBodyXNA).rigidBody; |
421 | IndexedVector3 inertia = new IndexedVector3(plocalInertia.X, plocalInertia.Y, plocalInertia.Z); | 428 | if (body != null) // Can't set mass props on collision object. |
422 | body.SetMassProps(pphysMass, inertia); | 429 | { |
430 | IndexedVector3 inertia = new IndexedVector3(plocalInertia.X, plocalInertia.Y, plocalInertia.Z); | ||
431 | body.SetMassProps(pphysMass, inertia); | ||
432 | } | ||
423 | } | 433 | } |
424 | 434 | ||
425 | 435 | ||
@@ -432,7 +442,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
432 | 442 | ||
433 | public override void SetFriction(BulletBody pCollisionObject, float _currentFriction) | 443 | public override void SetFriction(BulletBody pCollisionObject, float _currentFriction) |
434 | { | 444 | { |
435 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; | 445 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; |
436 | collisionObject.SetFriction(_currentFriction); | 446 | collisionObject.SetFriction(_currentFriction); |
437 | } | 447 | } |
438 | 448 | ||
@@ -459,7 +469,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
459 | 469 | ||
460 | public override CollisionFlags RemoveFromCollisionFlags(BulletBody pCollisionObject, CollisionFlags pcollisionFlags) | 470 | public override CollisionFlags RemoveFromCollisionFlags(BulletBody pCollisionObject, CollisionFlags pcollisionFlags) |
461 | { | 471 | { |
462 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; | 472 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; |
463 | CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)collisionObject.GetCollisionFlags(); | 473 | CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)collisionObject.GetCollisionFlags(); |
464 | existingcollisionFlags &= ~pcollisionFlags; | 474 | existingcollisionFlags &= ~pcollisionFlags; |
465 | collisionObject.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags); | 475 | collisionObject.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags); |
@@ -494,8 +504,11 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
494 | public override void SetGravity(BulletBody pBody, Vector3 pGravity) | 504 | public override void SetGravity(BulletBody pBody, Vector3 pGravity) |
495 | { | 505 | { |
496 | RigidBody body = (pBody as BulletBodyXNA).rigidBody; | 506 | RigidBody body = (pBody as BulletBodyXNA).rigidBody; |
497 | IndexedVector3 gravity = new IndexedVector3(pGravity.X, pGravity.Y, pGravity.Z); | 507 | if (body != null) // Can't set collisionobject.set gravity |
498 | body.SetGravity(gravity); | 508 | { |
509 | IndexedVector3 gravity = new IndexedVector3(pGravity.X, pGravity.Y, pGravity.Z); | ||
510 | body.SetGravity(gravity); | ||
511 | } | ||
499 | } | 512 | } |
500 | 513 | ||
501 | public override bool DestroyConstraint(BulletWorld pWorld, BulletConstraint pConstraint) | 514 | public override bool DestroyConstraint(BulletWorld pWorld, BulletConstraint pConstraint) |
@@ -733,7 +746,8 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
733 | public override void UpdateInertiaTensor(BulletBody pBody) | 746 | public override void UpdateInertiaTensor(BulletBody pBody) |
734 | { | 747 | { |
735 | RigidBody body = (pBody as BulletBodyXNA).rigidBody; | 748 | RigidBody body = (pBody as BulletBodyXNA).rigidBody; |
736 | body.UpdateInertiaTensor(); | 749 | if (body != null) // can't update inertia tensor on CollisionObject |
750 | body.UpdateInertiaTensor(); | ||
737 | } | 751 | } |
738 | 752 | ||
739 | public override void RecalculateCompoundShapeLocalAabb(BulletShape pCompoundShape) | 753 | public override void RecalculateCompoundShapeLocalAabb(BulletShape pCompoundShape) |
@@ -770,7 +784,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
770 | 784 | ||
771 | public override CollisionObjectTypes GetBodyType(BulletBody pCollisionObject) | 785 | public override CollisionObjectTypes GetBodyType(BulletBody pCollisionObject) |
772 | { | 786 | { |
773 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody; | 787 | CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body; |
774 | return (CollisionObjectTypes)(int) collisionObject.GetInternalType(); | 788 | return (CollisionObjectTypes)(int) collisionObject.GetInternalType(); |
775 | } | 789 | } |
776 | 790 | ||
@@ -889,7 +903,18 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
889 | world.RemoveRigidBody(bo); | 903 | world.RemoveRigidBody(bo); |
890 | } | 904 | } |
891 | } | 905 | } |
892 | 906 | if (co != null) | |
907 | { | ||
908 | if (co.GetUserPointer() != null) | ||
909 | { | ||
910 | uint localId = (uint) co.GetUserPointer(); | ||
911 | if (specialCollisionObjects.ContainsKey(localId)) | ||
912 | { | ||
913 | specialCollisionObjects.Remove(localId); | ||
914 | } | ||
915 | } | ||
916 | } | ||
917 | |||
893 | } | 918 | } |
894 | 919 | ||
895 | public override void Shutdown(BulletWorld pWorld) | 920 | public override void Shutdown(BulletWorld pWorld) |
@@ -1050,7 +1075,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1050 | Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | 1075 | Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); |
1051 | m_maxCollisions = maxCollisions; | 1076 | m_maxCollisions = maxCollisions; |
1052 | m_maxUpdatesPerFrame = maxUpdates; | 1077 | m_maxUpdatesPerFrame = maxUpdates; |
1053 | 1078 | specialCollisionObjects = new Dictionary<uint, GhostObject>(); | |
1054 | 1079 | ||
1055 | return new BulletWorldXNA(1, PhysicsScene, BSAPIXNA.Initialize2(worldExtent, configparms, maxCollisions, ref collisionArray, maxUpdates, ref updateArray, null)); | 1080 | return new BulletWorldXNA(1, PhysicsScene, BSAPIXNA.Initialize2(worldExtent, configparms, maxCollisions, ref collisionArray, maxUpdates, ref updateArray, null)); |
1056 | } | 1081 | } |
@@ -1310,6 +1335,12 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1310 | CollisionShape shape = (pShape as BulletShapeXNA).shape; | 1335 | CollisionShape shape = (pShape as BulletShapeXNA).shape; |
1311 | gObj.SetCollisionShape(shape); | 1336 | gObj.SetCollisionShape(shape); |
1312 | gObj.SetUserPointer(pLocalID); | 1337 | gObj.SetUserPointer(pLocalID); |
1338 | |||
1339 | if (specialCollisionObjects.ContainsKey(pLocalID)) | ||
1340 | specialCollisionObjects[pLocalID] = gObj; | ||
1341 | else | ||
1342 | specialCollisionObjects.Add(pLocalID, gObj); | ||
1343 | |||
1313 | // TODO: Add to Special CollisionObjects! | 1344 | // TODO: Add to Special CollisionObjects! |
1314 | return new BulletBodyXNA(pLocalID, gObj); | 1345 | return new BulletBodyXNA(pLocalID, gObj); |
1315 | } | 1346 | } |
@@ -1399,7 +1430,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1399 | } | 1430 | } |
1400 | 1431 | ||
1401 | public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) { | 1432 | public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) { |
1402 | /* TODO */ | 1433 | |
1403 | if (cShape == null) | 1434 | if (cShape == null) |
1404 | return null; | 1435 | return null; |
1405 | CompoundShape compoundShape = (cShape as BulletShapeXNA).shape as CompoundShape; | 1436 | CompoundShape compoundShape = (cShape as BulletShapeXNA).shape as CompoundShape; |
@@ -1407,7 +1438,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1407 | BulletShape retShape = new BulletShapeXNA(shape, BSShapeTypeFromBroadPhaseNativeType(shape.GetShapeType())); | 1438 | BulletShape retShape = new BulletShapeXNA(shape, BSShapeTypeFromBroadPhaseNativeType(shape.GetShapeType())); |
1408 | 1439 | ||
1409 | 1440 | ||
1410 | return null; | 1441 | return retShape; |
1411 | } | 1442 | } |
1412 | 1443 | ||
1413 | public BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin) | 1444 | public BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin) |
@@ -1802,26 +1833,29 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1802 | numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); | 1833 | numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); |
1803 | int updates = 0; | 1834 | int updates = 0; |
1804 | 1835 | ||
1805 | 1836 | PersistentManifold contactManifold; | |
1806 | 1837 | CollisionObject objA; | |
1838 | CollisionObject objB; | ||
1839 | ManifoldPoint manifoldPoint; | ||
1840 | PairCachingGhostObject pairCachingGhostObject; | ||
1807 | 1841 | ||
1808 | m_collisionsThisFrame = 0; | 1842 | m_collisionsThisFrame = 0; |
1809 | int numManifolds = world.GetDispatcher().GetNumManifolds(); | 1843 | int numManifolds = world.GetDispatcher().GetNumManifolds(); |
1810 | for (int j = 0; j < numManifolds; j++) | 1844 | for (int j = 0; j < numManifolds; j++) |
1811 | { | 1845 | { |
1812 | PersistentManifold contactManifold = world.GetDispatcher().GetManifoldByIndexInternal(j); | 1846 | contactManifold = world.GetDispatcher().GetManifoldByIndexInternal(j); |
1813 | int numContacts = contactManifold.GetNumContacts(); | 1847 | int numContacts = contactManifold.GetNumContacts(); |
1814 | if (numContacts == 0) | 1848 | if (numContacts == 0) |
1815 | continue; | 1849 | continue; |
1816 | 1850 | ||
1817 | CollisionObject objA = contactManifold.GetBody0() as CollisionObject; | 1851 | objA = contactManifold.GetBody0() as CollisionObject; |
1818 | CollisionObject objB = contactManifold.GetBody1() as CollisionObject; | 1852 | objB = contactManifold.GetBody1() as CollisionObject; |
1819 | 1853 | ||
1820 | ManifoldPoint manifoldPoint = contactManifold.GetContactPoint(0); | 1854 | manifoldPoint = contactManifold.GetContactPoint(0); |
1821 | IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB(); | 1855 | //IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB(); |
1822 | IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A | 1856 | // IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A |
1823 | 1857 | ||
1824 | RecordCollision(this, objA, objB, contactPoint, contactNormal,manifoldPoint.GetDistance()); | 1858 | RecordCollision(this, objA, objB, manifoldPoint.GetPositionWorldOnB(), -manifoldPoint.m_normalWorldOnB, manifoldPoint.GetDistance()); |
1825 | m_collisionsThisFrame ++; | 1859 | m_collisionsThisFrame ++; |
1826 | if (m_collisionsThisFrame >= 9999999) | 1860 | if (m_collisionsThisFrame >= 9999999) |
1827 | break; | 1861 | break; |
@@ -1829,12 +1863,19 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1829 | 1863 | ||
1830 | } | 1864 | } |
1831 | 1865 | ||
1832 | updatedEntityCount = LastEntityProperty; | 1866 | foreach (GhostObject ghostObject in specialCollisionObjects.Values) |
1833 | updatedEntities = UpdatedObjects; | 1867 | { |
1834 | 1868 | pairCachingGhostObject = ghostObject as PairCachingGhostObject; | |
1869 | if (pairCachingGhostObject != null) | ||
1870 | { | ||
1871 | RecordGhostCollisions(pairCachingGhostObject); | ||
1872 | } | ||
1835 | 1873 | ||
1874 | } | ||
1836 | 1875 | ||
1837 | 1876 | ||
1877 | updatedEntityCount = LastEntityProperty; | ||
1878 | updatedEntities = UpdatedObjects; | ||
1838 | 1879 | ||
1839 | collidersCount = LastCollisionDesc; | 1880 | collidersCount = LastCollisionDesc; |
1840 | colliders = UpdatedCollisions; | 1881 | colliders = UpdatedCollisions; |
@@ -1860,60 +1901,49 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1860 | } | 1901 | } |
1861 | public void RecordGhostCollisions(PairCachingGhostObject obj) | 1902 | public void RecordGhostCollisions(PairCachingGhostObject obj) |
1862 | { | 1903 | { |
1863 | /* | 1904 | IOverlappingPairCache cache = obj.GetOverlappingPairCache(); |
1864 | *void BulletSim::RecordGhostCollisions(btPairCachingGhostObject* obj) | 1905 | ObjectArray<BroadphasePair> pairs = cache.GetOverlappingPairArray(); |
1865 | { | 1906 | |
1866 | btManifoldArray manifoldArray; | 1907 | DiscreteDynamicsWorld world = (PhysicsScene.World as BulletWorldXNA).world; |
1867 | btBroadphasePairArray& pairArray = obj->getOverlappingPairCache()->getOverlappingPairArray(); | 1908 | PersistentManifoldArray manifoldArray = new PersistentManifoldArray(); |
1868 | int numPairs = pairArray.size(); | 1909 | BroadphasePair collisionPair; |
1869 | 1910 | PersistentManifold contactManifold; | |
1870 | // For all the pairs of sets of contact points | 1911 | |
1871 | for (int i=0; i < numPairs; i++) | 1912 | CollisionObject objA; |
1872 | { | 1913 | CollisionObject objB; |
1873 | if (m_collisionsThisFrame >= m_maxCollisionsPerFrame) | 1914 | |
1874 | break; | 1915 | ManifoldPoint pt; |
1875 | 1916 | ||
1876 | manifoldArray.clear(); | 1917 | int numPairs = pairs.Count; |
1877 | const btBroadphasePair& pair = pairArray[i]; | 1918 | |
1878 | 1919 | for (int i = 0; i < numPairs; i++) | |
1879 | // The real representation is over in the world pair cache | 1920 | { |
1880 | btBroadphasePair* collisionPair = m_worldData.dynamicsWorld->getPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1); | 1921 | manifoldArray.Clear(); |
1881 | if (!collisionPair) | 1922 | if (LastCollisionDesc < UpdatedCollisions.Length) |
1882 | continue; | 1923 | break; |
1883 | 1924 | collisionPair = world.GetPairCache().FindPair(pairs[i].m_pProxy0, pairs[i].m_pProxy1); | |
1884 | if (collisionPair->m_algorithm) | 1925 | if (collisionPair == null) |
1885 | collisionPair->m_algorithm->getAllContactManifolds(manifoldArray); | 1926 | continue; |
1886 | 1927 | ||
1887 | // The collision pair has sets of collision points (manifolds) | 1928 | collisionPair.m_algorithm.GetAllContactManifolds(manifoldArray); |
1888 | for (int j=0; j < manifoldArray.size(); j++) | 1929 | for (int j = 0; j < manifoldArray.Count; j++) |
1889 | { | 1930 | { |
1890 | btPersistentManifold* contactManifold = manifoldArray[j]; | 1931 | contactManifold = manifoldArray[j]; |
1891 | int numContacts = contactManifold->getNumContacts(); | 1932 | int numContacts = contactManifold.GetNumContacts(); |
1892 | 1933 | objA = contactManifold.GetBody0() as CollisionObject; | |
1893 | const btCollisionObject* objA = static_cast<const btCollisionObject*>(contactManifold->getBody0()); | 1934 | objB = contactManifold.GetBody1() as CollisionObject; |
1894 | const btCollisionObject* objB = static_cast<const btCollisionObject*>(contactManifold->getBody1()); | 1935 | for (int p = 0; p < numContacts; p++) |
1895 | 1936 | { | |
1896 | // TODO: this is a more thurough check than the regular collision code -- | 1937 | pt = contactManifold.GetContactPoint(p); |
1897 | // here we find the penetrating contact in the manifold but for regular | 1938 | if (pt.GetDistance() < 0.0f) |
1898 | // collisions we assume the first point in the manifold is good enough. | 1939 | { |
1899 | // Decide of this extra checking is required or if first point is good enough. | 1940 | RecordCollision(this, objA, objB, pt.GetPositionWorldOnA(), -pt.m_normalWorldOnB,pt.GetDistance()); |
1900 | for (int p=0; p < numContacts; p++) | 1941 | break; |
1901 | { | 1942 | } |
1902 | const btManifoldPoint& pt = contactManifold->getContactPoint(p); | 1943 | } |
1903 | // If a penetrating contact, this is a hit | 1944 | } |
1904 | if (pt.getDistance()<0.f) | 1945 | } |
1905 | { | 1946 | |
1906 | const btVector3& contactPoint = pt.getPositionWorldOnA(); | ||
1907 | const btVector3& normalOnA = -pt.m_normalWorldOnB; | ||
1908 | RecordCollision(objA, objB, contactPoint, normalOnA, pt.getDistance()); | ||
1909 | // Only one contact point for each set of colliding objects | ||
1910 | break; | ||
1911 | } | ||
1912 | } | ||
1913 | } | ||
1914 | } | ||
1915 | } | ||
1916 | */ | ||
1917 | } | 1947 | } |
1918 | private static void RecordCollision(BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm, float penetration) | 1948 | private static void RecordCollision(BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm, float penetration) |
1919 | { | 1949 | { |
@@ -1934,7 +1964,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1934 | contactNormal = -contactNormal; | 1964 | contactNormal = -contactNormal; |
1935 | } | 1965 | } |
1936 | 1966 | ||
1937 | ulong collisionID = ((ulong) idA << 32) | idB; | 1967 | //ulong collisionID = ((ulong) idA << 32) | idB; |
1938 | 1968 | ||
1939 | CollisionDesc cDesc = new CollisionDesc() | 1969 | CollisionDesc cDesc = new CollisionDesc() |
1940 | { | 1970 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index f1ef449..7ad7c89 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -158,6 +158,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
158 | get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); } | 158 | get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); } |
159 | } | 159 | } |
160 | 160 | ||
161 | // Return 'true' if this a vehicle that should be sitting on the ground | ||
162 | public bool IsGroundVehicle | ||
163 | { | ||
164 | get { return (Type == Vehicle.TYPE_CAR || Type == Vehicle.TYPE_SLED); } | ||
165 | } | ||
166 | |||
161 | #region Vehicle parameter setting | 167 | #region Vehicle parameter setting |
162 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) | 168 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) |
163 | { | 169 | { |
@@ -1176,6 +1182,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1176 | private void ApplyGravity(float pTimeStep) | 1182 | private void ApplyGravity(float pTimeStep) |
1177 | { | 1183 | { |
1178 | Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; | 1184 | Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; |
1185 | |||
1186 | // Hack to reduce downward force if the vehicle is probably sitting on the ground | ||
1187 | if (Prim.IsColliding && IsGroundVehicle) | ||
1188 | appliedGravity *= 0.2f; | ||
1189 | |||
1179 | VehicleAddForce(appliedGravity); | 1190 | VehicleAddForce(appliedGravity); |
1180 | 1191 | ||
1181 | VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}", | 1192 | VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}", |
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs new file mode 100644 index 0000000..51f2712 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs | |||
@@ -0,0 +1,214 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared; | ||
38 | |||
39 | namespace OpenSim.Tests.Common | ||
40 | { | ||
41 | public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine | ||
42 | { | ||
43 | private Scene m_scene; | ||
44 | |||
45 | public void Initialise(IConfigSource source) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | public void Close() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | public void AddRegion(Scene scene) | ||
54 | { | ||
55 | m_scene = scene; | ||
56 | |||
57 | m_scene.StackModuleInterface<IScriptModule>(this); | ||
58 | } | ||
59 | |||
60 | public void RemoveRegion(Scene scene) | ||
61 | { | ||
62 | } | ||
63 | |||
64 | public void RegionLoaded(Scene scene) | ||
65 | { | ||
66 | } | ||
67 | |||
68 | public string Name { get { return "Mock Script Engine"; } } | ||
69 | public string ScriptEngineName { get { return Name; } } | ||
70 | |||
71 | public Type ReplaceableInterface { get { return null; } } | ||
72 | |||
73 | public event ScriptRemoved OnScriptRemoved; | ||
74 | public event ObjectRemoved OnObjectRemoved; | ||
75 | |||
76 | public string GetXMLState (UUID itemID) | ||
77 | { | ||
78 | throw new System.NotImplementedException (); | ||
79 | } | ||
80 | |||
81 | public bool SetXMLState(UUID itemID, string xml) | ||
82 | { | ||
83 | throw new System.NotImplementedException (); | ||
84 | } | ||
85 | |||
86 | public bool PostScriptEvent(UUID itemID, string name, object[] args) | ||
87 | { | ||
88 | throw new System.NotImplementedException (); | ||
89 | } | ||
90 | |||
91 | public bool PostObjectEvent(UUID itemID, string name, object[] args) | ||
92 | { | ||
93 | throw new System.NotImplementedException (); | ||
94 | } | ||
95 | |||
96 | public void SuspendScript(UUID itemID) | ||
97 | { | ||
98 | throw new System.NotImplementedException (); | ||
99 | } | ||
100 | |||
101 | public void ResumeScript(UUID itemID) | ||
102 | { | ||
103 | throw new System.NotImplementedException (); | ||
104 | } | ||
105 | |||
106 | public ArrayList GetScriptErrors(UUID itemID) | ||
107 | { | ||
108 | throw new System.NotImplementedException (); | ||
109 | } | ||
110 | |||
111 | public bool HasScript(UUID itemID, out bool running) | ||
112 | { | ||
113 | throw new System.NotImplementedException (); | ||
114 | } | ||
115 | |||
116 | public bool GetScriptState(UUID itemID) | ||
117 | { | ||
118 | throw new System.NotImplementedException (); | ||
119 | } | ||
120 | |||
121 | public void SaveAllState() | ||
122 | { | ||
123 | throw new System.NotImplementedException (); | ||
124 | } | ||
125 | |||
126 | public void StartProcessing() | ||
127 | { | ||
128 | throw new System.NotImplementedException (); | ||
129 | } | ||
130 | |||
131 | public float GetScriptExecutionTime(List<UUID> itemIDs) | ||
132 | { | ||
133 | throw new System.NotImplementedException (); | ||
134 | } | ||
135 | |||
136 | public Dictionary<uint, float> GetObjectScriptsExecutionTimes() | ||
137 | { | ||
138 | throw new System.NotImplementedException (); | ||
139 | } | ||
140 | |||
141 | public IScriptWorkItem QueueEventHandler(object parms) | ||
142 | { | ||
143 | throw new System.NotImplementedException (); | ||
144 | } | ||
145 | |||
146 | public bool PostScriptEvent(UUID itemID,EventParams parms) | ||
147 | { | ||
148 | throw new System.NotImplementedException (); | ||
149 | } | ||
150 | |||
151 | public bool PostObjectEvent (uint localID, EventParams parms) | ||
152 | { | ||
153 | throw new System.NotImplementedException (); | ||
154 | } | ||
155 | |||
156 | public DetectParams GetDetectParams(UUID item, int number) | ||
157 | { | ||
158 | throw new System.NotImplementedException (); | ||
159 | } | ||
160 | |||
161 | public void SetMinEventDelay(UUID itemID, double delay) | ||
162 | { | ||
163 | throw new System.NotImplementedException (); | ||
164 | } | ||
165 | |||
166 | public int GetStartParameter(UUID itemID) | ||
167 | { | ||
168 | throw new System.NotImplementedException (); | ||
169 | } | ||
170 | |||
171 | public void SetScriptState(UUID itemID, bool state) | ||
172 | { | ||
173 | throw new System.NotImplementedException (); | ||
174 | } | ||
175 | |||
176 | public void SetState(UUID itemID, string newState) | ||
177 | { | ||
178 | throw new System.NotImplementedException (); | ||
179 | } | ||
180 | |||
181 | public void ApiResetScript(UUID itemID) | ||
182 | { | ||
183 | throw new System.NotImplementedException (); | ||
184 | } | ||
185 | |||
186 | public void ResetScript (UUID itemID) | ||
187 | { | ||
188 | throw new System.NotImplementedException (); | ||
189 | } | ||
190 | |||
191 | public IScriptApi GetApi(UUID itemID, string name) | ||
192 | { | ||
193 | throw new System.NotImplementedException (); | ||
194 | } | ||
195 | |||
196 | public Scene World { get { return m_scene; } } | ||
197 | |||
198 | public IScriptModule ScriptModule { get { throw new System.NotImplementedException(); } } | ||
199 | |||
200 | public IConfig Config { get { throw new System.NotImplementedException (); } } | ||
201 | |||
202 | public IConfigSource ConfigSource { get { throw new System.NotImplementedException (); } } | ||
203 | |||
204 | public string ScriptEnginePath { get { throw new System.NotImplementedException (); }} | ||
205 | |||
206 | public string ScriptClassName { get { throw new System.NotImplementedException (); } } | ||
207 | |||
208 | public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } } | ||
209 | |||
210 | public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } } | ||
211 | |||
212 | public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } } | ||
213 | } | ||
214 | } \ No newline at end of file | ||
diff --git a/prebuild.xml b/prebuild.xml index b2c76ea..4caa1a6 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -2866,12 +2866,13 @@ | |||
2866 | <Reference name="OpenSim.Framework.Console"/> | 2866 | <Reference name="OpenSim.Framework.Console"/> |
2867 | <Reference name="OpenSim.Framework.Servers"/> | 2867 | <Reference name="OpenSim.Framework.Servers"/> |
2868 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | 2868 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> |
2869 | <Reference name="OpenSim.Services.Interfaces"/> | ||
2870 | <Reference name="OpenSim.Server.Base"/> | ||
2871 | <Reference name="OpenSim.Region.Framework"/> | 2869 | <Reference name="OpenSim.Region.Framework"/> |
2872 | <Reference name="OpenSim.Region.CoreModules"/> | 2870 | <Reference name="OpenSim.Region.CoreModules"/> |
2873 | <Reference name="OpenSim.Region.OptionalModules"/> | 2871 | <Reference name="OpenSim.Region.OptionalModules"/> |
2874 | <Reference name="OpenSim.Region.Physics.Manager"/> | 2872 | <Reference name="OpenSim.Region.Physics.Manager"/> |
2873 | <Reference name="OpenSim.Region.ScriptEngine.Shared"/> | ||
2874 | <Reference name="OpenSim.Server.Base"/> | ||
2875 | <Reference name="OpenSim.Services.Interfaces"/> | ||
2875 | 2876 | ||
2876 | <Files> | 2877 | <Files> |
2877 | <Match pattern="*.cs" recurse="true"/> | 2878 | <Match pattern="*.cs" recurse="true"/> |
@@ -3234,6 +3235,7 @@ | |||
3234 | <Reference name="OpenSim.Region.CoreModules"/> | 3235 | <Reference name="OpenSim.Region.CoreModules"/> |
3235 | <Reference name="OpenSim.Region.OptionalModules"/> | 3236 | <Reference name="OpenSim.Region.OptionalModules"/> |
3236 | <Reference name="OpenSim.Region.Physics.Manager"/> | 3237 | <Reference name="OpenSim.Region.Physics.Manager"/> |
3238 | <Reference name="OpenSim.Region.ScriptEngine.Shared"/> | ||
3237 | <Reference name="OpenSim.Services.AvatarService"/> | 3239 | <Reference name="OpenSim.Services.AvatarService"/> |
3238 | <Reference name="OpenSim.Services.Interfaces"/> | 3240 | <Reference name="OpenSim.Services.Interfaces"/> |
3239 | 3241 | ||
@@ -3258,6 +3260,7 @@ | |||
3258 | <Files> | 3260 | <Files> |
3259 | <!-- SADLY the way this works means you need to keep adding these paths --> | 3261 | <!-- SADLY the way this works means you need to keep adding these paths --> |
3260 | <Match path="Avatar/XmlRpcGroups/Tests" pattern="*.cs" recurse="true"/> | 3262 | <Match path="Avatar/XmlRpcGroups/Tests" pattern="*.cs" recurse="true"/> |
3263 | <Match path="Scripting/JsonStore/Tests" pattern="*.cs" recurse="true"/> | ||
3261 | <Match path="World/NPC/Tests" pattern="*.cs" recurse="true"/> | 3264 | <Match path="World/NPC/Tests" pattern="*.cs" recurse="true"/> |
3262 | </Files> | 3265 | </Files> |
3263 | </Project> | 3266 | </Project> |