aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-27 03:25:00 +0000
committerTeravus Ovares2007-12-27 03:25:00 +0000
commit87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8 (patch)
tree69599226423b5a4620ab4308b3e0088328894bde /OpenSim/Region
parentPrim inventory persistence phase 1: Creation of preliminary table in sqlite. (diff)
downloadopensim-SC_OLD-87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8.zip
opensim-SC_OLD-87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8.tar.gz
opensim-SC_OLD-87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8.tar.bz2
opensim-SC_OLD-87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8.tar.xz
* Added slightly better object sit handling
* Added sit handling for sit targets * Implemented llSitTarget() * Implemented llAvatarOnSitTarget() * Sit targets do not persist sim restart.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs182
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs4
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs12
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs34
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs110
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs14
6 files changed, 245 insertions, 111 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 823214a..45806ff 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -1999,118 +1999,128 @@ namespace OpenSim.Region.ClientStack
1999 { 1999 {
2000 // Can't act on Null Data 2000 // Can't act on Null Data
2001 if (multipleupdate.ObjectData[i].Data != null) 2001 if (multipleupdate.ObjectData[i].Data != null)
2002 { 2002 {
2003 if (tScene.PermissionsMngr.CanEditObjectPosition(simClient.AgentId, tScene.GetSceneObjectPart(multipleupdate.ObjectData[i].ObjectLocalID).UUID)) 2003 LLUUID editobj = tScene.GetSceneObjectPart(multipleupdate.ObjectData[i].ObjectLocalID).UUID;
2004 if (editobj != null)
2004 { 2005 {
2005 #region position 2006 if (tScene.PermissionsMngr.CanEditObjectPosition(simClient.AgentId, editobj))
2006
2007 if (multipleupdate.ObjectData[i].Type == 9) //change position
2008 { 2007 {
2009 if (OnUpdatePrimGroupPosition != null) 2008 #region position
2009
2010 if (multipleupdate.ObjectData[i].Type == 9) //change position
2010 { 2011 {
2011 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 2012 if (OnUpdatePrimGroupPosition != null)
2012 OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 2013 {
2014 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
2015 OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
2016 }
2013 } 2017 }
2014 } 2018 else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position
2015 else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position
2016 {
2017 if (OnUpdatePrimSinglePosition != null)
2018 { 2019 {
2019 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 2020 if (OnUpdatePrimSinglePosition != null)
2020 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 2021 {
2021 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 2022 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
2023 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
2024 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
2025 }
2022 } 2026 }
2023 } 2027 #endregion position
2024 #endregion position 2028 #region rotation
2025 #region rotation
2026 2029
2027 else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab 2030 else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab
2028 {
2029 if (OnUpdatePrimSingleRotation != null)
2030 { 2031 {
2031 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); 2032 if (OnUpdatePrimSingleRotation != null)
2032 //System.Console.WriteLine("new tab rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2033 {
2033 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); 2034 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
2035 //System.Console.WriteLine("new tab rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2036 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
2037 }
2034 } 2038 }
2035 } 2039 else if (multipleupdate.ObjectData[i].Type == 3) // single item of group rotation from mouse
2036 else if (multipleupdate.ObjectData[i].Type == 3) // single item of group rotation from mouse
2037 {
2038 if (OnUpdatePrimSingleRotation != null)
2039 { 2040 {
2040 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); 2041 if (OnUpdatePrimSingleRotation != null)
2041 //System.Console.WriteLine("new mouse rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2042 {
2042 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); 2043 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true);
2044 //System.Console.WriteLine("new mouse rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2045 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
2046 }
2043 } 2047 }
2044 } 2048 else if (multipleupdate.ObjectData[i].Type == 10) //group rotation from object tab
2045 else if (multipleupdate.ObjectData[i].Type == 10) //group rotation from object tab
2046 {
2047 if (OnUpdatePrimGroupRotation != null)
2048 { 2049 {
2049 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); 2050 if (OnUpdatePrimGroupRotation != null)
2050 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2051 {
2051 OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); 2052 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
2053 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2054 OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
2055 }
2052 } 2056 }
2053 } 2057 else if (multipleupdate.ObjectData[i].Type == 11) //group rotation from mouse
2054 else if (multipleupdate.ObjectData[i].Type == 11) //group rotation from mouse
2055 {
2056 if (OnUpdatePrimGroupMouseRotation != null)
2057 { 2058 {
2058 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 2059 if (OnUpdatePrimGroupMouseRotation != null)
2059 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); 2060 {
2060 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 2061 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
2061 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2062 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true);
2062 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); 2063 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
2064 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2065 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this);
2066 }
2063 } 2067 }
2064 } 2068 #endregion
2065 #endregion 2069 #region scale
2066 #region scale
2067 2070
2068 else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab 2071 else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab
2069 {
2070 if (OnUpdatePrimScale != null)
2071 { 2072 {
2072 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 2073 if (OnUpdatePrimScale != null)
2073 //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 2074 {
2074 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 2075 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
2075 2076 //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
2076 // Change the position based on scale (for bug number 246) 2077 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
2077 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 2078
2078 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 2079 // Change the position based on scale (for bug number 246)
2079 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 2080 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
2081 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
2082 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
2083 }
2080 } 2084 }
2081 } 2085 else if (multipleupdate.ObjectData[i].Type == 29) //group scale from mouse
2082 else if (multipleupdate.ObjectData[i].Type == 29) //group scale from mouse
2083 {
2084 if (OnUpdatePrimScale != null)
2085 { 2086 {
2086 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 2087 if (OnUpdatePrimScale != null)
2087 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); 2088 {
2088 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 2089 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
2089 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 2090 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z );
2090 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 2091 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
2092 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
2093 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
2094 }
2091 } 2095 }
2092 } 2096 else if (multipleupdate.ObjectData[i].Type == 5) //single prim scale from object tab
2093 else if (multipleupdate.ObjectData[i].Type == 5) //single prim scale from object tab
2094 {
2095 if (OnUpdatePrimScale != null)
2096 { 2097 {
2097 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 2098 if (OnUpdatePrimScale != null)
2098 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 2099 {
2099 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 2100 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
2101 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
2102 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
2103 }
2100 } 2104 }
2101 } 2105 else if (multipleupdate.ObjectData[i].Type == 21) //single prim scale from mouse
2102 else if (multipleupdate.ObjectData[i].Type == 21) //single prim scale from mouse
2103 {
2104 if (OnUpdatePrimScale != null)
2105 { 2106 {
2106 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 2107 if (OnUpdatePrimScale != null)
2107 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 2108 {
2108 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 2109 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
2110 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
2111 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
2112 }
2109 } 2113 }
2110 }
2111 2114
2112 #endregion 2115 #endregion
2116 }
2117 } // editobj != null;
2118 else
2119 {
2120 // It's a ghost! tell the client to delete it from view.
2121 simClient.SendKillObject(this.Scene.RegionInfo.RegionHandle, multipleupdate.ObjectData[i].ObjectLocalID);
2113 } 2122 }
2123
2114 } 2124 }
2115 } 2125 }
2116 return true; 2126 return true;
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
index a4c18d0..a232db8 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -123,9 +123,9 @@ namespace OpenSim.Region.ClientStack
123 /// <param name="circuitcode"></param> 123 /// <param name="circuitcode"></param>
124 public virtual void CloseCircuit(uint circuitcode) 124 public virtual void CloseCircuit(uint circuitcode)
125 { 125 {
126 OpenSim.Framework.Console.MainLog.Instance.Debug("PACKETSERVER", "Removing Circuit Code"); 126
127 m_networkHandler.RemoveClientCircuit(circuitcode); 127 m_networkHandler.RemoveClientCircuit(circuitcode);
128 OpenSim.Framework.Console.MainLog.Instance.Debug("PACKETSERVER", "Removed Circuit Code"); 128
129 //m_scene.ClientManager.CloseAllAgents(circuitcode); 129 //m_scene.ClientManager.CloseAllAgents(circuitcode);
130 } 130 }
131 131
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index a8a1ff6..47e0b3c 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -326,9 +326,9 @@ namespace OpenSim.Region.ClientStack
326 uint circuit; 326 uint circuit;
327 if (clientCircuits.TryGetValue(sender, out circuit)) 327 if (clientCircuits.TryGetValue(sender, out circuit))
328 { 328 {
329 MainLog.Instance.Debug("UDPSERVER", "CloseEndPoint:ClosingCircuit"); 329
330 m_packetServer.CloseCircuit(circuit); 330 m_packetServer.CloseCircuit(circuit);
331 MainLog.Instance.Debug("UDPSERVER", "CloseEndPoint:ClosedCircuit"); 331
332 } 332 }
333 } 333 }
334 334
@@ -381,13 +381,13 @@ namespace OpenSim.Region.ClientStack
381 EndPoint sendto = null; 381 EndPoint sendto = null;
382 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) 382 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
383 { 383 {
384 MainLog.Instance.Debug("UDPSERVER", "RemovingClientCircuit"); 384
385 clientCircuits.Remove(sendto); 385 clientCircuits.Remove(sendto);
386 MainLog.Instance.Debug("UDPSERVER", "Removed Client Circuit"); 386
387 387
388 MainLog.Instance.Debug("UDPSERVER", "Removing Reverse ClientCircuit"); 388
389 clientCircuits_reverse.Remove(circuitcode); 389 clientCircuits_reverse.Remove(circuitcode);
390 MainLog.Instance.Debug("UDPSERVER", "Removed Reverse ClientCircuit"); 390
391 } 391 }
392 } 392 }
393 } 393 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 34705db..bcd31c2 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -68,6 +68,11 @@ namespace OpenSim.Region.Environment.Scenes
68 public Int32 CreationDate; 68 public Int32 CreationDate;
69 public uint ParentID = 0; 69 public uint ParentID = 0;
70 70
71 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0);
72 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
73 private LLUUID m_SitTargetAvatar = LLUUID.Zero;
74
75
71 // Main grid has default permissions as follows 76 // Main grid has default permissions as follows
72 // 77 //
73 public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER; 78 public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER;
@@ -161,6 +166,8 @@ namespace OpenSim.Region.Environment.Scenes
161 //unkown if this will be kept, added as a way of removing the group position from the group class 166 //unkown if this will be kept, added as a way of removing the group position from the group class
162 protected LLVector3 m_groupPosition; 167 protected LLVector3 m_groupPosition;
163 168
169
170
164 public LLVector3 GroupPosition 171 public LLVector3 GroupPosition
165 { 172 {
166 get 173 get
@@ -774,6 +781,33 @@ namespace OpenSim.Region.Environment.Scenes
774 m_parentGroup = parent; 781 m_parentGroup = parent;
775 } 782 }
776 783
784 public void SetSitTarget(Vector3 offset, Quaternion orientation)
785 {
786 m_sitTargetPosition = offset;
787 m_sitTargetOrientation = orientation;
788 }
789
790 public Vector3 GetSitTargetPosition()
791 {
792 return m_sitTargetPosition;
793 }
794
795 public Quaternion GetSitTargetOrientation()
796 {
797 return m_sitTargetOrientation;
798 }
799
800 public void SetAvatarOnSitTarget(LLUUID avatarID)
801 {
802 m_SitTargetAvatar = avatarID;
803 }
804
805 public LLUUID GetAvatarOnSitTarget()
806 {
807 return m_SitTargetAvatar;
808 }
809
810
777 public LLUUID GetRootPartUUID() 811 public LLUUID GetRootPartUUID()
778 { 812 {
779 if (m_parentGroup != null) 813 if (m_parentGroup != null)
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 4b8ca97..9a937a2 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -537,7 +537,7 @@ namespace OpenSim.Region.Environment.Scenes
537 // and send a full object update. 537 // and send a full object update.
538 // There's no message to send the client to tell it to stop flying 538 // There's no message to send the client to tell it to stop flying
539 539
540 // Add 1/2 the avatar's height to it's position so it doesn't shoot into the air 540 // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
541 // when the avatar stands up 541 // when the avatar stands up
542 542
543 AbsolutePosition = AbsolutePosition + new LLVector3(0, 0, (m_avHeight/6)); 543 AbsolutePosition = AbsolutePosition + new LLVector3(0, 0, (m_avHeight/6));
@@ -748,6 +748,15 @@ namespace OpenSim.Region.Environment.Scenes
748 { 748 {
749 if (m_parentID != 0) 749 if (m_parentID != 0)
750 { 750 {
751
752 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
753 if (part != null)
754 {
755 // Reset sit target.
756 if (part.GetAvatarOnSitTarget() == UUID)
757 part.SetAvatarOnSitTarget(LLUUID.Zero);
758 }
759
751 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); 760 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
752 m_parentPosition = new LLVector3(); 761 m_parentPosition = new LLVector3();
753 762
@@ -769,34 +778,82 @@ namespace OpenSim.Region.Environment.Scenes
769 778
770 bool autopilot = true; 779 bool autopilot = true;
771 LLVector3 pos = new LLVector3(); 780 LLVector3 pos = new LLVector3();
781 LLQuaternion sitOrientation = new LLQuaternion(0,0,0,1);
772 782
773 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 783 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
774 if (part != null) 784 if (part != null)
775 { 785 {
776 // TODO: determine position to sit at based on scene geometry; don't trust offset from client 786 // TODO: determine position to sit at based on scene geometry; don't trust offset from client
777 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it 787 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
788
789
790 // Is a sit target available?
791 Vector3 avSitOffSet = part.GetSitTargetPosition();
792 Quaternion avSitOrientation = part.GetSitTargetOrientation();
793 LLUUID avOnTargetAlready = part.GetAvatarOnSitTarget();
794
795 bool SitTargetUnOccupied = (!(avOnTargetAlready != LLUUID.Zero));
796 bool SitTargetisSet = (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1));
797
798 if (SitTargetisSet && SitTargetUnOccupied)
799 {
800 part.SetAvatarOnSitTarget(UUID);
801 offset = new LLVector3(avSitOffSet.x,avSitOffSet.y,avSitOffSet.z);
802 sitOrientation = new LLQuaternion(avSitOrientation.w,avSitOrientation.x,avSitOrientation.y,avSitOrientation.z);
803 autopilot = false;
804
805 }
806
778 807
779 pos = part.AbsolutePosition + offset; 808 pos = part.AbsolutePosition + offset;
780 809
781 if (m_physicsActor != null) 810 if (m_physicsActor != null)
782 { 811 {
812 //
813 // If we're not using the client autopilot, we're immediately warping the avatar to the location
814 // We can remove the physicsActor until they stand up.
815 //
783 m_sitAvatarHeight = m_physicsActor.Size.Z; 816 m_sitAvatarHeight = m_physicsActor.Size.Z;
784 }
785 817
786 // this doesn't seem to quite work yet.... 818 if (autopilot)
787 // // if we're close, set the avatar position to the target position and forgo autopilot 819 {
788 // if (AbsolutePosition.GetDistanceTo(pos) < 2.5) 820
789 // { 821 if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5)
790 // autopilot = false; 822 {
791 // AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight); 823 autopilot = false;
792 // } 824
793 } 825 RemoveFromPhysicalScene();
826 AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight);
827
828 }
829 else
830 {
831
832 }
833 }
834 else
835 {
836 RemoveFromPhysicalScene();
837
838
839 }
840 } // Physactor != null
841 } // part != null
842
794 843
795 avatarSitResponse.SitTransform.AutoPilot = autopilot; 844 avatarSitResponse.SitTransform.AutoPilot = autopilot;
796 avatarSitResponse.SitTransform.SitPosition = offset; 845 avatarSitResponse.SitTransform.SitPosition = offset;
797 avatarSitResponse.SitTransform.SitRotation = new LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f); 846 avatarSitResponse.SitTransform.SitRotation = sitOrientation;
798 847
799 remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); 848 remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
849
850 // This calls HandleAgentSit twice, once from here, and the client calls
851 // HandleAgentSit itself after it gets to the location
852 // It doesn't get to the location until we've moved them there though
853 // which happens in HandleAgentSit :P
854 if (!autopilot)
855 HandleAgentSit(remoteClient, UUID);
856
800 } 857 }
801 858
802 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset) 859 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset)
@@ -806,7 +863,7 @@ namespace OpenSim.Region.Environment.Scenes
806 StandUp(); 863 StandUp();
807 } 864 }
808 865
809 SendSitResponse(remoteClient, targetID, offset); 866
810 867
811 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 868 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
812 869
@@ -819,6 +876,7 @@ namespace OpenSim.Region.Environment.Scenes
819 { 876 {
820 MainLog.Instance.Warn("Sit requested on unknown object: " + targetID.ToString()); 877 MainLog.Instance.Warn("Sit requested on unknown object: " + targetID.ToString());
821 } 878 }
879 SendSitResponse(remoteClient, targetID, offset);
822 } 880 }
823 881
824 public void HandleAgentSit(IClientAPI remoteClient, LLUUID agentID) 882 public void HandleAgentSit(IClientAPI remoteClient, LLUUID agentID)
@@ -827,8 +885,28 @@ namespace OpenSim.Region.Environment.Scenes
827 885
828 if (part != null) 886 if (part != null)
829 { 887 {
830 m_pos -= part.AbsolutePosition; 888 if (part.GetAvatarOnSitTarget() == UUID)
831 m_parentPosition = part.AbsolutePosition; 889 {
890 Vector3 sitTargetPos = part.GetSitTargetPosition();
891 Quaternion sitTargetOrient = part.GetSitTargetOrientation();
892
893 //Quaternion vq = new Quaternion(sitTargetPos.x, sitTargetPos.y+0.2f, sitTargetPos.z+0.2f, 0);
894 //Quaternion nq = new Quaternion(sitTargetOrient.w, -sitTargetOrient.x, -sitTargetOrient.y, -sitTargetOrient.z);
895
896 //Quaternion result = (sitTargetOrient * vq) * nq;
897
898 m_pos = new LLVector3(sitTargetPos.x, sitTargetPos.y, sitTargetPos.z);
899 m_bodyRot = sitTargetOrient;
900 //Rotation = sitTargetOrient;
901 m_parentPosition = part.AbsolutePosition;
902
903 //SendTerseUpdateToAllClients();
904 }
905 else
906 {
907 m_pos -= part.AbsolutePosition;
908 m_parentPosition = part.AbsolutePosition;
909 }
832 } 910 }
833 911
834 m_parentID = m_requestedSitTargetID; 912 m_parentID = m_requestedSitTargetID;
@@ -838,6 +916,10 @@ namespace OpenSim.Region.Environment.Scenes
838 916
839 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1); 917 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1);
840 SendFullUpdateToAllClients(); 918 SendFullUpdateToAllClients();
919 // This may seem stupid, but Our Full updates don't send avatar rotation :P
920 // So we're also sending a terse update (which has avatar rotation)
921 SendTerseUpdateToAllClients();
922
841 } 923 }
842 924
843 /// <summary> 925 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
index eeecd21..fb521df 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
@@ -2162,13 +2162,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
2162 2162
2163 public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) 2163 public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot)
2164 { 2164 {
2165 NotImplemented("llSitTarget"); 2165 // LSL quaternions can normalize to 0, normal Quaternions can't.
2166 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
2167 rot.z = 1; // ZERO_ROTATION = 0,0,0,1
2168
2169 m_host.SetSitTarget(new Vector3((float)offset.x, (float)offset.y, (float)offset.z), new Quaternion((float)rot.s, (float)rot.x, (float)rot.y, (float)rot.z));
2166 } 2170 }
2167 2171
2168 public string llAvatarOnSitTarget() 2172 public string llAvatarOnSitTarget()
2169 { 2173 {
2170 NotImplemented("llAvatarOnSitTarget"); 2174 LLUUID AVID = m_host.GetAvatarOnSitTarget();
2171 return ""; 2175
2176 if (AVID != LLUUID.Zero)
2177 return AVID.ToString();
2178 else
2179 return "";
2172 } 2180 }
2173 2181
2174 public void llAddToLandPassList(string avatar, double hours) 2182 public void llAddToLandPassList(string avatar, double hours)