diff options
author | UbitUmarov | 2014-09-22 23:32:55 +0100 |
---|---|---|
committer | UbitUmarov | 2014-09-22 23:32:55 +0100 |
commit | 79e47eb60e304fba1bdf04b57d374a843c250ef8 (patch) | |
tree | 435e2feaab8268bdf9731e712864af8951076475 /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |
parent | debug show stack trace (diff) | |
download | opensim-SC_OLD-79e47eb60e304fba1bdf04b57d374a843c250ef8.zip opensim-SC_OLD-79e47eb60e304fba1bdf04b57d374a843c250ef8.tar.gz opensim-SC_OLD-79e47eb60e304fba1bdf04b57d374a843c250ef8.tar.bz2 opensim-SC_OLD-79e47eb60e304fba1bdf04b57d374a843c250ef8.tar.xz |
some changes in link/unlink code, bypassing complex variables set methods
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 50 |
1 files changed, 25 insertions, 25 deletions
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 | ||