From 4b8c22ecfaf573b26e1b8f65cb8c95c39c3f519b Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 12 Feb 2013 11:10:17 -0800 Subject: Adds the parameter for OSD serialization to encode default values. This makes the JsonStore get/set operations symmetric. --- .../Region/OptionalModules/Scripting/JsonStore/JsonStore.cs | 11 +++++++---- .../OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs index 82a4da7..3bad06c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs @@ -131,15 +131,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore m_TakeStore = new List(); m_ReadStore = new List(); } - + public JsonStore(string value) : this() { + // This is going to throw an exception if the value is not + // a valid JSON chunk. Calling routines should catch the + // exception and handle it appropriately if (String.IsNullOrEmpty(value)) ValueStore = new OSDMap(); else ValueStore = OSDParser.DeserializeJson(value); } - + // ----------------------------------------------------------------- /// /// @@ -574,14 +577,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore // The path pointed to an intermediate hash structure if (result.Type == OSDType.Map) { - value = OSDParser.SerializeJsonString(result as OSDMap); + value = OSDParser.SerializeJsonString(result as OSDMap,true); return true; } // The path pointed to an intermediate hash structure if (result.Type == OSDType.Array) { - value = OSDParser.SerializeJsonString(result as OSDArray); + value = OSDParser.SerializeJsonString(result as OSDArray,true); return true; } diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index f1ce856..cc13661 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs @@ -227,7 +227,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } catch (Exception e) { - m_log.Error(string.Format("[JsonStore]: Unable to initialize store from {0}", value), e); + m_log.ErrorFormat("[JsonStore]: Unable to initialize store from {0}", value); return false; } -- cgit v1.1 From 058d477ce7cfb9ddc4f5508368141b5d74ba91e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Feb 2013 20:51:36 +0000 Subject: Re-enable subtest for single quoted token in TestJsonSetValueJson() This is in response to the resolution of http://opensimulator.org/mantis/view.php?id=6540 --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 717484c..012a528 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -369,15 +369,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // TestHelpers.EnableLogging(); // Single quoted token case -// { -// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); -// -// int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "'Times'"); -// Assert.That(result, Is.EqualTo(1)); -// -// string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); -// Assert.That(value, Is.EqualTo("Times")); -// } + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); + + int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "'Times'"); + Assert.That(result, Is.EqualTo(1)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); + Assert.That(value, Is.EqualTo("Times")); + } // Sub-tree case { -- cgit v1.1 From a82bd5678ec14ea45f7ddcf54e4dd0af43b64c8c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Feb 2013 21:34:12 +0000 Subject: Use an integer when specifying the XWorkItem wait rather than a TimeSpan to avoid a Windows casting issue in SmartThreadPool for large TimeSpans. TimeSpan.Milliseconds is an int64. However, STP casts this to an int (32-bit). If TimeSpan.MaxValue is given then the casting results in an invalid value for the SDK WaitHandle.WaitAll() call. This was causing the co-op script termination regression tests to fail on Windows but not Mono 2.10.8 (which is perhaps not strict in the negative values that it accepts). Solution here is to use the int millisecondsTimeout STP call rather than the TimeSpan one. This also allows us to more clearly specify Timeout.Infinite rather than TimeSpan.MaxValue Thanks to Teravus for this spot. --- OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | 7 ++++++- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 4 ++-- OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index f68612c..35ae44c 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -52,7 +52,12 @@ namespace OpenSim.Region.ScriptEngine.Interfaces { bool Cancel(); void Abort(); - bool Wait(TimeSpan t); + + /// + /// Wait for the work item to complete. + /// + /// The number of milliseconds to wait. Must be >= -1 (Timeout.Infinite). + bool Wait(int t); } /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 669cc37..bf19a42 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -595,7 +595,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (!m_coopTermination) { // If we're not co-operative terminating then try and wait for the event to complete before stopping - if (workItem.Wait(new TimeSpan((long)timeout * 100000))) + if (workItem.Wait(timeout)) return true; } else @@ -610,7 +610,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance // For now, we will wait forever since the event should always cleanly terminate once LSL loop // checking is implemented. May want to allow a shorter timeout option later. - if (workItem.Wait(TimeSpan.MaxValue)) + if (workItem.Wait(Timeout.Infinite)) { if (DebugLevel >= 1) m_log.DebugFormat( diff --git a/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs b/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs index 2ac5c31..8dd7677 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs @@ -57,8 +57,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine wr.Abort(); } - public bool Wait(TimeSpan t) + public bool Wait(int t) { + // We use the integer version of WaitAll because the current version of SmartThreadPool has a bug with the + // TimeSpan version. The number of milliseconds in TimeSpan is an int64 so when STP casts it down to an + // int (32-bit) we can end up with bad values. This occurs on Windows though curious not on Mono 2.10.8 + // (or very likely other versions of Mono at least up until 3.0.3). return SmartThreadPool.WaitAll(new IWorkItemResult[] {wr}, t, false); } } -- cgit v1.1 From aaa80d11a8ad82c5b237381a934c2a1d6f2089bd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 12 Feb 2013 14:47:26 -0800 Subject: Replaced Ionic.Zip.dll with a new one that fixes a bug in it. DotNetZip (from which Ionic.Zip.dll is derived) is now a fork in opensim-libs, forked from 1.9.1.8 and added that simple bug fix. --- bin/Ionic.Zip.dll | Bin 462336 -> 491520 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/Ionic.Zip.dll b/bin/Ionic.Zip.dll index 95fa928..e37f1bd 100755 Binary files a/bin/Ionic.Zip.dll and b/bin/Ionic.Zip.dll differ -- cgit v1.1 From 992ef9e971112af34590e971b0ccf5d48db513b2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Feb 2013 23:00:24 +0000 Subject: Extend TestJsonCreateStore() with a one key input and an input with raw number values --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 012a528..eb4bc22 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -115,8 +115,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); - Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); + // Test blank store + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); + } + + // Test single element store + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); + Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); + } + + // Test with an integer value + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 42.15 }"); + Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); + Assert.That(value, Is.EqualTo("42.15")); + } } [Test] -- cgit v1.1 From fb903ff49089d5fd7a56aa2401528c3e7cf1800c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 10 Feb 2013 09:51:34 -0800 Subject: BulletSim: More work on center-of-mass. Remove linksetinfo and rely on simulator to update info. --- .../Region/Physics/BulletSPlugin/BSApiTemplate.cs | 7 +- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 3 + .../Physics/BulletSPlugin/BSLinksetCompound.cs | 150 ++++++++++----------- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 31 +++-- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 4 +- .../Physics/BulletSPlugin/BSPrimDisplaced.cs | 85 ++++++++---- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 4 +- 8 files changed, 162 insertions(+), 124 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index 7ab86d2..3f83ef0 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -225,9 +225,10 @@ public enum CollisionFlags : uint CF_DISABLE_VISUALIZE_OBJECT = 1 << 5, CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, // Following used by BulletSim to control collisions and updates - BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, - BS_FLOATS_ON_WATER = 1 << 11, - BS_VEHICLE_COLLISIONS = 1 << 12, + BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, // return collision events from unmanaged to managed + BS_FLOATS_ON_WATER = 1 << 11, // the object should float at water level + BS_VEHICLE_COLLISIONS = 1 << 12, // return collisions for vehicle ground checking + BS_RETURN_ROOT_COMPOUND_SHAPE = 1 << 13, // return the pos/rot of the root shape in a compound shape BS_NONE = 0, BS_ALL = 0xFFFFFFFF }; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index f781aea..04fb05b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -274,7 +274,7 @@ public sealed class BSCharacter : BSPhysObject // This test is done if moving forward, not flying and is colliding with something. // DetailLog("{0},BSCharacter.WalkUpStairs,IsColliding={1},flying={2},targSpeed={3},collisions={4}", // LocalID, IsColliding, Flying, TargetSpeed, CollisionsLastTick.Count); - if (IsColliding && !Flying && TargetSpeed > 0.1f /* && ForwardSpeed < 0.1f */) + if (IsColliding && !Flying && TargetVelocitySpeed > 0.1f /* && ForwardSpeed < 0.1f */) { // The range near the character's feet where we will consider stairs float nearFeetHeightMin = RawPosition.Z - (Size.Z / 2f) + 0.05f; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index e35311f..4ece1eb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -127,6 +127,8 @@ public abstract class BSLinkset m_children = new HashSet(); LinksetMass = parent.RawMass; Rebuilding = false; + + parent.ClearDisplacement(); } // Link to a linkset where the child knows the parent. @@ -280,6 +282,7 @@ public abstract class BSLinkset return mass; } + // Computes linkset's center of mass in world coordinates. protected virtual OMV.Vector3 ComputeLinksetCenterOfMass() { OMV.Vector3 com; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 36bae9b..1f66b56 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -93,7 +93,8 @@ public sealed class BSLinksetCompound : BSLinkset { private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]"; - public BSLinksetCompound(BSScene scene, BSPrimLinkable parent) : base(scene, parent) + public BSLinksetCompound(BSScene scene, BSPrimLinkable parent) + : base(scene, parent) { } @@ -217,59 +218,45 @@ public sealed class BSLinksetCompound : BSLinkset // and that is caused by us updating the object. if ((whichUpdated & ~(UpdatedProperties.Position | UpdatedProperties.Orientation)) == 0) { - // Gather the child info. It might not be there if the linkset is in transition. - BSLinksetCompoundInfo lsi = updated.LinksetInfo as BSLinksetCompoundInfo; - if (lsi != null) - { - // Since the child moved or rotationed, it needs a new relative position within the linkset - BSLinksetCompoundInfo newLsi = new BSLinksetCompoundInfo(lsi.Index, LinksetRoot, updated, OMV.Vector3.Zero); - updated.LinksetInfo = newLsi; - // Find the physical instance of the child - if (LinksetRoot.PhysShape.HasPhysicalShape && PhysicsScene.PE.IsCompound(LinksetRoot.PhysShape)) + if (LinksetRoot.PhysShape.HasPhysicalShape && PhysicsScene.PE.IsCompound(LinksetRoot.PhysShape)) + { + // It is possible that the linkset is still under construction and the child is not yet + // inserted into the compound shape. A rebuild of the linkset in a pre-step action will + // build the whole thing with the new position or rotation. + // The index must be checked because Bullet references the child array but does no validity + // checking of the child index passed. + int numLinksetChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(LinksetRoot.PhysShape); + if (updated.LinksetChildIndex < numLinksetChildren) { - // It is possible that the linkset is still under construction and the child is not yet - // inserted into the compound shape. A rebuild of the linkset in a pre-step action will - // build the whole thing with the new position or rotation. - // The index must be checked because Bullet references the child array but does no validity - // checking of the child index passed. - int numLinksetChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(LinksetRoot.PhysShape); - if (lsi.Index < numLinksetChildren) + BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape, updated.LinksetChildIndex); + if (linksetChildShape.HasPhysicalShape) { - BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape, lsi.Index); - if (linksetChildShape.HasPhysicalShape) - { - // Found the child shape within the compound shape - PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, lsi.Index, - newLsi.OffsetFromCenterOfMass, - newLsi.OffsetRot, - true /* shouldRecalculateLocalAabb */); - updatedChild = true; - DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}", - updated.LocalID, whichUpdated, newLsi); - } - else // DEBUG DEBUG - { // DEBUG DEBUG - DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noChildShape,shape={1}", - updated.LocalID, linksetChildShape); - } // DEBUG DEBUG + // Found the child shape within the compound shape + PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, updated.LinksetChildIndex, + updated.RawPosition - LinksetRoot.RawPosition, + updated.RawOrientation * OMV.Quaternion.Inverse(LinksetRoot.RawOrientation), + true /* shouldRecalculateLocalAabb */); + updatedChild = true; + DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},pos={2},rot={3}", + updated.LocalID, whichUpdated, updated.RawPosition, updated.RawOrientation); } else // DEBUG DEBUG { // DEBUG DEBUG - // the child is not yet in the compound shape. This is non-fatal. - DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,childNotInCompoundShape,numChildren={1},index={2}", - updated.LocalID, numLinksetChildren, lsi.Index); + DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noChildShape,shape={1}", + updated.LocalID, linksetChildShape); } // DEBUG DEBUG } else // DEBUG DEBUG { // DEBUG DEBUG - DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noBodyOrNotCompound", updated.LocalID); + // the child is not yet in the compound shape. This is non-fatal. + DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,childNotInCompoundShape,numChildren={1},index={2}", + updated.LocalID, numLinksetChildren, updated.LinksetChildIndex); } // DEBUG DEBUG } else // DEBUG DEBUG { // DEBUG DEBUG - DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noLinkSetInfo,rootPhysShape={1}", - updated.LocalID, LinksetRoot.PhysShape); + DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noBodyOrNotCompound", updated.LocalID); } // DEBUG DEBUG if (!updatedChild) @@ -379,6 +366,8 @@ public sealed class BSLinksetCompound : BSLinkset // Safe to call even if the child is not really in the linkset. protected override void RemoveChildFromLinkset(BSPrimLinkable child) { + child.ClearDisplacement(); + if (m_children.Remove(child)) { DetailLog("{0},BSLinksetCompound.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", @@ -410,7 +399,7 @@ public sealed class BSLinksetCompound : BSLinkset // Constraint linksets are rebuilt every time. // Note that this works for rebuilding just the root after a linkset is taken apart. // Called at taint time!! - private bool disableCOM = true; // DEBUG DEBUG: disable until we get this debugged + private bool disableCOM = false; // DEBUG DEBUG: disable until we get this debugged private void RecomputeLinksetCompound() { try @@ -424,30 +413,31 @@ public sealed class BSLinksetCompound : BSLinkset // The center of mass for the linkset is the geometric center of the group. // Compute a displacement for each component so it is relative to the center-of-mass. // Bullet presumes an object's origin (relative <0,0,0>) is its center-of-mass - OMV.Vector3 centerOfMass; - OMV.Vector3 centerDisplacement = OMV.Vector3.Zero; - if (disableCOM) // DEBUG DEBUG - { // DEBUG DEBUG - centerOfMass = LinksetRoot.RawPosition; // DEBUG DEBUG - // LinksetRoot.PositionDisplacement = OMV.Vector3.Zero; - } // DEBUG DEBUG - else + OMV.Vector3 centerOfMassW = LinksetRoot.RawPosition; + if (!disableCOM) // DEBUG DEBUG { - centerOfMass = ComputeLinksetCenterOfMass(); - // 'centerDisplacement' is the value to *add* to all the shape offsets - centerDisplacement = LinksetRoot.RawPosition - centerOfMass; - - // Since we're displacing the center of the shape, we need to move the body in the world - // LinksetRoot.PositionDisplacement = centerDisplacement; - - // This causes the root prim position to be set properly based on the new PositionDisplacement - LinksetRoot.ForcePosition = LinksetRoot.RawPosition; - // Update the local transform for the root child shape so it is offset from the <0,0,0> which is COM - PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, 0, -centerDisplacement, OMV.Quaternion.Identity, false); - DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,com={1},rootPos={2},centerDisp={3}", - LinksetRoot.LocalID, centerOfMass, LinksetRoot.RawPosition, centerDisplacement); + // Compute a center-of-mass in world coordinates. + centerOfMassW = ComputeLinksetCenterOfMass(); } + OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation); + + // 'centerDisplacement' is the value to subtract from children to give physical offset position + OMV.Vector3 centerDisplacement = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation; + LinksetRoot.SetEffectiveCenterOfMassW(centerDisplacement); + + // This causes the physical position of the root prim to be offset to accomodate for the displacements + LinksetRoot.ForcePosition = LinksetRoot.RawPosition; + + // Update the local transform for the root child shape so it is offset from the <0,0,0> which is COM + PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, 0, + -centerDisplacement, + LinksetRoot.RawOrientation, + false /* shouldRecalculateLocalAabb */); + + DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,com={1},rootPos={2},centerDisp={3}", + LinksetRoot.LocalID, centerOfMassW, LinksetRoot.RawPosition, centerDisplacement); + DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,start,rBody={1},rShape={2},numChildren={3}", LinksetRoot.LocalID, LinksetRoot.PhysBody, LinksetRoot.PhysShape, NumberOfChildren); @@ -455,29 +445,20 @@ public sealed class BSLinksetCompound : BSLinkset int memberIndex = 1; ForEachMember(delegate(BSPrimLinkable cPrim) { - if (!IsRoot(cPrim)) + if (IsRoot(cPrim)) { - // Compute the displacement of the child from the root of the linkset. - // This info is saved in the child prim so the relationship does not - // change over time and the new child position can be computed - // when the linkset is being disassembled (the linkset may have moved). - BSLinksetCompoundInfo lci = cPrim.LinksetInfo as BSLinksetCompoundInfo; - if (lci == null) - { - lci = new BSLinksetCompoundInfo(memberIndex, LinksetRoot, cPrim, centerDisplacement); - cPrim.LinksetInfo = lci; - DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,creatingRelPos,lci={1}", cPrim.LocalID, lci); - } - - DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addMemberToShape,mID={1},mShape={2},lci={3}", - LinksetRoot.LocalID, cPrim.LocalID, cPrim.PhysShape, lci); + cPrim.LinksetChildIndex = 0; + } + else + { + cPrim.LinksetChildIndex = memberIndex; if (cPrim.PhysShape.isNativeShape) { // A native shape is turned into a hull collision shape because native // shapes are not shared so we have to hullify it so it will be tracked // and freed at the correct time. This also solves the scaling problem - // (native shapes scaled but hull/meshes are assumed to not be). + // (native shapes scale but hull/meshes are assumed to not be). // TODO: decide of the native shape can just be used in the compound shape. // Use call to CreateGeomNonSpecial(). BulletShape saveShape = cPrim.PhysShape; @@ -486,7 +467,10 @@ public sealed class BSLinksetCompound : BSLinkset PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null); BulletShape newShape = cPrim.PhysShape; cPrim.PhysShape = saveShape; - PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, newShape, lci.OffsetFromCenterOfMass, lci.OffsetRot); + + OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; + OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; + PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, newShape, offsetPos, offsetRot); } else { @@ -498,9 +482,10 @@ public sealed class BSLinksetCompound : BSLinkset PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}", LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape); } - PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, lci.OffsetFromCenterOfMass, lci.OffsetRot); + OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; + OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; + PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); } - lci.Index = memberIndex; memberIndex++; } return false; // 'false' says to move onto the next child in the list @@ -509,6 +494,9 @@ public sealed class BSLinksetCompound : BSLinkset // With all of the linkset packed into the root prim, it has the mass of everyone. LinksetMass = ComputeLinksetMass(); LinksetRoot.UpdatePhysicalMassProperties(LinksetMass, true); + + // Enable the physical position updator to return the position and rotation of the root shape + PhysicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE); } finally { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index de69fa0..8ebb532 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -136,6 +136,7 @@ public abstract class BSPhysObject : PhysicsActor // The objects base shape information. Null if not a prim type shape. public PrimitiveBaseShape BaseShape { get; protected set; } + // Some types of objects have preferred physical representations. // Returns SHAPE_UNKNOWN if there is no preference. public virtual BSPhysicsShapeType PreferredPhysicalShape @@ -150,15 +151,17 @@ public abstract class BSPhysObject : PhysicsActor public EntityProperties LastEntityProperties { get; set; } public virtual OMV.Vector3 Scale { get; set; } - public abstract bool IsSolid { get; } - public abstract bool IsStatic { get; } - public abstract bool IsSelected { get; } // It can be confusing for an actor to know if it should move or update an object // depeneding on the setting of 'selected', 'physical, ... // This flag is the true test -- if true, the object is being acted on in the physical world public abstract bool IsPhysicallyActive { get; } + // Detailed state of the object. + public abstract bool IsSolid { get; } + public abstract bool IsStatic { get; } + public abstract bool IsSelected { get; } + // Materialness public MaterialAttributes.Material Material { get; private set; } public override void SetMaterial(int material) @@ -185,14 +188,6 @@ public abstract class BSPhysObject : PhysicsActor public abstract OMV.Quaternion RawOrientation { get; set; } public abstract OMV.Quaternion ForceOrientation { get; set; } - public virtual float TargetSpeed - { - get - { - OMV.Vector3 characterOrientedVelocity = TargetVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation)); - return characterOrientedVelocity.X; - } - } public abstract OMV.Vector3 RawVelocity { get; set; } public abstract OMV.Vector3 ForceVelocity { get; set; } @@ -202,6 +197,7 @@ public abstract class BSPhysObject : PhysicsActor public virtual bool ForceBodyShapeRebuild(bool inTaintTime) { return false; } + // The current velocity forward public virtual float ForwardSpeed { get @@ -210,6 +206,19 @@ public abstract class BSPhysObject : PhysicsActor return characterOrientedVelocity.X; } } + // The forward speed we are trying to achieve (TargetVelocity) + public virtual float TargetVelocitySpeed + { + get + { + OMV.Vector3 characterOrientedVelocity = TargetVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation)); + return characterOrientedVelocity.X; + } + } + + // The user can optionally set the center of mass. The user's setting will override any + // computed center-of-mass (like in linksets). + public OMV.Vector3? UserSetCenterOfMass { get; set; } #region Collisions diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index cf7aa0f..a76f8b9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -442,7 +442,7 @@ public class BSPrim : BSPhysObject RegisterPreStepAction("BSPrim.setForce", LocalID, delegate(float timeStep) { - if (!IsPhysicallyActive) + if (!IsPhysicallyActive || _force == OMV.Vector3.Zero) { UnRegisterPreStepAction("BSPrim.setForce", LocalID); return; @@ -647,7 +647,7 @@ public class BSPrim : BSPhysObject RegisterPreStepAction("BSPrim.setTorque", LocalID, delegate(float timeStep) { - if (!IsPhysicallyActive) + if (!IsPhysicallyActive || _torque == OMV.Vector3.Zero) { UnRegisterPreStepAction("BSPrim.setTorque", LocalID); return; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs index 6401308..b9f2cca 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs @@ -44,72 +44,107 @@ namespace OpenSim.Region.Physics.BulletSPlugin { public class BSPrimDisplaced : BSPrim { - // 'Position' and 'Orientation' is what the simulator thinks the positions of the prim is. - // Because Bullet needs the zero coordinate to be the center of mass of the linkset, - // sometimes it is necessary to displace the position the physics engine thinks - // the position is. PositionDisplacement must be added and removed from the - // position as the simulator position is stored and fetched from the physics - // engine. Similar to OrientationDisplacement. + // The purpose of this module is to do any mapping between what the simulator thinks + // the prim position and orientation is and what the physical position/orientation. + // This difference happens because Bullet assumes the center-of-mass is the <0,0,0> + // of the prim/linkset. The simulator tracks the location of the prim/linkset by + // the location of the root prim. So, if center-of-mass is anywhere but the origin + // of the root prim, the physical origin is displaced from the simulator origin. + // + // This routine works by capturing the Force* setting of position/orientation/... and + // adjusting the simulator values (being set) into the physical values. + // The conversion is also done in the opposite direction (physical origin -> simulator origin). + // + // The updateParameter call is also captured and the values from the physics engine + // are converted into simulator origin values before being passed to the base + // class. + public virtual OMV.Vector3 PositionDisplacement { get; set; } public virtual OMV.Quaternion OrientationDisplacement { get; set; } - public virtual OMV.Vector3 CenterOfMassLocation { get; set; } - public virtual OMV.Vector3 GeometricCenterLocation { get; set; } public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical) { - CenterOfMassLocation = RawPosition; - GeometricCenterLocation = RawPosition; + ClearDisplacement(); } - public override Vector3 ForcePosition + public void ClearDisplacement() + { + PositionDisplacement = OMV.Vector3.Zero; + OrientationDisplacement = OMV.Quaternion.Identity; + } + + // Set this sets and computes the displacement from the passed prim to the center-of-mass. + // A user set value for center-of-mass overrides whatever might be passed in here. + // The displacement is in local coordinates (relative to root prim in linkset oriented coordinates). + public virtual void SetEffectiveCenterOfMassW(Vector3 centerOfMassDisplacement) { - get + Vector3 comDisp; + if (UserSetCenterOfMass.HasValue) + comDisp = (OMV.Vector3)UserSetCenterOfMass; + else + comDisp = centerOfMassDisplacement; + + if (comDisp == Vector3.Zero) { - return base.ForcePosition; + // If there is no diplacement. Things get reset. + PositionDisplacement = OMV.Vector3.Zero; + OrientationDisplacement = OMV.Quaternion.Identity; } - set + else { - base.ForcePosition = value; - CenterOfMassLocation = RawPosition; - GeometricCenterLocation = RawPosition; + // Remember the displacement from root as well as the origional rotation of the + // new center-of-mass. + PositionDisplacement = comDisp; + OrientationDisplacement = OMV.Quaternion.Identity; } } - public override Quaternion ForceOrientation + public override Vector3 ForcePosition { - get + get { return base.ForcePosition; } + set { - return base.ForceOrientation; + if (PositionDisplacement != OMV.Vector3.Zero) + base.ForcePosition = value - (PositionDisplacement * RawOrientation); + else + base.ForcePosition = value; } + } + + public override Quaternion ForceOrientation + { + get { return base.ForceOrientation; } set { base.ForceOrientation = value; } } + // TODO: decide if this is the right place for these variables. + // Somehow incorporate the optional settability by the user. // Is this used? public override OMV.Vector3 CenterOfMass { - get { return CenterOfMassLocation; } + get { return RawPosition; } } // Is this used? public override OMV.Vector3 GeometricCenter { - get { return GeometricCenterLocation; } + get { return RawPosition; } } - public override void UpdateProperties(EntityProperties entprop) { // Undo any center-of-mass displacement that might have been done. - if (PositionDisplacement != OMV.Vector3.Zero) + if (PositionDisplacement != OMV.Vector3.Zero || OrientationDisplacement != OMV.Quaternion.Identity) { // Correct for any rotation around the center-of-mass // TODO!!! - entprop.Position -= PositionDisplacement; + entprop.Position = entprop.Position + (PositionDisplacement * entprop.Rotation); + entprop.Rotation = something; } base.UpdateProperties(entprop); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 9898562..96f9762 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -38,6 +38,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin public class BSPrimLinkable : BSPrimDisplaced { public BSLinkset Linkset { get; set; } + // The index of this child prim. + public int LinksetChildIndex { get; set; } + public BSLinksetInfo LinksetInfo { get; set; } public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, @@ -90,7 +93,6 @@ public class BSPrimLinkable : BSPrimDisplaced DetailLog("{0},BSPrimLinkset.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ", LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren); return; - base.delink(); } // When simulator changes position, this might be moving a child of the linkset. -- cgit v1.1 From 0194a3d890b95c8a29fcdf130c378e3a8a629c77 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 12 Feb 2013 15:45:44 -0800 Subject: BulletSim: fix density since the simulator/viewer track density in a funny unit that is 100 times real density (default 1000). Fix avatar drifting slowly when stationary flying. Fix for physical prims getting corrected for being under terrain when it was just its geometric center that was below terrain. Add PreUpdatePropertyAction allowing plugable modifiction of phys parameters returned from Bullet. Fix an exception setting GravityMultiplier on initialization. Update DLLs and SOs for good measure (no functional change). --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 13 +++- .../Physics/BulletSPlugin/BSLinksetCompound.cs | 19 +++--- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 17 ++++-- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 66 +++++++++++++++++++-- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 55 ++++++++++++++++- .../Physics/BulletSPlugin/BSPrimDisplaced.cs | 2 +- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 3 +- bin/lib32/BulletSim.dll | Bin 546816 -> 546816 bytes bin/lib32/libBulletSim.so | Bin 1695699 -> 1700826 bytes bin/lib64/BulletSim.dll | Bin 694272 -> 694784 bytes bin/lib64/libBulletSim.so | Bin 1842163 -> 1843498 bytes 11 files changed, 150 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 04fb05b..8dca7c6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -83,7 +83,7 @@ public sealed class BSCharacter : BSPhysObject _velocity = OMV.Vector3.Zero; _buoyancy = ComputeBuoyancyFromFlying(isFlying); Friction = BSParam.AvatarStandingFriction; - Density = BSParam.AvatarDensity; + Density = BSParam.AvatarDensity / BSParam.DensityScaleFactor; // Old versions of ScenePresence passed only the height. If width and/or depth are zero, // replace with the default values. @@ -231,6 +231,15 @@ public sealed class BSCharacter : BSPhysObject PhysicsScene.PE.SetFriction(PhysBody, Friction); } } + else + { + if (Flying) + { + // Flying and not collising and velocity nearly zero. + ZeroMotion(true /* inTaintTime */); + } + } + DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding); } else @@ -869,7 +878,7 @@ public sealed class BSCharacter : BSPhysObject * Math.Min(Size.X, Size.Y) / 2 * Size.Y / 2f // plus the volume of the capsule end caps ); - _mass = Density * _avatarVolume; + _mass = Density * BSParam.DensityScaleFactor * _avatarVolume; } // The physics engine says that properties have updated. Update same and inform diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 1f66b56..4ce58c7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -399,7 +399,7 @@ public sealed class BSLinksetCompound : BSLinkset // Constraint linksets are rebuilt every time. // Note that this works for rebuilding just the root after a linkset is taken apart. // Called at taint time!! - private bool disableCOM = false; // DEBUG DEBUG: disable until we get this debugged + private bool disableCOM = true; // DEBUG DEBUG: disable until we get this debugged private void RecomputeLinksetCompound() { try @@ -430,10 +430,10 @@ public sealed class BSLinksetCompound : BSLinkset LinksetRoot.ForcePosition = LinksetRoot.RawPosition; // Update the local transform for the root child shape so it is offset from the <0,0,0> which is COM - PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, 0, - -centerDisplacement, - LinksetRoot.RawOrientation, - false /* shouldRecalculateLocalAabb */); + PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, 0 /* childIndex */, + -centerDisplacement, + OMV.Quaternion.Identity, // LinksetRoot.RawOrientation, + false /* shouldRecalculateLocalAabb (is done later after linkset built) */); DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,com={1},rootPos={2},centerDisp={3}", LinksetRoot.LocalID, centerOfMassW, LinksetRoot.RawPosition, centerDisplacement); @@ -463,7 +463,6 @@ public sealed class BSLinksetCompound : BSLinkset // Use call to CreateGeomNonSpecial(). BulletShape saveShape = cPrim.PhysShape; cPrim.PhysShape.Clear(); // Don't let the create free the child's shape - // PhysicsScene.Shapes.CreateGeomNonSpecial(true, cPrim, null); PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null); BulletShape newShape = cPrim.PhysShape; cPrim.PhysShape = saveShape; @@ -471,6 +470,8 @@ public sealed class BSLinksetCompound : BSLinkset OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, newShape, offsetPos, offsetRot); + DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addNative,indx={1},rShape={2},cShape={3},offPos={4},offRot={5}", + LinksetRoot.LocalID, memberIndex, LinksetRoot.PhysShape, newShape, offsetPos, offsetRot); } else { @@ -484,7 +485,10 @@ public sealed class BSLinksetCompound : BSLinkset } OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; - PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); + PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); + DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addNonNative,indx={1},rShape={2},cShape={3},offPos={4},offRot={5}", + LinksetRoot.LocalID, memberIndex, LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); + } memberIndex++; } @@ -503,6 +507,7 @@ public sealed class BSLinksetCompound : BSLinkset Rebuilding = false; } + // See that the Aabb surrounds the new shape PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape); } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 3e0b4bc..329169f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -49,6 +49,7 @@ public static class BSParam public static float MaxLinearVelocity { get; private set; } public static float MaxAngularVelocity { get; private set; } public static float MaxAddForceMagnitude { get; private set; } + public static float DensityScaleFactor { get; private set; } public static float LinearDamping { get; private set; } public static float AngularDamping { get; private set; } @@ -281,29 +282,35 @@ public static class BSParam new ParameterDefn("MinObjectMass", "Minimum object mass (0.0001)", 0.0001f, (s,cf,p,v) => { MinimumObjectMass = cf.GetFloat(p, v); }, - (s) => { return (float)MinimumObjectMass; }, + (s) => { return MinimumObjectMass; }, (s,p,l,v) => { MinimumObjectMass = v; } ), new ParameterDefn("MaxObjectMass", "Maximum object mass (10000.01)", 10000.01f, (s,cf,p,v) => { MaximumObjectMass = cf.GetFloat(p, v); }, - (s) => { return (float)MaximumObjectMass; }, + (s) => { return MaximumObjectMass; }, (s,p,l,v) => { MaximumObjectMass = v; } ), new ParameterDefn("MaxLinearVelocity", "Maximum velocity magnitude that can be assigned to an object", 1000.0f, (s,cf,p,v) => { MaxLinearVelocity = cf.GetFloat(p, v); }, - (s) => { return (float)MaxLinearVelocity; }, + (s) => { return MaxLinearVelocity; }, (s,p,l,v) => { MaxLinearVelocity = v; } ), new ParameterDefn("MaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to an object", 1000.0f, (s,cf,p,v) => { MaxAngularVelocity = cf.GetFloat(p, v); }, - (s) => { return (float)MaxAngularVelocity; }, + (s) => { return MaxAngularVelocity; }, (s,p,l,v) => { MaxAngularVelocity = v; } ), // LL documentation says thie number should be 20f for llApplyImpulse and 200f for llRezObject new ParameterDefn("MaxAddForceMagnitude", "Maximum force that can be applied by llApplyImpulse (SL says 20f)", 20000.0f, (s,cf,p,v) => { MaxAddForceMagnitude = cf.GetFloat(p, v); }, - (s) => { return (float)MaxAddForceMagnitude; }, + (s) => { return MaxAddForceMagnitude; }, (s,p,l,v) => { MaxAddForceMagnitude = v; } ), + // Density is passed around as 100kg/m3. This scales that to 1kg/m3. + new ParameterDefn("DensityScaleFactor", "Conversion for simulator/viewer density (100kg/m3) to physical density (1kg/m3)", + 0.01f, + (s,cf,p,v) => { DensityScaleFactor = cf.GetFloat(p, v); }, + (s) => { return DensityScaleFactor; }, + (s,p,l,v) => { DensityScaleFactor = v; } ), new ParameterDefn("PID_D", "Derivitive factor for motion smoothing", 2200f, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 8ebb532..f953c1e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -99,6 +99,9 @@ public abstract class BSPhysObject : PhysicsActor CollisionAccumulation = 0; ColliderIsMoving = false; CollisionScore = 0; + + // All axis free. + LockedAxis = LockedAxisFree; } // Tell the object to clean up. @@ -172,7 +175,8 @@ public abstract class BSPhysObject : PhysicsActor MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); Friction = matAttrib.friction; Restitution = matAttrib.restitution; - Density = matAttrib.density; + Density = matAttrib.density / BSParam.DensityScaleFactor; + DetailLog("{0},{1}.SetMaterial,Mat={2},frict={3},rest={4},den={5}", LocalID, TypeName, Material, Friction, Restitution, Density); } // Stop all physical motion. @@ -220,6 +224,9 @@ public abstract class BSPhysObject : PhysicsActor // computed center-of-mass (like in linksets). public OMV.Vector3? UserSetCenterOfMass { get; set; } + public OMV.Vector3 LockedAxis { get; set; } // zero means locked. one means free. + public readonly OMV.Vector3 LockedAxisFree = new OMV.Vector3(1f, 1f, 1f); // All axis are free + #region Collisions // Requested number of milliseconds between collision events. Zero means disabled. @@ -416,9 +423,7 @@ public abstract class BSPhysObject : PhysicsActor { // Clean out any existing action UnRegisterPreStepAction(op, id); - RegisteredPrestepActions[identifier] = actn; - PhysicsScene.BeforeStep += actn; } DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier); @@ -464,9 +469,7 @@ public abstract class BSPhysObject : PhysicsActor { // Clean out any existing action UnRegisterPostStepAction(op, id); - RegisteredPoststepActions[identifier] = actn; - PhysicsScene.AfterStep += actn; } DetailLog("{0},BSPhysObject.RegisterPostStepAction,id={1}", LocalID, identifier); @@ -503,7 +506,58 @@ public abstract class BSPhysObject : PhysicsActor } DetailLog("{0},BSPhysObject.UnRegisterAllPostStepActions,", LocalID); } - + + // When an update to the physical properties happens, this event is fired to let + // different actors to modify the update before it is passed around + public delegate void PreUpdatePropertyAction(ref EntityProperties entprop); + public event PreUpdatePropertyAction OnPreUpdateProperty; + protected void TriggerPreUpdatePropertyAction(ref EntityProperties entprop) + { + PreUpdatePropertyAction actions = OnPreUpdateProperty; + if (actions != null) + actions(ref entprop); + } + + private Dictionary RegisteredPreUpdatePropertyActions = new Dictionary(); + public void RegisterPreUpdatePropertyAction(string identifier, PreUpdatePropertyAction actn) + { + lock (RegisteredPreUpdatePropertyActions) + { + // Clean out any existing action + UnRegisterPreUpdatePropertyAction(identifier); + RegisteredPreUpdatePropertyActions[identifier] = actn; + OnPreUpdateProperty += actn; + } + DetailLog("{0},BSPhysObject.RegisterPreUpdatePropertyAction,id={1}", LocalID, identifier); + } + public bool UnRegisterPreUpdatePropertyAction(string identifier) + { + bool removed = false; + lock (RegisteredPreUpdatePropertyActions) + { + if (RegisteredPreUpdatePropertyActions.ContainsKey(identifier)) + { + OnPreUpdateProperty -= RegisteredPreUpdatePropertyActions[identifier]; + RegisteredPreUpdatePropertyActions.Remove(identifier); + removed = true; + } + } + DetailLog("{0},BSPhysObject.UnRegisterPreUpdatePropertyAction,id={1},removed={2}", LocalID, identifier, removed); + return removed; + } + public void UnRegisterAllPreUpdatePropertyActions() + { + lock (RegisteredPreUpdatePropertyActions) + { + foreach (KeyValuePair kvp in RegisteredPreUpdatePropertyActions) + { + OnPreUpdateProperty -= kvp.Value; + } + RegisteredPreUpdatePropertyActions.Clear(); + } + DetailLog("{0},BSPhysObject.UnRegisterAllPreUpdatePropertyAction,", LocalID); + } + #endregion // Per Simulation Step actions // High performance detailed logging routine used by the physical objects. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index a76f8b9..0323b0d 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -242,6 +242,45 @@ public class BSPrim : BSPhysObject public override void LockAngularMotion(OMV.Vector3 axis) { DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); + + OMV.Vector3 locking = new OMV.Vector3(1f, 1f, 1f); + if (axis.X != 1) locking.X = 0f; + if (axis.Y != 1) locking.Y = 0f; + if (axis.Z != 1) locking.Z = 0f; + LockedAxis = locking; + + /* Not implemented yet + if (LockedAxis != LockedAxisFree) + { + // Something is locked so start the thingy that keeps that axis from changing + RegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion", delegate(ref EntityProperties entprop) + { + if (LockedAxis != LockedAxisFree) + { + if (IsPhysicallyActive) + { + // Bullet can lock axis but it only works for global axis. + // Check if this prim is aligned on global axis and use Bullet's + // system if so. + + ForceOrientation = entprop.Rotation; + ForceRotationalVelocity = entprop.RotationalVelocity; + } + } + else + { + UnRegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion"); + } + + }); + } + else + { + // Everything seems unlocked + UnRegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion"); + } + */ + return; } @@ -311,7 +350,8 @@ public class BSPrim : BSPhysObject float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); OMV.Vector3 upForce = OMV.Vector3.Zero; - if (RawPosition.Z < terrainHeight) + float approxSize = Math.Max(Size.X, Math.Max(Size.Y, Size.Z)); + if ((RawPosition.Z + approxSize / 2f) < terrainHeight) { DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight); float targetHeight = terrainHeight + (Size.Z / 2f); @@ -576,6 +616,8 @@ public class BSPrim : BSPhysObject } } } + // The simulator/viewer keep density as 100kg/m3. + // Remember to use BSParam.DensityScaleFactor to create the physical density. public override float Density { get { return base.Density; } @@ -1569,7 +1611,8 @@ public class BSPrim : BSPhysObject profileEnd = 1.0f - (float)BaseShape.ProfileEnd * 2.0e-5f; volume *= (profileEnd - profileBegin); - returnMass = Density * volume; + returnMass = Density * BSParam.DensityScaleFactor * volume; + DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass); returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass); @@ -1607,6 +1650,8 @@ public class BSPrim : BSPhysObject // the world that things have changed. public override void UpdateProperties(EntityProperties entprop) { + TriggerPreUpdatePropertyAction(ref entprop); + // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet // TODO: handle physics introduced by Bullet with computed vehicle physics. if (VehicleController.IsActive) @@ -1619,7 +1664,11 @@ public class BSPrim : BSPhysObject // Assign directly to the local variables so the normal set actions do not happen _position = entprop.Position; _orientation = entprop.Rotation; - _velocity = entprop.Velocity; + // _velocity = entprop.Velocity; + // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be + // very sensitive to velocity changes. + if (!entprop.Velocity.ApproxEquals(_velocity, 0.1f)) + _velocity = entprop.Velocity; _acceleration = entprop.Acceleration; _rotationalVelocity = entprop.RotationalVelocity; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs index b9f2cca..f1c3b5c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs @@ -144,7 +144,7 @@ public class BSPrimDisplaced : BSPrim // Correct for any rotation around the center-of-mass // TODO!!! entprop.Position = entprop.Position + (PositionDisplacement * entprop.Rotation); - entprop.Rotation = something; + // entprop.Rotation = something; } base.UpdateProperties(entprop); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 96f9762..d65d407 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -135,7 +135,8 @@ public class BSPrimLinkable : BSPrimDisplaced // When going from non-physical to physical, this re-enables the constraints that // had been automatically disabled when the mass was set to zero. // For compound based linksets, this enables and disables interactions of the children. - Linkset.Refresh(this); + if (Linkset != null) // null can happen during initialization + Linkset.Refresh(this); } protected override void MakeDynamic(bool makeStatic) diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll index 4dd2f38..e7a8a41 100755 Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so index cb8742a..4bf23a6 100755 Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index c9f5814..63ac1a9 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so index 19fc7bf..422681e 100755 Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ -- cgit v1.1 From 4b797f2ead3052ca24ff36948f4bfb4e28bbb638 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Feb 2013 00:12:20 +0000 Subject: Extend TestJsonRemoveValue() with tests for non-penultimate nodes and arrays --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 70 ++++++++++++++++++---- 1 file changed, 57 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index eb4bc22..bba727d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -260,25 +260,69 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); + // Test remove of node in object pointing to a string + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); + + int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); + Assert.That(returnValue, Is.EqualTo(1)); + + int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); + Assert.That(result, Is.EqualTo(0)); + + string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); + Assert.That(returnValue2, Is.EqualTo("")); + } + + // Test remove of node in object pointing to another object + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Wally' } }"); + + int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); + Assert.That(returnValue, Is.EqualTo(1)); + + int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); + Assert.That(result, Is.EqualTo(0)); - int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); - Assert.That(returnValue, Is.EqualTo(1)); + string returnValue2 = (string)InvokeOp("JsonGetValueJson", storeId, "Hello"); + Assert.That(returnValue2, Is.EqualTo("")); + } - int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); - Assert.That(result, Is.EqualTo(0)); + // Test remove of node in an array + { + UUID storeId + = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : [ 'value1', 'value2' ] }"); - string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); - Assert.That(returnValue2, Is.EqualTo("")); + int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]"); + Assert.That(returnValue, Is.EqualTo(1)); + + int result = (int)InvokeOp("JsonTestPath", storeId, "Hello[0]"); + Assert.That(result, Is.EqualTo(1)); + + result = (int)InvokeOp("JsonTestPath", storeId, "Hello[1]"); + Assert.That(result, Is.EqualTo(0)); + + string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]"); + Assert.That(stringReturnValue, Is.EqualTo("value2")); + + stringReturnValue = (string)InvokeOp("JsonGetValueJson", storeId, "Hello[1]"); + Assert.That(stringReturnValue, Is.EqualTo("")); + } // Test remove of non-existing value - int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Hello"); - Assert.That(fakeValueRemove, Is.EqualTo(0)); + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); - // Test get from non-existing store - UUID fakeStoreId = TestHelpers.ParseTail(0x500); - int fakeStoreValueRemove = (int)InvokeOp("JsonRemoveValue", fakeStoreId, "Hello"); - Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); + int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Cheese"); + Assert.That(fakeValueRemove, Is.EqualTo(0)); + } + + { + // Test get from non-existing store + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + int fakeStoreValueRemove = (int)InvokeOp("JsonRemoveValue", fakeStoreId, "Hello"); + Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); + } } [Test] -- cgit v1.1 From 70e641c70828bc0b726e4962a40efc90c54a5420 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Feb 2013 00:51:45 +0000 Subject: Add test for array as root element in TestJsonCreateStore() --- .../Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index bba727d..9721b8d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -135,6 +135,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); Assert.That(value, Is.EqualTo("42.15")); } + + // Test with an array as the root node + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "[ 'one', 'two', 'three' ]"); + Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "[1]"); + Assert.That(value, Is.EqualTo("two")); + } } [Test] -- cgit v1.1 From b1a165a39ad5aef2b55e367aa7ff984374016ba7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Feb 2013 01:25:30 +0000 Subject: Extend JsonTestSetValue() with tests for escaping brackets, periods and unbalanced braces from paths The sub-tests that are commented out are currently those which fail unexpectedly based on my understanding of the path syntax --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 73 +++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 9721b8d..71983b3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -405,7 +405,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // TestHelpers.EnableLogging(); { - UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); int result = (int)InvokeOp("JsonSetValue", storeId, "Fun", "Times"); Assert.That(result, Is.EqualTo(1)); @@ -414,9 +414,78 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("Times")); } + // Commented out as this currently unexpectedly fails. + // Test setting a key containing periods. +// { +// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); +// +// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times"); +// Assert.That(result, Is.EqualTo(1)); +// +// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}"); +// Assert.That(value, Is.EqualTo("Times")); +// } + + // Test setting a key containing empty brackets + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[]Circus}", "Times"); + Assert.That(result, Is.EqualTo(1)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[]Circus}"); + Assert.That(value, Is.EqualTo("Times")); + } + + // Commented out as this currently unexpectedly fails. +// // Test setting a key containing brackets with an integer +// { +// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); +// +// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times"); +// Assert.That(result, Is.EqualTo(1)); +// +// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[]Circus}"); +// Assert.That(value, Is.EqualTo("Times")); +// } + + // Commented out as this currently unexpectedly fails. +// // Test setting a key containing unbalanced } +// { +// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); +// +// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times"); +// Assert.That(result, Is.EqualTo(1)); +// +// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun}Circus}"); +// Assert.That(value, Is.EqualTo("Times")); +// } + + // Test setting a key containing unbalanced { + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Circus}", "Times"); + Assert.That(result, Is.EqualTo(1)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun{Circus}"); + Assert.That(value, Is.EqualTo("Times")); + } + + // Test setting a key containing balanced {}. This should fail. + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Filled}Circus}", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun{Filled}Circus}"); + Assert.That(value, Is.EqualTo("")); + } + // Test setting to location that does not exist. This should fail. { - UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); int result = (int)InvokeOp("JsonSetValue", storeId, "Fun.Circus", "Times"); Assert.That(result, Is.EqualTo(0)); -- cgit v1.1 From 5557b523fdae64e0017cbf5285331f71fe046961 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Feb 2013 01:38:33 +0000 Subject: Add more sub-tests to TestJsonSetValue for paths containing []{} without {} delineation. As expected, values are not set and the set call returns FALSE (0). As a reminder, these tests are not currently running on jenkins continuous integration as the functionality is only available on .net 4 (mono 2.8 and later). --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 91 ++++++++++++++++++++-- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 71983b3..f25f290 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -415,7 +415,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } // Commented out as this currently unexpectedly fails. - // Test setting a key containing periods. + // Test setting a key containing periods with delineation // { // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); // @@ -426,7 +426,64 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // Assert.That(value, Is.EqualTo("Times")); // } - // Test setting a key containing empty brackets + // *** Test [] *** + + // Test setting a key containing unbalanced ] without delineation. Expecting failure + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun]Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun]Circus"); + Assert.That(value, Is.EqualTo("")); + } + + // Test setting a key containing unbalanced [ without delineation. Expecting failure + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun[Circus"); + Assert.That(value, Is.EqualTo("")); + } + + // Test setting a key containing unbalanced [] without delineation. Expecting failure + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[]Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun[]Circus"); + Assert.That(value, Is.EqualTo("")); + } + + // Test setting a key containing unbalanced ] with delineation + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun]Circus}", "Times"); + Assert.That(result, Is.EqualTo(1)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun]Circus}"); + Assert.That(value, Is.EqualTo("Times")); + } + + // Test setting a key containing unbalanced [ with delineation + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[Circus}", "Times"); + Assert.That(result, Is.EqualTo(1)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[Circus}"); + Assert.That(value, Is.EqualTo("Times")); + } + + // Test setting a key containing empty balanced [] with delineation { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); @@ -438,7 +495,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } // Commented out as this currently unexpectedly fails. -// // Test setting a key containing brackets with an integer +// // Test setting a key containing brackets around an integer with delineation // { // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); // @@ -449,6 +506,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // Assert.That(value, Is.EqualTo("Times")); // } + // *** Test {} *** + + // Test setting a key containing unbalanced } without delineation. Expecting failure (?) + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun}Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun}Circus"); + Assert.That(value, Is.EqualTo("")); + } + + // Test setting a key containing unbalanced { without delineation. Expecting failure (?) + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "Fun{Circus", "Times"); + Assert.That(result, Is.EqualTo(0)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "Fun}Circus"); + Assert.That(value, Is.EqualTo("")); + } + // Commented out as this currently unexpectedly fails. // // Test setting a key containing unbalanced } // { @@ -461,7 +542,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // Assert.That(value, Is.EqualTo("Times")); // } - // Test setting a key containing unbalanced { + // Test setting a key containing unbalanced { with delineation { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); @@ -472,7 +553,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("Times")); } - // Test setting a key containing balanced {}. This should fail. + // Test setting a key containing balanced {} with delineation. This should fail. { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); -- cgit v1.1 From c2bfdaa026b02b1a6f41745464e7934e166ab35f Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 13 Feb 2013 01:52:25 +0000 Subject: Make the sim features module register it's interface so it can be used --- OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 191bccf..8f38737 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -94,6 +94,8 @@ namespace OpenSim.Region.ClientStack.Linden { m_scene = s; m_scene.EventManager.OnRegisterCaps += RegisterCaps; + + m_scene.RegisterModuleInterface(this); } public void RemoveRegion(Scene s) -- cgit v1.1 From 708c3f8b864812abc1c9642f65bc284d4bd3f074 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 12 Feb 2013 23:21:49 -0800 Subject: Make path parsing more robust in the JsonStore. --- .../OptionalModules/Scripting/JsonStore/JsonStore.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs index 3bad06c..f7625fb 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs @@ -68,14 +68,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore protected List m_TakeStore; protected List m_ReadStore; - // add separators for quoted paths - protected static Regex m_ParsePassOne = new Regex("{[^}]+}"); - - // add separators for array references - protected static Regex m_ParsePassTwo = new Regex("(\\[[0-9]+\\]|\\[\\+\\])"); + // add separators for quoted paths and array references + protected static Regex m_ParsePassOne = new Regex("({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])"); // add quotes to bare identifiers which are limited to alphabetic characters - protected static Regex m_ParsePassThree = new Regex("\\.([a-zA-Z]+)"); + protected static Regex m_ParsePassThree = new Regex("(? // ----------------------------------------------------------------- + public JsonStoreNodeType PathType(string expr) + { + Stack path; + if (! ParsePathExpression(expr,out path)) + return JsonStoreNodeType.Undefined; + + OSD result = ProcessPathExpression(ValueStore,path); + + if (result == null) + return JsonStoreNodeType.Undefined; + + if (result is OSDMap) + return JsonStoreNodeType.Object; + + if (result is OSDArray) + return JsonStoreNodeType.Array; + + if (OSDBaseType(result.Type)) + return JsonStoreNodeType.Value; + + return JsonStoreNodeType.Undefined; + } + + // ----------------------------------------------------------------- + /// + /// + /// + // ----------------------------------------------------------------- public bool TestPath(string expr, bool useJson) { Stack path; @@ -167,6 +195,27 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// /// // ----------------------------------------------------------------- + public int ArrayLength(string expr) + { + Stack path; + if (! ParsePathExpression(expr,out path)) + return -1; + + OSD result = ProcessPathExpression(ValueStore,path); + if (result != null && result.Type == OSDType.Array) + { + OSDArray arr = result as OSDArray; + return arr.Count; + } + + return -1; + } + + // ----------------------------------------------------------------- + /// + /// + /// + // ----------------------------------------------------------------- public bool GetValue(string expr, out string value, bool useJson) { Stack path; diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index cc13661..eec86ef 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs @@ -270,6 +270,38 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// /// // ----------------------------------------------------------------- + public JsonStoreNodeType PathType(UUID storeID, string path) + { + if (! m_enabled) return JsonStoreNodeType.Undefined; + + JsonStore map = null; + lock (m_JsonValueStore) + { + if (! m_JsonValueStore.TryGetValue(storeID,out map)) + { + m_log.InfoFormat("[JsonStore] Missing store {0}",storeID); + return JsonStoreNodeType.Undefined; + } + } + + try + { + lock (map) + return map.PathType(path); + } + catch (Exception e) + { + m_log.Error(string.Format("[JsonStore]: Path test failed for {0} in {1}", path, storeID), e); + } + + return JsonStoreNodeType.Undefined; + } + + // ----------------------------------------------------------------- + /// + /// + /// + // ----------------------------------------------------------------- public bool TestPath(UUID storeID, string path, bool useJson) { if (! m_enabled) return false; @@ -375,6 +407,37 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// /// // ----------------------------------------------------------------- + public int ArrayLength(UUID storeID, string path) + { + if (! m_enabled) return -1; + + JsonStore map = null; + lock (m_JsonValueStore) + { + if (! m_JsonValueStore.TryGetValue(storeID,out map)) + return -1; + } + + try + { + lock (map) + { + return map.ArrayLength(path); + } + } + catch (Exception e) + { + m_log.Error("[JsonStore]: unable to retrieve value", e); + } + + return -1; + } + + // ----------------------------------------------------------------- + /// + /// + /// + // ----------------------------------------------------------------- public bool GetValue(UUID storeID, string path, bool useJson, out string value) { value = String.Empty; diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index e436304..3955bff 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -167,7 +167,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore try { m_comms.RegisterScriptInvocations(this); - + m_comms.RegisterConstants(this); + // m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); // m_comms.RegisterScriptInvocation(this, "JsonAttachObjectStore"); // m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); @@ -214,6 +215,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore #endregion +#region ScriptConstantInteface + + [ScriptConstant] + public static readonly int JSONTYPEUNDEF = (int)JsonStoreNodeType.Undefined; + + [ScriptConstant] + public static readonly int JSONTYPEOBJECT = (int)JsonStoreNodeType.Object; + + [ScriptConstant] + public static readonly int JSONTYPEARRAY = (int)JsonStoreNodeType.Array; + + [ScriptConstant] + public static readonly int JSONTYPEVALUE = (int)JsonStoreNodeType.Value; + +#endregion + #region ScriptInvocationInteface // ----------------------------------------------------------------- /// @@ -319,6 +336,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// // ----------------------------------------------------------------- [ScriptInvocation] + public int JsonPathType(UUID hostID, UUID scriptID, UUID storeID, string path) + { + return (int)m_store.PathType(storeID,path); + } + + [ScriptInvocation] public int JsonTestPath(UUID hostID, UUID scriptID, UUID storeID, string path) { return m_store.TestPath(storeID,path,false) ? 1 : 0; @@ -364,6 +387,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// // ----------------------------------------------------------------- [ScriptInvocation] + public int JsonArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path) + { + return m_store.ArrayLength(storeID,path); + } + + // ----------------------------------------------------------------- + /// + /// + /// + // ----------------------------------------------------------------- + [ScriptInvocation] public string JsonGetValue(UUID hostID, UUID scriptID, UUID storeID, string path) { string value = String.Empty; -- cgit v1.1 From 69d0e168fb2b945ffcd1fb005abd0192d1eb8876 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 14 Feb 2013 00:19:28 +0000 Subject: Fix a very unlikely-to-occur NullReferenceException race condition in llPushObject() where the code assumed that the physics actor it null-checked would still be null when it invoked a method on it --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index be6ac0a..96f650e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4479,6 +4479,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + if (pushAllowed) { float distance = (PusheePos - m_host.AbsolutePosition).Length(); @@ -4507,17 +4508,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api applied_linear_impulse *= scaling_factor; } + if (pusheeIsAvatar) { if (pusheeav != null) { - if (pusheeav.PhysicsActor != null) + PhysicsActor pa = pusheeav.PhysicsActor; + + if (pa != null) { if (local != 0) { applied_linear_impulse *= m_host.GetWorldRotation(); } - pusheeav.PhysicsActor.AddForce(applied_linear_impulse, true); + + pa.AddForce(applied_linear_impulse, true); } } } -- cgit v1.1 From ef662fc959c7943e55c548c50c6b160d12e5c095 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 14 Feb 2013 08:40:15 +0100 Subject: Add an event and some logic to allow customizing Simulator Features by avatar --- .../Linden/Caps/SimulatorFeaturesModule.cs | 25 ++++++++++++++++++---- .../Interfaces/ISimulatorFeaturesModule.cs | 6 +++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 8f38737..6ef8815 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.Linden // private static readonly ILog m_log = // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; + private Scene m_scene; /// @@ -158,7 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden IRequestHandler reqHandler = new RestHTTPHandler( "GET", "/CAPS/" + UUID.Random(), - HandleSimulatorFeaturesRequest, "SimulatorFeatures", agentID.ToString()); + x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString()); caps.RegisterHandler("SimulatorFeatures", reqHandler); } @@ -187,18 +189,33 @@ namespace OpenSim.Region.ClientStack.Linden return new OSDMap(m_features); } - private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) + private OSDMap DeepCopy() + { + // This isn't the cheapest way of doing this but the rate + // of occurrence is low (on sim entry only) and it's a sure + // way to get a true deep copy. + OSD copy = OSDParser.DeserializeLLSDXml(OSDParser.SerializeLLSDXmlString(m_features)); + + return (OSDMap)copy; + } + + private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID) { // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); + OSDMap copy = DeepCopy(); + + SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; + if (handlerOnSimulatorFeaturesRequest != null) + handlerOnSimulatorFeaturesRequest(agentID, ref copy); + //Send back data Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; - lock (m_features) - responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features); + responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy); return responsedata; } diff --git a/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs index 8cef14e..6effcc1 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs @@ -26,18 +26,22 @@ */ using System; +using OpenMetaverse; using OpenMetaverse.StructuredData; namespace OpenSim.Region.Framework.Interfaces { + public delegate void SimulatorFeaturesRequestDelegate(UUID agentID, ref OSDMap features); + /// /// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability. /// public interface ISimulatorFeaturesModule { + event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; void AddFeature(string name, OSD value); bool RemoveFeature(string name); bool TryGetFeature(string name, out OSD value); OSDMap GetFeatures(); } -} \ No newline at end of file +} -- cgit v1.1 From 5920abbf8d1b1770c03bc6232f1afe0551b4a331 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 14 Feb 2013 09:48:11 -0800 Subject: Add EventManager events triggered when a SOP is added or removed from the physical scene. Invocations added in SceneObjectPart. --- OpenSim/Region/Framework/Scenes/EventManager.cs | 55 ++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 + 2 files changed, 57 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 9ee1520..59d0148 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -791,6 +791,19 @@ namespace OpenSim.Region.Framework.Scenes public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); /// + /// Triggered when an object is placed into the physical scene (PhysicsActor created). + /// + public event Action OnObjectAddedToPhysicalScene; + /// + /// Triggered when an object is removed from the physical scene (PhysicsActor destroyed). + /// + /// + /// Note: this is triggered just before the PhysicsActor is removed from the + /// physics engine so the receiver can do any necessary cleanup before its destruction. + /// + public event Action OnObjectRemovedFromPhysicalScene; + + /// /// Triggered when an object is removed from the scene. /// /// @@ -1516,6 +1529,48 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerObjectAddedToPhysicalScene(SceneObjectPart obj) + { + Action handler = OnObjectAddedToPhysicalScene; + if (handler != null) + { + foreach (Action d in handler.GetInvocationList()) + { + try + { + d(obj); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerObjectAddedToPhysicalScene failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + + public void TriggerObjectRemovedFromPhysicalScene(SceneObjectPart obj) + { + Action handler = OnObjectRemovedFromPhysicalScene; + if (handler != null) + { + foreach (Action d in handler.GetInvocationList()) + { + try + { + d(obj); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerObjectRemovedFromPhysicalScene failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + public void TriggerShutdown() { Action handlerShutdown = OnShutdown; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9b29973..cce8b21 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4316,6 +4316,7 @@ namespace OpenSim.Region.Framework.Scenes } PhysActor = pa; + ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); } /// @@ -4328,6 +4329,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void RemoveFromPhysics() { + ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); PhysActor = null; } -- cgit v1.1 From a52dfd43b6c7f5b1893bf027d949c7cc15c233b3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 14 Feb 2013 21:03:07 +0000 Subject: Make new JsonStore script constants separated with underscores, to be consistent with existing LSL/OSSL, etc script constants. Agreed with cmickeyb --- .../Scripting/JsonStore/JsonStoreScriptModule.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 3955bff..669d752 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -215,19 +215,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore #endregion -#region ScriptConstantInteface +#region ScriptConstantsInterface [ScriptConstant] - public static readonly int JSONTYPEUNDEF = (int)JsonStoreNodeType.Undefined; + public static readonly int JSON_TYPE_UNDEF = (int)JsonStoreNodeType.Undefined; [ScriptConstant] - public static readonly int JSONTYPEOBJECT = (int)JsonStoreNodeType.Object; + public static readonly int JSON_TYPE_OBJECT = (int)JsonStoreNodeType.Object; [ScriptConstant] - public static readonly int JSONTYPEARRAY = (int)JsonStoreNodeType.Array; + public static readonly int JSON_TYPE_ARRAY = (int)JsonStoreNodeType.Array; [ScriptConstant] - public static readonly int JSONTYPEVALUE = (int)JsonStoreNodeType.Value; + public static readonly int JSON_TYPE_VALUE = (int)JsonStoreNodeType.Value; #endregion -- cgit v1.1 From edb99dcc19d20980ab8fc1a0a272017855e1f266 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 14 Feb 2013 21:11:58 +0000 Subject: Rename new JsonScript functions JsonPathType() -> JsonGetPathType() and JsonArrayLength() -> JsonGetArrayLength() This is for consistentency with the verb:noun naming approach existing json script functions and other script functions. Corresponding c# methods also changed since verb:noun is also the .net c# method naming guideline (as used by OpenSimulator) and for consistency with script functions. As agreed with cmickeyb --- OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs | 4 ++-- .../Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | 4 ++-- .../OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs index d7907e3..b40d24f 100644 --- a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.Framework.Interfaces bool CreateStore(string value, ref UUID result); bool DestroyStore(UUID storeID); - JsonStoreNodeType PathType(UUID storeID, string path); + JsonStoreNodeType GetPathType(UUID storeID, string path); bool TestStore(UUID storeID); bool TestPath(UUID storeID, string path, bool useJson); @@ -60,6 +60,6 @@ namespace OpenSim.Region.Framework.Interfaces void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); - int ArrayLength(UUID storeID, string path); + int GetArrayLength(UUID storeID, string path); } } diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index eec86ef..fb35068 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs @@ -270,7 +270,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// /// // ----------------------------------------------------------------- - public JsonStoreNodeType PathType(UUID storeID, string path) + public JsonStoreNodeType GetPathType(UUID storeID, string path) { if (! m_enabled) return JsonStoreNodeType.Undefined; @@ -407,7 +407,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// /// // ----------------------------------------------------------------- - public int ArrayLength(UUID storeID, string path) + public int GetArrayLength(UUID storeID, string path) { if (! m_enabled) return -1; diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 669d752..1ed7df7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -336,9 +336,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// // ----------------------------------------------------------------- [ScriptInvocation] - public int JsonPathType(UUID hostID, UUID scriptID, UUID storeID, string path) + public int JsonGetPathType(UUID hostID, UUID scriptID, UUID storeID, string path) { - return (int)m_store.PathType(storeID,path); + return (int)m_store.GetPathType(storeID,path); } [ScriptInvocation] @@ -387,9 +387,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// // ----------------------------------------------------------------- [ScriptInvocation] - public int JsonArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path) + public int JsonGetArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path) { - return m_store.ArrayLength(storeID,path); + return m_store.GetArrayLength(storeID,path); } // ----------------------------------------------------------------- -- cgit v1.1 From 0ad07eb44d38fd1b57ef40c5aaf073663bc0694c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 14 Feb 2013 21:29:35 +0000 Subject: minor: remove some mono compiler warnings --- .../Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs | 2 +- .../Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index d1ad74f..b67c0df 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction public class AssetTransactionModule : INonSharedRegionModule, IAgentAssetTransactions { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Scene m_Scene; private bool m_dumpAssetsToFile = false; diff --git a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs index d36f65a..37131b9 100644 --- a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs +++ b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs @@ -44,7 +44,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")] public class DAExampleModule : INonSharedRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly bool ENABLED = false; // enable for testing -- cgit v1.1 From 6fe771f27e08f516a93ba7c04010a3157841b061 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 14 Feb 2013 21:31:34 +0000 Subject: Add regression TestJsonGetPathType() --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index f25f290..e5555d6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -399,6 +399,53 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } [Test] + public void TestJsonGetPathType() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }"); + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "."); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT)); + } + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT)); + } + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_ARRAY)); + } + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[0]"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); + } + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[1]"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); + } + + // Test for non-existant path + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "foo"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); + } + + // Test for non-existant store + { + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + int result = (int)InvokeOp("JsonGetPathType", fakeStoreId, "."); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); + } + } + + [Test] public void TestJsonSetValue() { TestHelpers.InMethod(); -- cgit v1.1 From 13d4f6f747d3432f7b7d2f3e1d383dcdce91c01b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 14 Feb 2013 21:34:57 +0000 Subject: Add regression TestGetArrayLength() --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index e5555d6..a457c7b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -399,6 +399,39 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } [Test] + public void TestGetArrayLength() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }"); + + { + int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello.World"); + Assert.That(result, Is.EqualTo(2)); + } + + // Test path which is not an array + { + int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello"); + Assert.That(result, Is.EqualTo(-1)); + } + + // Test fake path + { + int result = (int)InvokeOp("JsonGetArrayLength", storeId, "foo"); + Assert.That(result, Is.EqualTo(-1)); + } + + // Test fake store + { + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + int result = (int)InvokeOp("JsonGetArrayLength", fakeStoreId, "Hello.World"); + Assert.That(result, Is.EqualTo(-1)); + } + } + + [Test] public void TestJsonGetPathType() { TestHelpers.InMethod(); -- cgit v1.1 From c22276a169125e97b39d72c2e9ca55f5e1807320 Mon Sep 17 00:00:00 2001 From: teravus Date: Thu, 14 Feb 2013 18:43:53 -0500 Subject: * gracefully handle a Situation where a double close is called on the WebSocket handler --- OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs index cfb1605..bb8825b 100644 --- a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs @@ -535,6 +535,8 @@ namespace OpenSim.Framework.Servers.HttpServer /// public void Close(string message) { + if (_networkContext == null) + return; if (_networkContext.Stream != null) { if (_networkContext.Stream.CanWrite) -- cgit v1.1 From 71862f34b6e97e19fceefd9ccb813ce09ef0a0c3 Mon Sep 17 00:00:00 2001 From: teravus Date: Thu, 14 Feb 2013 18:52:11 -0500 Subject: * Handle null check on configs in module startup so that the the code can be run on 'stop on handled and unhandled null reference exceptions' mode without pausing during startup a bunch of times. I don't think exceptions were really meant for replacing a single if statement... --- .../Framework/Statistics/Logging/BinaryLoggingModule.cs | 2 +- .../Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/Statistics/Logging/BinaryLoggingModule.cs b/OpenSim/Region/CoreModules/Framework/Statistics/Logging/BinaryLoggingModule.cs index fb74cc6..f3436d1 100644 --- a/OpenSim/Region/CoreModules/Framework/Statistics/Logging/BinaryLoggingModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Statistics/Logging/BinaryLoggingModule.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Framework.Statistics.Logging try { IConfig statConfig = source.Configs["Statistics.Binary"]; - if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) + if (statConfig != null && statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) { if (statConfig.Contains("collect_region_stats")) { diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs index 385f5ad..cbffca7 100644 --- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs @@ -111,13 +111,15 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC m_rpcPending = new Dictionary(); m_rpcPendingResponses = new Dictionary(); m_pendingSRDResponses = new Dictionary(); - - try - { - m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort); - } - catch (Exception) + if (config.Configs["XMLRPC"] != null) { + try + { + m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort); + } + catch (Exception) + { + } } } -- cgit v1.1 From cc40517863a9a32d3c5af1293623c4466c736c13 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Feb 2013 00:27:30 +0000 Subject: Add regression TestJsonList2Path() --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index a457c7b..68eed1d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -53,6 +53,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests private Scene m_scene; private MockScriptEngine m_engine; private ScriptModuleCommsModule m_smcm; + private JsonStoreScriptModule m_jssm; [TestFixtureSetUp] public void FixtureInit() @@ -82,10 +83,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests m_engine = new MockScriptEngine(); m_smcm = new ScriptModuleCommsModule(); JsonStoreModule jsm = new JsonStoreModule(); - JsonStoreScriptModule jssm = new JsonStoreScriptModule(); + m_jssm = new JsonStoreScriptModule(); m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); + SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, m_jssm); try { @@ -479,6 +480,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } [Test] + public void TestJsonList2Path() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + // Invoking these methods directly since I just couldn't get comms module invocation to work for some reason + // - some confusion with the methods that take a params object[] invocation. + { + string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo" }); + Assert.That(result, Is.EqualTo("{foo}")); + } + + { + string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo", "bar" }); + Assert.That(result, Is.EqualTo("{foo}.{bar}")); + } + + { + string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo", 1, "bar" }); + Assert.That(result, Is.EqualTo("{foo}.[1].{bar}")); + } + } + + [Test] public void TestJsonSetValue() { TestHelpers.InMethod(); -- cgit v1.1 From 0b2608d8f4c715acf693565d57d2919dda4d7f18 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Feb 2013 00:32:20 +0000 Subject: Comment out regression TestJsonTestPath and TestJsonTestPathJson as these will go away soon --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 124 ++++++++++----------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 68eed1d..1c4737b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -335,69 +335,69 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } } - [Test] - public void TestJsonTestPath() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); - - { - int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World"); - Assert.That(result, Is.EqualTo(1)); - } - - // Test for path which does not resolve to a value. - { - int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); - Assert.That(result, Is.EqualTo(0)); - } - - { - int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo"); - Assert.That(result2, Is.EqualTo(0)); - } - - // Test with fake store - { - UUID fakeStoreId = TestHelpers.ParseTail(0x500); - int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello"); - Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); - } - } - - [Test] - public void TestJsonTestPathJson() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); - - { - int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World"); - Assert.That(result, Is.EqualTo(1)); - } - - // Test for path which does not resolve to a value. - { - int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello"); - Assert.That(result, Is.EqualTo(1)); - } - - { - int result2 = (int)InvokeOp("JsonTestPathJson", storeId, "foo"); - Assert.That(result2, Is.EqualTo(0)); - } +// [Test] +// public void TestJsonTestPath() +// { +// TestHelpers.InMethod(); +//// TestHelpers.EnableLogging(); +// +// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); +// +// { +// int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World"); +// Assert.That(result, Is.EqualTo(1)); +// } +// +// // Test for path which does not resolve to a value. +// { +// int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); +// Assert.That(result, Is.EqualTo(0)); +// } +// +// { +// int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo"); +// Assert.That(result2, Is.EqualTo(0)); +// } +// +// // Test with fake store +// { +// UUID fakeStoreId = TestHelpers.ParseTail(0x500); +// int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello"); +// Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); +// } +// } - // Test with fake store - { - UUID fakeStoreId = TestHelpers.ParseTail(0x500); - int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello"); - Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); - } - } +// [Test] +// public void TestJsonTestPathJson() +// { +// TestHelpers.InMethod(); +//// TestHelpers.EnableLogging(); +// +// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); +// +// { +// int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World"); +// Assert.That(result, Is.EqualTo(1)); +// } +// +// // Test for path which does not resolve to a value. +// { +// int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello"); +// Assert.That(result, Is.EqualTo(1)); +// } +// +// { +// int result2 = (int)InvokeOp("JsonTestPathJson", storeId, "foo"); +// Assert.That(result2, Is.EqualTo(0)); +// } +// +// // Test with fake store +// { +// UUID fakeStoreId = TestHelpers.ParseTail(0x500); +// int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello"); +// Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); +// } +// } [Test] public void TestGetArrayLength() -- cgit v1.1 From 61f18d15e1115275588e9e5a27f5d148ed762b4e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Feb 2013 00:38:07 +0000 Subject: Rename JsonSetValueJson() -> JsonSetJson() and JsonGetValueJson() -> JsonGetJson() This is because JsonGetJson() is getting json from anywhere in the structure, not just values. Equally, JsonSetJson() is setting any type of json, not just json which represents a value. Agreed with cmickeyb --- .../Scripting/JsonStore/JsonStoreScriptModule.cs | 4 ++-- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 26 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 1ed7df7..ef08c05 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -365,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } [ScriptInvocation] - public int JsonSetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value) + public int JsonSetJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value) { return m_store.SetValue(storeID,path,value,true) ? 1 : 0; } @@ -406,7 +406,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore } [ScriptInvocation] - public string JsonGetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path) + public string JsonGetJson(UUID hostID, UUID scriptID, UUID storeID, string path) { string value = String.Empty; m_store.GetValue(storeID,path,true, out value); diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 1c4737b..ffa8250 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -209,7 +209,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } [Test] - public void TestJsonGetValueJson() + public void TestJsonGetJson() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); @@ -217,26 +217,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }"); { - string value = (string)InvokeOp("JsonGetValueJson", storeId, "Hello.World"); + string value = (string)InvokeOp("JsonGetJson", storeId, "Hello.World"); Assert.That(value, Is.EqualTo("'Two'")); } // Test get of path section instead of leaf { - string value = (string)InvokeOp("JsonGetValueJson", storeId, "Hello"); + string value = (string)InvokeOp("JsonGetJson", storeId, "Hello"); Assert.That(value, Is.EqualTo("{\"World\":\"Two\"}")); } // Test get of non-existing value { - string fakeValueGet = (string)InvokeOp("JsonGetValueJson", storeId, "foo"); + string fakeValueGet = (string)InvokeOp("JsonGetJson", storeId, "foo"); Assert.That(fakeValueGet, Is.EqualTo("")); } // Test get from non-existing store { UUID fakeStoreId = TestHelpers.ParseTail(0x500); - string fakeStoreValueGet = (string)InvokeOp("JsonGetValueJson", fakeStoreId, "Hello"); + string fakeStoreValueGet = (string)InvokeOp("JsonGetJson", fakeStoreId, "Hello"); Assert.That(fakeStoreValueGet, Is.EqualTo("")); } } @@ -294,7 +294,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); Assert.That(result, Is.EqualTo(0)); - string returnValue2 = (string)InvokeOp("JsonGetValueJson", storeId, "Hello"); + string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello"); Assert.That(returnValue2, Is.EqualTo("")); } @@ -315,7 +315,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]"); Assert.That(stringReturnValue, Is.EqualTo("value2")); - stringReturnValue = (string)InvokeOp("JsonGetValueJson", storeId, "Hello[1]"); + stringReturnValue = (string)InvokeOp("JsonGetJson", storeId, "Hello[1]"); Assert.That(stringReturnValue, Is.EqualTo("")); } @@ -689,7 +689,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } [Test] - public void TestJsonSetValueJson() + public void TestJsonSetJson() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); @@ -698,7 +698,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); - int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "'Times'"); + int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "'Times'"); Assert.That(result, Is.EqualTo(1)); string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); @@ -709,7 +709,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); - int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "{ 'Filled' : 'Times' }"); + int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "{ 'Filled' : 'Times' }"); Assert.That(result, Is.EqualTo(1)); string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled"); @@ -720,7 +720,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); - int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "Times"); + int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "Times"); Assert.That(result, Is.EqualTo(0)); string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); @@ -731,7 +731,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests { UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); - int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun.Circus", "'Times'"); + int result = (int)InvokeOp("JsonSetJson", storeId, "Fun.Circus", "'Times'"); Assert.That(result, Is.EqualTo(0)); string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus"); @@ -741,7 +741,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // Test with fake store { UUID fakeStoreId = TestHelpers.ParseTail(0x500); - int fakeStoreValueSet = (int)InvokeOp("JsonSetValueJson", fakeStoreId, "Hello", "'World'"); + int fakeStoreValueSet = (int)InvokeOp("JsonSetJson", fakeStoreId, "Hello", "'World'"); Assert.That(fakeStoreValueSet, Is.EqualTo(0)); } } -- cgit v1.1 From 8d5fe5c22232e23b414531b07c5a8b343bb4b886 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Feb 2013 01:00:49 +0000 Subject: Enable one sub-test in TestJsonSetValue() which now works (using identifier with embedded .). Need to look further at other still commented tests. Still need to check coverage against some of Mic's scripts. --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 30 ++++++++++------------ 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index ffa8250..3d9ad16 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -519,17 +519,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("Times")); } - // Commented out as this currently unexpectedly fails. // Test setting a key containing periods with delineation -// { -// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); -// -// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times"); -// Assert.That(result, Is.EqualTo(1)); -// -// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}"); -// Assert.That(value, Is.EqualTo("Times")); -// } + { + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); + + int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times"); + Assert.That(result, Is.EqualTo(1)); + + string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}"); + Assert.That(value, Is.EqualTo("Times")); + } // *** Test [] *** @@ -599,7 +598,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("Times")); } - // Commented out as this currently unexpectedly fails. +// // Commented out as this currently unexpectedly fails. // // Test setting a key containing brackets around an integer with delineation // { // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); @@ -607,7 +606,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times"); // Assert.That(result, Is.EqualTo(1)); // -// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[]Circus}"); +// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[0]Circus}"); // Assert.That(value, Is.EqualTo("Times")); // } @@ -635,16 +634,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests Assert.That(value, Is.EqualTo("")); } - // Commented out as this currently unexpectedly fails. +// // Commented out as this currently unexpectedly fails. // // Test setting a key containing unbalanced } // { // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); // // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times"); -// Assert.That(result, Is.EqualTo(1)); -// -// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun}Circus}"); -// Assert.That(value, Is.EqualTo("Times")); +// Assert.That(result, Is.EqualTo(0)); // } // Test setting a key containing unbalanced { with delineation -- cgit v1.1