diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f0ceff6..e27d309 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -594,6 +594,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
594 | private UUID m_parentUUID = UUID.Zero; | 594 | private UUID m_parentUUID = UUID.Zero; |
595 | 595 | ||
596 | /// <summary> | 596 | /// <summary> |
597 | /// Are we sitting on an object? | ||
598 | /// </summary> | ||
599 | /// <remarks>A more readable way of testing presence sit status than ParentID == 0</remarks> | ||
600 | public bool IsSatOnObject { get { return ParentID != 0; } } | ||
601 | |||
602 | /// <summary> | ||
597 | /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. | 603 | /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. |
598 | /// </summary> | 604 | /// </summary> |
599 | /// <remarks> | 605 | /// <remarks> |
@@ -1940,10 +1946,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1940 | } | 1946 | } |
1941 | } | 1947 | } |
1942 | 1948 | ||
1943 | // Reset sit target. | ||
1944 | if (part.SitTargetAvatar == UUID) | ||
1945 | part.SitTargetAvatar = UUID.Zero; | ||
1946 | |||
1947 | part.ParentGroup.DeleteAvatar(UUID); | 1949 | part.ParentGroup.DeleteAvatar(UUID); |
1948 | // ParentPosition = part.GetWorldPosition(); | 1950 | // ParentPosition = part.GetWorldPosition(); |
1949 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1951 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
@@ -1961,6 +1963,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1961 | SendAvatarDataToAllAgents(); | 1963 | SendAvatarDataToAllAgents(); |
1962 | m_requestedSitTargetID = 0; | 1964 | m_requestedSitTargetID = 0; |
1963 | 1965 | ||
1966 | part.RemoveSittingAvatar(UUID); | ||
1967 | |||
1964 | if (part != null) | 1968 | if (part != null) |
1965 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1969 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1966 | } | 1970 | } |
@@ -1994,15 +1998,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1994 | //look for prims with explicit sit targets that are available | 1998 | //look for prims with explicit sit targets that are available |
1995 | foreach (SceneObjectPart part in partArray) | 1999 | foreach (SceneObjectPart part in partArray) |
1996 | { | 2000 | { |
1997 | // Is a sit target available? | 2001 | if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) |
1998 | Vector3 avSitOffset = part.SitTargetPosition; | ||
1999 | Quaternion avSitOrientation = part.SitTargetOrientation; | ||
2000 | UUID avOnTargetAlready = part.SitTargetAvatar; | ||
2001 | |||
2002 | bool SitTargetUnOccupied = avOnTargetAlready == UUID.Zero; | ||
2003 | bool SitTargetisSet = avSitOffset != Vector3.Zero || avSitOrientation != Quaternion.Identity; | ||
2004 | |||
2005 | if (SitTargetisSet && SitTargetUnOccupied) | ||
2006 | { | 2002 | { |
2007 | //switch the target to this prim | 2003 | //switch the target to this prim |
2008 | return part; | 2004 | return part; |
@@ -2013,10 +2009,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2013 | return targetPart; | 2009 | return targetPart; |
2014 | } | 2010 | } |
2015 | 2011 | ||
2016 | private void SendSitResponse(UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 2012 | private void SendSitResponse(UUID targetID, Vector3 offset, Quaternion sitOrientation) |
2017 | { | 2013 | { |
2018 | Vector3 pos = new Vector3(); | ||
2019 | Quaternion sitOrientation = pSitOrientation; | ||
2020 | Vector3 cameraEyeOffset = Vector3.Zero; | 2014 | Vector3 cameraEyeOffset = Vector3.Zero; |
2021 | Vector3 cameraAtOffset = Vector3.Zero; | 2015 | Vector3 cameraAtOffset = Vector3.Zero; |
2022 | bool forceMouselook = false; | 2016 | bool forceMouselook = false; |
@@ -2028,42 +2022,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
2028 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 2022 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
2029 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 2023 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
2030 | 2024 | ||
2031 | // Is a sit target available? | ||
2032 | Vector3 avSitOffSet = part.SitTargetPosition; | ||
2033 | Quaternion avSitOrientation = part.SitTargetOrientation; | ||
2034 | UUID avOnTargetAlready = part.SitTargetAvatar; | ||
2035 | |||
2036 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | ||
2037 | bool SitTargetisSet = | ||
2038 | (!(avSitOffSet == Vector3.Zero && | ||
2039 | ( | ||
2040 | avSitOrientation == Quaternion.Identity // Valid Zero Rotation quaternion | ||
2041 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point | ||
2042 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion | ||
2043 | ) | ||
2044 | )); | ||
2045 | |||
2046 | // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); | ||
2047 | |||
2048 | if (PhysicsActor != null) | 2025 | if (PhysicsActor != null) |
2049 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; | 2026 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2050 | 2027 | ||
2051 | bool canSit = false; | 2028 | bool canSit = false; |
2052 | pos = part.AbsolutePosition + offset; | 2029 | Vector3 pos = part.AbsolutePosition + offset; |
2053 | 2030 | ||
2054 | if (SitTargetisSet) | 2031 | if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) |
2055 | { | 2032 | { |
2056 | if (SitTargetUnOccupied) | ||
2057 | { | ||
2058 | // m_log.DebugFormat( | 2033 | // m_log.DebugFormat( |
2059 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied", | 2034 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied", |
2060 | // Name, part.Name, part.LocalId); | 2035 | // Name, part.Name, part.LocalId); |
2061 | 2036 | ||
2062 | part.SitTargetAvatar = UUID; | 2037 | offset = part.SitTargetPosition; |
2063 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 2038 | sitOrientation = part.SitTargetOrientation; |
2064 | sitOrientation = avSitOrientation; | 2039 | canSit = true; |
2065 | canSit = true; | ||
2066 | } | ||
2067 | } | 2040 | } |
2068 | else | 2041 | else |
2069 | { | 2042 | { |
@@ -2076,6 +2049,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2076 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2049 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2077 | canSit = true; | 2050 | canSit = true; |
2078 | } | 2051 | } |
2052 | // else | ||
2053 | // { | ||
2054 | // m_log.DebugFormat( | ||
2055 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
2056 | // Name, part.Name, part.LocalId); | ||
2057 | // } | ||
2079 | } | 2058 | } |
2080 | 2059 | ||
2081 | if (canSit) | 2060 | if (canSit) |
@@ -2086,6 +2065,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2086 | RemoveFromPhysicalScene(); | 2065 | RemoveFromPhysicalScene(); |
2087 | } | 2066 | } |
2088 | 2067 | ||
2068 | part.AddSittingAvatar(UUID); | ||
2069 | |||
2089 | cameraAtOffset = part.GetCameraAtOffset(); | 2070 | cameraAtOffset = part.GetCameraAtOffset(); |
2090 | cameraEyeOffset = part.GetCameraEyeOffset(); | 2071 | cameraEyeOffset = part.GetCameraEyeOffset(); |
2091 | forceMouselook = part.GetForceMouselook(); | 2072 | forceMouselook = part.GetForceMouselook(); |
@@ -2362,6 +2343,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2362 | 2343 | ||
2363 | if (part != null) | 2344 | if (part != null) |
2364 | { | 2345 | { |
2346 | if (part.ParentGroup.IsAttachment) | ||
2347 | { | ||
2348 | m_log.WarnFormat( | ||
2349 | "[SCENE PRESENCE]: Avatar {0} tried to sit on part {1} from object {2} in {3} but this is an attachment for avatar id {4}", | ||
2350 | Name, part.Name, part.ParentGroup.Name, Scene.Name, part.ParentGroup.AttachedAvatar); | ||
2351 | |||
2352 | return; | ||
2353 | } | ||
2354 | |||
2365 | if (part.SitTargetAvatar == UUID) | 2355 | if (part.SitTargetAvatar == UUID) |
2366 | { | 2356 | { |
2367 | Vector3 sitTargetPos = part.SitTargetPosition; | 2357 | Vector3 sitTargetPos = part.SitTargetPosition; |