aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs228
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs9
2 files changed, 223 insertions, 14 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 24840d4..7cdbd4b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -124,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes
124 private Vector3? m_forceToApply; 124 private Vector3? m_forceToApply;
125 private uint m_requestedSitTargetID; 125 private uint m_requestedSitTargetID;
126 private UUID m_requestedSitTargetUUID; 126 private UUID m_requestedSitTargetUUID;
127 private Vector3 m_requestedSitOffset;
127 private SendCourseLocationsMethod m_sendCourseLocationsMethod; 128 private SendCourseLocationsMethod m_sendCourseLocationsMethod;
128 129
129 private bool m_startAnimationSet; 130 private bool m_startAnimationSet;
@@ -1663,11 +1664,11 @@ namespace OpenSim.Region.Framework.Scenes
1663 return targetPart; 1664 return targetPart;
1664 } 1665 }
1665 1666
1666 private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset) 1667 private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation)
1667 { 1668 {
1668 bool autopilot = true; 1669 bool autopilot = true;
1669 Vector3 pos = new Vector3(); 1670 Vector3 pos = new Vector3();
1670 Quaternion sitOrientation = Quaternion.Identity; 1671 Quaternion sitOrientation = pSitOrientation;
1671 Vector3 cameraEyeOffset = Vector3.Zero; 1672 Vector3 cameraEyeOffset = Vector3.Zero;
1672 Vector3 cameraAtOffset = Vector3.Zero; 1673 Vector3 cameraAtOffset = Vector3.Zero;
1673 bool forceMouselook = false; 1674 bool forceMouselook = false;
@@ -1766,12 +1767,17 @@ namespace OpenSim.Region.Framework.Scenes
1766 m_nextSitAnimation = part.SitAnimation; 1767 m_nextSitAnimation = part.SitAnimation;
1767 } 1768 }
1768 m_requestedSitTargetID = part.LocalId; 1769 m_requestedSitTargetID = part.LocalId;
1769 //m_requestedSitOffset = offset; 1770 m_requestedSitOffset = offset;
1770 //offset.X += part.Scale.X;// *offset.X; 1771 m_requestedSitTargetUUID = targetID;
1771 //offset.Y += part.Scale.Y;// * offset.Y; 1772
1772 //offset.Z += part.Scale.Z;// * offset.Z;
1773 //m_requestedSitOffset = offset;
1774 m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); 1773 m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset);
1774
1775 if (m_scene.PhysicsScene.SupportsRayCast())
1776 {
1777 //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback());
1778 //SitRayCastAvatarPosition(part);
1779 //return;
1780 }
1775 } 1781 }
1776 else 1782 else
1777 { 1783 {
@@ -1779,14 +1785,201 @@ namespace OpenSim.Region.Framework.Scenes
1779 m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); 1785 m_log.Warn("Sit requested on unknown object: " + targetID.ToString());
1780 } 1786 }
1781 1787
1782 if (m_scene.PhysicsScene.SupportsRayCast()) 1788
1789
1790 SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity);
1791 }
1792 /*
1793 public void SitRayCastAvatarPosition(SceneObjectPart part)
1794 {
1795 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
1796 Vector3 StartRayCastPosition = AbsolutePosition;
1797 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
1798 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
1799 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse);
1800 }
1801
1802 public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal)
1803 {
1804 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
1805 if (part != null)
1783 { 1806 {
1784 //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); 1807 if (hitYN)
1808 {
1809 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
1810 {
1811 SitRaycastFindEdge(collisionPoint, normal);
1812 m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal );
1813 }
1814 else
1815 {
1816 SitRayCastAvatarPositionCameraZ(part);
1817 }
1818 }
1819 else
1820 {
1821 SitRayCastAvatarPositionCameraZ(part);
1822 }
1823 }
1824 else
1825 {
1826 ControllingClient.SendAlertMessage("Sit position no longer exists");
1827 m_requestedSitTargetUUID = UUID.Zero;
1828 m_requestedSitTargetID = 0;
1829 m_requestedSitOffset = Vector3.Zero;
1785 } 1830 }
1786 1831
1787 SendSitResponse(remoteClient, targetID, offset);
1788 } 1832 }
1789 1833
1834 public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part)
1835 {
1836 // Next, try to raycast from the camera Z position
1837 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
1838 Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z;
1839 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
1840 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
1841 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse);
1842 }
1843
1844 public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal)
1845 {
1846 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
1847 if (part != null)
1848 {
1849 if (hitYN)
1850 {
1851 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
1852 {
1853 SitRaycastFindEdge(collisionPoint, normal);
1854 m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal);
1855 }
1856 else
1857 {
1858 SitRayCastCameraPosition(part);
1859 }
1860 }
1861 else
1862 {
1863 SitRayCastCameraPosition(part);
1864 }
1865 }
1866 else
1867 {
1868 ControllingClient.SendAlertMessage("Sit position no longer exists");
1869 m_requestedSitTargetUUID = UUID.Zero;
1870 m_requestedSitTargetID = 0;
1871 m_requestedSitOffset = Vector3.Zero;
1872 }
1873
1874 }
1875
1876 public void SitRayCastCameraPosition(SceneObjectPart part)
1877 {
1878 // Next, try to raycast from the camera position
1879 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
1880 Vector3 StartRayCastPosition = CameraPosition;
1881 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
1882 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
1883 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse);
1884 }
1885
1886 public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal)
1887 {
1888 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
1889 if (part != null)
1890 {
1891 if (hitYN)
1892 {
1893 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
1894 {
1895 SitRaycastFindEdge(collisionPoint, normal);
1896 m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
1897 }
1898 else
1899 {
1900 SitRayHorizontal(part);
1901 }
1902 }
1903 else
1904 {
1905 SitRayHorizontal(part);
1906 }
1907 }
1908 else
1909 {
1910 ControllingClient.SendAlertMessage("Sit position no longer exists");
1911 m_requestedSitTargetUUID = UUID.Zero;
1912 m_requestedSitTargetID = 0;
1913 m_requestedSitOffset = Vector3.Zero;
1914 }
1915
1916 }
1917
1918 public void SitRayHorizontal(SceneObjectPart part)
1919 {
1920 // Next, try to raycast from the avatar position to fwd
1921 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
1922 Vector3 StartRayCastPosition = CameraPosition;
1923 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
1924 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
1925 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse);
1926 }
1927
1928 public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal)
1929 {
1930 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
1931 if (part != null)
1932 {
1933 if (hitYN)
1934 {
1935 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
1936 {
1937 SitRaycastFindEdge(collisionPoint, normal);
1938 m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
1939 // Next, try to raycast from the camera position
1940 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
1941 Vector3 StartRayCastPosition = CameraPosition;
1942 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
1943 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
1944 //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition);
1945 }
1946 else
1947 {
1948 ControllingClient.SendAlertMessage("Sit position not accessable.");
1949 m_requestedSitTargetUUID = UUID.Zero;
1950 m_requestedSitTargetID = 0;
1951 m_requestedSitOffset = Vector3.Zero;
1952 }
1953 }
1954 else
1955 {
1956 ControllingClient.SendAlertMessage("Sit position not accessable.");
1957 m_requestedSitTargetUUID = UUID.Zero;
1958 m_requestedSitTargetID = 0;
1959 m_requestedSitOffset = Vector3.Zero;
1960 }
1961 }
1962 else
1963 {
1964 ControllingClient.SendAlertMessage("Sit position no longer exists");
1965 m_requestedSitTargetUUID = UUID.Zero;
1966 m_requestedSitTargetID = 0;
1967 m_requestedSitOffset = Vector3.Zero;
1968 }
1969
1970 }
1971
1972 private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal)
1973 {
1974 int i = 0;
1975 //throw new NotImplementedException();
1976 //m_requestedSitTargetUUID = UUID.Zero;
1977 //m_requestedSitTargetID = 0;
1978 //m_requestedSitOffset = Vector3.Zero;
1979
1980 SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity);
1981 }
1982 */
1790 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) 1983 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation)
1791 { 1984 {
1792 if (m_parentID != 0) 1985 if (m_parentID != 0)
@@ -1807,14 +2000,23 @@ namespace OpenSim.Region.Framework.Scenes
1807 if (part != null) 2000 if (part != null)
1808 { 2001 {
1809 m_requestedSitTargetID = part.LocalId; 2002 m_requestedSitTargetID = part.LocalId;
1810 //m_requestedSitOffset = offset; 2003 m_requestedSitOffset = offset;
2004 m_requestedSitTargetUUID = targetID;
2005
2006 m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset);
2007
2008 if (m_scene.PhysicsScene.SupportsRayCast())
2009 {
2010 //SitRayCastAvatarPosition(part);
2011 //return;
2012 }
1811 } 2013 }
1812 else 2014 else
1813 { 2015 {
1814 m_log.Warn("Sit requested on unknown object: " + targetID); 2016 m_log.Warn("Sit requested on unknown object: " + targetID);
1815 } 2017 }
1816 2018
1817 SendSitResponse(remoteClient, targetID, offset); 2019 SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity);
1818 } 2020 }
1819 2021
1820 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 2022 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
diff --git a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
index 732e835..7314107 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
@@ -106,13 +106,20 @@ namespace OpenSim.Region.Physics.OdePlugin
106 { 106 {
107 if (m_PendingRequests.Count > 0) 107 if (m_PendingRequests.Count > 0)
108 { 108 {
109 ODERayCastRequest[] reqs = m_PendingRequests.ToArray();
110 for (int i = 0; i < reqs.Length; i++)
111 {
112 if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast
113 RayCast(reqs[i]); // if there isn't anyone to send results
114 }
115 /*
109 foreach (ODERayCastRequest req in m_PendingRequests) 116 foreach (ODERayCastRequest req in m_PendingRequests)
110 { 117 {
111 if (req.callbackMethod != null) // quick optimization here, don't raycast 118 if (req.callbackMethod != null) // quick optimization here, don't raycast
112 RayCast(req); // if there isn't anyone to send results to 119 RayCast(req); // if there isn't anyone to send results to
113 120
114 } 121 }
115 122 */
116 m_PendingRequests.Clear(); 123 m_PendingRequests.Clear();
117 } 124 }
118 } 125 }