aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorTom Grimshaw2010-06-19 10:06:09 -0700
committerTom Grimshaw2010-06-19 10:06:09 -0700
commit49d7d8534ccd037f4690c5ac6aecd66a460960df (patch)
treef3ca2c089c01c31d1e643a645fe26ea072b9f79e /OpenSim/Region/ScriptEngine/Shared
parentAdd "AvatarHeight/2" to the Home Position when set to avoid having the avatar... (diff)
downloadopensim-SC-49d7d8534ccd037f4690c5ac6aecd66a460960df.zip
opensim-SC-49d7d8534ccd037f4690c5ac6aecd66a460960df.tar.gz
opensim-SC-49d7d8534ccd037f4690c5ac6aecd66a460960df.tar.bz2
opensim-SC-49d7d8534ccd037f4690c5ac6aecd66a460960df.tar.xz
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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs97
1 files changed, 97 insertions, 0 deletions
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
219 } 219 }
220 } 220 }
221 221
222 public List<ScenePresence> GetLinkAvatars(int linkType)
223 {
224 List<ScenePresence> ret = new List<ScenePresence>();
225 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
226 return ret;
227
228 List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars();
229
230 switch (linkType)
231 {
232 case ScriptBaseClass.LINK_SET:
233 return avs;
234
235 case ScriptBaseClass.LINK_ROOT:
236 return ret;
237
238 case ScriptBaseClass.LINK_ALL_OTHERS:
239 return avs;
240
241 case ScriptBaseClass.LINK_ALL_CHILDREN:
242 return avs;
243
244 case ScriptBaseClass.LINK_THIS:
245 return ret;
246
247 default:
248 if (linkType < 0)
249 return ret;
250
251 int partCount = m_host.ParentGroup.GetPartCount();
252
253 if (linkType <= partCount)
254 {
255 return ret;
256 }
257 else
258 {
259 linkType = linkType - partCount;
260 if (linkType > avs.Count)
261 {
262 return ret;
263 }
264 else
265 {
266 ret.Add(avs[linkType-1]);
267 return ret;
268 }
269 }
270 }
271 }
272
222 public List<SceneObjectPart> GetLinkParts(int linkType) 273 public List<SceneObjectPart> GetLinkParts(int linkType)
223 { 274 {
224 List<SceneObjectPart> ret = new List<SceneObjectPart>(); 275 List<SceneObjectPart> ret = new List<SceneObjectPart>();
@@ -7152,6 +7203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7152 m_host.AddScriptLPS(1); 7203 m_host.AddScriptLPS(1);
7153 7204
7154 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7205 List<SceneObjectPart> parts = GetLinkParts(linknumber);
7206 List<ScenePresence> avatars = GetLinkAvatars(linknumber);
7155 if (parts.Count>0) 7207 if (parts.Count>0)
7156 { 7208 {
7157 try 7209 try
@@ -7165,6 +7217,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7165 parts[0].ParentGroup.areUpdatesSuspended = false; 7217 parts[0].ParentGroup.areUpdatesSuspended = false;
7166 } 7218 }
7167 } 7219 }
7220 if (avatars.Count > 0)
7221 {
7222 foreach (ScenePresence avatar in avatars)
7223 SetPrimParams(avatar, rules);
7224 }
7168 } 7225 }
7169 7226
7170 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) 7227 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules)
@@ -7172,6 +7229,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7172 llSetLinkPrimitiveParams(linknumber, rules); 7229 llSetLinkPrimitiveParams(linknumber, rules);
7173 } 7230 }
7174 7231
7232 protected void SetPrimParams(ScenePresence av, LSL_List rules)
7233 {
7234 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7235 //We only support PRIM_POSITION and PRIM_ROTATION
7236
7237 int idx = 0;
7238
7239 while (idx < rules.Length)
7240 {
7241 int code = rules.GetLSLIntegerItem(idx++);
7242
7243 int remain = rules.Length - idx;
7244
7245
7246
7247 switch (code)
7248 {
7249 case (int)ScriptBaseClass.PRIM_POSITION:
7250 if (remain < 1)
7251 return;
7252 LSL_Vector v;
7253 v = rules.GetVector3Item(idx++);
7254 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7255 av.SendFullUpdateToAllClients();
7256
7257 break;
7258
7259 case (int)ScriptBaseClass.PRIM_ROTATION:
7260 if (remain < 1)
7261 return;
7262 LSL_Rotation r;
7263 r = rules.GetQuaternionItem(idx++);
7264 av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7265 av.SendFullUpdateToAllClients();
7266 break;
7267 }
7268 }
7269
7270 }
7271
7175 protected void SetPrimParams(SceneObjectPart part, LSL_List rules) 7272 protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
7176 { 7273 {
7177 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 7274 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)