diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1027 |
1 files changed, 835 insertions, 192 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 00a1487..6267797 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Timers; | 32 | using System.Timers; |
@@ -72,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
72 | // { | 73 | // { |
73 | // m_log.Debug("[ScenePresence] Destructor called"); | 74 | // m_log.Debug("[ScenePresence] Destructor called"); |
74 | // } | 75 | // } |
75 | 76 | ||
76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 77 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
77 | 78 | ||
78 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | 79 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); |
@@ -87,7 +88,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
87 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 88 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
88 | /// issue #1716 | 89 | /// issue #1716 |
89 | /// </summary> | 90 | /// </summary> |
90 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | 91 | // private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); |
92 | // Value revised by KF 091121 by comparison with SL. | ||
93 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | ||
91 | 94 | ||
92 | public UUID currentParcelUUID = UUID.Zero; | 95 | public UUID currentParcelUUID = UUID.Zero; |
93 | 96 | ||
@@ -110,6 +113,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
110 | { | 113 | { |
111 | get { return m_attachments; } | 114 | get { return m_attachments; } |
112 | } | 115 | } |
116 | |||
113 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | 117 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); |
114 | 118 | ||
115 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); | 119 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); |
@@ -119,10 +123,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
119 | private SceneObjectGroup proxyObjectGroup; | 123 | private SceneObjectGroup proxyObjectGroup; |
120 | //private SceneObjectPart proxyObjectPart = null; | 124 | //private SceneObjectPart proxyObjectPart = null; |
121 | public Vector3 lastKnownAllowedPosition; | 125 | public Vector3 lastKnownAllowedPosition; |
122 | public bool sentMessageAboutRestrictedParcelFlyingDown; | ||
123 | public Vector4 CollisionPlane = Vector4.UnitW; | 126 | public Vector4 CollisionPlane = Vector4.UnitW; |
124 | 127 | ||
128 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | ||
129 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims | ||
125 | private Vector3 m_lastPosition; | 130 | private Vector3 m_lastPosition; |
131 | private Vector3 m_lastWorldPosition; | ||
126 | private Quaternion m_lastRotation; | 132 | private Quaternion m_lastRotation; |
127 | private Vector3 m_lastVelocity; | 133 | private Vector3 m_lastVelocity; |
128 | //private int m_lastTerseSent; | 134 | //private int m_lastTerseSent; |
@@ -130,6 +136,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
130 | private bool m_updateflag; | 136 | private bool m_updateflag; |
131 | private byte m_movementflag; | 137 | private byte m_movementflag; |
132 | private Vector3? m_forceToApply; | 138 | private Vector3? m_forceToApply; |
139 | private int m_userFlags; | ||
140 | public int UserFlags | ||
141 | { | ||
142 | get { return m_userFlags; } | ||
143 | } | ||
133 | private TeleportFlags m_teleportFlags; | 144 | private TeleportFlags m_teleportFlags; |
134 | public TeleportFlags TeleportFlags | 145 | public TeleportFlags TeleportFlags |
135 | { | 146 | { |
@@ -160,9 +171,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | private int m_perfMonMS; | 171 | private int m_perfMonMS; |
161 | 172 | ||
162 | private bool m_setAlwaysRun; | 173 | private bool m_setAlwaysRun; |
163 | |||
164 | private bool m_forceFly; | 174 | private bool m_forceFly; |
165 | private bool m_flyDisabled; | 175 | private bool m_flyDisabled; |
176 | private bool m_flyingOld; // add for fly velocity control | ||
177 | public bool m_wasFlying; // add for fly velocity control | ||
166 | 178 | ||
167 | private float m_speedModifier = 1.0f; | 179 | private float m_speedModifier = 1.0f; |
168 | 180 | ||
@@ -181,7 +193,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
181 | protected RegionInfo m_regionInfo; | 193 | protected RegionInfo m_regionInfo; |
182 | protected ulong crossingFromRegion; | 194 | protected ulong crossingFromRegion; |
183 | 195 | ||
184 | private readonly Vector3[] Dir_Vectors = new Vector3[9]; | 196 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
197 | private bool m_isNudging = false; | ||
185 | 198 | ||
186 | // Position of agent's camera in world (region cordinates) | 199 | // Position of agent's camera in world (region cordinates) |
187 | protected Vector3 m_CameraCenter; | 200 | protected Vector3 m_CameraCenter; |
@@ -206,17 +219,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
206 | private bool m_autopilotMoving; | 219 | private bool m_autopilotMoving; |
207 | private Vector3 m_autoPilotTarget; | 220 | private Vector3 m_autoPilotTarget; |
208 | private bool m_sitAtAutoTarget; | 221 | private bool m_sitAtAutoTarget; |
222 | private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit | ||
209 | 223 | ||
210 | private string m_nextSitAnimation = String.Empty; | 224 | private string m_nextSitAnimation = String.Empty; |
211 | 225 | ||
212 | //PauPaw:Proper PID Controler for autopilot************ | 226 | //PauPaw:Proper PID Controler for autopilot************ |
213 | private bool m_moveToPositionInProgress; | 227 | private bool m_moveToPositionInProgress; |
214 | private Vector3 m_moveToPositionTarget; | 228 | private Vector3 m_moveToPositionTarget; |
229 | private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
215 | 230 | ||
216 | private bool m_followCamAuto; | 231 | private bool m_followCamAuto; |
217 | 232 | ||
218 | private int m_movementUpdateCount; | 233 | private int m_movementUpdateCount; |
234 | private int m_lastColCount = -1; //KF: Look for Collision chnages | ||
235 | private int m_updateCount = 0; //KF: Update Anims for a while | ||
236 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | ||
219 | private const int NumMovementsBetweenRayCast = 5; | 237 | private const int NumMovementsBetweenRayCast = 5; |
238 | private List<uint> m_lastColliders = new List<uint>(); | ||
239 | |||
240 | private object m_syncRoot = new Object(); | ||
220 | 241 | ||
221 | private bool CameraConstraintActive; | 242 | private bool CameraConstraintActive; |
222 | //private int m_moveToPositionStateStatus; | 243 | //private int m_moveToPositionStateStatus; |
@@ -243,7 +264,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
243 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 264 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
244 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 265 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, |
245 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, | 266 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, |
246 | DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, | 267 | DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, |
268 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, | ||
269 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, | ||
247 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 270 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
248 | } | 271 | } |
249 | 272 | ||
@@ -450,7 +473,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
450 | get | 473 | get |
451 | { | 474 | { |
452 | PhysicsActor actor = m_physicsActor; | 475 | PhysicsActor actor = m_physicsActor; |
453 | if (actor != null) | 476 | // if (actor != null) |
477 | if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! | ||
454 | m_pos = actor.Position; | 478 | m_pos = actor.Position; |
455 | else | 479 | else |
456 | { | 480 | { |
@@ -472,7 +496,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
472 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | 496 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); |
473 | if (part != null) | 497 | if (part != null) |
474 | { | 498 | { |
475 | return m_parentPosition + (m_pos * part.GetWorldRotation()); | 499 | return part.AbsolutePosition + (m_pos * part.GetWorldRotation()); |
476 | } | 500 | } |
477 | else | 501 | else |
478 | { | 502 | { |
@@ -499,7 +523,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
499 | } | 523 | } |
500 | } | 524 | } |
501 | 525 | ||
502 | m_pos = value; | 526 | if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! |
527 | m_pos = value; | ||
503 | m_parentPosition = Vector3.Zero; | 528 | m_parentPosition = Vector3.Zero; |
504 | } | 529 | } |
505 | } | 530 | } |
@@ -543,10 +568,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
543 | } | 568 | } |
544 | } | 569 | } |
545 | 570 | ||
571 | public Quaternion OffsetRotation | ||
572 | { | ||
573 | get { return m_offsetRotation; } | ||
574 | set { m_offsetRotation = value; } | ||
575 | } | ||
576 | |||
546 | public Quaternion Rotation | 577 | public Quaternion Rotation |
547 | { | 578 | { |
548 | get { return m_bodyRot; } | 579 | get { |
549 | set { m_bodyRot = value; } | 580 | if (m_parentID != 0) |
581 | { | ||
582 | if (m_offsetRotation != null) | ||
583 | { | ||
584 | return m_offsetRotation; | ||
585 | } | ||
586 | else | ||
587 | { | ||
588 | return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
589 | } | ||
590 | |||
591 | } | ||
592 | else | ||
593 | { | ||
594 | return m_bodyRot; | ||
595 | } | ||
596 | } | ||
597 | set { | ||
598 | m_bodyRot = value; | ||
599 | if (m_parentID != 0) | ||
600 | { | ||
601 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
602 | } | ||
603 | } | ||
550 | } | 604 | } |
551 | 605 | ||
552 | public Quaternion PreviousRotation | 606 | public Quaternion PreviousRotation |
@@ -571,11 +625,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
571 | 625 | ||
572 | private uint m_parentID; | 626 | private uint m_parentID; |
573 | 627 | ||
628 | |||
629 | private UUID m_linkedPrim; | ||
630 | |||
574 | public uint ParentID | 631 | public uint ParentID |
575 | { | 632 | { |
576 | get { return m_parentID; } | 633 | get { return m_parentID; } |
577 | set { m_parentID = value; } | 634 | set { m_parentID = value; } |
578 | } | 635 | } |
636 | |||
637 | public UUID LinkedPrim | ||
638 | { | ||
639 | get { return m_linkedPrim; } | ||
640 | set { m_linkedPrim = value; } | ||
641 | } | ||
642 | |||
579 | public float Health | 643 | public float Health |
580 | { | 644 | { |
581 | get { return m_health; } | 645 | get { return m_health; } |
@@ -697,7 +761,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
697 | CreateSceneViewer(); | 761 | CreateSceneViewer(); |
698 | m_animator = new ScenePresenceAnimator(this); | 762 | m_animator = new ScenePresenceAnimator(this); |
699 | } | 763 | } |
700 | 764 | ||
701 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() | 765 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() |
702 | { | 766 | { |
703 | m_DrawDistance = world.DefaultDrawDistance; | 767 | m_DrawDistance = world.DefaultDrawDistance; |
@@ -712,6 +776,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
712 | m_localId = m_scene.AllocateLocalId(); | 776 | m_localId = m_scene.AllocateLocalId(); |
713 | 777 | ||
714 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | 778 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); |
779 | m_userFlags = account.UserFlags; | ||
715 | 780 | ||
716 | if (account != null) | 781 | if (account != null) |
717 | m_userLevel = account.UserLevel; | 782 | m_userLevel = account.UserLevel; |
@@ -730,10 +795,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
730 | m_reprioritization_timer.AutoReset = false; | 795 | m_reprioritization_timer.AutoReset = false; |
731 | 796 | ||
732 | AdjustKnownSeeds(); | 797 | AdjustKnownSeeds(); |
733 | |||
734 | // TODO: I think, this won't send anything, as we are still a child here... | ||
735 | Animator.TrySetMovementAnimation("STAND"); | 798 | Animator.TrySetMovementAnimation("STAND"); |
736 | |||
737 | // we created a new ScenePresence (a new child agent) in a fresh region. | 799 | // we created a new ScenePresence (a new child agent) in a fresh region. |
738 | // Request info about all the (root) agents in this region | 800 | // Request info about all the (root) agents in this region |
739 | // Note: This won't send data *to* other clients in that region (children don't send) | 801 | // Note: This won't send data *to* other clients in that region (children don't send) |
@@ -784,25 +846,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
784 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT | 846 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
785 | Dir_Vectors[4] = Vector3.UnitZ; //UP | 847 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
786 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN | 848 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
787 | Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 849 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE |
788 | Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD | 850 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE |
789 | Dir_Vectors[7] = -Vector3.UnitX; //BACK | 851 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE |
852 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE | ||
853 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | ||
790 | } | 854 | } |
791 | 855 | ||
792 | private Vector3[] GetWalkDirectionVectors() | 856 | private Vector3[] GetWalkDirectionVectors() |
793 | { | 857 | { |
794 | Vector3[] vector = new Vector3[9]; | 858 | Vector3[] vector = new Vector3[11]; |
795 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD | 859 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
796 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK | 860 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
797 | vector[2] = Vector3.UnitY; //LEFT | 861 | vector[2] = Vector3.UnitY; //LEFT |
798 | vector[3] = -Vector3.UnitY; //RIGHT | 862 | vector[3] = -Vector3.UnitY; //RIGHT |
799 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP | 863 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
800 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN | 864 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
801 | vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge | 865 | vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE |
802 | vector[6] = (new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z) * 2); //FORWARD Nudge | 866 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE |
803 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK Nudge | 867 | vector[8] = Vector3.UnitY; //LEFT_NUDGE |
868 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | ||
869 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE | ||
804 | return vector; | 870 | return vector; |
805 | } | 871 | } |
872 | |||
873 | private bool[] GetDirectionIsNudge() | ||
874 | { | ||
875 | bool[] isNudge = new bool[11]; | ||
876 | isNudge[0] = false; //FORWARD | ||
877 | isNudge[1] = false; //BACK | ||
878 | isNudge[2] = false; //LEFT | ||
879 | isNudge[3] = false; //RIGHT | ||
880 | isNudge[4] = false; //UP | ||
881 | isNudge[5] = false; //DOWN | ||
882 | isNudge[6] = true; //FORWARD_NUDGE | ||
883 | isNudge[7] = true; //BACK_NUDGE | ||
884 | isNudge[8] = true; //LEFT_NUDGE | ||
885 | isNudge[9] = true; //RIGHT_NUDGE | ||
886 | isNudge[10] = true; //DOWN_Nudge | ||
887 | return isNudge; | ||
888 | } | ||
889 | |||
806 | 890 | ||
807 | #endregion | 891 | #endregion |
808 | 892 | ||
@@ -864,6 +948,62 @@ namespace OpenSim.Region.Framework.Scenes | |||
864 | pos.Y = crossedBorder.BorderLine.Z - 1; | 948 | pos.Y = crossedBorder.BorderLine.Z - 1; |
865 | } | 949 | } |
866 | 950 | ||
951 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
952 | if (land != null) | ||
953 | { | ||
954 | // If we come in via login, landmark or map, we want to | ||
955 | // honor landing points. If we come in via Lure, we want | ||
956 | // to ignore them. | ||
957 | if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || | ||
958 | (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || | ||
959 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0) | ||
960 | { | ||
961 | // Don't restrict gods, estate managers, or land owners to | ||
962 | // the TP point. This behaviour mimics agni. | ||
963 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
964 | land.LandData.UserLocation != Vector3.Zero && | ||
965 | GodLevel < 200 && | ||
966 | ((land.LandData.OwnerID != m_uuid && | ||
967 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
968 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) | ||
969 | { | ||
970 | pos = land.LandData.UserLocation; | ||
971 | } | ||
972 | } | ||
973 | |||
974 | land.SendLandUpdateToClient(ControllingClient); | ||
975 | } | ||
976 | |||
977 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | ||
978 | { | ||
979 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | ||
980 | |||
981 | if (pos.X < 0) | ||
982 | { | ||
983 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | ||
984 | if (!(pos.Y < 0)) | ||
985 | emergencyPos.Y = pos.Y; | ||
986 | if (!(pos.Z < 0)) | ||
987 | emergencyPos.Z = pos.Z; | ||
988 | } | ||
989 | if (pos.Y < 0) | ||
990 | { | ||
991 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | ||
992 | if (!(pos.X < 0)) | ||
993 | emergencyPos.X = pos.X; | ||
994 | if (!(pos.Z < 0)) | ||
995 | emergencyPos.Z = pos.Z; | ||
996 | } | ||
997 | if (pos.Z < 0) | ||
998 | { | ||
999 | emergencyPos.Z = 128; | ||
1000 | if (!(pos.Y < 0)) | ||
1001 | emergencyPos.Y = pos.Y; | ||
1002 | if (!(pos.X < 0)) | ||
1003 | emergencyPos.X = pos.X; | ||
1004 | } | ||
1005 | } | ||
1006 | |||
867 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 1007 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
868 | { | 1008 | { |
869 | m_log.WarnFormat( | 1009 | m_log.WarnFormat( |
@@ -988,16 +1128,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
988 | /// <summary> | 1128 | /// <summary> |
989 | /// Removes physics plugin scene representation of this agent if it exists. | 1129 | /// Removes physics plugin scene representation of this agent if it exists. |
990 | /// </summary> | 1130 | /// </summary> |
991 | private void RemoveFromPhysicalScene() | 1131 | public void RemoveFromPhysicalScene() |
992 | { | 1132 | { |
993 | if (PhysicsActor != null) | 1133 | if (PhysicsActor != null) |
994 | { | 1134 | { |
995 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1135 | try |
996 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1136 | { |
997 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | 1137 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
998 | m_physicsActor.UnSubscribeEvents(); | 1138 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; |
999 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1139 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1000 | PhysicsActor = null; | 1140 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); |
1141 | m_physicsActor.UnSubscribeEvents(); | ||
1142 | PhysicsActor = null; | ||
1143 | } | ||
1144 | catch | ||
1145 | { } | ||
1001 | } | 1146 | } |
1002 | } | 1147 | } |
1003 | 1148 | ||
@@ -1008,11 +1153,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1008 | public void Teleport(Vector3 pos) | 1153 | public void Teleport(Vector3 pos) |
1009 | { | 1154 | { |
1010 | bool isFlying = false; | 1155 | bool isFlying = false; |
1156 | |||
1011 | if (m_physicsActor != null) | 1157 | if (m_physicsActor != null) |
1012 | isFlying = m_physicsActor.Flying; | 1158 | isFlying = m_physicsActor.Flying; |
1013 | 1159 | ||
1014 | RemoveFromPhysicalScene(); | 1160 | RemoveFromPhysicalScene(); |
1015 | Velocity = Vector3.Zero; | 1161 | Velocity = Vector3.Zero; |
1162 | CheckLandingPoint(ref pos); | ||
1016 | AbsolutePosition = pos; | 1163 | AbsolutePosition = pos; |
1017 | AddToPhysicalScene(isFlying); | 1164 | AddToPhysicalScene(isFlying); |
1018 | if (m_appearance != null) | 1165 | if (m_appearance != null) |
@@ -1022,6 +1169,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1022 | } | 1169 | } |
1023 | 1170 | ||
1024 | SendTerseUpdateToAllClients(); | 1171 | SendTerseUpdateToAllClients(); |
1172 | |||
1025 | } | 1173 | } |
1026 | 1174 | ||
1027 | public void TeleportWithMomentum(Vector3 pos) | 1175 | public void TeleportWithMomentum(Vector3 pos) |
@@ -1031,6 +1179,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1031 | isFlying = m_physicsActor.Flying; | 1179 | isFlying = m_physicsActor.Flying; |
1032 | 1180 | ||
1033 | RemoveFromPhysicalScene(); | 1181 | RemoveFromPhysicalScene(); |
1182 | CheckLandingPoint(ref pos); | ||
1034 | AbsolutePosition = pos; | 1183 | AbsolutePosition = pos; |
1035 | AddToPhysicalScene(isFlying); | 1184 | AddToPhysicalScene(isFlying); |
1036 | if (m_appearance != null) | 1185 | if (m_appearance != null) |
@@ -1242,6 +1391,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1242 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1391 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1243 | 1392 | ||
1244 | m_pos = m_LastFinitePos; | 1393 | m_pos = m_LastFinitePos; |
1394 | |||
1245 | if (!m_pos.IsFinite()) | 1395 | if (!m_pos.IsFinite()) |
1246 | { | 1396 | { |
1247 | m_pos.X = 127f; | 1397 | m_pos.X = 127f; |
@@ -1312,7 +1462,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1312 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1462 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1313 | } | 1463 | } |
1314 | } | 1464 | } |
1315 | |||
1316 | lock (scriptedcontrols) | 1465 | lock (scriptedcontrols) |
1317 | { | 1466 | { |
1318 | if (scriptedcontrols.Count > 0) | 1467 | if (scriptedcontrols.Count > 0) |
@@ -1327,6 +1476,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1327 | 1476 | ||
1328 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1477 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1329 | { | 1478 | { |
1479 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. | ||
1480 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | ||
1481 | |||
1330 | // TODO: This doesn't prevent the user from walking yet. | 1482 | // TODO: This doesn't prevent the user from walking yet. |
1331 | // Setting parent ID would fix this, if we knew what value | 1483 | // Setting parent ID would fix this, if we knew what value |
1332 | // to use. Or we could add a m_isSitting variable. | 1484 | // to use. Or we could add a m_isSitting variable. |
@@ -1375,12 +1527,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1375 | if (actor.Flying != oldflying) | 1527 | if (actor.Flying != oldflying) |
1376 | update_movementflag = true; | 1528 | update_movementflag = true; |
1377 | 1529 | ||
1530 | if (m_animator.m_jumping) // add for jumping | ||
1531 | update_movementflag = true; | ||
1532 | |||
1378 | if (q != m_bodyRot) | 1533 | if (q != m_bodyRot) |
1379 | { | 1534 | { |
1380 | m_bodyRot = q; | 1535 | m_bodyRot = q; |
1381 | update_rotation = true; | 1536 | update_rotation = true; |
1382 | } | 1537 | } |
1383 | 1538 | ||
1539 | //guilty until proven innocent.. | ||
1540 | bool Nudging = true; | ||
1541 | //Basically, if there is at least one non-nudge control then we don't need | ||
1542 | //to worry about stopping the avatar | ||
1543 | |||
1384 | if (m_parentID == 0) | 1544 | if (m_parentID == 0) |
1385 | { | 1545 | { |
1386 | bool bAllowUpdateMoveToPosition = false; | 1546 | bool bAllowUpdateMoveToPosition = false; |
@@ -1395,9 +1555,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1395 | else | 1555 | else |
1396 | dirVectors = Dir_Vectors; | 1556 | dirVectors = Dir_Vectors; |
1397 | 1557 | ||
1398 | // The fact that m_movementflag is a byte needs to be fixed | 1558 | bool[] isNudge = GetDirectionIsNudge(); |
1399 | // it really should be a uint | 1559 | |
1400 | uint nudgehack = 250; | 1560 | |
1561 | |||
1562 | |||
1563 | |||
1401 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1564 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1402 | { | 1565 | { |
1403 | if (((uint)flags & (uint)DCF) != 0) | 1566 | if (((uint)flags & (uint)DCF) != 0) |
@@ -1407,40 +1570,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1407 | try | 1570 | try |
1408 | { | 1571 | { |
1409 | agent_control_v3 += dirVectors[i]; | 1572 | agent_control_v3 += dirVectors[i]; |
1410 | //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); | 1573 | if (isNudge[i] == false) |
1574 | { | ||
1575 | Nudging = false; | ||
1576 | } | ||
1411 | } | 1577 | } |
1412 | catch (IndexOutOfRangeException) | 1578 | catch (IndexOutOfRangeException) |
1413 | { | 1579 | { |
1414 | // Why did I get this? | 1580 | // Why did I get this? |
1415 | } | 1581 | } |
1416 | 1582 | ||
1417 | if ((m_movementflag & (byte)(uint)DCF) == 0) | 1583 | if ((m_movementflag & (uint)DCF) == 0) |
1418 | { | 1584 | { |
1419 | if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1420 | { | ||
1421 | m_movementflag |= (byte)nudgehack; | ||
1422 | } | ||
1423 | m_movementflag += (byte)(uint)DCF; | 1585 | m_movementflag += (byte)(uint)DCF; |
1424 | update_movementflag = true; | 1586 | update_movementflag = true; |
1425 | } | 1587 | } |
1426 | } | 1588 | } |
1427 | else | 1589 | else |
1428 | { | 1590 | { |
1429 | if ((m_movementflag & (byte)(uint)DCF) != 0 || | 1591 | if ((m_movementflag & (uint)DCF) != 0) |
1430 | ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1431 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1432 | ) // This or is for Nudge forward | ||
1433 | { | 1592 | { |
1434 | m_movementflag -= ((byte)(uint)DCF); | 1593 | m_movementflag -= (byte)(uint)DCF; |
1435 | |||
1436 | update_movementflag = true; | 1594 | update_movementflag = true; |
1437 | /* | ||
1438 | if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1439 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1440 | { | ||
1441 | m_log.Debug("Removed Hack flag"); | ||
1442 | } | ||
1443 | */ | ||
1444 | } | 1595 | } |
1445 | else | 1596 | else |
1446 | { | 1597 | { |
@@ -1449,7 +1600,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1449 | } | 1600 | } |
1450 | i++; | 1601 | i++; |
1451 | } | 1602 | } |
1452 | |||
1453 | //Paupaw:Do Proper PID for Autopilot here | 1603 | //Paupaw:Do Proper PID for Autopilot here |
1454 | if (bResetMoveToPosition) | 1604 | if (bResetMoveToPosition) |
1455 | { | 1605 | { |
@@ -1484,6 +1634,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1484 | // Ignore z component of vector | 1634 | // Ignore z component of vector |
1485 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1635 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1486 | LocalVectorToTarget2D.Normalize(); | 1636 | LocalVectorToTarget2D.Normalize(); |
1637 | |||
1638 | //We're not nudging | ||
1639 | Nudging = false; | ||
1487 | agent_control_v3 += LocalVectorToTarget2D; | 1640 | agent_control_v3 += LocalVectorToTarget2D; |
1488 | 1641 | ||
1489 | // update avatar movement flags. the avatar coordinate system is as follows: | 1642 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1574,13 +1727,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1574 | // m_log.DebugFormat( | 1727 | // m_log.DebugFormat( |
1575 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1728 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1576 | 1729 | ||
1577 | AddNewMovement(agent_control_v3, q); | 1730 | AddNewMovement(agent_control_v3, q, Nudging); |
1578 | 1731 | ||
1579 | 1732 | ||
1580 | } | 1733 | } |
1581 | } | 1734 | } |
1582 | 1735 | ||
1583 | if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround) | 1736 | if (update_movementflag && !SitGround) |
1584 | Animator.UpdateMovementAnimations(); | 1737 | Animator.UpdateMovementAnimations(); |
1585 | 1738 | ||
1586 | m_scene.EventManager.TriggerOnClientMovement(this); | 1739 | m_scene.EventManager.TriggerOnClientMovement(this); |
@@ -1595,7 +1748,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1595 | m_sitAtAutoTarget = false; | 1748 | m_sitAtAutoTarget = false; |
1596 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | 1749 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; |
1597 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1750 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1598 | |||
1599 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); | 1751 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); |
1600 | proxyObjectGroup.AttachToScene(m_scene); | 1752 | proxyObjectGroup.AttachToScene(m_scene); |
1601 | 1753 | ||
@@ -1636,8 +1788,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1636 | return; | 1788 | return; |
1637 | } | 1789 | } |
1638 | m_moveToPositionInProgress = true; | 1790 | m_moveToPositionInProgress = true; |
1639 | m_moveToPositionTarget = new Vector3(locx, locy, locz); | 1791 | m_moveToPositionTarget = new Vector3(locx, locy, locz + (m_appearance.AvatarHeight / 2.0f)); |
1640 | } | 1792 | } |
1641 | catch (Exception ex) | 1793 | catch (Exception ex) |
1642 | { | 1794 | { |
1643 | //Why did I get this error? | 1795 | //Why did I get this error? |
@@ -1659,7 +1811,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1659 | Velocity = Vector3.Zero; | 1811 | Velocity = Vector3.Zero; |
1660 | SendAvatarDataToAllAgents(); | 1812 | SendAvatarDataToAllAgents(); |
1661 | 1813 | ||
1662 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1814 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1663 | } | 1815 | } |
1664 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1816 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1665 | m_requestedSitTargetUUID = UUID.Zero; | 1817 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1696,25 +1848,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1696 | 1848 | ||
1697 | if (m_parentID != 0) | 1849 | if (m_parentID != 0) |
1698 | { | 1850 | { |
1699 | m_log.Debug("StandupCode Executed"); | 1851 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
1700 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | ||
1701 | if (part != null) | 1852 | if (part != null) |
1702 | { | 1853 | { |
1854 | part.TaskInventory.LockItemsForRead(true); | ||
1703 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1855 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1704 | if (taskIDict != null) | 1856 | if (taskIDict != null) |
1705 | { | 1857 | { |
1706 | lock (taskIDict) | 1858 | foreach (UUID taskID in taskIDict.Keys) |
1707 | { | 1859 | { |
1708 | foreach (UUID taskID in taskIDict.Keys) | 1860 | UnRegisterControlEventsToScript(LocalId, taskID); |
1709 | { | 1861 | taskIDict[taskID].PermsMask &= ~( |
1710 | UnRegisterControlEventsToScript(LocalId, taskID); | 1862 | 2048 | //PERMISSION_CONTROL_CAMERA |
1711 | taskIDict[taskID].PermsMask &= ~( | 1863 | 4); // PERMISSION_TAKE_CONTROLS |
1712 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1713 | 4); // PERMISSION_TAKE_CONTROLS | ||
1714 | } | ||
1715 | } | 1864 | } |
1716 | |||
1717 | } | 1865 | } |
1866 | part.TaskInventory.LockItemsForRead(false); | ||
1718 | // Reset sit target. | 1867 | // Reset sit target. |
1719 | if (part.GetAvatarOnSitTarget() == UUID) | 1868 | if (part.GetAvatarOnSitTarget() == UUID) |
1720 | part.SitTargetAvatar = UUID.Zero; | 1869 | part.SitTargetAvatar = UUID.Zero; |
@@ -1723,16 +1872,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
1723 | m_parentPosition = part.GetWorldPosition(); | 1872 | m_parentPosition = part.GetWorldPosition(); |
1724 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1873 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1725 | } | 1874 | } |
1875 | // part.GetWorldRotation() is the rotation of the object being sat on | ||
1876 | // Rotation is the sittiing Av's rotation | ||
1877 | |||
1878 | Quaternion partRot; | ||
1879 | // if (part.LinkNum == 1) | ||
1880 | // { // Root prim of linkset | ||
1881 | // partRot = part.ParentGroup.RootPart.RotationOffset; | ||
1882 | // } | ||
1883 | // else | ||
1884 | // { // single or child prim | ||
1885 | |||
1886 | // } | ||
1887 | if (part == null) //CW: Part may be gone. llDie() for example. | ||
1888 | { | ||
1889 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1890 | } | ||
1891 | else | ||
1892 | { | ||
1893 | partRot = part.GetWorldRotation(); | ||
1894 | } | ||
1895 | |||
1896 | Quaternion partIRot = Quaternion.Inverse(partRot); | ||
1726 | 1897 | ||
1898 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av | ||
1899 | Vector3 avStandUp = new Vector3(0.3f, 0f, 0f) * avatarRot; // 0.3M infront of av | ||
1900 | |||
1901 | |||
1727 | if (m_physicsActor == null) | 1902 | if (m_physicsActor == null) |
1728 | { | 1903 | { |
1729 | AddToPhysicalScene(false); | 1904 | AddToPhysicalScene(false); |
1730 | } | 1905 | } |
1731 | 1906 | //CW: If the part isn't null then we can set the current position | |
1732 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1907 | if (part != null) |
1733 | m_parentPosition = Vector3.Zero; | 1908 | { |
1734 | 1909 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! | |
1735 | m_parentID = 0; | 1910 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. |
1911 | part.IsOccupied = false; | ||
1912 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); | ||
1913 | } | ||
1914 | else | ||
1915 | { | ||
1916 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue | ||
1917 | AbsolutePosition = m_lastWorldPosition; | ||
1918 | } | ||
1919 | |||
1920 | m_parentPosition = Vector3.Zero; | ||
1921 | m_parentID = 0; | ||
1922 | m_linkedPrim = UUID.Zero; | ||
1923 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1736 | SendAvatarDataToAllAgents(); | 1924 | SendAvatarDataToAllAgents(); |
1737 | m_requestedSitTargetID = 0; | 1925 | m_requestedSitTargetID = 0; |
1738 | if (m_physicsActor != null && m_appearance != null) | 1926 | if (m_physicsActor != null && m_appearance != null) |
@@ -1741,7 +1929,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1741 | SetHeight(m_appearance.AvatarHeight); | 1929 | SetHeight(m_appearance.AvatarHeight); |
1742 | } | 1930 | } |
1743 | } | 1931 | } |
1744 | |||
1745 | Animator.TrySetMovementAnimation("STAND"); | 1932 | Animator.TrySetMovementAnimation("STAND"); |
1746 | } | 1933 | } |
1747 | 1934 | ||
@@ -1772,13 +1959,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1772 | Vector3 avSitOffSet = part.SitTargetPosition; | 1959 | Vector3 avSitOffSet = part.SitTargetPosition; |
1773 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1960 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1774 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1961 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1775 | 1962 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); | |
1776 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1963 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1777 | bool SitTargetisSet = | 1964 | if (SitTargetisSet && !SitTargetOccupied) |
1778 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | ||
1779 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | ||
1780 | |||
1781 | if (SitTargetisSet && SitTargetUnOccupied) | ||
1782 | { | 1965 | { |
1783 | //switch the target to this prim | 1966 | //switch the target to this prim |
1784 | return part; | 1967 | return part; |
@@ -1792,85 +1975,168 @@ namespace OpenSim.Region.Framework.Scenes | |||
1792 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 1975 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) |
1793 | { | 1976 | { |
1794 | bool autopilot = true; | 1977 | bool autopilot = true; |
1978 | Vector3 autopilotTarget = new Vector3(); | ||
1979 | Quaternion sitOrientation = Quaternion.Identity; | ||
1795 | Vector3 pos = new Vector3(); | 1980 | Vector3 pos = new Vector3(); |
1796 | Quaternion sitOrientation = pSitOrientation; | ||
1797 | Vector3 cameraEyeOffset = Vector3.Zero; | 1981 | Vector3 cameraEyeOffset = Vector3.Zero; |
1798 | Vector3 cameraAtOffset = Vector3.Zero; | 1982 | Vector3 cameraAtOffset = Vector3.Zero; |
1799 | bool forceMouselook = false; | 1983 | bool forceMouselook = false; |
1800 | 1984 | ||
1801 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1985 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1802 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1986 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1803 | if (part != null) | 1987 | if (part == null) return; |
1804 | { | 1988 | |
1805 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1989 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1806 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1990 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1807 | 1991 | ||
1808 | // Is a sit target available? | 1992 | // part is the prim to sit on |
1809 | Vector3 avSitOffSet = part.SitTargetPosition; | 1993 | // offset is the world-ref vector distance from that prim center to the click-spot |
1810 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1994 | // UUID is the UUID of the Avatar doing the clicking |
1811 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1995 | |
1812 | 1996 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | |
1813 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1997 | |
1814 | bool SitTargetisSet = | 1998 | // Is a sit target available? |
1815 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && | 1999 | Vector3 avSitOffSet = part.SitTargetPosition; |
1816 | ( | 2000 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1817 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 1f // Valid Zero Rotation quaternion | 2001 | |
1818 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point | 2002 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1819 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion | 2003 | // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
1820 | ) | 2004 | Quaternion partRot; |
1821 | )); | 2005 | // if (part.LinkNum == 1) |
1822 | 2006 | // { // Root prim of linkset | |
1823 | if (SitTargetisSet && SitTargetUnOccupied) | 2007 | // partRot = part.ParentGroup.RootPart.RotationOffset; |
1824 | { | 2008 | // } |
1825 | part.SitTargetAvatar = UUID; | 2009 | // else |
1826 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 2010 | // { // single or child prim |
1827 | sitOrientation = avSitOrientation; | 2011 | partRot = part.GetWorldRotation(); |
1828 | autopilot = false; | 2012 | // } |
1829 | } | 2013 | Quaternion partIRot = Quaternion.Inverse(partRot); |
1830 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2014 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); |
1831 | 2015 | // Sit analysis rewritten by KF 091125 | |
1832 | pos = part.AbsolutePosition + offset; | 2016 | if (SitTargetisSet) // scipted sit |
1833 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 2017 | { |
1834 | //{ | 2018 | if (!part.IsOccupied) |
1835 | // offset = pos; | 2019 | { |
1836 | //autopilot = false; | 2020 | //Console.WriteLine("Scripted, unoccupied"); |
1837 | //} | 2021 | part.SitTargetAvatar = UUID; // set that Av will be on it |
1838 | if (m_physicsActor != null) | 2022 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1839 | { | 2023 | |
1840 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 2024 | Quaternion nrot = avSitOrientation; |
1841 | // We can remove the physicsActor until they stand up. | 2025 | if (!part.IsRoot) |
1842 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
1843 | |||
1844 | if (autopilot) | ||
1845 | { | 2026 | { |
1846 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 2027 | nrot = part.RotationOffset * avSitOrientation; |
1847 | { | ||
1848 | autopilot = false; | ||
1849 | |||
1850 | RemoveFromPhysicalScene(); | ||
1851 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | ||
1852 | } | ||
1853 | } | 2028 | } |
1854 | else | 2029 | sitOrientation = nrot; // Change rotatione to the scripted one |
2030 | OffsetRotation = nrot; | ||
2031 | autopilot = false; // Jump direct to scripted llSitPos() | ||
2032 | } | ||
2033 | else | ||
2034 | { | ||
2035 | //Console.WriteLine("Scripted, occupied"); | ||
2036 | return; | ||
2037 | } | ||
2038 | } | ||
2039 | else // Not Scripted | ||
2040 | { | ||
2041 | if ( (Math.Abs(offset.X) > 0.1f) || (Math.Abs(offset.Y) > 0.1f) ) // Changed 0.5M to 0.1M as they want to be able to sit close together | ||
2042 | { | ||
2043 | // large prim & offset, ignore if other Avs sitting | ||
2044 | // offset.Z -= 0.05f; | ||
2045 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked | ||
2046 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point | ||
2047 | |||
2048 | //Console.WriteLine(" offset ={0}", offset); | ||
2049 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); | ||
2050 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); | ||
2051 | |||
2052 | } | ||
2053 | else // small offset | ||
2054 | { | ||
2055 | //Console.WriteLine("Small offset"); | ||
2056 | if (!part.IsOccupied) | ||
2057 | { | ||
2058 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | ||
2059 | autopilotTarget = part.AbsolutePosition; | ||
2060 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
2061 | } | ||
2062 | else return; // occupied small | ||
2063 | } // end large/small | ||
2064 | } // end Scripted/not | ||
2065 | |||
2066 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2067 | |||
2068 | cameraAtOffset = part.GetCameraAtOffset(); | ||
2069 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2070 | forceMouselook = part.GetForceMouselook(); | ||
2071 | if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // | ||
2072 | if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // | ||
2073 | |||
2074 | if (m_physicsActor != null) | ||
2075 | { | ||
2076 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | ||
2077 | // We can remove the physicsActor until they stand up. | ||
2078 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
2079 | if (autopilot) | ||
2080 | { // its not a scripted sit | ||
2081 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | ||
2082 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) | ||
1855 | { | 2083 | { |
2084 | autopilot = false; // close enough | ||
2085 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2086 | Not using the part's position because returning the AV to the last known standing | ||
2087 | position is likely to be more friendly, isn't it? */ | ||
1856 | RemoveFromPhysicalScene(); | 2088 | RemoveFromPhysicalScene(); |
1857 | } | 2089 | Velocity = Vector3.Zero; |
2090 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target | ||
2091 | } // else the autopilot will get us close | ||
2092 | } | ||
2093 | else | ||
2094 | { // its a scripted sit | ||
2095 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2096 | I *am* using the part's position this time because we have no real idea how far away | ||
2097 | the avatar is from the sit target. */ | ||
2098 | RemoveFromPhysicalScene(); | ||
2099 | Velocity = Vector3.Zero; | ||
1858 | } | 2100 | } |
1859 | |||
1860 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1861 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1862 | forceMouselook = part.GetForceMouselook(); | ||
1863 | } | 2101 | } |
1864 | 2102 | else return; // physactor is null! | |
1865 | ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2103 | |
1866 | m_requestedSitTargetUUID = targetID; | 2104 | Vector3 offsetr; // = offset * partIRot; |
2105 | // KF: In a linkset, offsetr needs to be relative to the group root! 091208 | ||
2106 | // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); | ||
2107 | // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. | ||
2108 | // { // Single, or Root prim of linkset, target is ClickOffset * RootRot | ||
2109 | //offsetr = offset * partIRot; | ||
2110 | // | ||
2111 | // } | ||
2112 | // else | ||
2113 | // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) | ||
2114 | // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + | ||
2115 | // (offset * partRot); | ||
2116 | // } | ||
2117 | |||
2118 | //Console.WriteLine(" "); | ||
2119 | //Console.WriteLine("link number ={0}", part.LinkNum); | ||
2120 | //Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); | ||
2121 | //Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); | ||
2122 | //Console.WriteLine("Click offst ={0}", offset); | ||
2123 | //Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); | ||
2124 | //Console.WriteLine("offsetr ={0}", offsetr); | ||
2125 | //Console.WriteLine("Camera At ={0}", cameraAtOffset); | ||
2126 | //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); | ||
2127 | |||
2128 | //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child | ||
2129 | ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2130 | |||
2131 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target | ||
1867 | // This calls HandleAgentSit twice, once from here, and the client calls | 2132 | // This calls HandleAgentSit twice, once from here, and the client calls |
1868 | // HandleAgentSit itself after it gets to the location | 2133 | // HandleAgentSit itself after it gets to the location |
1869 | // It doesn't get to the location until we've moved them there though | 2134 | // It doesn't get to the location until we've moved them there though |
1870 | // which happens in HandleAgentSit :P | 2135 | // which happens in HandleAgentSit :P |
1871 | m_autopilotMoving = autopilot; | 2136 | m_autopilotMoving = autopilot; |
1872 | m_autoPilotTarget = pos; | 2137 | m_autoPilotTarget = autopilotTarget; |
1873 | m_sitAtAutoTarget = autopilot; | 2138 | m_sitAtAutoTarget = autopilot; |
2139 | m_initialSitTarget = autopilotTarget; | ||
1874 | if (!autopilot) | 2140 | if (!autopilot) |
1875 | HandleAgentSit(remoteClient, UUID); | 2141 | HandleAgentSit(remoteClient, UUID); |
1876 | } | 2142 | } |
@@ -2165,47 +2431,130 @@ namespace OpenSim.Region.Framework.Scenes | |||
2165 | { | 2431 | { |
2166 | if (part != null) | 2432 | if (part != null) |
2167 | { | 2433 | { |
2434 | //Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); | ||
2168 | if (part.GetAvatarOnSitTarget() == UUID) | 2435 | if (part.GetAvatarOnSitTarget() == UUID) |
2169 | { | 2436 | { |
2437 | //Console.WriteLine("Scripted Sit"); | ||
2438 | // Scripted sit | ||
2170 | Vector3 sitTargetPos = part.SitTargetPosition; | 2439 | Vector3 sitTargetPos = part.SitTargetPosition; |
2171 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 2440 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
2172 | |||
2173 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
2174 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
2175 | |||
2176 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
2177 | |||
2178 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 2441 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
2179 | m_pos += SIT_TARGET_ADJUSTMENT; | 2442 | m_pos += SIT_TARGET_ADJUSTMENT; |
2443 | if (!part.IsRoot) | ||
2444 | { | ||
2445 | m_pos *= part.RotationOffset; | ||
2446 | } | ||
2180 | m_bodyRot = sitTargetOrient; | 2447 | m_bodyRot = sitTargetOrient; |
2181 | //Rotation = sitTargetOrient; | ||
2182 | m_parentPosition = part.AbsolutePosition; | 2448 | m_parentPosition = part.AbsolutePosition; |
2183 | 2449 | part.IsOccupied = true; | |
2184 | //SendTerseUpdateToAllClients(); | 2450 | part.ParentGroup.AddAvatar(agentID); |
2185 | } | 2451 | } |
2186 | else | 2452 | else |
2187 | { | 2453 | { |
2188 | m_pos -= part.AbsolutePosition; | 2454 | // if m_avUnscriptedSitPos is zero then Av sits above center |
2455 | // Else Av sits at m_avUnscriptedSitPos | ||
2456 | |||
2457 | // Non-scripted sit by Kitto Flora 21Nov09 | ||
2458 | // Calculate angle of line from prim to Av | ||
2459 | Quaternion partIRot; | ||
2460 | // if (part.LinkNum == 1) | ||
2461 | // { // Root prim of linkset | ||
2462 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2463 | // } | ||
2464 | // else | ||
2465 | // { // single or child prim | ||
2466 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2467 | // } | ||
2468 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | ||
2469 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | ||
2470 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | ||
2471 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
2472 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
2473 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
2474 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
2475 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
2476 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
2477 | |||
2189 | m_parentPosition = part.AbsolutePosition; | 2478 | m_parentPosition = part.AbsolutePosition; |
2190 | } | 2479 | part.IsOccupied = true; |
2480 | part.ParentGroup.AddAvatar(agentID); | ||
2481 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation | ||
2482 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center | ||
2483 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + | ||
2484 | m_avUnscriptedSitPos; // adds click offset, if any | ||
2485 | //Set up raytrace to find top surface of prim | ||
2486 | Vector3 size = part.Scale; | ||
2487 | float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
2488 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
2489 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
2490 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); | ||
2491 | m_scene.PhysicsScene.RaycastWorld( | ||
2492 | start, // Vector3 position, | ||
2493 | down, // Vector3 direction, | ||
2494 | mag, // float length, | ||
2495 | SitAltitudeCallback); // retMethod | ||
2496 | } // end scripted/not | ||
2191 | } | 2497 | } |
2192 | else | 2498 | else // no Av |
2193 | { | 2499 | { |
2194 | return; | 2500 | return; |
2195 | } | 2501 | } |
2196 | } | 2502 | } |
2197 | m_parentID = m_requestedSitTargetID; | ||
2198 | 2503 | ||
2504 | //We want our offsets to reference the root prim, not the child we may have sat on | ||
2505 | if (!part.IsRoot) | ||
2506 | { | ||
2507 | m_parentID = part.ParentGroup.RootPart.LocalId; | ||
2508 | m_pos += part.OffsetPosition; | ||
2509 | } | ||
2510 | else | ||
2511 | { | ||
2512 | m_parentID = m_requestedSitTargetID; | ||
2513 | } | ||
2514 | |||
2515 | m_linkedPrim = part.UUID; | ||
2516 | if (part.GetAvatarOnSitTarget() != UUID) | ||
2517 | { | ||
2518 | m_offsetRotation = m_offsetRotation / part.RotationOffset; | ||
2519 | } | ||
2199 | Velocity = Vector3.Zero; | 2520 | Velocity = Vector3.Zero; |
2200 | RemoveFromPhysicalScene(); | 2521 | RemoveFromPhysicalScene(); |
2201 | |||
2202 | Animator.TrySetMovementAnimation(sitAnimation); | 2522 | Animator.TrySetMovementAnimation(sitAnimation); |
2203 | SendAvatarDataToAllAgents(); | 2523 | SendAvatarDataToAllAgents(); |
2204 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | ||
2205 | // So we're also sending a terse update (which has avatar rotation) | ||
2206 | // [Update] We do now. | ||
2207 | //SendTerseUpdateToAllClients(); | 2524 | //SendTerseUpdateToAllClients(); |
2208 | } | 2525 | } |
2526 | |||
2527 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) | ||
2528 | { | ||
2529 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer | ||
2530 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. | ||
2531 | if(hitYN) | ||
2532 | { | ||
2533 | // m_pos = Av offset from prim center to make look like on center | ||
2534 | // m_parentPosition = Actual center pos of prim | ||
2535 | // collisionPoint = spot on prim where we want to sit | ||
2536 | // collisionPoint.Z = global sit surface height | ||
2537 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
2538 | Quaternion partIRot; | ||
2539 | // if (part.LinkNum == 1) | ||
2540 | /// { // Root prim of linkset | ||
2541 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2542 | // } | ||
2543 | // else | ||
2544 | // { // single or child prim | ||
2545 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2546 | // } | ||
2547 | if (m_initialSitTarget != null) | ||
2548 | { | ||
2549 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | ||
2550 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction | ||
2551 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); | ||
2552 | m_pos += offset; | ||
2553 | // ControllingClient.SendClearFollowCamProperties(part.UUID); | ||
2554 | } | ||
2555 | |||
2556 | } | ||
2557 | } // End SitAltitudeCallback KF. | ||
2209 | 2558 | ||
2210 | /// <summary> | 2559 | /// <summary> |
2211 | /// Event handler for the 'Always run' setting on the client | 2560 | /// Event handler for the 'Always run' setting on the client |
@@ -2235,12 +2584,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2235 | /// </summary> | 2584 | /// </summary> |
2236 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2585 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
2237 | /// <param name="rotation">The direction in which this avatar should now face. | 2586 | /// <param name="rotation">The direction in which this avatar should now face. |
2238 | public void AddNewMovement(Vector3 vec, Quaternion rotation) | 2587 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) |
2239 | { | 2588 | { |
2240 | if (m_isChildAgent) | 2589 | if (m_isChildAgent) |
2241 | { | 2590 | { |
2242 | // WHAT??? | 2591 | // WHAT??? |
2243 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); | 2592 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent"); |
2593 | |||
2244 | return; | 2594 | return; |
2245 | } | 2595 | } |
2246 | 2596 | ||
@@ -2249,15 +2599,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
2249 | Rotation = rotation; | 2599 | Rotation = rotation; |
2250 | Vector3 direc = vec * rotation; | 2600 | Vector3 direc = vec * rotation; |
2251 | direc.Normalize(); | 2601 | direc.Normalize(); |
2602 | PhysicsActor actor = m_physicsActor; | ||
2603 | |||
2604 | if (actor.Flying != m_flyingOld) // add for fly velocity control | ||
2605 | { | ||
2606 | m_flyingOld = actor.Flying; // add for fly velocity control | ||
2607 | if (!actor.Flying) m_wasFlying = true; // add for fly velocity control | ||
2608 | } | ||
2609 | |||
2610 | if (m_physicsActor.IsColliding == true) m_wasFlying = false; // add for fly velocity control | ||
2611 | |||
2612 | if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. | ||
2252 | 2613 | ||
2253 | direc *= 0.03f * 128f * m_speedModifier; | 2614 | direc *= 0.03f * 128f * m_speedModifier; |
2254 | 2615 | ||
2255 | PhysicsActor actor = m_physicsActor; | ||
2256 | if (actor != null) | 2616 | if (actor != null) |
2257 | { | 2617 | { |
2258 | if (actor.Flying) | 2618 | if (actor.Flying) |
2259 | { | 2619 | { |
2260 | direc *= 4.0f; | 2620 | // rm speed mod direc *= 4.0f; |
2621 | direc *= 5.2f; // for speed mod | ||
2261 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2622 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2262 | //bool colliding = (m_physicsActor.IsColliding==true); | 2623 | //bool colliding = (m_physicsActor.IsColliding==true); |
2263 | //if (controlland) | 2624 | //if (controlland) |
@@ -2270,22 +2631,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
2270 | // m_log.Info("[AGENT]: Stop FLying"); | 2631 | // m_log.Info("[AGENT]: Stop FLying"); |
2271 | //} | 2632 | //} |
2272 | } | 2633 | } |
2634 | if (Animator.m_falling && m_wasFlying) // if falling from flying, disable motion add | ||
2635 | { | ||
2636 | direc *= 0.0f; | ||
2637 | } | ||
2638 | /* This jumping section removed to SPA | ||
2273 | else if (!actor.Flying && actor.IsColliding) | 2639 | else if (!actor.Flying && actor.IsColliding) |
2274 | { | 2640 | { |
2275 | if (direc.Z > 2.0f) | 2641 | if (direc.Z > 2.0f) |
2276 | { | 2642 | { |
2277 | direc.Z *= 3.0f; | 2643 | if(m_animator.m_animTickJump == -1) |
2278 | 2644 | { | |
2279 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2645 | direc.Z *= 3.0f; // jump |
2280 | Animator.TrySetMovementAnimation("PREJUMP"); | 2646 | } |
2281 | Animator.TrySetMovementAnimation("JUMP"); | 2647 | else |
2648 | { | ||
2649 | direc.Z *= 0.1f; // prejump | ||
2650 | } | ||
2651 | / * Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs | ||
2652 | Animator.TrySetMovementAnimation("PREJUMP"); | ||
2653 | Animator.TrySetMovementAnimation("JUMP"); | ||
2654 | * / | ||
2282 | } | 2655 | } |
2283 | } | 2656 | } */ |
2284 | } | 2657 | } |
2285 | 2658 | ||
2286 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2659 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2287 | m_forceToApply = direc; | 2660 | m_forceToApply = direc; |
2288 | 2661 | m_isNudging = Nudging; | |
2289 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2662 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2290 | } | 2663 | } |
2291 | 2664 | ||
@@ -2334,6 +2707,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2334 | 2707 | ||
2335 | CheckForSignificantMovement(); // sends update to the modules. | 2708 | CheckForSignificantMovement(); // sends update to the modules. |
2336 | } | 2709 | } |
2710 | |||
2711 | //Sending prim updates AFTER the avatar terse updates are sent | ||
2712 | SendPrimUpdates(); | ||
2337 | } | 2713 | } |
2338 | 2714 | ||
2339 | #endregion | 2715 | #endregion |
@@ -3143,6 +3519,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3143 | m_callbackURI = cAgent.CallbackURI; | 3519 | m_callbackURI = cAgent.CallbackURI; |
3144 | 3520 | ||
3145 | m_pos = cAgent.Position; | 3521 | m_pos = cAgent.Position; |
3522 | |||
3146 | m_velocity = cAgent.Velocity; | 3523 | m_velocity = cAgent.Velocity; |
3147 | m_CameraCenter = cAgent.Center; | 3524 | m_CameraCenter = cAgent.Center; |
3148 | m_CameraAtAxis = cAgent.AtAxis; | 3525 | m_CameraAtAxis = cAgent.AtAxis; |
@@ -3265,20 +3642,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
3265 | /// </summary> | 3642 | /// </summary> |
3266 | public override void UpdateMovement() | 3643 | public override void UpdateMovement() |
3267 | { | 3644 | { |
3268 | if (m_forceToApply.HasValue) | 3645 | if (Animator!=null) // add for jumping |
3269 | { | 3646 | { // add for jumping |
3270 | Vector3 force = m_forceToApply.Value; | 3647 | // if (!m_animator.m_jumping) // add for jumping |
3271 | 3648 | // { // add for jumping | |
3272 | m_updateflag = true; | ||
3273 | 3649 | ||
3274 | // The magic constant 0.95f seems to make walking feel less jerky, | 3650 | if (m_forceToApply.HasValue) // this section realigned |
3275 | // probably because it hackishly accounts for the overall latency of | 3651 | { |
3276 | // these Velocity updates -- Diva | ||
3277 | Velocity = force * .95F; | ||
3278 | 3652 | ||
3279 | m_forceToApply = null; | 3653 | Vector3 force = m_forceToApply.Value; |
3280 | } | 3654 | m_updateflag = true; |
3281 | } | 3655 | if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping |
3656 | Velocity = force; | ||
3657 | //Console.WriteLine("UM1 {0}", Velocity); | ||
3658 | m_forceToApply = null; | ||
3659 | } | ||
3660 | else | ||
3661 | { | ||
3662 | if (m_isNudging) | ||
3663 | { | ||
3664 | Vector3 force = Vector3.Zero; | ||
3665 | |||
3666 | m_updateflag = true; | ||
3667 | if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping | ||
3668 | Velocity = force; | ||
3669 | //Console.WriteLine("UM2 {0}", Velocity); | ||
3670 | m_isNudging = false; | ||
3671 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" | ||
3672 | } | ||
3673 | else // add for jumping | ||
3674 | { // add for jumping | ||
3675 | Vector3 force = Vector3.Zero; // add for jumping | ||
3676 | if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping | ||
3677 | //Console.WriteLine("UM3 {0}", Velocity); | ||
3678 | Velocity = force; // add for jumping | ||
3679 | } | ||
3680 | } | ||
3681 | // } // end realign | ||
3682 | } // add for jumping | ||
3683 | } // add for jumping | ||
3282 | 3684 | ||
3283 | /// <summary> | 3685 | /// <summary> |
3284 | /// Adds a physical representation of the avatar to the Physics plugin | 3686 | /// Adds a physical representation of the avatar to the Physics plugin |
@@ -3292,10 +3694,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3292 | 3694 | ||
3293 | Vector3 pVec = AbsolutePosition; | 3695 | Vector3 pVec = AbsolutePosition; |
3294 | 3696 | ||
3295 | // Old bug where the height was in centimeters instead of meters | ||
3296 | m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, | 3697 | m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, |
3297 | new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying); | 3698 | new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying); |
3298 | |||
3299 | scene.AddPhysicsActorTaint(m_physicsActor); | 3699 | scene.AddPhysicsActorTaint(m_physicsActor); |
3300 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3700 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3301 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3701 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
@@ -3319,18 +3719,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
3319 | { | 3719 | { |
3320 | if (e == null) | 3720 | if (e == null) |
3321 | return; | 3721 | return; |
3322 | 3722 | ||
3323 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3723 | // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( |
3324 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | ||
3325 | // as of this comment the interval is set in AddToPhysicalScene | 3724 | // as of this comment the interval is set in AddToPhysicalScene |
3326 | if (Animator!=null) | 3725 | if (Animator!=null) |
3327 | Animator.UpdateMovementAnimations(); | 3726 | { |
3727 | if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, | ||
3728 | { // else its will lock out other animation changes, like ground sit. | ||
3729 | Animator.UpdateMovementAnimations(); | ||
3730 | m_updateCount--; | ||
3731 | } | ||
3732 | } | ||
3328 | 3733 | ||
3329 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3734 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3330 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3735 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3331 | 3736 | ||
3332 | CollisionPlane = Vector4.UnitW; | 3737 | CollisionPlane = Vector4.UnitW; |
3333 | 3738 | ||
3739 | if (m_lastColCount != coldata.Count) | ||
3740 | { | ||
3741 | m_updateCount = UPDATE_COUNT; | ||
3742 | m_lastColCount = coldata.Count; | ||
3743 | } | ||
3744 | |||
3334 | if (coldata.Count != 0 && Animator != null) | 3745 | if (coldata.Count != 0 && Animator != null) |
3335 | { | 3746 | { |
3336 | switch (Animator.CurrentMovementAnimation) | 3747 | switch (Animator.CurrentMovementAnimation) |
@@ -3360,6 +3771,148 @@ namespace OpenSim.Region.Framework.Scenes | |||
3360 | } | 3771 | } |
3361 | } | 3772 | } |
3362 | 3773 | ||
3774 | List<uint> thisHitColliders = new List<uint>(); | ||
3775 | List<uint> endedColliders = new List<uint>(); | ||
3776 | List<uint> startedColliders = new List<uint>(); | ||
3777 | |||
3778 | foreach (uint localid in coldata.Keys) | ||
3779 | { | ||
3780 | thisHitColliders.Add(localid); | ||
3781 | if (!m_lastColliders.Contains(localid)) | ||
3782 | { | ||
3783 | startedColliders.Add(localid); | ||
3784 | } | ||
3785 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3786 | } | ||
3787 | |||
3788 | // calculate things that ended colliding | ||
3789 | foreach (uint localID in m_lastColliders) | ||
3790 | { | ||
3791 | if (!thisHitColliders.Contains(localID)) | ||
3792 | { | ||
3793 | endedColliders.Add(localID); | ||
3794 | } | ||
3795 | } | ||
3796 | //add the items that started colliding this time to the last colliders list. | ||
3797 | foreach (uint localID in startedColliders) | ||
3798 | { | ||
3799 | m_lastColliders.Add(localID); | ||
3800 | } | ||
3801 | // remove things that ended colliding from the last colliders list | ||
3802 | foreach (uint localID in endedColliders) | ||
3803 | { | ||
3804 | m_lastColliders.Remove(localID); | ||
3805 | } | ||
3806 | |||
3807 | // do event notification | ||
3808 | if (startedColliders.Count > 0) | ||
3809 | { | ||
3810 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3811 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3812 | foreach (uint localId in startedColliders) | ||
3813 | { | ||
3814 | if (localId == 0) | ||
3815 | continue; | ||
3816 | |||
3817 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3818 | string data = ""; | ||
3819 | if (obj != null) | ||
3820 | { | ||
3821 | DetectedObject detobj = new DetectedObject(); | ||
3822 | detobj.keyUUID = obj.UUID; | ||
3823 | detobj.nameStr = obj.Name; | ||
3824 | detobj.ownerUUID = obj.OwnerID; | ||
3825 | detobj.posVector = obj.AbsolutePosition; | ||
3826 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3827 | detobj.velVector = obj.Velocity; | ||
3828 | detobj.colliderType = 0; | ||
3829 | detobj.groupUUID = obj.GroupID; | ||
3830 | colliding.Add(detobj); | ||
3831 | } | ||
3832 | } | ||
3833 | |||
3834 | if (colliding.Count > 0) | ||
3835 | { | ||
3836 | StartCollidingMessage.Colliders = colliding; | ||
3837 | |||
3838 | foreach (SceneObjectGroup att in Attachments) | ||
3839 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3840 | } | ||
3841 | } | ||
3842 | |||
3843 | if (endedColliders.Count > 0) | ||
3844 | { | ||
3845 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3846 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3847 | foreach (uint localId in endedColliders) | ||
3848 | { | ||
3849 | if (localId == 0) | ||
3850 | continue; | ||
3851 | |||
3852 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3853 | string data = ""; | ||
3854 | if (obj != null) | ||
3855 | { | ||
3856 | DetectedObject detobj = new DetectedObject(); | ||
3857 | detobj.keyUUID = obj.UUID; | ||
3858 | detobj.nameStr = obj.Name; | ||
3859 | detobj.ownerUUID = obj.OwnerID; | ||
3860 | detobj.posVector = obj.AbsolutePosition; | ||
3861 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3862 | detobj.velVector = obj.Velocity; | ||
3863 | detobj.colliderType = 0; | ||
3864 | detobj.groupUUID = obj.GroupID; | ||
3865 | colliding.Add(detobj); | ||
3866 | } | ||
3867 | } | ||
3868 | |||
3869 | if (colliding.Count > 0) | ||
3870 | { | ||
3871 | EndCollidingMessage.Colliders = colliding; | ||
3872 | |||
3873 | foreach (SceneObjectGroup att in Attachments) | ||
3874 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3875 | } | ||
3876 | } | ||
3877 | |||
3878 | if (thisHitColliders.Count > 0) | ||
3879 | { | ||
3880 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3881 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3882 | foreach (uint localId in thisHitColliders) | ||
3883 | { | ||
3884 | if (localId == 0) | ||
3885 | continue; | ||
3886 | |||
3887 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3888 | string data = ""; | ||
3889 | if (obj != null) | ||
3890 | { | ||
3891 | DetectedObject detobj = new DetectedObject(); | ||
3892 | detobj.keyUUID = obj.UUID; | ||
3893 | detobj.nameStr = obj.Name; | ||
3894 | detobj.ownerUUID = obj.OwnerID; | ||
3895 | detobj.posVector = obj.AbsolutePosition; | ||
3896 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3897 | detobj.velVector = obj.Velocity; | ||
3898 | detobj.colliderType = 0; | ||
3899 | detobj.groupUUID = obj.GroupID; | ||
3900 | colliding.Add(detobj); | ||
3901 | } | ||
3902 | } | ||
3903 | |||
3904 | if (colliding.Count > 0) | ||
3905 | { | ||
3906 | CollidingMessage.Colliders = colliding; | ||
3907 | |||
3908 | lock (m_attachments) | ||
3909 | { | ||
3910 | foreach (SceneObjectGroup att in m_attachments) | ||
3911 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3912 | } | ||
3913 | } | ||
3914 | } | ||
3915 | |||
3363 | if (m_invulnerable) | 3916 | if (m_invulnerable) |
3364 | return; | 3917 | return; |
3365 | 3918 | ||
@@ -3785,6 +4338,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3785 | return; | 4338 | return; |
3786 | } | 4339 | } |
3787 | 4340 | ||
4341 | XmlDocument doc = new XmlDocument(); | ||
4342 | string stateData = String.Empty; | ||
4343 | |||
4344 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
4345 | if (attServ != null) | ||
4346 | { | ||
4347 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
4348 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | ||
4349 | if (stateData != String.Empty) | ||
4350 | { | ||
4351 | try | ||
4352 | { | ||
4353 | doc.LoadXml(stateData); | ||
4354 | } | ||
4355 | catch { } | ||
4356 | } | ||
4357 | } | ||
4358 | |||
4359 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
4360 | |||
4361 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
4362 | if (nodes.Count > 0) | ||
4363 | { | ||
4364 | foreach (XmlNode n in nodes) | ||
4365 | { | ||
4366 | XmlElement elem = (XmlElement)n; | ||
4367 | string itemID = elem.GetAttribute("ItemID"); | ||
4368 | string xml = elem.InnerXml; | ||
4369 | |||
4370 | itemData[new UUID(itemID)] = xml; | ||
4371 | } | ||
4372 | } | ||
4373 | |||
3788 | List<AvatarAttachment> attachments = m_appearance.GetAttachments(); | 4374 | List<AvatarAttachment> attachments = m_appearance.GetAttachments(); |
3789 | foreach (AvatarAttachment attach in attachments) | 4375 | foreach (AvatarAttachment attach in attachments) |
3790 | { | 4376 | { |
@@ -3805,7 +4391,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3805 | 4391 | ||
3806 | try | 4392 | try |
3807 | { | 4393 | { |
3808 | m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); | 4394 | string xmlData; |
4395 | XmlDocument d = new XmlDocument(); | ||
4396 | UUID asset; | ||
4397 | if (itemData.TryGetValue(itemID, out xmlData)) | ||
4398 | { | ||
4399 | d.LoadXml(xmlData); | ||
4400 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | ||
4401 | |||
4402 | // Rez from inventory | ||
4403 | asset | ||
4404 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | ||
4405 | |||
4406 | } | ||
4407 | else | ||
4408 | { | ||
4409 | // Rez from inventory (with a null doc to let | ||
4410 | // CHANGED_OWNER happen) | ||
4411 | asset | ||
4412 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | ||
4413 | } | ||
4414 | |||
4415 | m_log.InfoFormat( | ||
4416 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2}", | ||
4417 | p, itemID, asset); | ||
3809 | } | 4418 | } |
3810 | catch (Exception e) | 4419 | catch (Exception e) |
3811 | { | 4420 | { |
@@ -3838,6 +4447,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3838 | m_reprioritization_called = false; | 4447 | m_reprioritization_called = false; |
3839 | } | 4448 | } |
3840 | } | 4449 | } |
4450 | |||
4451 | private Vector3 Quat2Euler(Quaternion rot){ | ||
4452 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , | ||
4453 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); | ||
4454 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); | ||
4455 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | ||
4456 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); | ||
4457 | return(new Vector3(x,y,z)); | ||
4458 | } | ||
3841 | 4459 | ||
3842 | public void SaveChangedAttachments() | 4460 | public void SaveChangedAttachments() |
3843 | { | 4461 | { |
@@ -3861,5 +4479,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3861 | } | 4479 | } |
3862 | } | 4480 | } |
3863 | } | 4481 | } |
4482 | |||
4483 | private void CheckLandingPoint(ref Vector3 pos) | ||
4484 | { | ||
4485 | // Never constrain lures | ||
4486 | if ((TeleportFlags & TeleportFlags.ViaLure) != 0) | ||
4487 | return; | ||
4488 | |||
4489 | if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) | ||
4490 | return; | ||
4491 | |||
4492 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
4493 | |||
4494 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
4495 | land.LandData.UserLocation != Vector3.Zero && | ||
4496 | land.LandData.OwnerID != m_uuid && | ||
4497 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
4498 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | ||
4499 | { | ||
4500 | float curr = Vector3.Distance(AbsolutePosition, pos); | ||
4501 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | ||
4502 | pos = land.LandData.UserLocation; | ||
4503 | else | ||
4504 | ControllingClient.SendAlertMessage("Can't teleport closer to destination"); | ||
4505 | } | ||
4506 | } | ||
3864 | } | 4507 | } |
3865 | } | 4508 | } |