diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 931 |
1 files changed, 751 insertions, 180 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 08c6e27..02e60f8 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[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | 79 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; |
@@ -88,7 +89,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
88 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 89 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
89 | /// issue #1716 | 90 | /// issue #1716 |
90 | /// </summary> | 91 | /// </summary> |
91 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | 92 | // private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); |
93 | // Value revised by KF 091121 by comparison with SL. | ||
94 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | ||
92 | 95 | ||
93 | public UUID currentParcelUUID = UUID.Zero; | 96 | public UUID currentParcelUUID = UUID.Zero; |
94 | 97 | ||
@@ -122,8 +125,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
122 | public Vector3 lastKnownAllowedPosition; | 125 | public Vector3 lastKnownAllowedPosition; |
123 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 126 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
124 | public Vector4 CollisionPlane = Vector4.UnitW; | 127 | public Vector4 CollisionPlane = Vector4.UnitW; |
125 | 128 | ||
129 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | ||
130 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims | ||
126 | private Vector3 m_lastPosition; | 131 | private Vector3 m_lastPosition; |
132 | private Vector3 m_lastWorldPosition; | ||
127 | private Quaternion m_lastRotation; | 133 | private Quaternion m_lastRotation; |
128 | private Vector3 m_lastVelocity; | 134 | private Vector3 m_lastVelocity; |
129 | //private int m_lastTerseSent; | 135 | //private int m_lastTerseSent; |
@@ -156,7 +162,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | private int m_perfMonMS; | 162 | private int m_perfMonMS; |
157 | 163 | ||
158 | private bool m_setAlwaysRun; | 164 | private bool m_setAlwaysRun; |
159 | |||
160 | private bool m_forceFly; | 165 | private bool m_forceFly; |
161 | private bool m_flyDisabled; | 166 | private bool m_flyDisabled; |
162 | 167 | ||
@@ -180,7 +185,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
180 | protected RegionInfo m_regionInfo; | 185 | protected RegionInfo m_regionInfo; |
181 | protected ulong crossingFromRegion; | 186 | protected ulong crossingFromRegion; |
182 | 187 | ||
183 | private readonly Vector3[] Dir_Vectors = new Vector3[9]; | 188 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
189 | private bool m_isNudging = false; | ||
184 | 190 | ||
185 | // Position of agent's camera in world (region cordinates) | 191 | // Position of agent's camera in world (region cordinates) |
186 | protected Vector3 m_CameraCenter; | 192 | protected Vector3 m_CameraCenter; |
@@ -205,17 +211,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
205 | private bool m_autopilotMoving; | 211 | private bool m_autopilotMoving; |
206 | private Vector3 m_autoPilotTarget; | 212 | private Vector3 m_autoPilotTarget; |
207 | private bool m_sitAtAutoTarget; | 213 | private bool m_sitAtAutoTarget; |
214 | private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit | ||
208 | 215 | ||
209 | private string m_nextSitAnimation = String.Empty; | 216 | private string m_nextSitAnimation = String.Empty; |
210 | 217 | ||
211 | //PauPaw:Proper PID Controler for autopilot************ | 218 | //PauPaw:Proper PID Controler for autopilot************ |
212 | private bool m_moveToPositionInProgress; | 219 | private bool m_moveToPositionInProgress; |
213 | private Vector3 m_moveToPositionTarget; | 220 | private Vector3 m_moveToPositionTarget; |
221 | private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
214 | 222 | ||
215 | private bool m_followCamAuto; | 223 | private bool m_followCamAuto; |
216 | 224 | ||
217 | private int m_movementUpdateCount; | 225 | private int m_movementUpdateCount; |
226 | private int m_lastColCount = -1; //KF: Look for Collision chnages | ||
227 | private int m_updateCount = 0; //KF: Update Anims for a while | ||
228 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | ||
218 | private const int NumMovementsBetweenRayCast = 5; | 229 | private const int NumMovementsBetweenRayCast = 5; |
230 | private List<uint> m_lastColliders = new List<uint>(); | ||
219 | 231 | ||
220 | private bool CameraConstraintActive; | 232 | private bool CameraConstraintActive; |
221 | //private int m_moveToPositionStateStatus; | 233 | //private int m_moveToPositionStateStatus; |
@@ -242,7 +254,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
242 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 254 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
243 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 255 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, |
244 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, | 256 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, |
245 | DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, | 257 | DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, |
258 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, | ||
259 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, | ||
246 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 260 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
247 | } | 261 | } |
248 | 262 | ||
@@ -449,9 +463,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
449 | get | 463 | get |
450 | { | 464 | { |
451 | PhysicsActor actor = m_physicsActor; | 465 | PhysicsActor actor = m_physicsActor; |
452 | if (actor != null) | 466 | // if (actor != null) |
467 | if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! | ||
453 | m_pos = actor.Position; | 468 | m_pos = actor.Position; |
454 | 469 | ||
470 | // If we're sitting, we need to update our position | ||
471 | if (m_parentID != 0) | ||
472 | { | ||
473 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | ||
474 | if (part != null) | ||
475 | m_parentPosition = part.AbsolutePosition; | ||
476 | } | ||
477 | |||
455 | return m_parentPosition + m_pos; | 478 | return m_parentPosition + m_pos; |
456 | } | 479 | } |
457 | set | 480 | set |
@@ -470,7 +493,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
470 | } | 493 | } |
471 | } | 494 | } |
472 | 495 | ||
473 | m_pos = value; | 496 | if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! |
497 | m_pos = value; | ||
474 | m_parentPosition = Vector3.Zero; | 498 | m_parentPosition = Vector3.Zero; |
475 | } | 499 | } |
476 | } | 500 | } |
@@ -514,10 +538,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
514 | } | 538 | } |
515 | } | 539 | } |
516 | 540 | ||
541 | public Quaternion OffsetRotation | ||
542 | { | ||
543 | get { return m_offsetRotation; } | ||
544 | set { m_offsetRotation = value; } | ||
545 | } | ||
546 | |||
517 | public Quaternion Rotation | 547 | public Quaternion Rotation |
518 | { | 548 | { |
519 | get { return m_bodyRot; } | 549 | get { |
520 | set { m_bodyRot = value; } | 550 | if (m_parentID != 0) |
551 | { | ||
552 | if (m_offsetRotation != null) | ||
553 | { | ||
554 | return m_offsetRotation; | ||
555 | } | ||
556 | else | ||
557 | { | ||
558 | return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
559 | } | ||
560 | |||
561 | } | ||
562 | else | ||
563 | { | ||
564 | return m_bodyRot; | ||
565 | } | ||
566 | } | ||
567 | set { | ||
568 | m_bodyRot = value; | ||
569 | if (m_parentID != 0) | ||
570 | { | ||
571 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
572 | } | ||
573 | } | ||
521 | } | 574 | } |
522 | 575 | ||
523 | public Quaternion PreviousRotation | 576 | public Quaternion PreviousRotation |
@@ -542,11 +595,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
542 | 595 | ||
543 | private uint m_parentID; | 596 | private uint m_parentID; |
544 | 597 | ||
598 | |||
599 | private UUID m_linkedPrim; | ||
600 | |||
545 | public uint ParentID | 601 | public uint ParentID |
546 | { | 602 | { |
547 | get { return m_parentID; } | 603 | get { return m_parentID; } |
548 | set { m_parentID = value; } | 604 | set { m_parentID = value; } |
549 | } | 605 | } |
606 | |||
607 | public UUID LinkedPrim | ||
608 | { | ||
609 | get { return m_linkedPrim; } | ||
610 | set { m_linkedPrim = value; } | ||
611 | } | ||
612 | |||
550 | public float Health | 613 | public float Health |
551 | { | 614 | { |
552 | get { return m_health; } | 615 | get { return m_health; } |
@@ -668,7 +731,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
668 | CreateSceneViewer(); | 731 | CreateSceneViewer(); |
669 | m_animator = new ScenePresenceAnimator(this); | 732 | m_animator = new ScenePresenceAnimator(this); |
670 | } | 733 | } |
671 | 734 | ||
672 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() | 735 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() |
673 | { | 736 | { |
674 | m_rootRegionHandle = reginfo.RegionHandle; | 737 | m_rootRegionHandle = reginfo.RegionHandle; |
@@ -700,16 +763,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
700 | m_reprioritization_timer.AutoReset = false; | 763 | m_reprioritization_timer.AutoReset = false; |
701 | 764 | ||
702 | AdjustKnownSeeds(); | 765 | AdjustKnownSeeds(); |
703 | |||
704 | // TODO: I think, this won't send anything, as we are still a child here... | ||
705 | Animator.TrySetMovementAnimation("STAND"); | 766 | Animator.TrySetMovementAnimation("STAND"); |
706 | |||
707 | // we created a new ScenePresence (a new child agent) in a fresh region. | 767 | // we created a new ScenePresence (a new child agent) in a fresh region. |
708 | // Request info about all the (root) agents in this region | 768 | // Request info about all the (root) agents in this region |
709 | // Note: This won't send data *to* other clients in that region (children don't send) | 769 | // Note: This won't send data *to* other clients in that region (children don't send) |
710 | SendInitialFullUpdateToAllClients(); | 770 | SendInitialFullUpdateToAllClients(); |
711 | |||
712 | RegisterToEvents(); | 771 | RegisterToEvents(); |
772 | if (m_controllingClient != null) | ||
773 | { | ||
774 | m_controllingClient.ProcessPendingPackets(); | ||
775 | } | ||
713 | SetDirectionVectors(); | 776 | SetDirectionVectors(); |
714 | } | 777 | } |
715 | 778 | ||
@@ -759,25 +822,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
759 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT | 822 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
760 | Dir_Vectors[4] = Vector3.UnitZ; //UP | 823 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
761 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN | 824 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
762 | Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 825 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE |
763 | Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD | 826 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE |
764 | Dir_Vectors[7] = -Vector3.UnitX; //BACK | 827 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE |
828 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE | ||
829 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | ||
765 | } | 830 | } |
766 | 831 | ||
767 | private Vector3[] GetWalkDirectionVectors() | 832 | private Vector3[] GetWalkDirectionVectors() |
768 | { | 833 | { |
769 | Vector3[] vector = new Vector3[9]; | 834 | Vector3[] vector = new Vector3[11]; |
770 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD | 835 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
771 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK | 836 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
772 | vector[2] = Vector3.UnitY; //LEFT | 837 | vector[2] = Vector3.UnitY; //LEFT |
773 | vector[3] = -Vector3.UnitY; //RIGHT | 838 | vector[3] = -Vector3.UnitY; //RIGHT |
774 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP | 839 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
775 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN | 840 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
776 | vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge | 841 | vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE |
777 | vector[6] = (new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z) * 2); //FORWARD Nudge | 842 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE |
778 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK Nudge | 843 | vector[8] = Vector3.UnitY; //LEFT_NUDGE |
844 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | ||
845 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE | ||
779 | return vector; | 846 | return vector; |
780 | } | 847 | } |
848 | |||
849 | private bool[] GetDirectionIsNudge() | ||
850 | { | ||
851 | bool[] isNudge = new bool[11]; | ||
852 | isNudge[0] = false; //FORWARD | ||
853 | isNudge[1] = false; //BACK | ||
854 | isNudge[2] = false; //LEFT | ||
855 | isNudge[3] = false; //RIGHT | ||
856 | isNudge[4] = false; //UP | ||
857 | isNudge[5] = false; //DOWN | ||
858 | isNudge[6] = true; //FORWARD_NUDGE | ||
859 | isNudge[7] = true; //BACK_NUDGE | ||
860 | isNudge[8] = true; //LEFT_NUDGE | ||
861 | isNudge[9] = true; //RIGHT_NUDGE | ||
862 | isNudge[10] = true; //DOWN_Nudge | ||
863 | return isNudge; | ||
864 | } | ||
865 | |||
781 | 866 | ||
782 | #endregion | 867 | #endregion |
783 | 868 | ||
@@ -839,6 +924,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
839 | pos.Y = crossedBorder.BorderLine.Z - 1; | 924 | pos.Y = crossedBorder.BorderLine.Z - 1; |
840 | } | 925 | } |
841 | 926 | ||
927 | //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. | ||
928 | //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, | ||
929 | //they'll bypass the landing point. But I can't think of any decent way of fixing this. | ||
930 | if (KnownChildRegionHandles.Count == 0) | ||
931 | { | ||
932 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
933 | if (land != null) | ||
934 | { | ||
935 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | ||
936 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) | ||
937 | { | ||
938 | pos = land.LandData.UserLocation; | ||
939 | } | ||
940 | } | ||
941 | } | ||
942 | |||
943 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | ||
944 | { | ||
945 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | ||
946 | |||
947 | if (pos.X < 0) | ||
948 | { | ||
949 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | ||
950 | if (!(pos.Y < 0)) | ||
951 | emergencyPos.Y = pos.Y; | ||
952 | if (!(pos.Z < 0)) | ||
953 | emergencyPos.Z = pos.Z; | ||
954 | } | ||
955 | if (pos.Y < 0) | ||
956 | { | ||
957 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | ||
958 | if (!(pos.X < 0)) | ||
959 | emergencyPos.X = pos.X; | ||
960 | if (!(pos.Z < 0)) | ||
961 | emergencyPos.Z = pos.Z; | ||
962 | } | ||
963 | if (pos.Z < 0) | ||
964 | { | ||
965 | emergencyPos.Z = 128; | ||
966 | if (!(pos.Y < 0)) | ||
967 | emergencyPos.Y = pos.Y; | ||
968 | if (!(pos.X < 0)) | ||
969 | emergencyPos.X = pos.X; | ||
970 | } | ||
971 | } | ||
972 | |||
842 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 973 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
843 | { | 974 | { |
844 | m_log.WarnFormat( | 975 | m_log.WarnFormat( |
@@ -960,12 +1091,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
960 | { | 1091 | { |
961 | if (PhysicsActor != null) | 1092 | if (PhysicsActor != null) |
962 | { | 1093 | { |
963 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1094 | try |
964 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1095 | { |
965 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | 1096 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
966 | m_physicsActor.UnSubscribeEvents(); | 1097 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; |
967 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1098 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
968 | PhysicsActor = null; | 1099 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); |
1100 | m_physicsActor.UnSubscribeEvents(); | ||
1101 | PhysicsActor = null; | ||
1102 | } | ||
1103 | catch | ||
1104 | { } | ||
969 | } | 1105 | } |
970 | } | 1106 | } |
971 | 1107 | ||
@@ -976,9 +1112,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
976 | public void Teleport(Vector3 pos) | 1112 | public void Teleport(Vector3 pos) |
977 | { | 1113 | { |
978 | bool isFlying = false; | 1114 | bool isFlying = false; |
1115 | |||
979 | if (m_physicsActor != null) | 1116 | if (m_physicsActor != null) |
980 | isFlying = m_physicsActor.Flying; | 1117 | isFlying = m_physicsActor.Flying; |
981 | 1118 | ||
982 | RemoveFromPhysicalScene(); | 1119 | RemoveFromPhysicalScene(); |
983 | Velocity = Vector3.Zero; | 1120 | Velocity = Vector3.Zero; |
984 | AbsolutePosition = pos; | 1121 | AbsolutePosition = pos; |
@@ -990,6 +1127,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
990 | } | 1127 | } |
991 | 1128 | ||
992 | SendTerseUpdateToAllClients(); | 1129 | SendTerseUpdateToAllClients(); |
1130 | |||
993 | } | 1131 | } |
994 | 1132 | ||
995 | public void TeleportWithMomentum(Vector3 pos) | 1133 | public void TeleportWithMomentum(Vector3 pos) |
@@ -1103,7 +1241,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1103 | pos.Z = ground + 1.5f; | 1241 | pos.Z = ground + 1.5f; |
1104 | AbsolutePosition = pos; | 1242 | AbsolutePosition = pos; |
1105 | } | 1243 | } |
1106 | |||
1107 | m_isChildAgent = false; | 1244 | m_isChildAgent = false; |
1108 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1245 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1109 | MakeRootAgent(AbsolutePosition, m_flying); | 1246 | MakeRootAgent(AbsolutePosition, m_flying); |
@@ -1202,6 +1339,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1202 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1339 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1203 | 1340 | ||
1204 | m_pos = m_LastFinitePos; | 1341 | m_pos = m_LastFinitePos; |
1342 | |||
1205 | if (!m_pos.IsFinite()) | 1343 | if (!m_pos.IsFinite()) |
1206 | { | 1344 | { |
1207 | m_pos.X = 127f; | 1345 | m_pos.X = 127f; |
@@ -1268,7 +1406,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1268 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1406 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1269 | } | 1407 | } |
1270 | } | 1408 | } |
1271 | |||
1272 | lock (scriptedcontrols) | 1409 | lock (scriptedcontrols) |
1273 | { | 1410 | { |
1274 | if (scriptedcontrols.Count > 0) | 1411 | if (scriptedcontrols.Count > 0) |
@@ -1283,6 +1420,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1283 | 1420 | ||
1284 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1421 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1285 | { | 1422 | { |
1423 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. | ||
1424 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | ||
1425 | |||
1286 | // TODO: This doesn't prevent the user from walking yet. | 1426 | // TODO: This doesn't prevent the user from walking yet. |
1287 | // Setting parent ID would fix this, if we knew what value | 1427 | // Setting parent ID would fix this, if we knew what value |
1288 | // to use. Or we could add a m_isSitting variable. | 1428 | // to use. Or we could add a m_isSitting variable. |
@@ -1337,6 +1477,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1337 | update_rotation = true; | 1477 | update_rotation = true; |
1338 | } | 1478 | } |
1339 | 1479 | ||
1480 | //guilty until proven innocent.. | ||
1481 | bool Nudging = true; | ||
1482 | //Basically, if there is at least one non-nudge control then we don't need | ||
1483 | //to worry about stopping the avatar | ||
1484 | |||
1340 | if (m_parentID == 0) | 1485 | if (m_parentID == 0) |
1341 | { | 1486 | { |
1342 | bool bAllowUpdateMoveToPosition = false; | 1487 | bool bAllowUpdateMoveToPosition = false; |
@@ -1351,9 +1496,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1351 | else | 1496 | else |
1352 | dirVectors = Dir_Vectors; | 1497 | dirVectors = Dir_Vectors; |
1353 | 1498 | ||
1354 | // The fact that m_movementflag is a byte needs to be fixed | 1499 | bool[] isNudge = GetDirectionIsNudge(); |
1355 | // it really should be a uint | 1500 | |
1356 | uint nudgehack = 250; | 1501 | |
1502 | |||
1503 | |||
1504 | |||
1357 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1505 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1358 | { | 1506 | { |
1359 | if (((uint)flags & (uint)DCF) != 0) | 1507 | if (((uint)flags & (uint)DCF) != 0) |
@@ -1363,40 +1511,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1363 | try | 1511 | try |
1364 | { | 1512 | { |
1365 | agent_control_v3 += dirVectors[i]; | 1513 | agent_control_v3 += dirVectors[i]; |
1366 | //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); | 1514 | if (isNudge[i] == false) |
1515 | { | ||
1516 | Nudging = false; | ||
1517 | } | ||
1367 | } | 1518 | } |
1368 | catch (IndexOutOfRangeException) | 1519 | catch (IndexOutOfRangeException) |
1369 | { | 1520 | { |
1370 | // Why did I get this? | 1521 | // Why did I get this? |
1371 | } | 1522 | } |
1372 | 1523 | ||
1373 | if ((m_movementflag & (byte)(uint)DCF) == 0) | 1524 | if ((m_movementflag & (uint)DCF) == 0) |
1374 | { | 1525 | { |
1375 | if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1376 | { | ||
1377 | m_movementflag |= (byte)nudgehack; | ||
1378 | } | ||
1379 | m_movementflag += (byte)(uint)DCF; | 1526 | m_movementflag += (byte)(uint)DCF; |
1380 | update_movementflag = true; | 1527 | update_movementflag = true; |
1381 | } | 1528 | } |
1382 | } | 1529 | } |
1383 | else | 1530 | else |
1384 | { | 1531 | { |
1385 | if ((m_movementflag & (byte)(uint)DCF) != 0 || | 1532 | if ((m_movementflag & (uint)DCF) != 0) |
1386 | ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1387 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1388 | ) // This or is for Nudge forward | ||
1389 | { | 1533 | { |
1390 | m_movementflag -= ((byte)(uint)DCF); | 1534 | m_movementflag -= (byte)(uint)DCF; |
1391 | |||
1392 | update_movementflag = true; | 1535 | update_movementflag = true; |
1393 | /* | ||
1394 | if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1395 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1396 | { | ||
1397 | m_log.Debug("Removed Hack flag"); | ||
1398 | } | ||
1399 | */ | ||
1400 | } | 1536 | } |
1401 | else | 1537 | else |
1402 | { | 1538 | { |
@@ -1405,7 +1541,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1405 | } | 1541 | } |
1406 | i++; | 1542 | i++; |
1407 | } | 1543 | } |
1408 | |||
1409 | //Paupaw:Do Proper PID for Autopilot here | 1544 | //Paupaw:Do Proper PID for Autopilot here |
1410 | if (bResetMoveToPosition) | 1545 | if (bResetMoveToPosition) |
1411 | { | 1546 | { |
@@ -1440,6 +1575,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1440 | // Ignore z component of vector | 1575 | // Ignore z component of vector |
1441 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1576 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1442 | LocalVectorToTarget2D.Normalize(); | 1577 | LocalVectorToTarget2D.Normalize(); |
1578 | |||
1579 | //We're not nudging | ||
1580 | Nudging = false; | ||
1443 | agent_control_v3 += LocalVectorToTarget2D; | 1581 | agent_control_v3 += LocalVectorToTarget2D; |
1444 | 1582 | ||
1445 | // update avatar movement flags. the avatar coordinate system is as follows: | 1583 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1528,13 +1666,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1528 | // m_log.DebugFormat( | 1666 | // m_log.DebugFormat( |
1529 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1667 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1530 | 1668 | ||
1531 | AddNewMovement(agent_control_v3, q); | 1669 | AddNewMovement(agent_control_v3, q, Nudging); |
1532 | 1670 | ||
1533 | 1671 | ||
1534 | } | 1672 | } |
1535 | } | 1673 | } |
1536 | 1674 | ||
1537 | if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround) | 1675 | if (update_movementflag && !SitGround) |
1538 | Animator.UpdateMovementAnimations(); | 1676 | Animator.UpdateMovementAnimations(); |
1539 | 1677 | ||
1540 | m_scene.EventManager.TriggerOnClientMovement(this); | 1678 | m_scene.EventManager.TriggerOnClientMovement(this); |
@@ -1549,7 +1687,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1549 | m_sitAtAutoTarget = false; | 1687 | m_sitAtAutoTarget = false; |
1550 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | 1688 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; |
1551 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1689 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1552 | |||
1553 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); | 1690 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); |
1554 | proxyObjectGroup.AttachToScene(m_scene); | 1691 | proxyObjectGroup.AttachToScene(m_scene); |
1555 | 1692 | ||
@@ -1591,7 +1728,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1591 | } | 1728 | } |
1592 | m_moveToPositionInProgress = true; | 1729 | m_moveToPositionInProgress = true; |
1593 | m_moveToPositionTarget = new Vector3(locx, locy, locz); | 1730 | m_moveToPositionTarget = new Vector3(locx, locy, locz); |
1594 | } | 1731 | } |
1595 | catch (Exception ex) | 1732 | catch (Exception ex) |
1596 | { | 1733 | { |
1597 | //Why did I get this error? | 1734 | //Why did I get this error? |
@@ -1613,7 +1750,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1613 | Velocity = Vector3.Zero; | 1750 | Velocity = Vector3.Zero; |
1614 | SendFullUpdateToAllClients(); | 1751 | SendFullUpdateToAllClients(); |
1615 | 1752 | ||
1616 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1753 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1617 | } | 1754 | } |
1618 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1755 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1619 | m_requestedSitTargetUUID = UUID.Zero; | 1756 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1650,50 +1787,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
1650 | 1787 | ||
1651 | if (m_parentID != 0) | 1788 | if (m_parentID != 0) |
1652 | { | 1789 | { |
1653 | m_log.Debug("StandupCode Executed"); | 1790 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
1654 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | ||
1655 | if (part != null) | 1791 | if (part != null) |
1656 | { | 1792 | { |
1793 | part.TaskInventory.LockItemsForRead(true); | ||
1657 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1794 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1658 | if (taskIDict != null) | 1795 | if (taskIDict != null) |
1659 | { | 1796 | { |
1660 | lock (taskIDict) | 1797 | foreach (UUID taskID in taskIDict.Keys) |
1661 | { | 1798 | { |
1662 | foreach (UUID taskID in taskIDict.Keys) | 1799 | UnRegisterControlEventsToScript(LocalId, taskID); |
1663 | { | 1800 | taskIDict[taskID].PermsMask &= ~( |
1664 | UnRegisterControlEventsToScript(LocalId, taskID); | 1801 | 2048 | //PERMISSION_CONTROL_CAMERA |
1665 | taskIDict[taskID].PermsMask &= ~( | 1802 | 4); // PERMISSION_TAKE_CONTROLS |
1666 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1667 | 4); // PERMISSION_TAKE_CONTROLS | ||
1668 | } | ||
1669 | } | 1803 | } |
1670 | |||
1671 | } | 1804 | } |
1805 | part.TaskInventory.LockItemsForRead(false); | ||
1672 | // Reset sit target. | 1806 | // Reset sit target. |
1673 | if (part.GetAvatarOnSitTarget() == UUID) | 1807 | if (part.GetAvatarOnSitTarget() == UUID) |
1674 | part.SetAvatarOnSitTarget(UUID.Zero); | 1808 | part.SetAvatarOnSitTarget(UUID.Zero); |
1675 | |||
1676 | m_parentPosition = part.GetWorldPosition(); | 1809 | m_parentPosition = part.GetWorldPosition(); |
1677 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1810 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1678 | } | 1811 | } |
1812 | // part.GetWorldRotation() is the rotation of the object being sat on | ||
1813 | // Rotation is the sittiing Av's rotation | ||
1814 | |||
1815 | Quaternion partRot; | ||
1816 | // if (part.LinkNum == 1) | ||
1817 | // { // Root prim of linkset | ||
1818 | // partRot = part.ParentGroup.RootPart.RotationOffset; | ||
1819 | // } | ||
1820 | // else | ||
1821 | // { // single or child prim | ||
1822 | |||
1823 | // } | ||
1824 | if (part == null) //CW: Part may be gone. llDie() for example. | ||
1825 | { | ||
1826 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1827 | } | ||
1828 | else | ||
1829 | { | ||
1830 | partRot = part.GetWorldRotation(); | ||
1831 | } | ||
1832 | |||
1833 | Quaternion partIRot = Quaternion.Inverse(partRot); | ||
1834 | |||
1835 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av | ||
1836 | Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av | ||
1679 | 1837 | ||
1838 | |||
1680 | if (m_physicsActor == null) | 1839 | if (m_physicsActor == null) |
1681 | { | 1840 | { |
1682 | AddToPhysicalScene(false); | 1841 | AddToPhysicalScene(false); |
1683 | } | 1842 | } |
1684 | 1843 | //CW: If the part isn't null then we can set the current position | |
1685 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1844 | if (part != null) |
1686 | m_parentPosition = Vector3.Zero; | 1845 | { |
1687 | 1846 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! | |
1688 | m_parentID = 0; | 1847 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. |
1848 | part.IsOccupied = false; | ||
1849 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); | ||
1850 | } | ||
1851 | else | ||
1852 | { | ||
1853 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue | ||
1854 | AbsolutePosition = m_lastWorldPosition; | ||
1855 | } | ||
1856 | |||
1857 | m_parentPosition = Vector3.Zero; | ||
1858 | m_parentID = 0; | ||
1859 | m_linkedPrim = UUID.Zero; | ||
1860 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1689 | SendFullUpdateToAllClients(); | 1861 | SendFullUpdateToAllClients(); |
1690 | m_requestedSitTargetID = 0; | 1862 | m_requestedSitTargetID = 0; |
1863 | |||
1691 | if ((m_physicsActor != null) && (m_avHeight > 0)) | 1864 | if ((m_physicsActor != null) && (m_avHeight > 0)) |
1692 | { | 1865 | { |
1693 | SetHeight(m_avHeight); | 1866 | SetHeight(m_avHeight); |
1694 | } | 1867 | } |
1695 | } | 1868 | } |
1696 | |||
1697 | Animator.TrySetMovementAnimation("STAND"); | 1869 | Animator.TrySetMovementAnimation("STAND"); |
1698 | } | 1870 | } |
1699 | 1871 | ||
@@ -1724,13 +1896,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1724 | Vector3 avSitOffSet = part.SitTargetPosition; | 1896 | Vector3 avSitOffSet = part.SitTargetPosition; |
1725 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1897 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1726 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1898 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1727 | 1899 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); | |
1728 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1900 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1729 | bool SitTargetisSet = | 1901 | if (SitTargetisSet && !SitTargetOccupied) |
1730 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | ||
1731 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | ||
1732 | |||
1733 | if (SitTargetisSet && SitTargetUnOccupied) | ||
1734 | { | 1902 | { |
1735 | //switch the target to this prim | 1903 | //switch the target to this prim |
1736 | return part; | 1904 | return part; |
@@ -1744,84 +1912,164 @@ namespace OpenSim.Region.Framework.Scenes | |||
1744 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 1912 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) |
1745 | { | 1913 | { |
1746 | bool autopilot = true; | 1914 | bool autopilot = true; |
1915 | Vector3 autopilotTarget = new Vector3(); | ||
1916 | Quaternion sitOrientation = Quaternion.Identity; | ||
1747 | Vector3 pos = new Vector3(); | 1917 | Vector3 pos = new Vector3(); |
1748 | Quaternion sitOrientation = pSitOrientation; | ||
1749 | Vector3 cameraEyeOffset = Vector3.Zero; | 1918 | Vector3 cameraEyeOffset = Vector3.Zero; |
1750 | Vector3 cameraAtOffset = Vector3.Zero; | 1919 | Vector3 cameraAtOffset = Vector3.Zero; |
1751 | bool forceMouselook = false; | 1920 | bool forceMouselook = false; |
1752 | 1921 | ||
1753 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1922 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1754 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1923 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1755 | if (part != null) | 1924 | if (part == null) return; |
1756 | { | 1925 | |
1757 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1926 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1758 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1927 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1759 | 1928 | ||
1760 | // Is a sit target available? | 1929 | // part is the prim to sit on |
1761 | Vector3 avSitOffSet = part.SitTargetPosition; | 1930 | // offset is the world-ref vector distance from that prim center to the click-spot |
1762 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1931 | // UUID is the UUID of the Avatar doing the clicking |
1763 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1932 | |
1764 | 1933 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | |
1765 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1934 | |
1766 | bool SitTargetisSet = | 1935 | // Is a sit target available? |
1767 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && | 1936 | Vector3 avSitOffSet = part.SitTargetPosition; |
1768 | ( | 1937 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1769 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 1f // Valid Zero Rotation quaternion | 1938 | |
1770 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point | 1939 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1771 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion | 1940 | // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
1772 | ) | 1941 | Quaternion partRot; |
1773 | )); | 1942 | // if (part.LinkNum == 1) |
1774 | 1943 | // { // Root prim of linkset | |
1775 | if (SitTargetisSet && SitTargetUnOccupied) | 1944 | // partRot = part.ParentGroup.RootPart.RotationOffset; |
1776 | { | 1945 | // } |
1777 | part.SetAvatarOnSitTarget(UUID); | 1946 | // else |
1778 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1947 | // { // single or child prim |
1779 | sitOrientation = avSitOrientation; | 1948 | partRot = part.GetWorldRotation(); |
1780 | autopilot = false; | 1949 | // } |
1781 | } | 1950 | Quaternion partIRot = Quaternion.Inverse(partRot); |
1782 | 1951 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); | |
1783 | pos = part.AbsolutePosition + offset; | 1952 | // Sit analysis rewritten by KF 091125 |
1784 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 1953 | if (SitTargetisSet) // scipted sit |
1785 | //{ | 1954 | { |
1786 | // offset = pos; | 1955 | if (!part.IsOccupied) |
1787 | //autopilot = false; | 1956 | { |
1788 | //} | 1957 | //Console.WriteLine("Scripted, unoccupied"); |
1789 | if (m_physicsActor != null) | 1958 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1790 | { | 1959 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1791 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 1960 | |
1792 | // We can remove the physicsActor until they stand up. | 1961 | Quaternion nrot = avSitOrientation; |
1793 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1962 | if (!part.IsRoot) |
1794 | |||
1795 | if (autopilot) | ||
1796 | { | 1963 | { |
1797 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1964 | nrot = part.RotationOffset * avSitOrientation; |
1798 | { | ||
1799 | autopilot = false; | ||
1800 | |||
1801 | RemoveFromPhysicalScene(); | ||
1802 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | ||
1803 | } | ||
1804 | } | 1965 | } |
1805 | else | 1966 | sitOrientation = nrot; // Change rotatione to the scripted one |
1967 | OffsetRotation = nrot; | ||
1968 | autopilot = false; // Jump direct to scripted llSitPos() | ||
1969 | } | ||
1970 | else | ||
1971 | { | ||
1972 | //Console.WriteLine("Scripted, occupied"); | ||
1973 | return; | ||
1974 | } | ||
1975 | } | ||
1976 | else // Not Scripted | ||
1977 | { | ||
1978 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) | ||
1979 | { | ||
1980 | // large prim & offset, ignore if other Avs sitting | ||
1981 | // offset.Z -= 0.05f; | ||
1982 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked | ||
1983 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point | ||
1984 | |||
1985 | //Console.WriteLine(" offset ={0}", offset); | ||
1986 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); | ||
1987 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); | ||
1988 | |||
1989 | } | ||
1990 | else // small offset | ||
1991 | { | ||
1992 | //Console.WriteLine("Small offset"); | ||
1993 | if (!part.IsOccupied) | ||
1994 | { | ||
1995 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | ||
1996 | autopilotTarget = part.AbsolutePosition; | ||
1997 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
1998 | } | ||
1999 | else return; // occupied small | ||
2000 | } // end large/small | ||
2001 | } // end Scripted/not | ||
2002 | cameraAtOffset = part.GetCameraAtOffset(); | ||
2003 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2004 | forceMouselook = part.GetForceMouselook(); | ||
2005 | if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // | ||
2006 | if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // | ||
2007 | |||
2008 | if (m_physicsActor != null) | ||
2009 | { | ||
2010 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | ||
2011 | // We can remove the physicsActor until they stand up. | ||
2012 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
2013 | if (autopilot) | ||
2014 | { // its not a scripted sit | ||
2015 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | ||
2016 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) | ||
1806 | { | 2017 | { |
2018 | autopilot = false; // close enough | ||
2019 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2020 | Not using the part's position because returning the AV to the last known standing | ||
2021 | position is likely to be more friendly, isn't it? */ | ||
1807 | RemoveFromPhysicalScene(); | 2022 | RemoveFromPhysicalScene(); |
1808 | } | 2023 | Velocity = Vector3.Zero; |
2024 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target | ||
2025 | } // else the autopilot will get us close | ||
2026 | } | ||
2027 | else | ||
2028 | { // its a scripted sit | ||
2029 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2030 | I *am* using the part's position this time because we have no real idea how far away | ||
2031 | the avatar is from the sit target. */ | ||
2032 | RemoveFromPhysicalScene(); | ||
2033 | Velocity = Vector3.Zero; | ||
1809 | } | 2034 | } |
1810 | |||
1811 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1812 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1813 | forceMouselook = part.GetForceMouselook(); | ||
1814 | } | 2035 | } |
1815 | 2036 | else return; // physactor is null! | |
1816 | ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2037 | |
1817 | m_requestedSitTargetUUID = targetID; | 2038 | Vector3 offsetr; // = offset * partIRot; |
2039 | // KF: In a linkset, offsetr needs to be relative to the group root! 091208 | ||
2040 | // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); | ||
2041 | // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. | ||
2042 | // { // Single, or Root prim of linkset, target is ClickOffset * RootRot | ||
2043 | //offsetr = offset * partIRot; | ||
2044 | // | ||
2045 | // else | ||
2046 | // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) | ||
2047 | // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + | ||
2048 | // (offset * partRot); | ||
2049 | // } | ||
2050 | |||
2051 | //Console.WriteLine(" "); | ||
2052 | //Console.WriteLine("link number ={0}", part.LinkNum); | ||
2053 | //Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); | ||
2054 | //Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); | ||
2055 | //Console.WriteLine("Click offst ={0}", offset); | ||
2056 | //Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); | ||
2057 | //Console.WriteLine("offsetr ={0}", offsetr); | ||
2058 | //Console.WriteLine("Camera At ={0}", cameraAtOffset); | ||
2059 | //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); | ||
2060 | |||
2061 | //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child | ||
2062 | ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2063 | |||
2064 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target | ||
1818 | // This calls HandleAgentSit twice, once from here, and the client calls | 2065 | // This calls HandleAgentSit twice, once from here, and the client calls |
1819 | // HandleAgentSit itself after it gets to the location | 2066 | // HandleAgentSit itself after it gets to the location |
1820 | // It doesn't get to the location until we've moved them there though | 2067 | // It doesn't get to the location until we've moved them there though |
1821 | // which happens in HandleAgentSit :P | 2068 | // which happens in HandleAgentSit :P |
1822 | m_autopilotMoving = autopilot; | 2069 | m_autopilotMoving = autopilot; |
1823 | m_autoPilotTarget = pos; | 2070 | m_autoPilotTarget = autopilotTarget; |
1824 | m_sitAtAutoTarget = autopilot; | 2071 | m_sitAtAutoTarget = autopilot; |
2072 | m_initialSitTarget = autopilotTarget; | ||
1825 | if (!autopilot) | 2073 | if (!autopilot) |
1826 | HandleAgentSit(remoteClient, UUID); | 2074 | HandleAgentSit(remoteClient, UUID); |
1827 | } | 2075 | } |
@@ -2116,47 +2364,130 @@ namespace OpenSim.Region.Framework.Scenes | |||
2116 | { | 2364 | { |
2117 | if (part != null) | 2365 | if (part != null) |
2118 | { | 2366 | { |
2367 | //Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); | ||
2119 | if (part.GetAvatarOnSitTarget() == UUID) | 2368 | if (part.GetAvatarOnSitTarget() == UUID) |
2120 | { | 2369 | { |
2370 | //Console.WriteLine("Scripted Sit"); | ||
2371 | // Scripted sit | ||
2121 | Vector3 sitTargetPos = part.SitTargetPosition; | 2372 | Vector3 sitTargetPos = part.SitTargetPosition; |
2122 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 2373 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
2123 | |||
2124 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
2125 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
2126 | |||
2127 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
2128 | |||
2129 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 2374 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
2130 | m_pos += SIT_TARGET_ADJUSTMENT; | 2375 | m_pos += SIT_TARGET_ADJUSTMENT; |
2376 | if (!part.IsRoot) | ||
2377 | { | ||
2378 | m_pos *= part.RotationOffset; | ||
2379 | } | ||
2131 | m_bodyRot = sitTargetOrient; | 2380 | m_bodyRot = sitTargetOrient; |
2132 | //Rotation = sitTargetOrient; | ||
2133 | m_parentPosition = part.AbsolutePosition; | 2381 | m_parentPosition = part.AbsolutePosition; |
2134 | 2382 | part.IsOccupied = true; | |
2135 | //SendTerseUpdateToAllClients(); | 2383 | part.ParentGroup.AddAvatar(agentID); |
2136 | } | 2384 | } |
2137 | else | 2385 | else |
2138 | { | 2386 | { |
2139 | m_pos -= part.AbsolutePosition; | 2387 | // if m_avUnscriptedSitPos is zero then Av sits above center |
2388 | // Else Av sits at m_avUnscriptedSitPos | ||
2389 | |||
2390 | // Non-scripted sit by Kitto Flora 21Nov09 | ||
2391 | // Calculate angle of line from prim to Av | ||
2392 | Quaternion partIRot; | ||
2393 | // if (part.LinkNum == 1) | ||
2394 | // { // Root prim of linkset | ||
2395 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2396 | // } | ||
2397 | // else | ||
2398 | // { // single or child prim | ||
2399 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2400 | // } | ||
2401 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | ||
2402 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | ||
2403 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | ||
2404 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
2405 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
2406 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
2407 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
2408 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
2409 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
2410 | |||
2140 | m_parentPosition = part.AbsolutePosition; | 2411 | m_parentPosition = part.AbsolutePosition; |
2141 | } | 2412 | part.IsOccupied = true; |
2413 | part.ParentGroup.AddAvatar(agentID); | ||
2414 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation | ||
2415 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center | ||
2416 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + | ||
2417 | m_avUnscriptedSitPos; // adds click offset, if any | ||
2418 | //Set up raytrace to find top surface of prim | ||
2419 | Vector3 size = part.Scale; | ||
2420 | float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
2421 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
2422 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
2423 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); | ||
2424 | m_scene.PhysicsScene.RaycastWorld( | ||
2425 | start, // Vector3 position, | ||
2426 | down, // Vector3 direction, | ||
2427 | mag, // float length, | ||
2428 | SitAltitudeCallback); // retMethod | ||
2429 | } // end scripted/not | ||
2142 | } | 2430 | } |
2143 | else | 2431 | else // no Av |
2144 | { | 2432 | { |
2145 | return; | 2433 | return; |
2146 | } | 2434 | } |
2147 | } | 2435 | } |
2148 | m_parentID = m_requestedSitTargetID; | ||
2149 | 2436 | ||
2437 | //We want our offsets to reference the root prim, not the child we may have sat on | ||
2438 | if (!part.IsRoot) | ||
2439 | { | ||
2440 | m_parentID = part.ParentGroup.RootPart.LocalId; | ||
2441 | m_pos += part.OffsetPosition; | ||
2442 | } | ||
2443 | else | ||
2444 | { | ||
2445 | m_parentID = m_requestedSitTargetID; | ||
2446 | } | ||
2447 | |||
2448 | m_linkedPrim = part.UUID; | ||
2449 | if (part.GetAvatarOnSitTarget() != UUID) | ||
2450 | { | ||
2451 | m_offsetRotation = m_offsetRotation / part.RotationOffset; | ||
2452 | } | ||
2150 | Velocity = Vector3.Zero; | 2453 | Velocity = Vector3.Zero; |
2151 | RemoveFromPhysicalScene(); | 2454 | RemoveFromPhysicalScene(); |
2152 | |||
2153 | Animator.TrySetMovementAnimation(sitAnimation); | 2455 | Animator.TrySetMovementAnimation(sitAnimation); |
2154 | SendFullUpdateToAllClients(); | 2456 | SendFullUpdateToAllClients(); |
2155 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | 2457 | SendTerseUpdateToAllClients(); |
2156 | // So we're also sending a terse update (which has avatar rotation) | ||
2157 | // [Update] We do now. | ||
2158 | //SendTerseUpdateToAllClients(); | ||
2159 | } | 2458 | } |
2459 | |||
2460 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) | ||
2461 | { | ||
2462 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer | ||
2463 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. | ||
2464 | if(hitYN) | ||
2465 | { | ||
2466 | // m_pos = Av offset from prim center to make look like on center | ||
2467 | // m_parentPosition = Actual center pos of prim | ||
2468 | // collisionPoint = spot on prim where we want to sit | ||
2469 | // collisionPoint.Z = global sit surface height | ||
2470 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
2471 | Quaternion partIRot; | ||
2472 | // if (part.LinkNum == 1) | ||
2473 | /// { // Root prim of linkset | ||
2474 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2475 | // } | ||
2476 | // else | ||
2477 | // { // single or child prim | ||
2478 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2479 | // } | ||
2480 | if (m_initialSitTarget != null) | ||
2481 | { | ||
2482 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | ||
2483 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction | ||
2484 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); | ||
2485 | m_pos += offset; | ||
2486 | // ControllingClient.SendClearFollowCamProperties(part.UUID); | ||
2487 | } | ||
2488 | |||
2489 | } | ||
2490 | } // End SitAltitudeCallback KF. | ||
2160 | 2491 | ||
2161 | /// <summary> | 2492 | /// <summary> |
2162 | /// Event handler for the 'Always run' setting on the client | 2493 | /// Event handler for the 'Always run' setting on the client |
@@ -2186,7 +2517,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2186 | /// </summary> | 2517 | /// </summary> |
2187 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2518 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
2188 | /// <param name="rotation">The direction in which this avatar should now face. | 2519 | /// <param name="rotation">The direction in which this avatar should now face. |
2189 | public void AddNewMovement(Vector3 vec, Quaternion rotation) | 2520 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) |
2190 | { | 2521 | { |
2191 | if (m_isChildAgent) | 2522 | if (m_isChildAgent) |
2192 | { | 2523 | { |
@@ -2227,10 +2558,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2227 | Rotation = rotation; | 2558 | Rotation = rotation; |
2228 | Vector3 direc = vec * rotation; | 2559 | Vector3 direc = vec * rotation; |
2229 | direc.Normalize(); | 2560 | direc.Normalize(); |
2561 | PhysicsActor actor = m_physicsActor; | ||
2562 | if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. | ||
2230 | 2563 | ||
2231 | direc *= 0.03f * 128f * m_speedModifier; | 2564 | direc *= 0.03f * 128f * m_speedModifier; |
2232 | 2565 | ||
2233 | PhysicsActor actor = m_physicsActor; | ||
2234 | if (actor != null) | 2566 | if (actor != null) |
2235 | { | 2567 | { |
2236 | if (actor.Flying) | 2568 | if (actor.Flying) |
@@ -2252,18 +2584,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2252 | { | 2584 | { |
2253 | if (direc.Z > 2.0f) | 2585 | if (direc.Z > 2.0f) |
2254 | { | 2586 | { |
2255 | direc.Z *= 3.0f; | 2587 | if(m_animator.m_animTickJump == -1) |
2256 | 2588 | { | |
2257 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2589 | direc.Z *= 3.0f; // jump |
2258 | Animator.TrySetMovementAnimation("PREJUMP"); | 2590 | } |
2259 | Animator.TrySetMovementAnimation("JUMP"); | 2591 | else |
2592 | { | ||
2593 | direc.Z *= 0.1f; // prejump | ||
2594 | } | ||
2595 | /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs | ||
2596 | Animator.TrySetMovementAnimation("PREJUMP"); | ||
2597 | Animator.TrySetMovementAnimation("JUMP"); | ||
2598 | */ | ||
2260 | } | 2599 | } |
2261 | } | 2600 | } |
2262 | } | 2601 | } |
2263 | 2602 | ||
2264 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2603 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2265 | m_forceToApply = direc; | 2604 | m_forceToApply = direc; |
2266 | 2605 | m_isNudging = Nudging; | |
2267 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2606 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2268 | } | 2607 | } |
2269 | 2608 | ||
@@ -2278,7 +2617,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2278 | const float POSITION_TOLERANCE = 0.05f; | 2617 | const float POSITION_TOLERANCE = 0.05f; |
2279 | //const int TIME_MS_TOLERANCE = 3000; | 2618 | //const int TIME_MS_TOLERANCE = 3000; |
2280 | 2619 | ||
2281 | SendPrimUpdates(); | 2620 | |
2282 | 2621 | ||
2283 | if (m_isChildAgent == false) | 2622 | if (m_isChildAgent == false) |
2284 | { | 2623 | { |
@@ -2308,6 +2647,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2308 | CheckForBorderCrossing(); | 2647 | CheckForBorderCrossing(); |
2309 | CheckForSignificantMovement(); // sends update to the modules. | 2648 | CheckForSignificantMovement(); // sends update to the modules. |
2310 | } | 2649 | } |
2650 | |||
2651 | //Sending prim updates AFTER the avatar terse updates are sent | ||
2652 | SendPrimUpdates(); | ||
2311 | } | 2653 | } |
2312 | 2654 | ||
2313 | #endregion | 2655 | #endregion |
@@ -3092,6 +3434,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3092 | m_callbackURI = cAgent.CallbackURI; | 3434 | m_callbackURI = cAgent.CallbackURI; |
3093 | 3435 | ||
3094 | m_pos = cAgent.Position; | 3436 | m_pos = cAgent.Position; |
3437 | |||
3095 | m_velocity = cAgent.Velocity; | 3438 | m_velocity = cAgent.Velocity; |
3096 | m_CameraCenter = cAgent.Center; | 3439 | m_CameraCenter = cAgent.Center; |
3097 | //m_avHeight = cAgent.Size.Z; | 3440 | //m_avHeight = cAgent.Size.Z; |
@@ -3202,14 +3545,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
3202 | { | 3545 | { |
3203 | if (m_forceToApply.HasValue) | 3546 | if (m_forceToApply.HasValue) |
3204 | { | 3547 | { |
3205 | Vector3 force = m_forceToApply.Value; | ||
3206 | 3548 | ||
3549 | Vector3 force = m_forceToApply.Value; | ||
3207 | m_updateflag = true; | 3550 | m_updateflag = true; |
3208 | // movementvector = force; | ||
3209 | Velocity = force; | 3551 | Velocity = force; |
3210 | 3552 | ||
3211 | m_forceToApply = null; | 3553 | m_forceToApply = null; |
3212 | } | 3554 | } |
3555 | else | ||
3556 | { | ||
3557 | if (m_isNudging) | ||
3558 | { | ||
3559 | Vector3 force = Vector3.Zero; | ||
3560 | |||
3561 | m_updateflag = true; | ||
3562 | Velocity = force; | ||
3563 | m_isNudging = false; | ||
3564 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" | ||
3565 | } | ||
3566 | } | ||
3213 | } | 3567 | } |
3214 | 3568 | ||
3215 | /// <summary> | 3569 | /// <summary> |
@@ -3255,18 +3609,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
3255 | { | 3609 | { |
3256 | if (e == null) | 3610 | if (e == null) |
3257 | return; | 3611 | return; |
3258 | 3612 | ||
3259 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3613 | // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( |
3260 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | ||
3261 | // as of this comment the interval is set in AddToPhysicalScene | 3614 | // as of this comment the interval is set in AddToPhysicalScene |
3262 | if (Animator!=null) | 3615 | if (Animator!=null) |
3263 | Animator.UpdateMovementAnimations(); | 3616 | { |
3617 | if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, | ||
3618 | { // else its will lock out other animation changes, like ground sit. | ||
3619 | Animator.UpdateMovementAnimations(); | ||
3620 | m_updateCount--; | ||
3621 | } | ||
3622 | } | ||
3264 | 3623 | ||
3265 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3624 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3266 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3625 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3267 | 3626 | ||
3268 | CollisionPlane = Vector4.UnitW; | 3627 | CollisionPlane = Vector4.UnitW; |
3269 | 3628 | ||
3629 | if (m_lastColCount != coldata.Count) | ||
3630 | { | ||
3631 | m_updateCount = UPDATE_COUNT; | ||
3632 | m_lastColCount = coldata.Count; | ||
3633 | } | ||
3634 | |||
3270 | if (coldata.Count != 0 && Animator != null) | 3635 | if (coldata.Count != 0 && Animator != null) |
3271 | { | 3636 | { |
3272 | switch (Animator.CurrentMovementAnimation) | 3637 | switch (Animator.CurrentMovementAnimation) |
@@ -3296,6 +3661,148 @@ namespace OpenSim.Region.Framework.Scenes | |||
3296 | } | 3661 | } |
3297 | } | 3662 | } |
3298 | 3663 | ||
3664 | List<uint> thisHitColliders = new List<uint>(); | ||
3665 | List<uint> endedColliders = new List<uint>(); | ||
3666 | List<uint> startedColliders = new List<uint>(); | ||
3667 | |||
3668 | foreach (uint localid in coldata.Keys) | ||
3669 | { | ||
3670 | thisHitColliders.Add(localid); | ||
3671 | if (!m_lastColliders.Contains(localid)) | ||
3672 | { | ||
3673 | startedColliders.Add(localid); | ||
3674 | } | ||
3675 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3676 | } | ||
3677 | |||
3678 | // calculate things that ended colliding | ||
3679 | foreach (uint localID in m_lastColliders) | ||
3680 | { | ||
3681 | if (!thisHitColliders.Contains(localID)) | ||
3682 | { | ||
3683 | endedColliders.Add(localID); | ||
3684 | } | ||
3685 | } | ||
3686 | //add the items that started colliding this time to the last colliders list. | ||
3687 | foreach (uint localID in startedColliders) | ||
3688 | { | ||
3689 | m_lastColliders.Add(localID); | ||
3690 | } | ||
3691 | // remove things that ended colliding from the last colliders list | ||
3692 | foreach (uint localID in endedColliders) | ||
3693 | { | ||
3694 | m_lastColliders.Remove(localID); | ||
3695 | } | ||
3696 | |||
3697 | // do event notification | ||
3698 | if (startedColliders.Count > 0) | ||
3699 | { | ||
3700 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3701 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3702 | foreach (uint localId in startedColliders) | ||
3703 | { | ||
3704 | if (localId == 0) | ||
3705 | continue; | ||
3706 | |||
3707 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3708 | string data = ""; | ||
3709 | if (obj != null) | ||
3710 | { | ||
3711 | DetectedObject detobj = new DetectedObject(); | ||
3712 | detobj.keyUUID = obj.UUID; | ||
3713 | detobj.nameStr = obj.Name; | ||
3714 | detobj.ownerUUID = obj.OwnerID; | ||
3715 | detobj.posVector = obj.AbsolutePosition; | ||
3716 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3717 | detobj.velVector = obj.Velocity; | ||
3718 | detobj.colliderType = 0; | ||
3719 | detobj.groupUUID = obj.GroupID; | ||
3720 | colliding.Add(detobj); | ||
3721 | } | ||
3722 | } | ||
3723 | |||
3724 | if (colliding.Count > 0) | ||
3725 | { | ||
3726 | StartCollidingMessage.Colliders = colliding; | ||
3727 | |||
3728 | foreach (SceneObjectGroup att in Attachments) | ||
3729 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3730 | } | ||
3731 | } | ||
3732 | |||
3733 | if (endedColliders.Count > 0) | ||
3734 | { | ||
3735 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3736 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3737 | foreach (uint localId in endedColliders) | ||
3738 | { | ||
3739 | if (localId == 0) | ||
3740 | continue; | ||
3741 | |||
3742 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3743 | string data = ""; | ||
3744 | if (obj != null) | ||
3745 | { | ||
3746 | DetectedObject detobj = new DetectedObject(); | ||
3747 | detobj.keyUUID = obj.UUID; | ||
3748 | detobj.nameStr = obj.Name; | ||
3749 | detobj.ownerUUID = obj.OwnerID; | ||
3750 | detobj.posVector = obj.AbsolutePosition; | ||
3751 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3752 | detobj.velVector = obj.Velocity; | ||
3753 | detobj.colliderType = 0; | ||
3754 | detobj.groupUUID = obj.GroupID; | ||
3755 | colliding.Add(detobj); | ||
3756 | } | ||
3757 | } | ||
3758 | |||
3759 | if (colliding.Count > 0) | ||
3760 | { | ||
3761 | EndCollidingMessage.Colliders = colliding; | ||
3762 | |||
3763 | foreach (SceneObjectGroup att in Attachments) | ||
3764 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3765 | } | ||
3766 | } | ||
3767 | |||
3768 | if (thisHitColliders.Count > 0) | ||
3769 | { | ||
3770 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3771 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3772 | foreach (uint localId in thisHitColliders) | ||
3773 | { | ||
3774 | if (localId == 0) | ||
3775 | continue; | ||
3776 | |||
3777 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3778 | string data = ""; | ||
3779 | if (obj != null) | ||
3780 | { | ||
3781 | DetectedObject detobj = new DetectedObject(); | ||
3782 | detobj.keyUUID = obj.UUID; | ||
3783 | detobj.nameStr = obj.Name; | ||
3784 | detobj.ownerUUID = obj.OwnerID; | ||
3785 | detobj.posVector = obj.AbsolutePosition; | ||
3786 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3787 | detobj.velVector = obj.Velocity; | ||
3788 | detobj.colliderType = 0; | ||
3789 | detobj.groupUUID = obj.GroupID; | ||
3790 | colliding.Add(detobj); | ||
3791 | } | ||
3792 | } | ||
3793 | |||
3794 | if (colliding.Count > 0) | ||
3795 | { | ||
3796 | CollidingMessage.Colliders = colliding; | ||
3797 | |||
3798 | lock (m_attachments) | ||
3799 | { | ||
3800 | foreach (SceneObjectGroup att in m_attachments) | ||
3801 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3802 | } | ||
3803 | } | ||
3804 | } | ||
3805 | |||
3299 | if (m_invulnerable) | 3806 | if (m_invulnerable) |
3300 | return; | 3807 | return; |
3301 | 3808 | ||
@@ -3470,7 +3977,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3470 | m_scene = scene; | 3977 | m_scene = scene; |
3471 | 3978 | ||
3472 | RegisterToEvents(); | 3979 | RegisterToEvents(); |
3473 | 3980 | if (m_controllingClient != null) | |
3981 | { | ||
3982 | m_controllingClient.ProcessPendingPackets(); | ||
3983 | } | ||
3474 | /* | 3984 | /* |
3475 | AbsolutePosition = client.StartPos; | 3985 | AbsolutePosition = client.StartPos; |
3476 | 3986 | ||
@@ -3700,6 +4210,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3700 | return; | 4210 | return; |
3701 | } | 4211 | } |
3702 | 4212 | ||
4213 | XmlDocument doc = new XmlDocument(); | ||
4214 | string stateData = String.Empty; | ||
4215 | |||
4216 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
4217 | if (attServ != null) | ||
4218 | { | ||
4219 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
4220 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | ||
4221 | if (stateData != String.Empty) | ||
4222 | { | ||
4223 | try | ||
4224 | { | ||
4225 | doc.LoadXml(stateData); | ||
4226 | } | ||
4227 | catch { } | ||
4228 | } | ||
4229 | } | ||
4230 | |||
4231 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
4232 | |||
4233 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
4234 | if (nodes.Count > 0) | ||
4235 | { | ||
4236 | foreach (XmlNode n in nodes) | ||
4237 | { | ||
4238 | XmlElement elem = (XmlElement)n; | ||
4239 | string itemID = elem.GetAttribute("ItemID"); | ||
4240 | string xml = elem.InnerXml; | ||
4241 | |||
4242 | itemData[new UUID(itemID)] = xml; | ||
4243 | } | ||
4244 | } | ||
4245 | |||
3703 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4246 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3704 | foreach (int p in attPoints) | 4247 | foreach (int p in attPoints) |
3705 | { | 4248 | { |
@@ -3719,9 +4262,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3719 | 4262 | ||
3720 | try | 4263 | try |
3721 | { | 4264 | { |
3722 | // Rez from inventory | 4265 | string xmlData; |
3723 | UUID asset | 4266 | XmlDocument d = new XmlDocument(); |
3724 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); | 4267 | UUID asset; |
4268 | if (itemData.TryGetValue(itemID, out xmlData)) | ||
4269 | { | ||
4270 | d.LoadXml(xmlData); | ||
4271 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | ||
4272 | |||
4273 | // Rez from inventory | ||
4274 | asset | ||
4275 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | ||
4276 | |||
4277 | } | ||
4278 | else | ||
4279 | { | ||
4280 | // Rez from inventory (with a null doc to let | ||
4281 | // CHANGED_OWNER happen) | ||
4282 | asset | ||
4283 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | ||
4284 | } | ||
3725 | 4285 | ||
3726 | m_log.InfoFormat( | 4286 | m_log.InfoFormat( |
3727 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | 4287 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", |
@@ -3758,5 +4318,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3758 | m_reprioritization_called = false; | 4318 | m_reprioritization_called = false; |
3759 | } | 4319 | } |
3760 | } | 4320 | } |
4321 | |||
4322 | private Vector3 Quat2Euler(Quaternion rot){ | ||
4323 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , | ||
4324 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); | ||
4325 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); | ||
4326 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | ||
4327 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); | ||
4328 | return(new Vector3(x,y,z)); | ||
4329 | } | ||
4330 | |||
4331 | |||
3761 | } | 4332 | } |
3762 | } | 4333 | } |