diff options
Diffstat (limited to 'OpenSim/Region/Framework')
4 files changed, 107 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs new file mode 100644 index 0000000..baac6e8 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Framework.Interfaces | ||
33 | { | ||
34 | public delegate void TakeValueCallback(string s); | ||
35 | |||
36 | public interface IJsonStoreModule | ||
37 | { | ||
38 | bool CreateStore(string value, out UUID result); | ||
39 | bool DestroyStore(UUID storeID); | ||
40 | bool TestPath(UUID storeID, string path, bool useJson); | ||
41 | bool SetValue(UUID storeID, string path, string value, bool useJson); | ||
42 | bool RemoveValue(UUID storeID, string path); | ||
43 | bool GetValue(UUID storeID, string path, bool useJson, out string value); | ||
44 | |||
45 | void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); | ||
46 | void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index cd4bd42..0a1b921 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -101,6 +101,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | /// </summary> | 101 | /// </summary> |
102 | protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); | 102 | protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); |
103 | 103 | ||
104 | /// <summary> | ||
105 | /// Lock to prevent object group update, linking and delinking operations from running concurrently. | ||
106 | /// </summary> | ||
104 | private Object m_updateLock = new Object(); | 107 | private Object m_updateLock = new Object(); |
105 | 108 | ||
106 | #endregion | 109 | #endregion |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6f3a084..7bd6c11 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2584,6 +2584,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2584 | /// <summary> | 2584 | /// <summary> |
2585 | /// Link the prims in a given group to this group | 2585 | /// Link the prims in a given group to this group |
2586 | /// </summary> | 2586 | /// </summary> |
2587 | /// <remarks> | ||
2588 | /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads. | ||
2589 | /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition. | ||
2590 | /// </remarks> | ||
2587 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> | 2591 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> |
2588 | public void LinkToGroup(SceneObjectGroup objectGroup) | 2592 | public void LinkToGroup(SceneObjectGroup objectGroup) |
2589 | { | 2593 | { |
@@ -2714,6 +2718,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2714 | /// Delink the given prim from this group. The delinked prim is established as | 2718 | /// Delink the given prim from this group. The delinked prim is established as |
2715 | /// an independent SceneObjectGroup. | 2719 | /// an independent SceneObjectGroup. |
2716 | /// </summary> | 2720 | /// </summary> |
2721 | /// <remarks> | ||
2722 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2723 | /// condition. But currently there is no | ||
2724 | /// alternative method that does take a lonk to delink a single prim. | ||
2725 | /// </remarks> | ||
2717 | /// <param name="partID"></param> | 2726 | /// <param name="partID"></param> |
2718 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2727 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
2719 | public SceneObjectGroup DelinkFromGroup(uint partID) | 2728 | public SceneObjectGroup DelinkFromGroup(uint partID) |
@@ -2725,6 +2734,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2725 | /// Delink the given prim from this group. The delinked prim is established as | 2734 | /// Delink the given prim from this group. The delinked prim is established as |
2726 | /// an independent SceneObjectGroup. | 2735 | /// an independent SceneObjectGroup. |
2727 | /// </summary> | 2736 | /// </summary> |
2737 | /// <remarks> | ||
2738 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2739 | /// condition. But currently there is no | ||
2740 | /// alternative method that does take a lonk to delink a single prim. | ||
2741 | /// </remarks> | ||
2728 | /// <param name="partID"></param> | 2742 | /// <param name="partID"></param> |
2729 | /// <param name="sendEvents"></param> | 2743 | /// <param name="sendEvents"></param> |
2730 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2744 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
@@ -2750,6 +2764,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2750 | /// Delink the given prim from this group. The delinked prim is established as | 2764 | /// Delink the given prim from this group. The delinked prim is established as |
2751 | /// an independent SceneObjectGroup. | 2765 | /// an independent SceneObjectGroup. |
2752 | /// </summary> | 2766 | /// </summary> |
2767 | /// <remarks> | ||
2768 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2769 | /// condition. But currently there is no | ||
2770 | /// alternative method that does take a lonk to delink a single prim. | ||
2771 | /// </remarks> | ||
2753 | /// <param name="partID"></param> | 2772 | /// <param name="partID"></param> |
2754 | /// <param name="sendEvents"></param> | 2773 | /// <param name="sendEvents"></param> |
2755 | /// <returns>The object group of the newly delinked prim.</returns> | 2774 | /// <returns>The object group of the newly delinked prim.</returns> |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs index fffa3bd..9fea3c6 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | |||
@@ -111,8 +111,44 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
111 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | 111 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); |
112 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | 112 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); |
113 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | 113 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); |
114 | } | ||
115 | |||
116 | [Test] | ||
117 | public void TestGetChildPartPositionAfterObjectRotation() | ||
118 | { | ||
119 | TestHelpers.InMethod(); | ||
120 | |||
121 | Vector3 rootPartPosition = new Vector3(10, 20, 30); | ||
122 | Vector3 childOffsetPosition = new Vector3(2, 3, 4); | ||
123 | |||
124 | SceneObjectGroup so | ||
125 | = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); | ||
126 | so.AbsolutePosition = rootPartPosition; | ||
127 | so.Parts[1].OffsetPosition = childOffsetPosition; | ||
128 | |||
129 | m_scene.AddNewSceneObject(so, false); | ||
130 | |||
131 | so.UpdateGroupRotationR(Quaternion.CreateFromEulers(0, 0, -90 * Utils.DEG_TO_RAD)); | ||
132 | |||
133 | // Calculate child absolute position. | ||
134 | Vector3 rotatedChildOffsetPosition | ||
135 | = new Vector3(childOffsetPosition.Y, -childOffsetPosition.X, childOffsetPosition.Z); | ||
136 | |||
137 | Vector3 childPosition = new Vector3(rootPartPosition + rotatedChildOffsetPosition); | ||
138 | |||
139 | SceneObjectPart childPart = so.Parts[1]; | ||
114 | 140 | ||
115 | // TODO: Write test for child part position after rotation. | 141 | // FIXME: Should be childPosition after rotation? |
142 | Assert.That(childPart.AbsolutePosition, Is.EqualTo(rootPartPosition + childOffsetPosition)); | ||
143 | |||
144 | Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); | ||
145 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | ||
146 | |||
147 | // Relative to root part as (0, 0, 0) | ||
148 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | ||
149 | |||
150 | // Relative to root part as (0, 0, 0) | ||
151 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | ||
116 | } | 152 | } |
117 | } | 153 | } |
118 | } \ No newline at end of file | 154 | } \ No newline at end of file |