diff options
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 50 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 23 |
3 files changed, 48 insertions, 27 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 8a65b06..dbe0e57 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -950,7 +950,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
950 | m_log.WarnFormat( | 950 | m_log.WarnFormat( |
951 | "[SCENE GRAPH]: Found scene object {0} {1} {2} via SceneObjectGroupsByLocalPartID index but it doesn't contain part with local id {3}. Removing from entry from index in {4}.", | 951 | "[SCENE GRAPH]: Found scene object {0} {1} {2} via SceneObjectGroupsByLocalPartID index but it doesn't contain part with local id {3}. Removing from entry from index in {4}.", |
952 | sog.Name, sog.UUID, sog.LocalId, localID, m_parentScene.RegionInfo.RegionName); | 952 | sog.Name, sog.UUID, sog.LocalId, localID, m_parentScene.RegionInfo.RegionName); |
953 | 953 | m_log.WarnFormat("stack: {0}", Environment.StackTrace); | |
954 | SceneObjectGroupsByLocalPartID.Remove(localID); | 954 | SceneObjectGroupsByLocalPartID.Remove(localID); |
955 | } | 955 | } |
956 | } | 956 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ca6f457..0eed64e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2929,22 +2929,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2929 | // First move the new group's root SOP's position to be relative to ours | 2929 | // First move the new group's root SOP's position to be relative to ours |
2930 | // (radams1: Not sure if the multiple setting of OffsetPosition is required. If not, | 2930 | // (radams1: Not sure if the multiple setting of OffsetPosition is required. If not, |
2931 | // this code can be reordered to have a more logical flow.) | 2931 | // this code can be reordered to have a more logical flow.) |
2932 | linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; | 2932 | linkPart.setOffsetPosition(linkPart.GroupPosition - AbsolutePosition); |
2933 | // Assign the new parent to the root of the old group | 2933 | // Assign the new parent to the root of the old group |
2934 | linkPart.ParentID = m_rootPart.LocalId; | 2934 | linkPart.ParentID = m_rootPart.LocalId; |
2935 | // Now that it's a child, it's group position is our root position | 2935 | // Now that it's a child, it's group position is our root position |
2936 | linkPart.GroupPosition = AbsolutePosition; | 2936 | linkPart.setGroupPosition(AbsolutePosition); |
2937 | 2937 | ||
2938 | Vector3 axPos = linkPart.OffsetPosition; | ||
2939 | // Rotate the linking root SOP's position to be relative to the new root prim | 2938 | // Rotate the linking root SOP's position to be relative to the new root prim |
2940 | Quaternion parentRot = m_rootPart.RotationOffset; | 2939 | Quaternion parentRot = m_rootPart.RotationOffset; |
2941 | axPos *= Quaternion.Conjugate(parentRot); | ||
2942 | linkPart.OffsetPosition = axPos; | ||
2943 | 2940 | ||
2944 | // Make the linking root SOP's rotation relative to the new root prim | 2941 | // Make the linking root SOP's rotation relative to the new root prim |
2945 | Quaternion oldRot = linkPart.RotationOffset; | 2942 | Quaternion oldRot = linkPart.RotationOffset; |
2946 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; | 2943 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
2947 | linkPart.RotationOffset = newRot; | 2944 | linkPart.setRotationOffset(newRot); |
2945 | |||
2946 | Vector3 axPos = linkPart.OffsetPosition; | ||
2947 | axPos *= Quaternion.Conjugate(parentRot); | ||
2948 | linkPart.OffsetPosition = axPos; | ||
2949 | |||
2948 | 2950 | ||
2949 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. | 2951 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. |
2950 | // Now that we know this SOG has at least two SOPs in it, the new root | 2952 | // Now that we know this SOG has at least two SOPs in it, the new root |
@@ -3168,9 +3170,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3168 | linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; | 3170 | linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; |
3169 | linkPart.OffsetPosition = new Vector3(0, 0, 0); | 3171 | linkPart.OffsetPosition = new Vector3(0, 0, 0); |
3170 | */ | 3172 | */ |
3171 | linkPart.GroupPosition = worldPos; | 3173 | linkPart.setGroupPosition(worldPos); |
3172 | linkPart.OffsetPosition = Vector3.Zero; | 3174 | linkPart.setOffsetPosition(Vector3.Zero); |
3173 | linkPart.RotationOffset = worldRot; | 3175 | linkPart.setRotationOffset(worldRot); |
3174 | 3176 | ||
3175 | // Create a new SOG to go around this unlinked and unattached SOP | 3177 | // Create a new SOG to go around this unlinked and unattached SOP |
3176 | SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); | 3178 | SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); |
@@ -3221,15 +3223,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3221 | Quaternion parentRot = oldGroupRotation; | 3223 | Quaternion parentRot = oldGroupRotation; |
3222 | Quaternion oldRot = part.RotationOffset; | 3224 | Quaternion oldRot = part.RotationOffset; |
3223 | 3225 | ||
3224 | // Move our position to not be relative to the old parent | 3226 | // Move our position in world |
3225 | Vector3 axPos = part.OffsetPosition; | 3227 | Vector3 axPos = part.OffsetPosition; |
3226 | axPos *= parentRot; | 3228 | axPos *= parentRot; |
3227 | part.OffsetPosition = axPos; | 3229 | Vector3 newPos = oldGroupPosition + axPos; |
3228 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; | 3230 | part.setGroupPosition(newPos); |
3229 | part.GroupPosition = newPos; | 3231 | part.setOffsetPosition(Vector3.Zero); |
3230 | part.OffsetPosition = Vector3.Zero; | ||
3231 | 3232 | ||
3232 | // Compution our rotation to be not relative to the old parent | 3233 | // Compution our rotation in world |
3233 | Quaternion worldRot = parentRot * oldRot; | 3234 | Quaternion worldRot = parentRot * oldRot; |
3234 | part.RotationOffset = worldRot; | 3235 | part.RotationOffset = worldRot; |
3235 | 3236 | ||
@@ -3237,31 +3238,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3237 | part.SetParent(this); | 3238 | part.SetParent(this); |
3238 | part.ParentID = m_rootPart.LocalId; | 3239 | part.ParentID = m_rootPart.LocalId; |
3239 | m_parts.Add(part.UUID, part); | 3240 | m_parts.Add(part.UUID, part); |
3240 | |||
3241 | 3241 | ||
3242 | part.LinkNum = linkNum; | 3242 | part.LinkNum = linkNum; |
3243 | 3243 | ||
3244 | m_scene.updateScenePartGroup(part, this); | 3244 | m_scene.updateScenePartGroup(part, this); |
3245 | 3245 | ||
3246 | // Compute the new position of this SOP relative to the group position | 3246 | // Compute the new position of this SOP relative to the group position |
3247 | part.OffsetPosition = newPos - AbsolutePosition; | 3247 | part.setOffsetPosition(newPos - AbsolutePosition); |
3248 | 3248 | ||
3249 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. | 3249 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. |
3250 | // It would have the affect of setting the physics engine position multiple | 3250 | // It would have the affect of setting the physics engine position multiple |
3251 | // times. In theory, that is not necessary but I don't have a good linkset | 3251 | // times. In theory, that is not necessary but I don't have a good linkset |
3252 | // test to know that cleaning up this code wouldn't break things.) | 3252 | // test to know that cleaning up this code wouldn't break things.) |
3253 | 3253 | ||
3254 | // Rotate the relative position by the rotation of the group | ||
3255 | Quaternion rootRotation = m_rootPart.RotationOffset; | ||
3256 | Vector3 pos = part.OffsetPosition; | ||
3257 | pos *= Quaternion.Conjugate(rootRotation); | ||
3258 | part.OffsetPosition = pos; | ||
3259 | |||
3260 | // Compute the SOP's rotation relative to the rotation of the group. | 3254 | // Compute the SOP's rotation relative to the rotation of the group. |
3261 | parentRot = m_rootPart.RotationOffset; | 3255 | parentRot = m_rootPart.RotationOffset; |
3256 | |||
3262 | oldRot = part.RotationOffset; | 3257 | oldRot = part.RotationOffset; |
3263 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; | 3258 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
3264 | part.RotationOffset = newRot; | 3259 | part.setRotationOffset(newRot); |
3260 | |||
3261 | Vector3 pos = part.OffsetPosition; | ||
3262 | pos *= Quaternion.Conjugate(parentRot); | ||
3263 | |||
3264 | part.OffsetPosition = pos; // update position and orientation on physics also | ||
3265 | 3265 | ||
3266 | // Since this SOP's state has changed, push those changes into the physics engine | 3266 | // Since this SOP's state has changed, push those changes into the physics engine |
3267 | // and the simulator. | 3267 | // and the simulator. |
@@ -3947,7 +3947,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3947 | } | 3947 | } |
3948 | 3948 | ||
3949 | AbsolutePosition = newPos; | 3949 | AbsolutePosition = newPos; |
3950 | 3950 | ||
3951 | if (IsAttachment) | 3951 | if (IsAttachment) |
3952 | m_rootPart.AttachedPos = newPos; | 3952 | m_rootPart.AttachedPos = newPos; |
3953 | 3953 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 43ae880..de07131 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -771,9 +771,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
771 | set { m_damage = value; } | 771 | set { m_damage = value; } |
772 | } | 772 | } |
773 | 773 | ||
774 | |||
775 | |||
776 | |||
777 | public void setGroupPosition(Vector3 pos) | ||
778 | { | ||
779 | m_groupPosition = pos; | ||
780 | } | ||
781 | |||
774 | /// <summary> | 782 | /// <summary> |
775 | /// The position of the entire group that this prim belongs to. | 783 | /// The position of the entire group that this prim belongs to. |
776 | /// </summary> | 784 | /// </summary> |
785 | /// | ||
786 | |||
787 | |||
777 | public Vector3 GroupPosition | 788 | public Vector3 GroupPosition |
778 | { | 789 | { |
779 | get | 790 | get |
@@ -811,7 +822,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
811 | // Root prim actually goes at Position | 822 | // Root prim actually goes at Position |
812 | if (ParentID == 0) | 823 | if (ParentID == 0) |
813 | { | 824 | { |
814 | actor.Position = value; | 825 | actor.Position = value; |
815 | } | 826 | } |
816 | else | 827 | else |
817 | { | 828 | { |
@@ -832,6 +843,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
832 | } | 843 | } |
833 | } | 844 | } |
834 | 845 | ||
846 | public void setOffsetPosition(Vector3 pos) | ||
847 | { | ||
848 | m_offsetPosition = pos; | ||
849 | } | ||
850 | |||
835 | public Vector3 OffsetPosition | 851 | public Vector3 OffsetPosition |
836 | { | 852 | { |
837 | get { return m_offsetPosition; } | 853 | get { return m_offsetPosition; } |
@@ -890,6 +906,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
890 | } | 906 | } |
891 | } | 907 | } |
892 | 908 | ||
909 | public void setRotationOffset(Quaternion q) | ||
910 | { | ||
911 | m_rotationOffset = q; | ||
912 | } | ||
913 | |||
893 | public Quaternion RotationOffset | 914 | public Quaternion RotationOffset |
894 | { | 915 | { |
895 | get | 916 | get |