diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 393 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | 33 |
2 files changed, 198 insertions, 228 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e098c62..6979d2e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -188,20 +188,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
188 | 188 | ||
189 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; | 189 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
190 | 190 | ||
191 | |||
192 | protected Timer m_reprioritization_timer; | 191 | protected Timer m_reprioritization_timer; |
193 | protected bool m_reprioritizing; | 192 | protected bool m_reprioritizing; |
194 | protected bool m_reprioritization_called; | 193 | protected bool m_reprioritization_called; |
195 | 194 | ||
196 | private Quaternion m_headrotation = Quaternion.Identity; | 195 | private Quaternion m_headrotation = Quaternion.Identity; |
197 | 196 | ||
198 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method | ||
199 | // private Vector3 movementvector; | ||
200 | |||
201 | private bool m_autopilotMoving; | ||
202 | private Vector3 m_autoPilotTarget; | ||
203 | private bool m_sitAtAutoTarget; | ||
204 | |||
205 | private string m_nextSitAnimation = String.Empty; | 197 | private string m_nextSitAnimation = String.Empty; |
206 | 198 | ||
207 | //PauPaw:Proper PID Controler for autopilot************ | 199 | //PauPaw:Proper PID Controler for autopilot************ |
@@ -1417,9 +1409,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1417 | } | 1409 | } |
1418 | } | 1410 | } |
1419 | 1411 | ||
1420 | if (m_autopilotMoving) | ||
1421 | CheckAtSitTarget(); | ||
1422 | |||
1423 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1412 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1424 | { | 1413 | { |
1425 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. | 1414 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. |
@@ -1636,111 +1625,109 @@ namespace OpenSim.Region.Framework.Scenes | |||
1636 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", | 1625 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", |
1637 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); | 1626 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); |
1638 | 1627 | ||
1639 | if (!m_autopilotMoving) | 1628 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); |
1640 | { | 1629 | |
1641 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); | ||
1642 | // m_log.DebugFormat( | 1630 | // m_log.DebugFormat( |
1643 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", | 1631 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", |
1644 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); | 1632 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); |
1645 | 1633 | ||
1646 | // Check the error term of the current position in relation to the target position | 1634 | // Check the error term of the current position in relation to the target position |
1647 | if (distanceToTarget <= 1) | 1635 | if (distanceToTarget <= 1) |
1648 | { | 1636 | { |
1649 | // We are close enough to the target | 1637 | // We are close enough to the target |
1650 | AbsolutePosition = MoveToPositionTarget; | 1638 | AbsolutePosition = MoveToPositionTarget; |
1651 | ResetMoveToTarget(); | 1639 | ResetMoveToTarget(); |
1652 | updated = true; | 1640 | updated = true; |
1653 | } | 1641 | } |
1654 | else | 1642 | else |
1643 | { | ||
1644 | try | ||
1655 | { | 1645 | { |
1656 | try | 1646 | // move avatar in 3D at one meter/second towards target, in avatar coordinate frame. |
1657 | { | 1647 | // This movement vector gets added to the velocity through AddNewMovement(). |
1658 | // move avatar in 3D at one meter/second towards target, in avatar coordinate frame. | 1648 | // Theoretically we might need a more complex PID approach here if other |
1659 | // This movement vector gets added to the velocity through AddNewMovement(). | 1649 | // unknown forces are acting on the avatar and we need to adaptively respond |
1660 | // Theoretically we might need a more complex PID approach here if other | 1650 | // to such forces, but the following simple approach seems to works fine. |
1661 | // unknown forces are acting on the avatar and we need to adaptively respond | 1651 | Vector3 LocalVectorToTarget3D = |
1662 | // to such forces, but the following simple approach seems to works fine. | 1652 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords |
1663 | Vector3 LocalVectorToTarget3D = | 1653 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords |
1664 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | 1654 | // Ignore z component of vector |
1665 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords | ||
1666 | // Ignore z component of vector | ||
1667 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1655 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1668 | LocalVectorToTarget3D.Normalize(); | 1656 | LocalVectorToTarget3D.Normalize(); |
1669 | 1657 | ||
1670 | // update avatar movement flags. the avatar coordinate system is as follows: | 1658 | // update avatar movement flags. the avatar coordinate system is as follows: |
1671 | // | 1659 | // |
1672 | // +X (forward) | 1660 | // +X (forward) |
1673 | // | 1661 | // |
1674 | // ^ | 1662 | // ^ |
1675 | // | | 1663 | // | |
1676 | // | | 1664 | // | |
1677 | // | | 1665 | // | |
1678 | // | | 1666 | // | |
1679 | // (left) +Y <--------o--------> -Y | 1667 | // (left) +Y <--------o--------> -Y |
1680 | // avatar | 1668 | // avatar |
1681 | // | | 1669 | // | |
1682 | // | | 1670 | // | |
1683 | // | | 1671 | // | |
1684 | // | | 1672 | // | |
1685 | // v | 1673 | // v |
1686 | // -X | 1674 | // -X |
1687 | // | 1675 | // |
1688 | 1676 | ||
1689 | // based on the above avatar coordinate system, classify the movement into | 1677 | // based on the above avatar coordinate system, classify the movement into |
1690 | // one of left/right/back/forward. | 1678 | // one of left/right/back/forward. |
1691 | if (LocalVectorToTarget3D.X < 0) //MoveBack | 1679 | if (LocalVectorToTarget3D.X < 0) //MoveBack |
1692 | { | 1680 | { |
1693 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 1681 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; |
1694 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 1682 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; |
1695 | updated = true; | 1683 | updated = true; |
1696 | } | 1684 | } |
1697 | else if (LocalVectorToTarget3D.X > 0) //Move Forward | 1685 | else if (LocalVectorToTarget3D.X > 0) //Move Forward |
1698 | { | 1686 | { |
1699 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 1687 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; |
1700 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 1688 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; |
1701 | updated = true; | 1689 | updated = true; |
1702 | } | 1690 | } |
1703 | 1691 | ||
1704 | if (LocalVectorToTarget3D.Y > 0) //MoveLeft | 1692 | if (LocalVectorToTarget3D.Y > 0) //MoveLeft |
1705 | { | 1693 | { |
1706 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 1694 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
1707 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 1695 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
1708 | updated = true; | 1696 | updated = true; |
1709 | } | 1697 | } |
1710 | else if (LocalVectorToTarget3D.Y < 0) //MoveRight | 1698 | else if (LocalVectorToTarget3D.Y < 0) //MoveRight |
1711 | { | 1699 | { |
1712 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 1700 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
1713 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 1701 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
1714 | updated = true; | 1702 | updated = true; |
1715 | } | 1703 | } |
1716 | 1704 | ||
1717 | if (LocalVectorToTarget3D.Z > 0) //Up | 1705 | if (LocalVectorToTarget3D.Z > 0) //Up |
1718 | { | 1706 | { |
1719 | // Don't set these flags for up or down - doing so will make the avatar crouch or | 1707 | // Don't set these flags for up or down - doing so will make the avatar crouch or |
1720 | // keep trying to jump even if walking along level ground | 1708 | // keep trying to jump even if walking along level ground |
1721 | //MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; | 1709 | //MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; |
1722 | //AgentControlFlags | 1710 | //AgentControlFlags |
1723 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; | 1711 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; |
1724 | updated = true; | 1712 | updated = true; |
1725 | } | 1713 | } |
1726 | else if (LocalVectorToTarget3D.Z < 0) //Down | 1714 | else if (LocalVectorToTarget3D.Z < 0) //Down |
1727 | { | 1715 | { |
1728 | //MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; | 1716 | //MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; |
1729 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; | 1717 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; |
1730 | updated = true; | 1718 | updated = true; |
1731 | } | 1719 | } |
1732 | 1720 | ||
1733 | // m_log.DebugFormat( | 1721 | // m_log.DebugFormat( |
1734 | // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", | 1722 | // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", |
1735 | // LocalVectorToTarget3D, agent_control_v3, Name); | 1723 | // LocalVectorToTarget3D, agent_control_v3, Name); |
1736 | 1724 | ||
1737 | agent_control_v3 += LocalVectorToTarget3D; | 1725 | agent_control_v3 += LocalVectorToTarget3D; |
1738 | } | 1726 | } |
1739 | catch (Exception e) | 1727 | catch (Exception e) |
1740 | { | 1728 | { |
1741 | //Avoid system crash, can be slower but... | 1729 | //Avoid system crash, can be slower but... |
1742 | m_log.DebugFormat("Crash! {0}", e.ToString()); | 1730 | m_log.DebugFormat("Crash! {0}", e.ToString()); |
1743 | } | ||
1744 | } | 1731 | } |
1745 | } | 1732 | } |
1746 | 1733 | ||
@@ -1842,47 +1829,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1842 | AgentControlFlags = (uint)AgentManager.ControlFlags.NONE; | 1829 | AgentControlFlags = (uint)AgentManager.ControlFlags.NONE; |
1843 | } | 1830 | } |
1844 | 1831 | ||
1845 | private void CheckAtSitTarget() | ||
1846 | { | ||
1847 | //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); | ||
1848 | if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5) | ||
1849 | { | ||
1850 | if (m_sitAtAutoTarget) | ||
1851 | { | ||
1852 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID); | ||
1853 | if (part != null) | ||
1854 | { | ||
1855 | AbsolutePosition = part.AbsolutePosition; | ||
1856 | Velocity = Vector3.Zero; | ||
1857 | SendAvatarDataToAllAgents(); | ||
1858 | |||
1859 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | ||
1860 | } | ||
1861 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | ||
1862 | m_requestedSitTargetUUID = UUID.Zero; | ||
1863 | } | ||
1864 | /* | ||
1865 | else | ||
1866 | { | ||
1867 | //ControllingClient.SendAlertMessage("Autopilot cancelled"); | ||
1868 | //SendTerseUpdateToAllClients(); | ||
1869 | //PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | ||
1870 | //proxy.PCode = (byte)PCode.ParticleSystem; | ||
1871 | ////uint nextUUID = m_scene.NextLocalId; | ||
1872 | |||
1873 | //proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, Quaternion.Identity, proxy); | ||
1874 | //if (proxyObjectGroup != null) | ||
1875 | //{ | ||
1876 | //proxyObjectGroup.SendGroupFullUpdate(); | ||
1877 | //ControllingClient.SendSitResponse(UUID.Zero, m_autoPilotTarget, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); | ||
1878 | //m_scene.DeleteSceneObject(proxyObjectGroup); | ||
1879 | //} | ||
1880 | } | ||
1881 | */ | ||
1882 | m_autoPilotTarget = Vector3.Zero; | ||
1883 | m_autopilotMoving = false; | ||
1884 | } | ||
1885 | } | ||
1886 | /// <summary> | 1832 | /// <summary> |
1887 | /// Perform the logic necessary to stand the avatar up. This method also executes | 1833 | /// Perform the logic necessary to stand the avatar up. This method also executes |
1888 | /// the stand animation. | 1834 | /// the stand animation. |
@@ -1893,7 +1839,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1893 | 1839 | ||
1894 | if (ParentID != 0) | 1840 | if (ParentID != 0) |
1895 | { | 1841 | { |
1896 | m_log.Debug("StandupCode Executed"); | 1842 | // m_log.Debug("StandupCode Executed"); |
1897 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); | 1843 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); |
1898 | if (part != null) | 1844 | if (part != null) |
1899 | { | 1845 | { |
@@ -1983,7 +1929,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1983 | 1929 | ||
1984 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 1930 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) |
1985 | { | 1931 | { |
1986 | bool autopilot = true; | ||
1987 | Vector3 pos = new Vector3(); | 1932 | Vector3 pos = new Vector3(); |
1988 | Quaternion sitOrientation = pSitOrientation; | 1933 | Quaternion sitOrientation = pSitOrientation; |
1989 | Vector3 cameraEyeOffset = Vector3.Zero; | 1934 | Vector3 cameraEyeOffset = Vector3.Zero; |
@@ -1991,86 +1936,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
1991 | bool forceMouselook = false; | 1936 | bool forceMouselook = false; |
1992 | 1937 | ||
1993 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1938 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1994 | if (part != null) | 1939 | if (part == null) |
1995 | { | 1940 | return; |
1996 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
1997 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
1998 | 1941 | ||
1999 | // Is a sit target available? | 1942 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
2000 | Vector3 avSitOffSet = part.SitTargetPosition; | 1943 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
2001 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1944 | |
2002 | UUID avOnTargetAlready = part.SitTargetAvatar; | 1945 | // Is a sit target available? |
1946 | Vector3 avSitOffSet = part.SitTargetPosition; | ||
1947 | Quaternion avSitOrientation = part.SitTargetOrientation; | ||
1948 | UUID avOnTargetAlready = part.SitTargetAvatar; | ||
2003 | 1949 | ||
2004 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1950 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); |
2005 | bool SitTargetisSet = | 1951 | bool SitTargetisSet = |
2006 | (!(avSitOffSet == Vector3.Zero && | 1952 | (!(avSitOffSet == Vector3.Zero && |
2007 | ( | 1953 | ( |
2008 | avSitOrientation == Quaternion.Identity // Valid Zero Rotation quaternion | 1954 | avSitOrientation == Quaternion.Identity // Valid Zero Rotation quaternion |
2009 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point | 1955 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point |
2010 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion | 1956 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion |
2011 | ) | 1957 | ) |
2012 | )); | 1958 | )); |
2013 | 1959 | ||
2014 | // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); | 1960 | // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); |
2015 | 1961 | ||
2016 | if (SitTargetisSet && SitTargetUnOccupied) | 1962 | if (PhysicsActor != null) |
1963 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
1964 | |||
1965 | bool canSit = false; | ||
1966 | pos = part.AbsolutePosition + offset; | ||
1967 | |||
1968 | if (SitTargetisSet) | ||
1969 | { | ||
1970 | if (SitTargetUnOccupied) | ||
2017 | { | 1971 | { |
1972 | m_log.DebugFormat( | ||
1973 | "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied", | ||
1974 | Name, part.Name, part.LocalId); | ||
1975 | |||
2018 | part.SitTargetAvatar = UUID; | 1976 | part.SitTargetAvatar = UUID; |
2019 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1977 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); |
2020 | sitOrientation = avSitOrientation; | 1978 | sitOrientation = avSitOrientation; |
2021 | autopilot = false; | 1979 | canSit = true; |
2022 | } | 1980 | } |
2023 | pos = part.AbsolutePosition + offset; | 1981 | } |
2024 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 1982 | else |
2025 | //{ | 1983 | { |
2026 | // offset = pos; | 1984 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2027 | //autopilot = false; | ||
2028 | //} | ||
2029 | if (PhysicsActor != null) | ||
2030 | { | 1985 | { |
2031 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 1986 | m_log.DebugFormat( |
2032 | // We can remove the physicsActor until they stand up. | 1987 | "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", |
2033 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 1988 | Name, part.Name, part.LocalId); |
2034 | 1989 | ||
2035 | if (autopilot) | 1990 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2036 | { | 1991 | canSit = true; |
2037 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 1992 | } |
2038 | { | 1993 | } |
2039 | autopilot = false; | ||
2040 | 1994 | ||
2041 | RemoveFromPhysicalScene(); | 1995 | if (canSit) |
2042 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 1996 | { |
2043 | } | 1997 | if (PhysicsActor != null) |
2044 | } | 1998 | { |
2045 | else | 1999 | // We can remove the physicsActor until they stand up. |
2046 | { | 2000 | RemoveFromPhysicalScene(); |
2047 | RemoveFromPhysicalScene(); | ||
2048 | } | ||
2049 | } | 2001 | } |
2050 | 2002 | ||
2051 | cameraAtOffset = part.GetCameraAtOffset(); | 2003 | cameraAtOffset = part.GetCameraAtOffset(); |
2052 | cameraEyeOffset = part.GetCameraEyeOffset(); | 2004 | cameraEyeOffset = part.GetCameraEyeOffset(); |
2053 | forceMouselook = part.GetForceMouselook(); | 2005 | forceMouselook = part.GetForceMouselook(); |
2054 | } | ||
2055 | 2006 | ||
2056 | ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2007 | ControllingClient.SendSitResponse( |
2057 | m_requestedSitTargetUUID = targetID; | 2008 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
2009 | |||
2010 | m_requestedSitTargetUUID = targetID; | ||
2058 | 2011 | ||
2059 | // This calls HandleAgentSit twice, once from here, and the client calls | ||
2060 | // HandleAgentSit itself after it gets to the location | ||
2061 | // It doesn't get to the location until we've moved them there though | ||
2062 | // which happens in HandleAgentSit :P | ||
2063 | m_autopilotMoving = autopilot; | ||
2064 | m_autoPilotTarget = pos; | ||
2065 | m_sitAtAutoTarget = autopilot; | ||
2066 | if (!autopilot) | ||
2067 | HandleAgentSit(remoteClient, UUID); | 2012 | HandleAgentSit(remoteClient, UUID); |
2068 | 2013 | ||
2069 | // Moved here to avoid a race with default sit anim | 2014 | // Moved here to avoid a race with default sit anim |
2070 | // The script event needs to be raised after the default sit anim is set. | 2015 | // The script event needs to be raised after the default sit anim is set. |
2071 | if (part != null) | ||
2072 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2016 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2073 | 2017 | } | |
2074 | } | 2018 | } |
2075 | 2019 | ||
2076 | // public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) | 2020 | // public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) |
@@ -2099,11 +2043,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2099 | { | 2043 | { |
2100 | m_nextSitAnimation = part.SitAnimation; | 2044 | m_nextSitAnimation = part.SitAnimation; |
2101 | } | 2045 | } |
2046 | |||
2102 | m_requestedSitTargetID = part.LocalId; | 2047 | m_requestedSitTargetID = part.LocalId; |
2103 | //m_requestedSitOffset = offset; | ||
2104 | m_requestedSitTargetUUID = targetID; | 2048 | m_requestedSitTargetUUID = targetID; |
2105 | 2049 | ||
2106 | m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | 2050 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); |
2107 | 2051 | ||
2108 | if (m_scene.PhysicsScene.SupportsRayCast()) | 2052 | if (m_scene.PhysicsScene.SupportsRayCast()) |
2109 | { | 2053 | { |
@@ -2328,43 +2272,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
2328 | { | 2272 | { |
2329 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); | 2273 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
2330 | 2274 | ||
2331 | if (m_sitAtAutoTarget || !m_autopilotMoving) | 2275 | if (part != null) |
2332 | { | 2276 | { |
2333 | if (part != null) | 2277 | if (part.SitTargetAvatar == UUID) |
2334 | { | 2278 | { |
2335 | if (part.SitTargetAvatar == UUID) | 2279 | Vector3 sitTargetPos = part.SitTargetPosition; |
2336 | { | 2280 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
2337 | Vector3 sitTargetPos = part.SitTargetPosition; | ||
2338 | Quaternion sitTargetOrient = part.SitTargetOrientation; | ||
2339 | 2281 | ||
2340 | // m_log.DebugFormat( | 2282 | // m_log.DebugFormat( |
2341 | // "[SCENE PRESENCE]: Sitting {0} at sit target {1}, {2} on {3} {4}", | 2283 | // "[SCENE PRESENCE]: Sitting {0} at sit target {1}, {2} on {3} {4}", |
2342 | // Name, sitTargetPos, sitTargetOrient, part.Name, part.LocalId); | 2284 | // Name, sitTargetPos, sitTargetOrient, part.Name, part.LocalId); |
2343 | 2285 | ||
2344 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | 2286 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); |
2345 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | 2287 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); |
2346 | 2288 | ||
2347 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2289 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2348 | 2290 | ||
2349 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2291 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; |
2350 | Rotation = sitTargetOrient; | 2292 | Rotation = sitTargetOrient; |
2351 | ParentPosition = part.AbsolutePosition; | 2293 | ParentPosition = part.AbsolutePosition; |
2352 | } | 2294 | } |
2353 | else | 2295 | else |
2354 | { | 2296 | { |
2355 | m_pos -= part.AbsolutePosition; | 2297 | m_pos -= part.AbsolutePosition; |
2356 | ParentPosition = part.AbsolutePosition; | 2298 | ParentPosition = part.AbsolutePosition; |
2357 | 2299 | ||
2358 | // m_log.DebugFormat( | 2300 | // m_log.DebugFormat( |
2359 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2301 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
2360 | // Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); | 2302 | // Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); |
2361 | } | ||
2362 | } | ||
2363 | else | ||
2364 | { | ||
2365 | return; | ||
2366 | } | 2303 | } |
2367 | } | 2304 | } |
2305 | else | ||
2306 | { | ||
2307 | return; | ||
2308 | } | ||
2368 | 2309 | ||
2369 | ParentID = m_requestedSitTargetID; | 2310 | ParentID = m_requestedSitTargetID; |
2370 | 2311 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index 2636473..a1d30f3 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
53 | } | 53 | } |
54 | 54 | ||
55 | [Test] | 55 | [Test] |
56 | public void TestSitOutsideRange() | 56 | public void TestSitOutsideRangeNoTarget() |
57 | { | 57 | { |
58 | TestHelpers.InMethod(); | 58 | TestHelpers.InMethod(); |
59 | // log4net.Config.XmlConfigurator.Configure(); | 59 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
73 | } | 73 | } |
74 | 74 | ||
75 | [Test] | 75 | [Test] |
76 | public void TestSitWithinRange() | 76 | public void TestSitWithinRangeNoTarget() |
77 | { | 77 | { |
78 | TestHelpers.InMethod(); | 78 | TestHelpers.InMethod(); |
79 | // log4net.Config.XmlConfigurator.Configure(); | 79 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -124,5 +124,34 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
124 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); | 124 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
125 | Assert.That(sp.ParentID, Is.EqualTo(0)); | 125 | Assert.That(sp.ParentID, Is.EqualTo(0)); |
126 | } | 126 | } |
127 | |||
128 | [Test] | ||
129 | public void TestSitAndStandWithSitTarget() | ||
130 | { | ||
131 | TestHelpers.InMethod(); | ||
132 | // log4net.Config.XmlConfigurator.Configure(); | ||
133 | |||
134 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | ||
135 | |||
136 | // If a prim has a sit target then we can sit from any distance away | ||
137 | Vector3 startPos = new Vector3(128, 128, 30); | ||
138 | sp.AbsolutePosition = startPos; | ||
139 | |||
140 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | ||
141 | part.SitTargetPosition = new Vector3(0, 0, 1); | ||
142 | |||
143 | sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); | ||
144 | |||
145 | Assert.That(part.SitTargetAvatar, Is.EqualTo(sp.UUID)); | ||
146 | Assert.That(sp.ParentID, Is.EqualTo(part.LocalId)); | ||
147 | Assert.That( | ||
148 | sp.AbsolutePosition, | ||
149 | Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); | ||
150 | |||
151 | sp.StandUp(); | ||
152 | |||
153 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); | ||
154 | Assert.That(sp.ParentID, Is.EqualTo(0)); | ||
155 | } | ||
127 | } | 156 | } |
128 | } \ No newline at end of file | 157 | } \ No newline at end of file |