From 49d7d8534ccd037f4690c5ac6aecd66a460960df Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 19 Jun 2010 10:06:09 -0700 Subject: Allow moving an avatar as part of a linkset using llSetLinkPrimitiveParams. This unlocks an awful lot of poseball-free content, and is a step towards resolving mantis #59. --- .../Shared/Api/Implementation/LSL_Api.cs | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fe8c70e..61c5add 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -219,6 +219,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public List GetLinkAvatars(int linkType) + { + List ret = new List(); + if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) + return ret; + + List avs = m_host.ParentGroup.GetLinkedAvatars(); + + switch (linkType) + { + case ScriptBaseClass.LINK_SET: + return avs; + + case ScriptBaseClass.LINK_ROOT: + return ret; + + case ScriptBaseClass.LINK_ALL_OTHERS: + return avs; + + case ScriptBaseClass.LINK_ALL_CHILDREN: + return avs; + + case ScriptBaseClass.LINK_THIS: + return ret; + + default: + if (linkType < 0) + return ret; + + int partCount = m_host.ParentGroup.GetPartCount(); + + if (linkType <= partCount) + { + return ret; + } + else + { + linkType = linkType - partCount; + if (linkType > avs.Count) + { + return ret; + } + else + { + ret.Add(avs[linkType-1]); + return ret; + } + } + } + } + public List GetLinkParts(int linkType) { List ret = new List(); @@ -7152,6 +7203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); List parts = GetLinkParts(linknumber); + List avatars = GetLinkAvatars(linknumber); if (parts.Count>0) { try @@ -7165,6 +7217,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api parts[0].ParentGroup.areUpdatesSuspended = false; } } + if (avatars.Count > 0) + { + foreach (ScenePresence avatar in avatars) + SetPrimParams(avatar, rules); + } } public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) @@ -7172,6 +7229,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api llSetLinkPrimitiveParams(linknumber, rules); } + protected void SetPrimParams(ScenePresence av, LSL_List rules) + { + //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. + //We only support PRIM_POSITION and PRIM_ROTATION + + int idx = 0; + + while (idx < rules.Length) + { + int code = rules.GetLSLIntegerItem(idx++); + + int remain = rules.Length - idx; + + + + switch (code) + { + case (int)ScriptBaseClass.PRIM_POSITION: + if (remain < 1) + return; + LSL_Vector v; + v = rules.GetVector3Item(idx++); + av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); + av.SendFullUpdateToAllClients(); + + break; + + case (int)ScriptBaseClass.PRIM_ROTATION: + if (remain < 1) + return; + LSL_Rotation r; + r = rules.GetQuaternionItem(idx++); + av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); + av.SendFullUpdateToAllClients(); + break; + } + } + + } + protected void SetPrimParams(SceneObjectPart part, LSL_List rules) { if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) -- cgit v1.1