diff options
author | Melanie | 2012-04-18 00:28:33 +0100 |
---|---|---|
committer | Melanie | 2012-04-18 00:28:33 +0100 |
commit | fc9f244a7da6f5b4507278988259cfc54e0dd375 (patch) | |
tree | 0ee0202e5f6acf9ebfbd1fd0442a0c6b9f1e3fcc /OpenSim/Region/Framework/Scenes | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-fc9f244a7da6f5b4507278988259cfc54e0dd375.zip opensim-SC-fc9f244a7da6f5b4507278988259cfc54e0dd375.tar.gz opensim-SC-fc9f244a7da6f5b4507278988259cfc54e0dd375.tar.bz2 opensim-SC-fc9f244a7da6f5b4507278988259cfc54e0dd375.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 19 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | 38 |
3 files changed, 59 insertions, 1 deletions
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 |