From 397aa74777bc0c54ecd9e1b286e59e9de0a4f3c2 Mon Sep 17 00:00:00 2001 From: teravus Date: Tue, 1 Jan 2013 23:07:37 -0500 Subject: * Fixes the attachment scripted rotation bug. The problem is the code was relying on m_host.ParentId = 0 to determine if the attachment should be rotated against root prim offset. To fix it for attachments, we also need to check if the host's localID == RootPart's localID. otherwise we are cumulatively rotating against the host's root part rotation offset (which in this case, is it's own rotation) --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7ff30ca..a559683 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2353,8 +2353,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + + SceneObjectPart rootPart = m_host.ParentGroup.RootPart; + + + // Teravus: if (m_host.ParentID == 0) is bug code because the ParentID for the Avatar will cause this to be nonzero for root prim attachments + // which is then treated like a child prim rotation and it's offset gets cumulatively multiplied against. + // to fix the scripted rotations we also have to check to see if the root part localid is the same as the host's localid. + // RootPart != null should shortcircuit + // try to let this work as in SL... - if (m_host.ParentID == 0) + if (m_host.ParentID == 0 ) //|| (rootPart != null && m_host.LocalId == rootPart.LocalId)) { // special case: If we are root, rotate complete SOG to new rotation SetRot(m_host, rot); @@ -2362,7 +2371,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - SceneObjectPart rootPart = m_host.ParentGroup.RootPart; + if (rootPart != null) // better safe than sorry { SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot); -- cgit v1.1 From f9148e5fc7178fe24323a67d8e26ba4a04a4a9e3 Mon Sep 17 00:00:00 2001 From: teravus Date: Tue, 1 Jan 2013 23:11:46 -0500 Subject: * This is actually the fix described the last commit.. I had commented it out to see if the problem had affected all attachments or just HUD attachments. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a559683..1fe095b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2363,7 +2363,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // RootPart != null should shortcircuit // try to let this work as in SL... - if (m_host.ParentID == 0 ) //|| (rootPart != null && m_host.LocalId == rootPart.LocalId)) + if (m_host.ParentID == 0 || (rootPart != null && m_host.LocalId == rootPart.LocalId)) { // special case: If we are root, rotate complete SOG to new rotation SetRot(m_host, rot); -- cgit v1.1 From 92c26e49947040a212db85ac4f59e5ba7f395856 Mon Sep 17 00:00:00 2001 From: teravus Date: Tue, 1 Jan 2013 23:55:24 -0500 Subject: * ubit pointed out another place where that check needed to be updated and I normalized it. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1fe095b..7e77b0f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2354,16 +2354,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - SceneObjectPart rootPart = m_host.ParentGroup.RootPart; - - // Teravus: if (m_host.ParentID == 0) is bug code because the ParentID for the Avatar will cause this to be nonzero for root prim attachments // which is then treated like a child prim rotation and it's offset gets cumulatively multiplied against. // to fix the scripted rotations we also have to check to see if the root part localid is the same as the host's localid. // RootPart != null should shortcircuit // try to let this work as in SL... - if (m_host.ParentID == 0 || (rootPart != null && m_host.LocalId == rootPart.LocalId)) + if (m_host.ParentID == 0 || (m_host.ParentGroup != null && m_host == m_host.ParentGroup.RootPart)) { // special case: If we are root, rotate complete SOG to new rotation SetRot(m_host, rot); @@ -2371,7 +2368,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - + SceneObjectPart rootPart = m_host.ParentGroup.RootPart; if (rootPart != null) // better safe than sorry { SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot); @@ -7920,7 +7917,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Rotation q = rules.GetQuaternionItem(idx++); // try to let this work as in SL... - if (part.ParentID == 0) + if (part.ParentID == 0 || (part.ParentGroup != null && part == part.ParentGroup.RootPart)) { // special case: If we are root, rotate complete SOG to new rotation SetRot(part, q); -- cgit v1.1 From 27b0914681f715d2dd270030ac1bfa5f726bf787 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jan 2013 16:01:00 +0100 Subject: Prevent a null ref in llGetLinkPrimiteveParams. Still not a fix for the real issue. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7e77b0f..267a175 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8750,7 +8750,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api remaining = GetPrimParams(avatar, rules, ref res); } - if (remaining != null && remaining.Length > 0) + if ((object)remaining != null && remaining.Length > 0) { linknumber = remaining.GetLSLIntegerItem(0); rules = remaining.GetSublist(1, -1); -- cgit v1.1 From b5282810180a548d0c29892a38388c379105c13b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Jan 2013 17:01:09 +0000 Subject: stop endless loop in lGetLinkPrimitiveParams --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 267a175..faa92dc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8755,6 +8755,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api linknumber = remaining.GetLSLIntegerItem(0); rules = remaining.GetSublist(1, -1); } + else + break; } return res; -- cgit v1.1 From b70d50edf25aaef63292fa164e01ebb69025744b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Jan 2013 17:59:32 +0000 Subject: fix llGetRot and parameters prim_rotation for attachments. Only on LSL_api to avoid side effects for now --- .../Shared/Api/Implementation/LSL_Api.cs | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index faa92dc..0dfcfd6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2443,6 +2443,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); Quaternion q = m_host.GetWorldRotation(); + + if (m_host.ParentGroup != null && m_host.ParentGroup.AttachmentPoint != 0) + { + ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); + if (avatar != null) + { + if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) + q = avatar.CameraRotation * q; // Mouselook + else + q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate + } + } + return new LSL_Rotation(q.X, q.Y, q.Z, q.W); } @@ -2468,7 +2481,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api q = part.ParentGroup.GroupRotation; // just the group rotation return new LSL_Rotation(q.X, q.Y, q.Z, q.W); } + q = part.GetWorldRotation(); + if (part.ParentGroup.AttachmentPoint != 0) + { + ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); + if (avatar != null) + { + if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) + q = avatar.CameraRotation * q; // Mouselook + else + q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate + } + } + return new LSL_Rotation(q.X, q.Y, q.Z, q.W); } @@ -8709,7 +8735,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List remaining = GetPrimParams(m_host, rules, ref result); - while (remaining != null && remaining.Length > 2) + while ((object)remaining != null && remaining.Length > 2) { int linknumber = remaining.GetLSLIntegerItem(0); rules = remaining.GetSublist(1, -1); -- cgit v1.1