* Make code fix to address prim rotation unlink issues (mantis 383, 454. 369)

* Many thanks to alex_carnell for the necessary information for this
ThreadPoolClientBranch
Justin Clarke Casey 2008-02-13 14:45:32 +00:00
parent 49a5a00b80
commit 3624efde85
1 changed files with 16 additions and 5 deletions

View File

@ -868,12 +868,13 @@ namespace OpenSim.Region.Environment.Scenes
#region Packet Handlers #region Packet Handlers
/// <summary> /// <summary>
/// /// Link the prims in a given group to this group
/// </summary> /// </summary>
/// <param name="objectGroup"></param> /// <param name="objectGroup">The group of prims which should be linked to this group</param>
public void LinkToGroup(SceneObjectGroup objectGroup) public void LinkToGroup(SceneObjectGroup objectGroup)
{ {
SceneObjectPart linkPart = objectGroup.m_rootPart; SceneObjectPart linkPart = objectGroup.m_rootPart;
Vector3 oldGroupPosition = Vector3 oldGroupPosition =
new Vector3(linkPart.GroupPosition.X, linkPart.GroupPosition.Y, linkPart.GroupPosition.Z); new Vector3(linkPart.GroupPosition.X, linkPart.GroupPosition.Y, linkPart.GroupPosition.Z);
Quaternion oldRootRotation = Quaternion oldRootRotation =
@ -882,20 +883,23 @@ namespace OpenSim.Region.Environment.Scenes
linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition;
linkPart.GroupPosition = AbsolutePosition; linkPart.GroupPosition = AbsolutePosition;
Vector3 axPos = new Vector3(linkPart.OffsetPosition.X, linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z); Vector3 axPos = new Vector3(linkPart.OffsetPosition.X, linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z);
Quaternion parentRot = Quaternion parentRot =
new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y,
m_rootPart.RotationOffset.Z); m_rootPart.RotationOffset.Z);
axPos = parentRot.Inverse()*axPos; axPos = parentRot.Inverse()*axPos;
linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
Quaternion oldRot = Quaternion oldRot =
new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y,
linkPart.RotationOffset.Z); linkPart.RotationOffset.Z);
Quaternion newRot = parentRot.Inverse()*oldRot; Quaternion newRot = parentRot.Inverse()*oldRot;
linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
linkPart.ParentID = m_rootPart.LocalID; linkPart.ParentID = m_rootPart.LocalID;
linkPart.LinkNum = m_parts.Count; linkPart.LinkNum = m_parts.Count;
m_parts.Add(linkPart.UUID, linkPart); m_parts.Add(linkPart.UUID, linkPart);
linkPart.SetParent(this); linkPart.SetParent(this);
@ -935,6 +939,7 @@ namespace OpenSim.Region.Environment.Scenes
if (null != linkPart) if (null != linkPart)
{ {
LLQuaternion worldRot = linkPart.GetWorldRotation();
// Remove the part from this object // Remove the part from this object
m_parts.Remove(linkPart.UUID); m_parts.Remove(linkPart.UUID);
@ -944,6 +949,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor);
} }
// We need to reset the child part's position // We need to reset the child part's position
// ready for life as a separate object after being a part of another object // ready for life as a separate object after being a part of another object
Quaternion parentRot Quaternion parentRot
@ -964,6 +970,10 @@ namespace OpenSim.Region.Environment.Scenes
linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition;
linkPart.OffsetPosition = new LLVector3(0, 0, 0); linkPart.OffsetPosition = new LLVector3(0, 0, 0);
linkPart.RotationOffset = worldRot;
// This chunk is probably unnecesary now - delete later on
/*
Quaternion oldRot Quaternion oldRot
= new Quaternion( = new Quaternion(
linkPart.RotationOffset.W, linkPart.RotationOffset.W,
@ -972,6 +982,7 @@ namespace OpenSim.Region.Environment.Scenes
linkPart.RotationOffset.Z); linkPart.RotationOffset.Z);
Quaternion newRot = parentRot*oldRot; Quaternion newRot = parentRot*oldRot;
linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
*/
// Add physics information back to delinked part if appropriate // Add physics information back to delinked part if appropriate
// XXX This is messy and should be refactorable with the similar section in // XXX This is messy and should be refactorable with the similar section in