diff options
Diffstat (limited to '')
7 files changed, 370 insertions, 138 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index ae72175..c472176 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
@@ -279,7 +279,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
279 | public string GetStats() | 279 | public string GetStats() |
280 | { | 280 | { |
281 | return string.Format( | 281 | return string.Format( |
282 | "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}", | 282 | "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7} {12,7}", |
283 | Util.EnvironmentTickCountSubtract(TickLastPacketReceived), | ||
283 | PacketsReceived, | 284 | PacketsReceived, |
284 | PacketsSent, | 285 | PacketsSent, |
285 | PacketsResent, | 286 | PacketsResent, |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index cd1e1c1..273e290 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -47,6 +47,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | |||
47 | using OpenSim.Region.CoreModules.World.Serialiser; | 47 | using OpenSim.Region.CoreModules.World.Serialiser; |
48 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
49 | using OpenSim.Region.Framework.Interfaces; | 49 | using OpenSim.Region.Framework.Interfaces; |
50 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
50 | using OpenSim.Region.ScriptEngine.XEngine; | 51 | using OpenSim.Region.ScriptEngine.XEngine; |
51 | using OpenSim.Services.Interfaces; | 52 | using OpenSim.Services.Interfaces; |
52 | using OpenSim.Tests.Common; | 53 | using OpenSim.Tests.Common; |
@@ -289,21 +290,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
289 | { | 290 | { |
290 | TestHelpers.InMethod(); | 291 | TestHelpers.InMethod(); |
291 | 292 | ||
292 | Scene scene = CreateTestScene(); | 293 | Scene scene = CreateScriptingEnabledTestScene(); |
293 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 294 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
294 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | 295 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
295 | 296 | ||
296 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); | 297 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); |
297 | TaskInventoryHelpers.AddScript(scene, so.RootPart); | 298 | TaskInventoryItem scriptItem |
299 | = TaskInventoryHelpers.AddScript( | ||
300 | scene, | ||
301 | so.RootPart, | ||
302 | "scriptItem", | ||
303 | "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }"); | ||
304 | |||
298 | InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); | 305 | InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); |
299 | 306 | ||
307 | // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running. | ||
308 | // In the future, we need to be able to do this programatically more predicably. | ||
309 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | ||
310 | |||
300 | scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 311 | scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); |
301 | 312 | ||
313 | m_chatEvent.WaitOne(60000); | ||
314 | |||
302 | // TODO: Need to have a test that checks the script is actually started but this involves a lot more | 315 | // TODO: Need to have a test that checks the script is actually started but this involves a lot more |
303 | // plumbing of the script engine and either pausing for events or more infrastructure to turn off various | 316 | // plumbing of the script engine and either pausing for events or more infrastructure to turn off various |
304 | // script engine delays/asychronicity that isn't helpful in an automated regression testing context. | 317 | // script engine delays/asychronicity that isn't helpful in an automated regression testing context. |
305 | SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.Name); | 318 | SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.Name); |
306 | Assert.That(attSo.ContainsScripts(), Is.True); | 319 | Assert.That(attSo.ContainsScripts(), Is.True); |
320 | |||
321 | TaskInventoryItem reRezzedScriptItem = attSo.RootPart.Inventory.GetInventoryItem(scriptItem.Name); | ||
322 | IScriptModule xengine = scene.RequestModuleInterface<IScriptModule>(); | ||
323 | Assert.That(xengine.GetScriptState(reRezzedScriptItem.ItemID), Is.True); | ||
307 | } | 324 | } |
308 | 325 | ||
309 | [Test] | 326 | [Test] |
@@ -379,29 +396,49 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
379 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | 396 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
380 | 397 | ||
381 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); | 398 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); |
382 | TaskInventoryHelpers.AddScript(scene, so.RootPart); | 399 | TaskInventoryItem scriptTaskItem |
400 | = TaskInventoryHelpers.AddScript( | ||
401 | scene, | ||
402 | so.RootPart, | ||
403 | "scriptItem", | ||
404 | "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }"); | ||
405 | |||
383 | InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); | 406 | InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); |
384 | 407 | ||
385 | // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running. | 408 | // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running. |
386 | // In the future, we need to be able to do this programatically more predicably. | 409 | // In the future, we need to be able to do this programatically more predicably. |
387 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 410 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; |
388 | 411 | ||
389 | SceneObjectGroup soRezzed | 412 | SceneObjectGroup rezzedSo |
390 | = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 413 | = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
391 | 414 | ||
392 | // Wait for chat to signal rezzed script has been started. | 415 | // Wait for chat to signal rezzed script has been started. |
393 | m_chatEvent.WaitOne(60000); | 416 | m_chatEvent.WaitOne(60000); |
394 | 417 | ||
395 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, soRezzed); | 418 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, rezzedSo); |
396 | 419 | ||
397 | InventoryItemBase userItemUpdated = scene.InventoryService.GetItem(userItem); | 420 | InventoryItemBase userItemUpdated = scene.InventoryService.GetItem(userItem); |
398 | AssetBase asset = scene.AssetService.Get(userItemUpdated.AssetID.ToString()); | 421 | AssetBase asset = scene.AssetService.Get(userItemUpdated.AssetID.ToString()); |
399 | 422 | ||
423 | // TODO: It would probably be better here to check script state via the saving and retrieval of state | ||
424 | // information at a higher level, rather than having to inspect the serialization. | ||
400 | XmlDocument soXml = new XmlDocument(); | 425 | XmlDocument soXml = new XmlDocument(); |
401 | soXml.LoadXml(Encoding.UTF8.GetString(asset.Data)); | 426 | soXml.LoadXml(Encoding.UTF8.GetString(asset.Data)); |
402 | 427 | ||
403 | XmlNodeList scriptStateNodes = soXml.GetElementsByTagName("ScriptState"); | 428 | XmlNodeList scriptStateNodes = soXml.GetElementsByTagName("ScriptState"); |
404 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); | 429 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); |
430 | |||
431 | // Re-rez the attachment to check script running state | ||
432 | SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); | ||
433 | |||
434 | // Wait for chat to signal rezzed script has been started. | ||
435 | m_chatEvent.WaitOne(60000); | ||
436 | |||
437 | TaskInventoryItem reRezzedScriptItem = reRezzedSo.RootPart.Inventory.GetInventoryItem(scriptTaskItem.Name); | ||
438 | IScriptModule xengine = scene.RequestModuleInterface<IScriptModule>(); | ||
439 | Assert.That(xengine.GetScriptState(reRezzedScriptItem.ItemID), Is.True); | ||
440 | |||
441 | // Console.WriteLine(soXml.OuterXml); | ||
405 | } | 442 | } |
406 | 443 | ||
407 | /// <summary> | 444 | /// <summary> |
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index a7ebecc..ca9bd4a 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | |||
@@ -82,18 +82,6 @@ namespace OpenSim.Region.CoreModules.UDP.Linden | |||
82 | m_scenes[scene.RegionInfo.RegionID] = scene; | 82 | m_scenes[scene.RegionInfo.RegionID] = scene; |
83 | 83 | ||
84 | scene.AddCommand( | 84 | scene.AddCommand( |
85 | "Comms", this, "image queues clear", | ||
86 | "image queues clear <first-name> <last-name>", | ||
87 | "Clear the image queues (textures downloaded via UDP) for a particular client.", | ||
88 | (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd))); | ||
89 | |||
90 | scene.AddCommand( | ||
91 | "Comms", this, "image queues show", | ||
92 | "image queues show <first-name> <last-name>", | ||
93 | "Show the image queues (textures downloaded via UDP) for a particular client.", | ||
94 | (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd))); | ||
95 | |||
96 | scene.AddCommand( | ||
97 | "Comms", this, "show pqueues", | 85 | "Comms", this, "show pqueues", |
98 | "show pqueues [full]", | 86 | "show pqueues [full]", |
99 | "Show priority queue data for each client", | 87 | "Show priority queue data for each client", |
@@ -105,8 +93,15 @@ namespace OpenSim.Region.CoreModules.UDP.Linden | |||
105 | "Comms", this, "show queues", | 93 | "Comms", this, "show queues", |
106 | "show queues [full]", | 94 | "show queues [full]", |
107 | "Show queue data for each client", | 95 | "Show queue data for each client", |
108 | "Without the 'full' option, only root agents are shown." | 96 | "Without the 'full' option, only root agents are shown.\n" |
109 | + " With the 'full' option child agents are also shown.", | 97 | + "With the 'full' option child agents are also shown.\n\n" |
98 | + "Type - Rt is a root (avatar) client whilst cd is a child (neighbour interacting) client.\n" | ||
99 | + "Since Last In - Time in milliseconds since last packet received.\n" | ||
100 | + "Pkts In - Number of packets processed from the client.\n" | ||
101 | + "Pkts Out - Number of packets sent to the client.\n" | ||
102 | + "Pkts Resent - Number of packets resent to the client.\n" | ||
103 | + "Bytes Unacked - Number of bytes transferred to the client that are awaiting acknowledgement.\n" | ||
104 | + "Q Pkts * - Number of packets of various types (land, wind, etc.) to be sent to the client that are waiting for available bandwidth.\n", | ||
110 | (mod, cmd) => MainConsole.Instance.Output(GetQueuesReport(cmd))); | 105 | (mod, cmd) => MainConsole.Instance.Output(GetQueuesReport(cmd))); |
111 | 106 | ||
112 | scene.AddCommand( | 107 | scene.AddCommand( |
@@ -114,6 +109,12 @@ namespace OpenSim.Region.CoreModules.UDP.Linden | |||
114 | "show image queues <first-name> <last-name>", | 109 | "show image queues <first-name> <last-name>", |
115 | "Show the image queues (textures downloaded via UDP) for a particular client.", | 110 | "Show the image queues (textures downloaded via UDP) for a particular client.", |
116 | (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd))); | 111 | (mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd))); |
112 | |||
113 | scene.AddCommand( | ||
114 | "Comms", this, "clear image queues", | ||
115 | "clear image queues <first-name> <last-name>", | ||
116 | "Clear the image queues (textures downloaded via UDP) for a particular client.", | ||
117 | (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd))); | ||
117 | 118 | ||
118 | scene.AddCommand( | 119 | scene.AddCommand( |
119 | "Comms", this, "show throttles", | 120 | "Comms", this, "show throttles", |
@@ -373,17 +374,22 @@ namespace OpenSim.Region.CoreModules.UDP.Linden | |||
373 | int maxNameLength = 18; | 374 | int maxNameLength = 18; |
374 | int maxRegionNameLength = 14; | 375 | int maxRegionNameLength = 14; |
375 | int maxTypeLength = 4; | 376 | int maxTypeLength = 4; |
376 | int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding; | 377 | |
378 | int totalInfoFieldsLength | ||
379 | = maxNameLength + columnPadding | ||
380 | + maxRegionNameLength + columnPadding | ||
381 | + maxTypeLength + columnPadding; | ||
377 | 382 | ||
378 | report.Append(GetColumnEntry("User", maxNameLength, columnPadding)); | 383 | report.Append(GetColumnEntry("User", maxNameLength, columnPadding)); |
379 | report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding)); | 384 | report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding)); |
380 | report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); | 385 | report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); |
381 | 386 | ||
382 | report.AppendFormat( | 387 | report.AppendFormat( |
383 | "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}\n", | 388 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", |
389 | "Since", | ||
390 | "Pkts", | ||
384 | "Pkts", | 391 | "Pkts", |
385 | "Pkts", | 392 | "Pkts", |
386 | "Pkts", | ||
387 | "Bytes", | 393 | "Bytes", |
388 | "Q Pkts", | 394 | "Q Pkts", |
389 | "Q Pkts", | 395 | "Q Pkts", |
@@ -396,7 +402,8 @@ namespace OpenSim.Region.CoreModules.UDP.Linden | |||
396 | 402 | ||
397 | report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); | 403 | report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); |
398 | report.AppendFormat( | 404 | report.AppendFormat( |
399 | "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}\n", | 405 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", |
406 | "Last In", | ||
400 | "In", | 407 | "In", |
401 | "Out", | 408 | "Out", |
402 | "Resent", | 409 | "Resent", |
@@ -417,22 +424,22 @@ namespace OpenSim.Region.CoreModules.UDP.Linden | |||
417 | scene.ForEachClient( | 424 | scene.ForEachClient( |
418 | delegate(IClientAPI client) | 425 | delegate(IClientAPI client) |
419 | { | 426 | { |
420 | if (client is IStatsCollector) | 427 | bool isChild = client.SceneAgent.IsChildAgent; |
421 | { | 428 | if (isChild && !showChildren) |
422 | bool isChild = client.SceneAgent.IsChildAgent; | 429 | return; |
423 | if (isChild && !showChildren) | 430 | |
424 | return; | 431 | string name = client.Name; |
425 | 432 | if (pname != "" && name != pname) | |
426 | string name = client.Name; | 433 | return; |
427 | if (pname != "" && name != pname) | ||
428 | return; | ||
429 | 434 | ||
430 | string regionName = scene.RegionInfo.RegionName; | 435 | string regionName = scene.RegionInfo.RegionName; |
431 | 436 | ||
432 | report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); | 437 | report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); |
433 | report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); | 438 | report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); |
434 | report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); | 439 | report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); |
435 | 440 | ||
441 | if (client is IStatsCollector) | ||
442 | { | ||
436 | IStatsCollector stats = (IStatsCollector)client; | 443 | IStatsCollector stats = (IStatsCollector)client; |
437 | 444 | ||
438 | report.AppendLine(stats.Report()); | 445 | report.AppendLine(stats.Report()); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 71a4303..a19d6d7 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -133,10 +133,7 @@ public sealed class BSPrim : PhysicsActor | |||
133 | _parentPrim = null; // not a child or a parent | 133 | _parentPrim = null; // not a child or a parent |
134 | _vehicle = new BSDynamics(this); // add vehicleness | 134 | _vehicle = new BSDynamics(this); // add vehicleness |
135 | _childrenPrims = new List<BSPrim>(); | 135 | _childrenPrims = new List<BSPrim>(); |
136 | if (_isPhysical) | 136 | _mass = CalculateMass(); |
137 | _mass = CalculateMass(); | ||
138 | else | ||
139 | _mass = 0f; | ||
140 | // do the actual object creation at taint time | 137 | // do the actual object creation at taint time |
141 | _scene.TaintedObject(delegate() | 138 | _scene.TaintedObject(delegate() |
142 | { | 139 | { |
@@ -149,22 +146,26 @@ public sealed class BSPrim : PhysicsActor | |||
149 | { | 146 | { |
150 | // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); | 147 | // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); |
151 | // DetailLog("{0},Destroy", LocalID); | 148 | // DetailLog("{0},Destroy", LocalID); |
149 | |||
152 | // Undo any vehicle properties | 150 | // Undo any vehicle properties |
153 | _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); | 151 | _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); |
154 | _scene.RemoveVehiclePrim(this); // just to make sure | 152 | _scene.RemoveVehiclePrim(this); // just to make sure |
155 | 153 | ||
156 | // undo any dependance with/on other objects | ||
157 | if (_parentPrim != null) | ||
158 | { | ||
159 | // If I'm someone's child, tell them to forget about me. | ||
160 | _parentPrim.RemoveChildFromLinkset(this); | ||
161 | _parentPrim = null; | ||
162 | } | ||
163 | |||
164 | _scene.TaintedObject(delegate() | 154 | _scene.TaintedObject(delegate() |
165 | { | 155 | { |
156 | // undo any dependance with/on other objects | ||
157 | if (_parentPrim != null) | ||
158 | { | ||
159 | // If I'm someone's child, tell them to forget about me. | ||
160 | _parentPrim.RemoveChildFromLinkset(this); | ||
161 | _parentPrim = null; | ||
162 | } | ||
163 | |||
164 | // make sure there are no possible children depending on me | ||
165 | UnlinkAllChildren(); | ||
166 | |||
166 | // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. | 167 | // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. |
167 | BulletSimAPI.DestroyObject(_scene.WorldID, _localID); | 168 | BulletSimAPI.DestroyObject(_scene.WorldID, LocalID); |
168 | }); | 169 | }); |
169 | } | 170 | } |
170 | 171 | ||
@@ -177,8 +178,8 @@ public sealed class BSPrim : PhysicsActor | |||
177 | _size = value; | 178 | _size = value; |
178 | _scene.TaintedObject(delegate() | 179 | _scene.TaintedObject(delegate() |
179 | { | 180 | { |
180 | if (_isPhysical) _mass = CalculateMass(); // changing size changes the mass | 181 | _mass = CalculateMass(); // changing size changes the mass |
181 | BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, _mass, _isPhysical); | 182 | BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, Mass, IsPhysical); |
182 | RecreateGeomAndObject(); | 183 | RecreateGeomAndObject(); |
183 | }); | 184 | }); |
184 | } | 185 | } |
@@ -188,7 +189,7 @@ public sealed class BSPrim : PhysicsActor | |||
188 | _pbs = value; | 189 | _pbs = value; |
189 | _scene.TaintedObject(delegate() | 190 | _scene.TaintedObject(delegate() |
190 | { | 191 | { |
191 | if (_isPhysical) _mass = CalculateMass(); // changing the shape changes the mass | 192 | _mass = CalculateMass(); // changing the shape changes the mass |
192 | RecreateGeomAndObject(); | 193 | RecreateGeomAndObject(); |
193 | }); | 194 | }); |
194 | } | 195 | } |
@@ -272,7 +273,10 @@ public sealed class BSPrim : PhysicsActor | |||
272 | DetailLog("{0},AddChildToLinkset,child={1}", LocalID, pchild.LocalID); | 273 | DetailLog("{0},AddChildToLinkset,child={1}", LocalID, pchild.LocalID); |
273 | _childrenPrims.Add(child); | 274 | _childrenPrims.Add(child); |
274 | child._parentPrim = this; // the child has gained a parent | 275 | child._parentPrim = this; // the child has gained a parent |
275 | RecreateGeomAndObject(); // rebuild my shape with the new child added | 276 | // RecreateGeomAndObject(); // rebuild my shape with the new child added |
277 | LinkAChildToMe(pchild); // build the physical binding between me and the child | ||
278 | |||
279 | _mass = CalculateMass(); | ||
276 | } | 280 | } |
277 | }); | 281 | }); |
278 | return; | 282 | return; |
@@ -288,14 +292,21 @@ public sealed class BSPrim : PhysicsActor | |||
288 | if (_childrenPrims.Contains(child)) | 292 | if (_childrenPrims.Contains(child)) |
289 | { | 293 | { |
290 | DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); | 294 | DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); |
291 | DetailLog("{0},RemoveChildToLinkset,child={1}", LocalID, pchild.LocalID); | 295 | DetailLog("{0},RemoveChildFromLinkset,child={1}", LocalID, pchild.LocalID); |
292 | if (!BulletSimAPI.RemoveConstraintByID(_scene.WorldID, child.LocalID)) | ||
293 | { | ||
294 | m_log.ErrorFormat("{0}: RemoveChildFromLinkset: Failed remove constraint for {1}", LogHeader, child.LocalID); | ||
295 | } | ||
296 | _childrenPrims.Remove(child); | 296 | _childrenPrims.Remove(child); |
297 | child._parentPrim = null; // the child has lost its parent | 297 | child._parentPrim = null; // the child has lost its parent |
298 | RecreateGeomAndObject(); // rebuild my shape with the child removed | 298 | if (_childrenPrims.Count == 0) |
299 | { | ||
300 | // if the linkset is empty, make sure all linkages have been removed | ||
301 | UnlinkAllChildren(); | ||
302 | } | ||
303 | else | ||
304 | { | ||
305 | // RecreateGeomAndObject(); // rebuild my shape with the child removed | ||
306 | UnlinkAChildFromMe(pchild); | ||
307 | } | ||
308 | |||
309 | _mass = CalculateMass(); | ||
299 | } | 310 | } |
300 | else | 311 | else |
301 | { | 312 | { |
@@ -314,12 +325,19 @@ public sealed class BSPrim : PhysicsActor | |||
314 | // Set motion values to zero. | 325 | // Set motion values to zero. |
315 | // Do it to the properties so the values get set in the physics engine. | 326 | // Do it to the properties so the values get set in the physics engine. |
316 | // Push the setting of the values to the viewer. | 327 | // Push the setting of the values to the viewer. |
328 | // Called at taint time! | ||
317 | private void ZeroMotion() | 329 | private void ZeroMotion() |
318 | { | 330 | { |
319 | Velocity = OMV.Vector3.Zero; | 331 | _velocity = OMV.Vector3.Zero; |
320 | _acceleration = OMV.Vector3.Zero; | 332 | _acceleration = OMV.Vector3.Zero; |
321 | RotationalVelocity = OMV.Vector3.Zero; | 333 | _rotationalVelocity = OMV.Vector3.Zero; |
322 | base.RequestPhysicsterseUpdate(); | 334 | |
335 | // Zero some other properties directly into the physics engine | ||
336 | IntPtr obj = BulletSimAPI.GetBodyHandleWorldID2(_scene.WorldID, LocalID); | ||
337 | BulletSimAPI.SetVelocity2(obj, OMV.Vector3.Zero); | ||
338 | BulletSimAPI.SetAngularVelocity2(obj, OMV.Vector3.Zero); | ||
339 | BulletSimAPI.SetInterpolation2(obj, OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
340 | BulletSimAPI.ClearForces2(obj); | ||
323 | } | 341 | } |
324 | 342 | ||
325 | public override void LockAngularMotion(OMV.Vector3 axis) | 343 | public override void LockAngularMotion(OMV.Vector3 axis) |
@@ -347,9 +365,17 @@ public sealed class BSPrim : PhysicsActor | |||
347 | }); | 365 | }); |
348 | } | 366 | } |
349 | } | 367 | } |
368 | |||
369 | // Return the effective mass of the object. Non-physical objects do not have mass. | ||
350 | public override float Mass { | 370 | public override float Mass { |
351 | get { return _mass; } | 371 | get { |
372 | if (IsPhysical) | ||
373 | return _mass; | ||
374 | else | ||
375 | return 0f; | ||
376 | } | ||
352 | } | 377 | } |
378 | |||
353 | public override OMV.Vector3 Force { | 379 | public override OMV.Vector3 Force { |
354 | get { return _force; } | 380 | get { return _force; } |
355 | set { | 381 | set { |
@@ -429,7 +455,8 @@ public sealed class BSPrim : PhysicsActor | |||
429 | // Called from Scene when doing simulation step so we're in taint processing time. | 455 | // Called from Scene when doing simulation step so we're in taint processing time. |
430 | public void StepVehicle(float timeStep) | 456 | public void StepVehicle(float timeStep) |
431 | { | 457 | { |
432 | _vehicle.Step(timeStep); | 458 | if (IsPhysical) |
459 | _vehicle.Step(timeStep); | ||
433 | } | 460 | } |
434 | 461 | ||
435 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | 462 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more |
@@ -526,20 +553,13 @@ public sealed class BSPrim : PhysicsActor | |||
526 | { | 553 | { |
527 | // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); | 554 | // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); |
528 | // non-physical things work best with a mass of zero | 555 | // non-physical things work best with a mass of zero |
529 | if (IsStatic) | 556 | if (!IsStatic) |
530 | { | ||
531 | _mass = 0f; | ||
532 | } | ||
533 | else | ||
534 | { | 557 | { |
535 | _mass = CalculateMass(); | 558 | _mass = CalculateMass(); |
536 | // If it's dynamic, make sure the hull has been created for it | ||
537 | // This shouldn't do much work if the object had previously been built | ||
538 | RecreateGeomAndObject(); | 559 | RecreateGeomAndObject(); |
539 | |||
540 | } | 560 | } |
541 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, _mass); | 561 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, Mass); |
542 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass); | 562 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), Mass); |
543 | } | 563 | } |
544 | 564 | ||
545 | // prims don't fly | 565 | // prims don't fly |
@@ -1234,7 +1254,7 @@ public sealed class BSPrim : PhysicsActor | |||
1234 | if (IsRootOfLinkset) | 1254 | if (IsRootOfLinkset) |
1235 | { | 1255 | { |
1236 | // Create a linkset around this object | 1256 | // Create a linkset around this object |
1237 | CreateLinksetWithConstraints(); | 1257 | CreateLinkset(); |
1238 | } | 1258 | } |
1239 | else | 1259 | else |
1240 | { | 1260 | { |
@@ -1247,30 +1267,6 @@ public sealed class BSPrim : PhysicsActor | |||
1247 | } | 1267 | } |
1248 | } | 1268 | } |
1249 | 1269 | ||
1250 | // Create a linkset by creating a compound hull at the root prim that consists of all | ||
1251 | // the children. | ||
1252 | // NOTE: This does not allow proper collisions with the children prims so it is not a workable solution | ||
1253 | void CreateLinksetWithCompoundHull() | ||
1254 | { | ||
1255 | // If I am the root prim of a linkset, replace my physical shape with all the | ||
1256 | // pieces of the children. | ||
1257 | // All of the children should have called CreateGeom so they have a hull | ||
1258 | // in the physics engine already. Here we pull together all of those hulls | ||
1259 | // into one shape. | ||
1260 | int totalPrimsInLinkset = _childrenPrims.Count + 1; | ||
1261 | // m_log.DebugFormat("{0}: CreateLinkset. Root prim={1}, prims={2}", LogHeader, LocalID, totalPrimsInLinkset); | ||
1262 | ShapeData[] shapes = new ShapeData[totalPrimsInLinkset]; | ||
1263 | FillShapeInfo(out shapes[0]); | ||
1264 | int ii = 1; | ||
1265 | foreach (BSPrim prim in _childrenPrims) | ||
1266 | { | ||
1267 | // m_log.DebugFormat("{0}: CreateLinkset: adding prim {1}", LogHeader, prim.LocalID); | ||
1268 | prim.FillShapeInfo(out shapes[ii]); | ||
1269 | ii++; | ||
1270 | } | ||
1271 | BulletSimAPI.CreateLinkset(_scene.WorldID, totalPrimsInLinkset, shapes); | ||
1272 | } | ||
1273 | |||
1274 | // Copy prim's info into the BulletSim shape description structure | 1270 | // Copy prim's info into the BulletSim shape description structure |
1275 | public void FillShapeInfo(out ShapeData shape) | 1271 | public void FillShapeInfo(out ShapeData shape) |
1276 | { | 1272 | { |
@@ -1280,7 +1276,7 @@ public sealed class BSPrim : PhysicsActor | |||
1280 | shape.Rotation = _orientation; | 1276 | shape.Rotation = _orientation; |
1281 | shape.Velocity = _velocity; | 1277 | shape.Velocity = _velocity; |
1282 | shape.Scale = _scale; | 1278 | shape.Scale = _scale; |
1283 | shape.Mass = _isPhysical ? _mass : 0f; | 1279 | shape.Mass = Mass; |
1284 | shape.Buoyancy = _buoyancy; | 1280 | shape.Buoyancy = _buoyancy; |
1285 | shape.HullKey = _hullKey; | 1281 | shape.HullKey = _hullKey; |
1286 | shape.MeshKey = _meshKey; | 1282 | shape.MeshKey = _meshKey; |
@@ -1290,45 +1286,73 @@ public sealed class BSPrim : PhysicsActor | |||
1290 | shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue; | 1286 | shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue; |
1291 | } | 1287 | } |
1292 | 1288 | ||
1289 | #region Linkset creation and destruction | ||
1290 | |||
1293 | // Create the linkset by putting constraints between the objects of the set so they cannot move | 1291 | // Create the linkset by putting constraints between the objects of the set so they cannot move |
1294 | // relative to each other. | 1292 | // relative to each other. |
1295 | // TODO: make this more effeicient: a large linkset gets rebuilt over and over and prims are added | 1293 | void CreateLinkset() |
1296 | void CreateLinksetWithConstraints() | ||
1297 | { | 1294 | { |
1298 | DebugLog("{0}: CreateLinkset. Root prim={1}, prims={2}", LogHeader, LocalID, _childrenPrims.Count+1); | 1295 | DebugLog("{0}: CreateLinkset. Root prim={1}, prims={2}", LogHeader, LocalID, _childrenPrims.Count+1); |
1299 | 1296 | ||
1300 | // remove any constraints that might be in place | 1297 | // remove any constraints that might be in place |
1301 | foreach (BSPrim prim in _childrenPrims) | 1298 | DebugLog("{0}: CreateLinkset: RemoveConstraints between me and any children", LogHeader, LocalID); |
1302 | { | 1299 | BulletSimAPI.RemoveConstraintByID(_scene.WorldID, LocalID); |
1303 | DebugLog("{0}: CreateLinkset: RemoveConstraint between root prim {1} and child prim {2}", LogHeader, LocalID, prim.LocalID); | 1300 | |
1304 | BulletSimAPI.RemoveConstraint(_scene.WorldID, LocalID, prim.LocalID); | ||
1305 | } | ||
1306 | // create constraints between the root prim and each of the children | 1301 | // create constraints between the root prim and each of the children |
1307 | foreach (BSPrim prim in _childrenPrims) | 1302 | foreach (BSPrim prim in _childrenPrims) |
1308 | { | 1303 | { |
1309 | // Zero motion for children so they don't interpolate | 1304 | LinkAChildToMe(prim); |
1310 | prim.ZeroMotion(); | ||
1311 | |||
1312 | // relative position normalized to the root prim | ||
1313 | OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(this._orientation); | ||
1314 | OMV.Vector3 childRelativePosition = (prim._position - this._position) * invThisOrientation; | ||
1315 | |||
1316 | // relative rotation of the child to the parent | ||
1317 | OMV.Quaternion childRelativeRotation = invThisOrientation * prim._orientation; | ||
1318 | |||
1319 | // this is a constraint that allows no freedom of movement between the two objects | ||
1320 | // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 | ||
1321 | DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, prim.LocalID); | ||
1322 | BulletSimAPI.AddConstraint(_scene.WorldID, LocalID, prim.LocalID, | ||
1323 | childRelativePosition, | ||
1324 | childRelativeRotation, | ||
1325 | OMV.Vector3.Zero, | ||
1326 | OMV.Quaternion.Identity, | ||
1327 | OMV.Vector3.Zero, OMV.Vector3.Zero, | ||
1328 | OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
1329 | } | 1305 | } |
1330 | } | 1306 | } |
1331 | 1307 | ||
1308 | // Create a constraint between me (root of linkset) and the passed prim (the child). | ||
1309 | // Called at taint time! | ||
1310 | private void LinkAChildToMe(BSPrim childPrim) | ||
1311 | { | ||
1312 | // Zero motion for children so they don't interpolate | ||
1313 | childPrim.ZeroMotion(); | ||
1314 | |||
1315 | // relative position normalized to the root prim | ||
1316 | OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(this._orientation); | ||
1317 | OMV.Vector3 childRelativePosition = (childPrim._position - this._position) * invThisOrientation; | ||
1318 | |||
1319 | // relative rotation of the child to the parent | ||
1320 | OMV.Quaternion childRelativeRotation = invThisOrientation * childPrim._orientation; | ||
1321 | |||
1322 | // create a constraint that allows no freedom of movement between the two objects | ||
1323 | // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 | ||
1324 | DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); | ||
1325 | DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", LocalID, LocalID, childPrim.LocalID); | ||
1326 | BulletSimAPI.AddConstraint(_scene.WorldID, LocalID, childPrim.LocalID, | ||
1327 | childRelativePosition, | ||
1328 | childRelativeRotation, | ||
1329 | OMV.Vector3.Zero, | ||
1330 | OMV.Quaternion.Identity, | ||
1331 | OMV.Vector3.Zero, OMV.Vector3.Zero, | ||
1332 | OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
1333 | } | ||
1334 | |||
1335 | // Remove linkage between myself and a particular child | ||
1336 | // Called at taint time! | ||
1337 | private void UnlinkAChildFromMe(BSPrim childPrim) | ||
1338 | { | ||
1339 | DebugLog("{0}: UnlinkAChildFromMe: RemoveConstraint between root prim {1} and child prim {2}", | ||
1340 | LogHeader, LocalID, childPrim.LocalID); | ||
1341 | DetailLog("{0},UnlinkAChildFromMe,taint,root={1},child={2}", LocalID, LocalID, childPrim.LocalID); | ||
1342 | BulletSimAPI.RemoveConstraint(_scene.WorldID, LocalID, childPrim.LocalID); | ||
1343 | } | ||
1344 | |||
1345 | // Remove linkage between myself and any possible children I might have | ||
1346 | // Called at taint time! | ||
1347 | private void UnlinkAllChildren() | ||
1348 | { | ||
1349 | DebugLog("{0}: UnlinkAllChildren:", LogHeader); | ||
1350 | DetailLog("{0},UnlinkAllChildren,taint", LocalID); | ||
1351 | BulletSimAPI.RemoveConstraintByID(_scene.WorldID, LocalID); | ||
1352 | } | ||
1353 | |||
1354 | #endregion // Linkset creation and destruction | ||
1355 | |||
1332 | // Rebuild the geometry and object. | 1356 | // Rebuild the geometry and object. |
1333 | // This is called when the shape changes so we need to recreate the mesh/hull. | 1357 | // This is called when the shape changes so we need to recreate the mesh/hull. |
1334 | // No locking here because this is done when the physics engine is not simulating | 1358 | // No locking here because this is done when the physics engine is not simulating |
@@ -1405,7 +1429,7 @@ public sealed class BSPrim : PhysicsActor | |||
1405 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. | 1429 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. |
1406 | 1430 | ||
1407 | // Updates only for individual prims and for the root object of a linkset. | 1431 | // Updates only for individual prims and for the root object of a linkset. |
1408 | if (this._parentPrim == null) | 1432 | if (_parentPrim == null) |
1409 | { | 1433 | { |
1410 | // Assign to the local variables so the normal set action does not happen | 1434 | // Assign to the local variables so the normal set action does not happen |
1411 | _position = entprop.Position; | 1435 | _position = entprop.Position; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 8773485..7cc3fe3 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -630,6 +630,27 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
630 | public override void Dispose() | 630 | public override void Dispose() |
631 | { | 631 | { |
632 | // m_log.DebugFormat("{0}: Dispose()", LogHeader); | 632 | // m_log.DebugFormat("{0}: Dispose()", LogHeader); |
633 | |||
634 | // make sure no stepping happens while we're deleting stuff | ||
635 | m_initialized = false; | ||
636 | |||
637 | foreach (KeyValuePair<uint, BSCharacter> kvp in m_avatars) | ||
638 | { | ||
639 | kvp.Value.Destroy(); | ||
640 | } | ||
641 | m_avatars.Clear(); | ||
642 | |||
643 | foreach (KeyValuePair<uint, BSPrim> kvp in m_prims) | ||
644 | { | ||
645 | kvp.Value.Destroy(); | ||
646 | } | ||
647 | m_prims.Clear(); | ||
648 | |||
649 | // Anything left in the unmanaged code should be cleaned out | ||
650 | BulletSimAPI.Shutdown(WorldID); | ||
651 | |||
652 | // Not logging any more | ||
653 | PhysicsLogging.Close(); | ||
633 | } | 654 | } |
634 | 655 | ||
635 | public override Dictionary<uint, float> GetTopColliders() | 656 | public override Dictionary<uint, float> GetTopColliders() |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index babb707..54a8cfd 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | |||
@@ -291,13 +291,14 @@ public static extern void SetDebugLogCallback(DebugLogCallback callback); | |||
291 | // =============================================================================== | 291 | // =============================================================================== |
292 | // =============================================================================== | 292 | // =============================================================================== |
293 | // =============================================================================== | 293 | // =============================================================================== |
294 | // A new version of the API that moves all the logic out of the C++ code and into | 294 | // A new version of the API that enables moving all the logic out of the C++ code and into |
295 | // the C# code. This will make modifications easier for the next person. | 295 | // the C# code. This will make modifications easier for the next person. |
296 | // This interface passes the actual pointers to the objects in the unmanaged | 296 | // This interface passes the actual pointers to the objects in the unmanaged |
297 | // address space. All the management (calls for creation/destruction/lookup) | 297 | // address space. All the management (calls for creation/destruction/lookup) |
298 | // is done in the C# code. | 298 | // is done in the C# code. |
299 | // The names have a 2 tacked on. This will be removed as the code gets rebuilt | 299 | // The names have a "2" tacked on. This will be removed as the C# code gets rebuilt |
300 | // and the old code is removed from the C# code. | 300 | // and the old code is removed. |
301 | |||
301 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 302 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
302 | public static extern IntPtr GetSimHandle2(uint worldID); | 303 | public static extern IntPtr GetSimHandle2(uint worldID); |
303 | 304 | ||
@@ -307,8 +308,101 @@ public static extern IntPtr GetBodyHandleWorldID2(uint worldID, uint id); | |||
307 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 308 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
308 | public static extern IntPtr GetBodyHandle2(IntPtr sim, uint id); | 309 | public static extern IntPtr GetBodyHandle2(IntPtr sim, uint id); |
309 | 310 | ||
311 | // =============================================================================== | ||
310 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 312 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
311 | public static extern IntPtr ClearForces2(IntPtr obj); | 313 | public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms, |
314 | int maxCollisions, IntPtr collisionArray, | ||
315 | int maxUpdates, IntPtr updateArray); | ||
316 | |||
317 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
318 | public static extern bool UpdateParameter2(IntPtr sim, uint localID, String parm, float value); | ||
319 | |||
320 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
321 | public static extern void SetHeightmap2(IntPtr sim, float[] heightmap); | ||
322 | |||
323 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
324 | public static extern void Shutdown2(IntPtr sim); | ||
325 | |||
326 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
327 | public static extern int PhysicsStep2(IntPtr sim, float timeStep, int maxSubSteps, float fixedTimeStep, | ||
328 | out int updatedEntityCount, | ||
329 | out IntPtr updatedEntitiesPtr, | ||
330 | out int collidersCount, | ||
331 | out IntPtr collidersPtr); | ||
332 | |||
333 | /* | ||
334 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
335 | public static extern IntPtr CreateMesh2(IntPtr sim, int indicesCount, int* indices, int verticesCount, float* vertices ); | ||
336 | |||
337 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
338 | public static extern bool BuildHull2(IntPtr sim, IntPtr mesh); | ||
339 | |||
340 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
341 | public static extern bool ReleaseHull2(IntPtr sim, IntPtr mesh); | ||
342 | |||
343 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
344 | public static extern bool DestroyMesh2(IntPtr sim, IntPtr mesh); | ||
345 | |||
346 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
347 | public static extern IntPtr CreateObject2(IntPtr sim, ShapeData shapeData); | ||
348 | */ | ||
349 | |||
350 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
351 | public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2, | ||
352 | Vector3 frame1loc, Quaternion frame1rot, | ||
353 | Vector3 frame2loc, Quaternion frame2rot, | ||
354 | Vector3 lowLinear, Vector3 hiLinear, Vector3 lowAngular, Vector3 hiAngular); | ||
355 | |||
356 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
357 | public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain); | ||
358 | |||
359 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
360 | public static extern Vector3 GetPosition2(IntPtr obj); | ||
361 | |||
362 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
363 | public static extern Quaternion GetOrientation2(IntPtr obj); | ||
364 | |||
365 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
366 | public static extern bool SetTranslation2(IntPtr obj, Vector3 position, Quaternion rotation); | ||
367 | |||
368 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
369 | public static extern bool SetVelocity2(IntPtr obj, Vector3 velocity); | ||
370 | |||
371 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
372 | public static extern bool SetAngularVelocity2(IntPtr obj, Vector3 angularVelocity); | ||
373 | |||
374 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
375 | public static extern bool SetObjectForce2(IntPtr obj, Vector3 force); | ||
376 | |||
377 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
378 | public static extern bool SetCcdMotionThreshold2(IntPtr obj, float val); | ||
379 | |||
380 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
381 | public static extern bool SetCcdSweepSphereRadius2(IntPtr obj, float val); | ||
382 | |||
383 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
384 | public static extern bool SetDamping2(IntPtr obj, float lin_damping, float ang_damping); | ||
385 | |||
386 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
387 | public static extern bool SetDeactivationTime2(IntPtr obj, float val); | ||
388 | |||
389 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
390 | public static extern bool SetSleepingThresholds2(IntPtr obj, float lin_threshold, float ang_threshold); | ||
391 | |||
392 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
393 | public static extern bool SetContactProcessingThreshold2(IntPtr obj, float val); | ||
394 | |||
395 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
396 | public static extern bool SetFriction2(IntPtr obj, float val); | ||
397 | |||
398 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
399 | public static extern bool SetRestitution2(IntPtr obj, float val); | ||
400 | |||
401 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
402 | public static extern bool SetLinearVelocity2(IntPtr obj, Vector3 val); | ||
403 | |||
404 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
405 | public static extern bool SetInterpolation2(IntPtr obj, Vector3 lin, Vector3 ang); | ||
312 | 406 | ||
313 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 407 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
314 | public static extern IntPtr SetCollisionFlags2(IntPtr obj, uint flags); | 408 | public static extern IntPtr SetCollisionFlags2(IntPtr obj, uint flags); |
@@ -319,5 +413,35 @@ public static extern IntPtr AddToCollisionFlags2(IntPtr obj, uint flags); | |||
319 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 413 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
320 | public static extern IntPtr RemoveFromCollisionFlags2(IntPtr obj, uint flags); | 414 | public static extern IntPtr RemoveFromCollisionFlags2(IntPtr obj, uint flags); |
321 | 415 | ||
416 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
417 | public static extern bool SetMassProps2(IntPtr obj, float mass, Vector3 inertia); | ||
418 | |||
419 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
420 | public static extern bool UpdateInertiaTensor2(IntPtr obj); | ||
421 | |||
422 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
423 | public static extern bool SetGravity2(IntPtr obj, Vector3 val); | ||
424 | |||
425 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
426 | public static extern IntPtr ClearForces2(IntPtr obj); | ||
427 | |||
428 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
429 | public static extern bool SetMargin2(IntPtr obj, float val); | ||
430 | |||
431 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
432 | public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj); | ||
433 | |||
434 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
435 | public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj); | ||
436 | |||
437 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
438 | public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj); | ||
439 | |||
440 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
441 | public static extern bool DestroyObject2(IntPtr world, uint id); | ||
442 | |||
443 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
444 | public static extern void DumpPhysicsStatistics2(IntPtr sim); | ||
445 | |||
322 | } | 446 | } |
323 | } | 447 | } |
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index fba03ab..0a2b30a 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | |||
@@ -80,8 +80,26 @@ namespace OpenSim.Tests.Common | |||
80 | /// <returns>The item that was added</returns> | 80 | /// <returns>The item that was added</returns> |
81 | public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) | 81 | public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) |
82 | { | 82 | { |
83 | return AddScript(scene, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }"); | ||
84 | } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Add a simple script to the given part. | ||
88 | /// </summary> | ||
89 | /// <remarks> | ||
90 | /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these | ||
91 | /// functions more than once in a test. | ||
92 | /// </remarks> | ||
93 | /// <param name="scene"></param> | ||
94 | /// <param name="part"></param> | ||
95 | /// <param name="scriptName">Name of the script to add</param> | ||
96 | /// <param name="scriptSource">LSL script source</param> | ||
97 | /// <returns>The item that was added</returns> | ||
98 | public static TaskInventoryItem AddScript( | ||
99 | Scene scene, SceneObjectPart part, string scriptName, string scriptSource) | ||
100 | { | ||
83 | AssetScriptText ast = new AssetScriptText(); | 101 | AssetScriptText ast = new AssetScriptText(); |
84 | ast.Source = "default { state_entry() { llSay(0, \"Hello World\"); } }"; | 102 | ast.Source = scriptSource; |
85 | ast.Encode(); | 103 | ast.Encode(); |
86 | 104 | ||
87 | UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | 105 | UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); |
@@ -91,7 +109,7 @@ namespace OpenSim.Tests.Common | |||
91 | scene.AssetService.Store(asset); | 109 | scene.AssetService.Store(asset); |
92 | TaskInventoryItem item | 110 | TaskInventoryItem item |
93 | = new TaskInventoryItem | 111 | = new TaskInventoryItem |
94 | { Name = "scriptItem", AssetID = assetUuid, ItemID = itemUuid, | 112 | { Name = scriptName, AssetID = assetUuid, ItemID = itemUuid, |
95 | Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; | 113 | Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; |
96 | part.Inventory.AddInventoryItem(item, true); | 114 | part.Inventory.AddInventoryItem(item, true); |
97 | 115 | ||