diff options
author | Tom Grimshaw | 2010-06-19 10:06:09 -0700 |
---|---|---|
committer | Tom Grimshaw | 2010-06-19 10:06:09 -0700 |
commit | 49d7d8534ccd037f4690c5ac6aecd66a460960df (patch) | |
tree | f3ca2c089c01c31d1e643a645fe26ea072b9f79e /OpenSim | |
parent | Add "AvatarHeight/2" to the Home Position when set to avoid having the avatar... (diff) | |
download | opensim-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 '')
3 files changed, 188 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c7d21bb..3e92954 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -110,8 +110,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
110 | private long m_minPersistTime = 0; | 110 | private long m_minPersistTime = 0; |
111 | private Random m_rand; | 111 | private Random m_rand; |
112 | private bool m_suspendUpdates; | 112 | private bool m_suspendUpdates; |
113 | 113 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); | |
114 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); | 114 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); |
115 | 115 | ||
116 | public bool areUpdatesSuspended | 116 | public bool areUpdatesSuspended |
117 | { | 117 | { |
@@ -1116,6 +1116,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | /// <summary> | 1118 | /// <summary> |
1119 | /// Add the avatar to this linkset (avatar is sat). | ||
1120 | /// </summary> | ||
1121 | /// <param name="agentID"></param> | ||
1122 | public void AddAvatar(UUID agentID) | ||
1123 | { | ||
1124 | ScenePresence presence; | ||
1125 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1126 | { | ||
1127 | if (!m_linkedAvatars.Contains(presence)) | ||
1128 | { | ||
1129 | m_linkedAvatars.Add(presence); | ||
1130 | } | ||
1131 | } | ||
1132 | } | ||
1133 | |||
1134 | /// <summary> | ||
1135 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1136 | /// </summary> | ||
1137 | /// <param name="agentID"></param> | ||
1138 | public void DeleteAvatar(UUID agentID) | ||
1139 | { | ||
1140 | ScenePresence presence; | ||
1141 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1142 | { | ||
1143 | if (m_linkedAvatars.Contains(presence)) | ||
1144 | { | ||
1145 | m_linkedAvatars.Remove(presence); | ||
1146 | } | ||
1147 | } | ||
1148 | } | ||
1149 | |||
1150 | /// <summary> | ||
1151 | /// Returns the list of linked presences (avatars sat on this group) | ||
1152 | /// </summary> | ||
1153 | /// <param name="agentID"></param> | ||
1154 | public List<ScenePresence> GetLinkedAvatars() | ||
1155 | { | ||
1156 | return m_linkedAvatars; | ||
1157 | } | ||
1158 | |||
1159 | /// <summary> | ||
1119 | /// Attach this scene object to the given avatar. | 1160 | /// Attach this scene object to the given avatar. |
1120 | /// </summary> | 1161 | /// </summary> |
1121 | /// <param name="agentID"></param> | 1162 | /// <param name="agentID"></param> |
@@ -2974,6 +3015,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2974 | } | 3015 | } |
2975 | } | 3016 | } |
2976 | 3017 | ||
3018 | |||
3019 | |||
3020 | /// <summary> | ||
3021 | /// Gets the number of parts | ||
3022 | /// </summary> | ||
3023 | /// <returns></returns> | ||
3024 | public int GetPartCount() | ||
3025 | { | ||
3026 | return Children.Count; | ||
3027 | } | ||
3028 | |||
2977 | /// <summary> | 3029 | /// <summary> |
2978 | /// Get the parts of this scene object | 3030 | /// Get the parts of this scene object |
2979 | /// </summary> | 3031 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d4fc6cd..76267ab 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -219,6 +219,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
219 | //PauPaw:Proper PID Controler for autopilot************ | 219 | //PauPaw:Proper PID Controler for autopilot************ |
220 | private bool m_moveToPositionInProgress; | 220 | private bool m_moveToPositionInProgress; |
221 | private Vector3 m_moveToPositionTarget; | 221 | private Vector3 m_moveToPositionTarget; |
222 | private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
222 | 223 | ||
223 | private bool m_followCamAuto; | 224 | private bool m_followCamAuto; |
224 | 225 | ||
@@ -537,10 +538,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
537 | } | 538 | } |
538 | } | 539 | } |
539 | 540 | ||
541 | public Quaternion OffsetRotation | ||
542 | { | ||
543 | get { return m_offsetRotation; } | ||
544 | set { m_offsetRotation = value; } | ||
545 | } | ||
546 | |||
540 | public Quaternion Rotation | 547 | public Quaternion Rotation |
541 | { | 548 | { |
542 | get { return m_bodyRot; } | 549 | get { |
543 | set { m_bodyRot = value; } | 550 | if (m_parentID != 0) |
551 | { | ||
552 | if (m_offsetRotation != null) | ||
553 | { | ||
554 | return m_offsetRotation; | ||
555 | } | ||
556 | else | ||
557 | { | ||
558 | return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
559 | } | ||
560 | |||
561 | } | ||
562 | else | ||
563 | { | ||
564 | return m_bodyRot; | ||
565 | } | ||
566 | } | ||
567 | set { | ||
568 | m_bodyRot = value; | ||
569 | if (m_parentID != 0) | ||
570 | { | ||
571 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
572 | } | ||
573 | } | ||
544 | } | 574 | } |
545 | 575 | ||
546 | public Quaternion PreviousRotation | 576 | public Quaternion PreviousRotation |
@@ -1795,6 +1825,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1795 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! | 1825 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! |
1796 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. | 1826 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. |
1797 | part.IsOccupied = false; | 1827 | part.IsOccupied = false; |
1828 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); | ||
1798 | } | 1829 | } |
1799 | else | 1830 | else |
1800 | { | 1831 | { |
@@ -1804,6 +1835,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1804 | 1835 | ||
1805 | m_parentPosition = Vector3.Zero; | 1836 | m_parentPosition = Vector3.Zero; |
1806 | m_parentID = 0; | 1837 | m_parentID = 0; |
1838 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1807 | SendFullUpdateToAllClients(); | 1839 | SendFullUpdateToAllClients(); |
1808 | m_requestedSitTargetID = 0; | 1840 | m_requestedSitTargetID = 0; |
1809 | 1841 | ||
@@ -1904,6 +1936,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1904 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it | 1936 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1905 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one | 1937 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1906 | sitOrientation = avSitOrientation; // Change rotatione to the scripted one | 1938 | sitOrientation = avSitOrientation; // Change rotatione to the scripted one |
1939 | OffsetRotation = avSitOrientation; | ||
1907 | autopilot = false; // Jump direct to scripted llSitPos() | 1940 | autopilot = false; // Jump direct to scripted llSitPos() |
1908 | } | 1941 | } |
1909 | else | 1942 | else |
@@ -2311,6 +2344,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2311 | m_bodyRot = sitTargetOrient; | 2344 | m_bodyRot = sitTargetOrient; |
2312 | m_parentPosition = part.AbsolutePosition; | 2345 | m_parentPosition = part.AbsolutePosition; |
2313 | part.IsOccupied = true; | 2346 | part.IsOccupied = true; |
2347 | part.ParentGroup.AddAvatar(agentID); | ||
2314 | Console.WriteLine("Scripted Sit ofset {0}", m_pos); | 2348 | Console.WriteLine("Scripted Sit ofset {0}", m_pos); |
2315 | } | 2349 | } |
2316 | else | 2350 | else |
@@ -2341,6 +2375,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); | |||
2341 | 2375 | ||
2342 | m_parentPosition = part.AbsolutePosition; | 2376 | m_parentPosition = part.AbsolutePosition; |
2343 | part.IsOccupied = true; | 2377 | part.IsOccupied = true; |
2378 | part.ParentGroup.AddAvatar(agentID); | ||
2344 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation | 2379 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation |
2345 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center | 2380 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center |
2346 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + | 2381 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + |
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) |