From acea31518b00b02e2ba8b08106a76de0fbef29ab Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 17 Jul 2009 14:58:54 +0000 Subject: fixed the bug where changing the rotation of a selection of prims in a linkset, made each of those prims rotate around its own centre rather than around the geometric centre of the selection like they should do (and like the client expects). This involved adding a new OnUpdatePrimSingleRotationPosition event to IClientAPI so that we can get the changed position from the client. Btw adding new events to IClientAPI is really tedious where you have to copy the change across to at least 5 or 6 other files. [Note this doesn't fix the bug where any rotation changes to the root prim (but not the whole linkset) cause rotation errors on the child prims.] --- OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 1 + .../Client/VWoHTTP/ClientStack/VWHClientView.cs | 1 + OpenSim/Framework/IClientAPI.cs | 3 + .../Region/ClientStack/LindenUDP/LLClientView.cs | 22 ++++--- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.cs | 1 + OpenSim/Region/Framework/Scenes/SceneGraph.cs | 19 ++++++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 70 +++++++++++++++++++++- .../Server/IRCClientView.cs | 1 + .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + OpenSim/Tests/Common/Mock/TestClient.cs | 1 + 11 files changed, 109 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index df1b4a3..d8980c1 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -624,6 +624,7 @@ namespace OpenSim.Client.MXP.ClientStack public event UpdateVector OnUpdatePrimGroupPosition; public event UpdateVector OnUpdatePrimSinglePosition; public event UpdatePrimRotation OnUpdatePrimGroupRotation; + public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; public event UpdateVector OnUpdatePrimScale; diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index c0c7625..4570395 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -272,6 +272,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack public event UpdateVector OnUpdatePrimSinglePosition = delegate { }; public event UpdatePrimRotation OnUpdatePrimGroupRotation = delegate { }; public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation = delegate { }; + public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition = delegate { }; public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation = delegate { }; public event UpdateVector OnUpdatePrimScale = delegate { }; public event UpdateVector OnUpdatePrimGroupScale = delegate { }; diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index efde5ce..fea0cea 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -129,6 +129,8 @@ namespace OpenSim.Framework public delegate void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient); + public delegate void UpdatePrimSingleRotationPosition( uint localID, Quaternion rot, Vector3 pos, IClientAPI remoteClient); + public delegate void UpdatePrimGroupRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient); public delegate void ObjectDuplicate(uint localID, Vector3 offset, uint dupeFlags, UUID AgentID, UUID GroupID); @@ -633,6 +635,7 @@ namespace OpenSim.Framework event UpdateVector OnUpdatePrimSinglePosition; event UpdatePrimRotation OnUpdatePrimGroupRotation; event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; + event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; event UpdateVector OnUpdatePrimScale; event UpdateVector OnUpdatePrimGroupScale; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 3fdb386..a13f6d4 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -267,6 +267,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private UpdateVector handlerUpdatePrimSinglePosition; //OnUpdatePrimSinglePosition; private UpdatePrimSingleRotation handlerUpdatePrimSingleRotation; //OnUpdatePrimSingleRotation; + private UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition; //OnUpdatePrimSingleRotation; private UpdateVector handlerUpdatePrimScale; //OnUpdatePrimScale; private UpdateVector handlerUpdatePrimGroupScale; //OnUpdateGroupScale; private UpdateVector handlerUpdateVector; //OnUpdatePrimGroupPosition; @@ -1095,6 +1096,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event UpdateVector OnUpdatePrimSinglePosition; public event UpdatePrimRotation OnUpdatePrimGroupRotation; public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; + public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; public event UpdateVector OnUpdatePrimScale; public event UpdateVector OnUpdatePrimGroupScale; @@ -4481,18 +4483,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation; if (handlerUpdatePrimSingleRotation != null) { - //m_log.Debug("new tab rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); + // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W); handlerUpdatePrimSingleRotation(localId, rot1, this); } break; case 3: - + Vector3 rotPos = new Vector3(block.Data, 0); Quaternion rot2 = new Quaternion(block.Data, 12, true); - handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation; - if (handlerUpdatePrimSingleRotation != null) + + handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition; + if (handlerUpdatePrimSingleRotationPosition != null) { - //m_log.Debug("new mouse rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); - handlerUpdatePrimSingleRotation(localId, rot2, this); + // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z); + // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W); + handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this); } break; case 4: @@ -4541,7 +4545,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; if (handlerUpdatePrimRotation != null) { - // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); + // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W); handlerUpdatePrimRotation(localId, rot3, this); } break; @@ -4552,8 +4556,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation; if (handlerUpdatePrimGroupRotation != null) { - //m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); - // m_log.Debug("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); + // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); + // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W); handlerUpdatePrimGroupRotation(localId, pos3, rot4, this); } break; diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 5e33729..ed38046 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -117,6 +117,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event UpdateVector OnUpdatePrimGroupPosition; public event UpdateVector OnUpdatePrimSinglePosition; public event UpdatePrimRotation OnUpdatePrimGroupRotation; + public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; public event UpdateVector OnUpdatePrimScale; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 81d54e7..63cf9ce 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1964,6 +1964,7 @@ namespace OpenSim.Region.Framework.Scenes client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation; client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimRotation; client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; + client.OnUpdatePrimSingleRotationPosition += m_sceneGraph.UpdatePrimSingleRotationPosition; client.OnUpdatePrimScale += m_sceneGraph.UpdatePrimScale; client.OnUpdatePrimGroupScale += m_sceneGraph.UpdatePrimGroupScale; client.OnUpdateExtraParams += m_sceneGraph.UpdateExtraParam; diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 62870d5..3f63481 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1207,6 +1207,25 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// + protected internal void UpdatePrimSingleRotationPosition(uint localID, Quaternion rot, Vector3 pos, IClientAPI remoteClient) + { + SceneObjectGroup group = GetGroupByPrim(localID); + if (group != null) + { + if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) + { + group.UpdateSingleRotation(rot,pos, localID); + } + } + } + + + /// + /// + /// + /// + /// + /// protected internal void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e987445..00ae504 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -625,6 +625,8 @@ namespace OpenSim.Region.Framework.Scenes Vector3 backBottomLeft; Vector3 backBottomRight; + // Vector3[] corners = new Vector3[8]; + Vector3 orig = Vector3.Zero; frontTopLeft.X = orig.X - (part.Scale.X / 2); @@ -660,6 +662,36 @@ namespace OpenSim.Region.Framework.Scenes backBottomRight.Y = orig.Y + (part.Scale.Y / 2); backBottomRight.Z = orig.Z - (part.Scale.Z / 2); + //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); + //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); + //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); + //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); + //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); + //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); + //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); + //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); + + //for (int i = 0; i < 8; i++) + //{ + // corners[i] = corners[i] * worldRot; + // corners[i] += offset; + + // if (corners[i].X > maxX) + // maxX = corners[i].X; + // if (corners[i].X < minX) + // minX = corners[i].X; + + // if (corners[i].Y > maxY) + // maxY = corners[i].Y; + // if (corners[i].Y < minY) + // minY = corners[i].Y; + + // if (corners[i].Z > maxZ) + // maxZ = corners[i].Y; + // if (corners[i].Z < minZ) + // minZ = corners[i].Z; + //} + frontTopLeft = frontTopLeft * worldRot; frontTopRight = frontTopRight * worldRot; frontBottomLeft = frontBottomLeft * worldRot; @@ -681,6 +713,15 @@ namespace OpenSim.Region.Framework.Scenes backTopLeft += offset; backTopRight += offset; + //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); + //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); + //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); + //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); + //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); + //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); + //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); + //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); + if (frontTopRight.X > maxX) maxX = frontTopRight.X; if (frontTopLeft.X > maxX) @@ -801,15 +842,15 @@ namespace OpenSim.Region.Framework.Scenes if (lower > maxZ) { offsetHeight = lower - (boundingBox.Z / 2); - + } else if (maxZ > lower) { offsetHeight = maxZ - (boundingBox.Z / 2); offsetHeight *= -1; } - - // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); + + // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); return boundingBox; } #endregion @@ -3017,6 +3058,29 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// + /// + public void UpdateSingleRotation(Quaternion rot, Vector3 pos, uint localID) + { + SceneObjectPart part = GetChildPart(localID); + if (part != null) + { + if (part.UUID == m_rootPart.UUID) + { + UpdateRootRotation(rot); + AbsolutePosition = pos; + } + else + { + part.UpdateRotation(rot); + part.OffsetPosition = pos; + } + } + } + + /// + /// + /// + /// private void UpdateRootRotation(Quaternion rot) { Quaternion axRot = rot; diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 8ec1780..776e972 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -699,6 +699,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event UpdateVector OnUpdatePrimSinglePosition; public event UpdatePrimRotation OnUpdatePrimGroupRotation; public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; + public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; public event UpdateVector OnUpdatePrimScale; public event UpdateVector OnUpdatePrimGroupScale; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 228683e..a1ed6ee 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -223,6 +223,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event UpdateVector OnUpdatePrimGroupPosition; public event UpdateVector OnUpdatePrimSinglePosition; public event UpdatePrimRotation OnUpdatePrimGroupRotation; + public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; public event UpdateVector OnUpdatePrimScale; diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index c76d180..21541e1 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -130,6 +130,7 @@ namespace OpenSim.Tests.Common.Mock public event UpdateVector OnUpdatePrimSinglePosition; public event UpdatePrimRotation OnUpdatePrimGroupRotation; public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; + public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; public event UpdateVector OnUpdatePrimScale; public event UpdateVector OnUpdatePrimGroupScale; -- cgit v1.1