diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 977 |
1 files changed, 789 insertions, 188 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a4533fa..b3df1ea 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. |
@@ -1331,12 +1471,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1331 | if (actor.Flying != oldflying) | 1471 | if (actor.Flying != oldflying) |
1332 | update_movementflag = true; | 1472 | update_movementflag = true; |
1333 | 1473 | ||
1474 | if (m_animator.m_jumping) // add for jumping | ||
1475 | update_movementflag = true; | ||
1476 | |||
1334 | if (q != m_bodyRot) | 1477 | if (q != m_bodyRot) |
1335 | { | 1478 | { |
1336 | m_bodyRot = q; | 1479 | m_bodyRot = q; |
1337 | update_rotation = true; | 1480 | update_rotation = true; |
1338 | } | 1481 | } |
1339 | 1482 | ||
1483 | //guilty until proven innocent.. | ||
1484 | bool Nudging = true; | ||
1485 | //Basically, if there is at least one non-nudge control then we don't need | ||
1486 | //to worry about stopping the avatar | ||
1487 | |||
1340 | if (m_parentID == 0) | 1488 | if (m_parentID == 0) |
1341 | { | 1489 | { |
1342 | bool bAllowUpdateMoveToPosition = false; | 1490 | bool bAllowUpdateMoveToPosition = false; |
@@ -1351,9 +1499,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1351 | else | 1499 | else |
1352 | dirVectors = Dir_Vectors; | 1500 | dirVectors = Dir_Vectors; |
1353 | 1501 | ||
1354 | // The fact that m_movementflag is a byte needs to be fixed | 1502 | bool[] isNudge = GetDirectionIsNudge(); |
1355 | // it really should be a uint | 1503 | |
1356 | uint nudgehack = 250; | 1504 | |
1505 | |||
1506 | |||
1507 | |||
1357 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1508 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1358 | { | 1509 | { |
1359 | if (((uint)flags & (uint)DCF) != 0) | 1510 | if (((uint)flags & (uint)DCF) != 0) |
@@ -1363,40 +1514,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1363 | try | 1514 | try |
1364 | { | 1515 | { |
1365 | agent_control_v3 += dirVectors[i]; | 1516 | agent_control_v3 += dirVectors[i]; |
1366 | //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); | 1517 | if (isNudge[i] == false) |
1518 | { | ||
1519 | Nudging = false; | ||
1520 | } | ||
1367 | } | 1521 | } |
1368 | catch (IndexOutOfRangeException) | 1522 | catch (IndexOutOfRangeException) |
1369 | { | 1523 | { |
1370 | // Why did I get this? | 1524 | // Why did I get this? |
1371 | } | 1525 | } |
1372 | 1526 | ||
1373 | if ((m_movementflag & (byte)(uint)DCF) == 0) | 1527 | if ((m_movementflag & (uint)DCF) == 0) |
1374 | { | 1528 | { |
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; | 1529 | m_movementflag += (byte)(uint)DCF; |
1380 | update_movementflag = true; | 1530 | update_movementflag = true; |
1381 | } | 1531 | } |
1382 | } | 1532 | } |
1383 | else | 1533 | else |
1384 | { | 1534 | { |
1385 | if ((m_movementflag & (byte)(uint)DCF) != 0 || | 1535 | 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 | { | 1536 | { |
1390 | m_movementflag -= ((byte)(uint)DCF); | 1537 | m_movementflag -= (byte)(uint)DCF; |
1391 | |||
1392 | update_movementflag = true; | 1538 | 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 | } | 1539 | } |
1401 | else | 1540 | else |
1402 | { | 1541 | { |
@@ -1405,7 +1544,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1405 | } | 1544 | } |
1406 | i++; | 1545 | i++; |
1407 | } | 1546 | } |
1408 | |||
1409 | //Paupaw:Do Proper PID for Autopilot here | 1547 | //Paupaw:Do Proper PID for Autopilot here |
1410 | if (bResetMoveToPosition) | 1548 | if (bResetMoveToPosition) |
1411 | { | 1549 | { |
@@ -1440,6 +1578,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1440 | // Ignore z component of vector | 1578 | // Ignore z component of vector |
1441 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1579 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1442 | LocalVectorToTarget2D.Normalize(); | 1580 | LocalVectorToTarget2D.Normalize(); |
1581 | |||
1582 | //We're not nudging | ||
1583 | Nudging = false; | ||
1443 | agent_control_v3 += LocalVectorToTarget2D; | 1584 | agent_control_v3 += LocalVectorToTarget2D; |
1444 | 1585 | ||
1445 | // update avatar movement flags. the avatar coordinate system is as follows: | 1586 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1530,13 +1671,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1530 | // m_log.DebugFormat( | 1671 | // m_log.DebugFormat( |
1531 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1672 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1532 | 1673 | ||
1533 | AddNewMovement(agent_control_v3, q); | 1674 | AddNewMovement(agent_control_v3, q, Nudging); |
1534 | 1675 | ||
1535 | 1676 | ||
1536 | } | 1677 | } |
1537 | } | 1678 | } |
1538 | 1679 | ||
1539 | if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround) | 1680 | if (update_movementflag && !SitGround) |
1540 | Animator.UpdateMovementAnimations(); | 1681 | Animator.UpdateMovementAnimations(); |
1541 | 1682 | ||
1542 | m_scene.EventManager.TriggerOnClientMovement(this); | 1683 | m_scene.EventManager.TriggerOnClientMovement(this); |
@@ -1551,7 +1692,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1551 | m_sitAtAutoTarget = false; | 1692 | m_sitAtAutoTarget = false; |
1552 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | 1693 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; |
1553 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1694 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1554 | |||
1555 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); | 1695 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); |
1556 | proxyObjectGroup.AttachToScene(m_scene); | 1696 | proxyObjectGroup.AttachToScene(m_scene); |
1557 | 1697 | ||
@@ -1593,7 +1733,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1593 | } | 1733 | } |
1594 | m_moveToPositionInProgress = true; | 1734 | m_moveToPositionInProgress = true; |
1595 | m_moveToPositionTarget = new Vector3(locx, locy, locz); | 1735 | m_moveToPositionTarget = new Vector3(locx, locy, locz); |
1596 | } | 1736 | } |
1597 | catch (Exception ex) | 1737 | catch (Exception ex) |
1598 | { | 1738 | { |
1599 | //Why did I get this error? | 1739 | //Why did I get this error? |
@@ -1615,7 +1755,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1615 | Velocity = Vector3.Zero; | 1755 | Velocity = Vector3.Zero; |
1616 | SendFullUpdateToAllClients(); | 1756 | SendFullUpdateToAllClients(); |
1617 | 1757 | ||
1618 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1758 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1619 | } | 1759 | } |
1620 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1760 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1621 | m_requestedSitTargetUUID = UUID.Zero; | 1761 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1652,50 +1792,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
1652 | 1792 | ||
1653 | if (m_parentID != 0) | 1793 | if (m_parentID != 0) |
1654 | { | 1794 | { |
1655 | m_log.Debug("StandupCode Executed"); | 1795 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
1656 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | ||
1657 | if (part != null) | 1796 | if (part != null) |
1658 | { | 1797 | { |
1798 | part.TaskInventory.LockItemsForRead(true); | ||
1659 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1799 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1660 | if (taskIDict != null) | 1800 | if (taskIDict != null) |
1661 | { | 1801 | { |
1662 | lock (taskIDict) | 1802 | foreach (UUID taskID in taskIDict.Keys) |
1663 | { | 1803 | { |
1664 | foreach (UUID taskID in taskIDict.Keys) | 1804 | UnRegisterControlEventsToScript(LocalId, taskID); |
1665 | { | 1805 | taskIDict[taskID].PermsMask &= ~( |
1666 | UnRegisterControlEventsToScript(LocalId, taskID); | 1806 | 2048 | //PERMISSION_CONTROL_CAMERA |
1667 | taskIDict[taskID].PermsMask &= ~( | 1807 | 4); // PERMISSION_TAKE_CONTROLS |
1668 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1669 | 4); // PERMISSION_TAKE_CONTROLS | ||
1670 | } | ||
1671 | } | 1808 | } |
1672 | |||
1673 | } | 1809 | } |
1810 | part.TaskInventory.LockItemsForRead(false); | ||
1674 | // Reset sit target. | 1811 | // Reset sit target. |
1675 | if (part.GetAvatarOnSitTarget() == UUID) | 1812 | if (part.GetAvatarOnSitTarget() == UUID) |
1676 | part.SetAvatarOnSitTarget(UUID.Zero); | 1813 | part.SetAvatarOnSitTarget(UUID.Zero); |
1677 | |||
1678 | m_parentPosition = part.GetWorldPosition(); | 1814 | m_parentPosition = part.GetWorldPosition(); |
1679 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1815 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1680 | } | 1816 | } |
1817 | // part.GetWorldRotation() is the rotation of the object being sat on | ||
1818 | // Rotation is the sittiing Av's rotation | ||
1819 | |||
1820 | Quaternion partRot; | ||
1821 | // if (part.LinkNum == 1) | ||
1822 | // { // Root prim of linkset | ||
1823 | // partRot = part.ParentGroup.RootPart.RotationOffset; | ||
1824 | // } | ||
1825 | // else | ||
1826 | // { // single or child prim | ||
1827 | |||
1828 | // } | ||
1829 | if (part == null) //CW: Part may be gone. llDie() for example. | ||
1830 | { | ||
1831 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1832 | } | ||
1833 | else | ||
1834 | { | ||
1835 | partRot = part.GetWorldRotation(); | ||
1836 | } | ||
1837 | |||
1838 | Quaternion partIRot = Quaternion.Inverse(partRot); | ||
1681 | 1839 | ||
1840 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av | ||
1841 | Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av | ||
1842 | |||
1843 | |||
1682 | if (m_physicsActor == null) | 1844 | if (m_physicsActor == null) |
1683 | { | 1845 | { |
1684 | AddToPhysicalScene(false); | 1846 | AddToPhysicalScene(false); |
1685 | } | 1847 | } |
1686 | 1848 | //CW: If the part isn't null then we can set the current position | |
1687 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1849 | if (part != null) |
1688 | m_parentPosition = Vector3.Zero; | 1850 | { |
1689 | 1851 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! | |
1690 | m_parentID = 0; | 1852 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. |
1853 | part.IsOccupied = false; | ||
1854 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); | ||
1855 | } | ||
1856 | else | ||
1857 | { | ||
1858 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue | ||
1859 | AbsolutePosition = m_lastWorldPosition; | ||
1860 | } | ||
1861 | |||
1862 | m_parentPosition = Vector3.Zero; | ||
1863 | m_parentID = 0; | ||
1864 | m_linkedPrim = UUID.Zero; | ||
1865 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1691 | SendFullUpdateToAllClients(); | 1866 | SendFullUpdateToAllClients(); |
1692 | m_requestedSitTargetID = 0; | 1867 | m_requestedSitTargetID = 0; |
1868 | |||
1693 | if ((m_physicsActor != null) && (m_avHeight > 0)) | 1869 | if ((m_physicsActor != null) && (m_avHeight > 0)) |
1694 | { | 1870 | { |
1695 | SetHeight(m_avHeight); | 1871 | SetHeight(m_avHeight); |
1696 | } | 1872 | } |
1697 | } | 1873 | } |
1698 | |||
1699 | Animator.TrySetMovementAnimation("STAND"); | 1874 | Animator.TrySetMovementAnimation("STAND"); |
1700 | } | 1875 | } |
1701 | 1876 | ||
@@ -1726,13 +1901,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1726 | Vector3 avSitOffSet = part.SitTargetPosition; | 1901 | Vector3 avSitOffSet = part.SitTargetPosition; |
1727 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1902 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1728 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1903 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1729 | 1904 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); | |
1730 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1905 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1731 | bool SitTargetisSet = | 1906 | if (SitTargetisSet && !SitTargetOccupied) |
1732 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | ||
1733 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | ||
1734 | |||
1735 | if (SitTargetisSet && SitTargetUnOccupied) | ||
1736 | { | 1907 | { |
1737 | //switch the target to this prim | 1908 | //switch the target to this prim |
1738 | return part; | 1909 | return part; |
@@ -1746,84 +1917,164 @@ namespace OpenSim.Region.Framework.Scenes | |||
1746 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 1917 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) |
1747 | { | 1918 | { |
1748 | bool autopilot = true; | 1919 | bool autopilot = true; |
1920 | Vector3 autopilotTarget = new Vector3(); | ||
1921 | Quaternion sitOrientation = Quaternion.Identity; | ||
1749 | Vector3 pos = new Vector3(); | 1922 | Vector3 pos = new Vector3(); |
1750 | Quaternion sitOrientation = pSitOrientation; | ||
1751 | Vector3 cameraEyeOffset = Vector3.Zero; | 1923 | Vector3 cameraEyeOffset = Vector3.Zero; |
1752 | Vector3 cameraAtOffset = Vector3.Zero; | 1924 | Vector3 cameraAtOffset = Vector3.Zero; |
1753 | bool forceMouselook = false; | 1925 | bool forceMouselook = false; |
1754 | 1926 | ||
1755 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1927 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1756 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1928 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1757 | if (part != null) | 1929 | if (part == null) return; |
1758 | { | 1930 | |
1759 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1931 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1760 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1932 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1761 | 1933 | ||
1762 | // Is a sit target available? | 1934 | // part is the prim to sit on |
1763 | Vector3 avSitOffSet = part.SitTargetPosition; | 1935 | // offset is the world-ref vector distance from that prim center to the click-spot |
1764 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1936 | // UUID is the UUID of the Avatar doing the clicking |
1765 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1937 | |
1766 | 1938 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | |
1767 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1939 | |
1768 | bool SitTargetisSet = | 1940 | // Is a sit target available? |
1769 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && | 1941 | Vector3 avSitOffSet = part.SitTargetPosition; |
1770 | ( | 1942 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1771 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 1f // Valid Zero Rotation quaternion | 1943 | |
1772 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point | 1944 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1773 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion | 1945 | // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
1774 | ) | 1946 | Quaternion partRot; |
1775 | )); | 1947 | // if (part.LinkNum == 1) |
1776 | 1948 | // { // Root prim of linkset | |
1777 | if (SitTargetisSet && SitTargetUnOccupied) | 1949 | // partRot = part.ParentGroup.RootPart.RotationOffset; |
1778 | { | 1950 | // } |
1779 | part.SetAvatarOnSitTarget(UUID); | 1951 | // else |
1780 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1952 | // { // single or child prim |
1781 | sitOrientation = avSitOrientation; | 1953 | partRot = part.GetWorldRotation(); |
1782 | autopilot = false; | 1954 | // } |
1783 | } | 1955 | Quaternion partIRot = Quaternion.Inverse(partRot); |
1784 | 1956 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); | |
1785 | pos = part.AbsolutePosition + offset; | 1957 | // Sit analysis rewritten by KF 091125 |
1786 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 1958 | if (SitTargetisSet) // scipted sit |
1787 | //{ | 1959 | { |
1788 | // offset = pos; | 1960 | if (!part.IsOccupied) |
1789 | //autopilot = false; | 1961 | { |
1790 | //} | 1962 | //Console.WriteLine("Scripted, unoccupied"); |
1791 | if (m_physicsActor != null) | 1963 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1792 | { | 1964 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1793 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 1965 | |
1794 | // We can remove the physicsActor until they stand up. | 1966 | Quaternion nrot = avSitOrientation; |
1795 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1967 | if (!part.IsRoot) |
1796 | |||
1797 | if (autopilot) | ||
1798 | { | 1968 | { |
1799 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1969 | nrot = part.RotationOffset * avSitOrientation; |
1800 | { | ||
1801 | autopilot = false; | ||
1802 | |||
1803 | RemoveFromPhysicalScene(); | ||
1804 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | ||
1805 | } | ||
1806 | } | 1970 | } |
1807 | else | 1971 | sitOrientation = nrot; // Change rotatione to the scripted one |
1972 | OffsetRotation = nrot; | ||
1973 | autopilot = false; // Jump direct to scripted llSitPos() | ||
1974 | } | ||
1975 | else | ||
1976 | { | ||
1977 | //Console.WriteLine("Scripted, occupied"); | ||
1978 | return; | ||
1979 | } | ||
1980 | } | ||
1981 | else // Not Scripted | ||
1982 | { | ||
1983 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) | ||
1984 | { | ||
1985 | // large prim & offset, ignore if other Avs sitting | ||
1986 | // offset.Z -= 0.05f; | ||
1987 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked | ||
1988 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point | ||
1989 | |||
1990 | //Console.WriteLine(" offset ={0}", offset); | ||
1991 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); | ||
1992 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); | ||
1993 | |||
1994 | } | ||
1995 | else // small offset | ||
1996 | { | ||
1997 | //Console.WriteLine("Small offset"); | ||
1998 | if (!part.IsOccupied) | ||
1999 | { | ||
2000 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | ||
2001 | autopilotTarget = part.AbsolutePosition; | ||
2002 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
2003 | } | ||
2004 | else return; // occupied small | ||
2005 | } // end large/small | ||
2006 | } // end Scripted/not | ||
2007 | cameraAtOffset = part.GetCameraAtOffset(); | ||
2008 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2009 | forceMouselook = part.GetForceMouselook(); | ||
2010 | if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // | ||
2011 | if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // | ||
2012 | |||
2013 | if (m_physicsActor != null) | ||
2014 | { | ||
2015 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | ||
2016 | // We can remove the physicsActor until they stand up. | ||
2017 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
2018 | if (autopilot) | ||
2019 | { // its not a scripted sit | ||
2020 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | ||
2021 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) | ||
1808 | { | 2022 | { |
2023 | autopilot = false; // close enough | ||
2024 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2025 | Not using the part's position because returning the AV to the last known standing | ||
2026 | position is likely to be more friendly, isn't it? */ | ||
1809 | RemoveFromPhysicalScene(); | 2027 | RemoveFromPhysicalScene(); |
1810 | } | 2028 | Velocity = Vector3.Zero; |
2029 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target | ||
2030 | } // else the autopilot will get us close | ||
2031 | } | ||
2032 | else | ||
2033 | { // its a scripted sit | ||
2034 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2035 | I *am* using the part's position this time because we have no real idea how far away | ||
2036 | the avatar is from the sit target. */ | ||
2037 | RemoveFromPhysicalScene(); | ||
2038 | Velocity = Vector3.Zero; | ||
1811 | } | 2039 | } |
1812 | |||
1813 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1814 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1815 | forceMouselook = part.GetForceMouselook(); | ||
1816 | } | 2040 | } |
1817 | 2041 | else return; // physactor is null! | |
1818 | ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2042 | |
1819 | m_requestedSitTargetUUID = targetID; | 2043 | Vector3 offsetr; // = offset * partIRot; |
2044 | // KF: In a linkset, offsetr needs to be relative to the group root! 091208 | ||
2045 | // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); | ||
2046 | // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. | ||
2047 | // { // Single, or Root prim of linkset, target is ClickOffset * RootRot | ||
2048 | //offsetr = offset * partIRot; | ||
2049 | // | ||
2050 | // else | ||
2051 | // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) | ||
2052 | // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + | ||
2053 | // (offset * partRot); | ||
2054 | // } | ||
2055 | |||
2056 | //Console.WriteLine(" "); | ||
2057 | //Console.WriteLine("link number ={0}", part.LinkNum); | ||
2058 | //Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); | ||
2059 | //Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); | ||
2060 | //Console.WriteLine("Click offst ={0}", offset); | ||
2061 | //Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); | ||
2062 | //Console.WriteLine("offsetr ={0}", offsetr); | ||
2063 | //Console.WriteLine("Camera At ={0}", cameraAtOffset); | ||
2064 | //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); | ||
2065 | |||
2066 | //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child | ||
2067 | ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2068 | |||
2069 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target | ||
1820 | // This calls HandleAgentSit twice, once from here, and the client calls | 2070 | // This calls HandleAgentSit twice, once from here, and the client calls |
1821 | // HandleAgentSit itself after it gets to the location | 2071 | // HandleAgentSit itself after it gets to the location |
1822 | // It doesn't get to the location until we've moved them there though | 2072 | // It doesn't get to the location until we've moved them there though |
1823 | // which happens in HandleAgentSit :P | 2073 | // which happens in HandleAgentSit :P |
1824 | m_autopilotMoving = autopilot; | 2074 | m_autopilotMoving = autopilot; |
1825 | m_autoPilotTarget = pos; | 2075 | m_autoPilotTarget = autopilotTarget; |
1826 | m_sitAtAutoTarget = autopilot; | 2076 | m_sitAtAutoTarget = autopilot; |
2077 | m_initialSitTarget = autopilotTarget; | ||
1827 | if (!autopilot) | 2078 | if (!autopilot) |
1828 | HandleAgentSit(remoteClient, UUID); | 2079 | HandleAgentSit(remoteClient, UUID); |
1829 | } | 2080 | } |
@@ -2118,47 +2369,130 @@ namespace OpenSim.Region.Framework.Scenes | |||
2118 | { | 2369 | { |
2119 | if (part != null) | 2370 | if (part != null) |
2120 | { | 2371 | { |
2372 | //Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); | ||
2121 | if (part.GetAvatarOnSitTarget() == UUID) | 2373 | if (part.GetAvatarOnSitTarget() == UUID) |
2122 | { | 2374 | { |
2375 | //Console.WriteLine("Scripted Sit"); | ||
2376 | // Scripted sit | ||
2123 | Vector3 sitTargetPos = part.SitTargetPosition; | 2377 | Vector3 sitTargetPos = part.SitTargetPosition; |
2124 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 2378 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
2125 | |||
2126 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
2127 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
2128 | |||
2129 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
2130 | |||
2131 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 2379 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
2132 | m_pos += SIT_TARGET_ADJUSTMENT; | 2380 | m_pos += SIT_TARGET_ADJUSTMENT; |
2381 | if (!part.IsRoot) | ||
2382 | { | ||
2383 | m_pos *= part.RotationOffset; | ||
2384 | } | ||
2133 | m_bodyRot = sitTargetOrient; | 2385 | m_bodyRot = sitTargetOrient; |
2134 | //Rotation = sitTargetOrient; | ||
2135 | m_parentPosition = part.AbsolutePosition; | 2386 | m_parentPosition = part.AbsolutePosition; |
2136 | 2387 | part.IsOccupied = true; | |
2137 | //SendTerseUpdateToAllClients(); | 2388 | part.ParentGroup.AddAvatar(agentID); |
2138 | } | 2389 | } |
2139 | else | 2390 | else |
2140 | { | 2391 | { |
2141 | m_pos -= part.AbsolutePosition; | 2392 | // if m_avUnscriptedSitPos is zero then Av sits above center |
2393 | // Else Av sits at m_avUnscriptedSitPos | ||
2394 | |||
2395 | // Non-scripted sit by Kitto Flora 21Nov09 | ||
2396 | // Calculate angle of line from prim to Av | ||
2397 | Quaternion partIRot; | ||
2398 | // if (part.LinkNum == 1) | ||
2399 | // { // Root prim of linkset | ||
2400 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2401 | // } | ||
2402 | // else | ||
2403 | // { // single or child prim | ||
2404 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2405 | // } | ||
2406 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | ||
2407 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | ||
2408 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | ||
2409 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
2410 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
2411 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
2412 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
2413 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
2414 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
2415 | |||
2142 | m_parentPosition = part.AbsolutePosition; | 2416 | m_parentPosition = part.AbsolutePosition; |
2143 | } | 2417 | part.IsOccupied = true; |
2418 | part.ParentGroup.AddAvatar(agentID); | ||
2419 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation | ||
2420 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center | ||
2421 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + | ||
2422 | m_avUnscriptedSitPos; // adds click offset, if any | ||
2423 | //Set up raytrace to find top surface of prim | ||
2424 | Vector3 size = part.Scale; | ||
2425 | float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
2426 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
2427 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
2428 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); | ||
2429 | m_scene.PhysicsScene.RaycastWorld( | ||
2430 | start, // Vector3 position, | ||
2431 | down, // Vector3 direction, | ||
2432 | mag, // float length, | ||
2433 | SitAltitudeCallback); // retMethod | ||
2434 | } // end scripted/not | ||
2144 | } | 2435 | } |
2145 | else | 2436 | else // no Av |
2146 | { | 2437 | { |
2147 | return; | 2438 | return; |
2148 | } | 2439 | } |
2149 | } | 2440 | } |
2150 | m_parentID = m_requestedSitTargetID; | ||
2151 | 2441 | ||
2442 | //We want our offsets to reference the root prim, not the child we may have sat on | ||
2443 | if (!part.IsRoot) | ||
2444 | { | ||
2445 | m_parentID = part.ParentGroup.RootPart.LocalId; | ||
2446 | m_pos += part.OffsetPosition; | ||
2447 | } | ||
2448 | else | ||
2449 | { | ||
2450 | m_parentID = m_requestedSitTargetID; | ||
2451 | } | ||
2452 | |||
2453 | m_linkedPrim = part.UUID; | ||
2454 | if (part.GetAvatarOnSitTarget() != UUID) | ||
2455 | { | ||
2456 | m_offsetRotation = m_offsetRotation / part.RotationOffset; | ||
2457 | } | ||
2152 | Velocity = Vector3.Zero; | 2458 | Velocity = Vector3.Zero; |
2153 | RemoveFromPhysicalScene(); | 2459 | RemoveFromPhysicalScene(); |
2154 | |||
2155 | Animator.TrySetMovementAnimation(sitAnimation); | 2460 | Animator.TrySetMovementAnimation(sitAnimation); |
2156 | SendFullUpdateToAllClients(); | 2461 | SendFullUpdateToAllClients(); |
2157 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | 2462 | SendTerseUpdateToAllClients(); |
2158 | // So we're also sending a terse update (which has avatar rotation) | ||
2159 | // [Update] We do now. | ||
2160 | //SendTerseUpdateToAllClients(); | ||
2161 | } | 2463 | } |
2464 | |||
2465 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) | ||
2466 | { | ||
2467 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer | ||
2468 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. | ||
2469 | if(hitYN) | ||
2470 | { | ||
2471 | // m_pos = Av offset from prim center to make look like on center | ||
2472 | // m_parentPosition = Actual center pos of prim | ||
2473 | // collisionPoint = spot on prim where we want to sit | ||
2474 | // collisionPoint.Z = global sit surface height | ||
2475 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
2476 | Quaternion partIRot; | ||
2477 | // if (part.LinkNum == 1) | ||
2478 | /// { // Root prim of linkset | ||
2479 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2480 | // } | ||
2481 | // else | ||
2482 | // { // single or child prim | ||
2483 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2484 | // } | ||
2485 | if (m_initialSitTarget != null) | ||
2486 | { | ||
2487 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | ||
2488 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction | ||
2489 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); | ||
2490 | m_pos += offset; | ||
2491 | // ControllingClient.SendClearFollowCamProperties(part.UUID); | ||
2492 | } | ||
2493 | |||
2494 | } | ||
2495 | } // End SitAltitudeCallback KF. | ||
2162 | 2496 | ||
2163 | /// <summary> | 2497 | /// <summary> |
2164 | /// Event handler for the 'Always run' setting on the client | 2498 | /// Event handler for the 'Always run' setting on the client |
@@ -2188,7 +2522,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2188 | /// </summary> | 2522 | /// </summary> |
2189 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2523 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
2190 | /// <param name="rotation">The direction in which this avatar should now face. | 2524 | /// <param name="rotation">The direction in which this avatar should now face. |
2191 | public void AddNewMovement(Vector3 vec, Quaternion rotation) | 2525 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) |
2192 | { | 2526 | { |
2193 | if (m_isChildAgent) | 2527 | if (m_isChildAgent) |
2194 | { | 2528 | { |
@@ -2229,15 +2563,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2229 | Rotation = rotation; | 2563 | Rotation = rotation; |
2230 | Vector3 direc = vec * rotation; | 2564 | Vector3 direc = vec * rotation; |
2231 | direc.Normalize(); | 2565 | direc.Normalize(); |
2566 | PhysicsActor actor = m_physicsActor; | ||
2567 | if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. | ||
2232 | 2568 | ||
2233 | direc *= 0.03f * 128f * m_speedModifier; | 2569 | direc *= 0.03f * 128f * m_speedModifier; |
2234 | 2570 | ||
2235 | PhysicsActor actor = m_physicsActor; | ||
2236 | if (actor != null) | 2571 | if (actor != null) |
2237 | { | 2572 | { |
2238 | if (actor.Flying) | 2573 | // rm falling if (actor.Flying) |
2574 | if ((actor.Flying) || Animator.m_falling) // add for falling lateral speed | ||
2239 | { | 2575 | { |
2240 | direc *= 4.0f; | 2576 | // rm speed mod direc *= 4.0f; |
2577 | direc *= 5.2f; // for speed mod | ||
2241 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2578 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2242 | //bool colliding = (m_physicsActor.IsColliding==true); | 2579 | //bool colliding = (m_physicsActor.IsColliding==true); |
2243 | //if (controlland) | 2580 | //if (controlland) |
@@ -2250,22 +2587,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
2250 | // m_log.Info("[AGENT]: Stop FLying"); | 2587 | // m_log.Info("[AGENT]: Stop FLying"); |
2251 | //} | 2588 | //} |
2252 | } | 2589 | } |
2590 | /* This jumping section removed to SPA | ||
2253 | else if (!actor.Flying && actor.IsColliding) | 2591 | else if (!actor.Flying && actor.IsColliding) |
2254 | { | 2592 | { |
2255 | if (direc.Z > 2.0f) | 2593 | if (direc.Z > 2.0f) |
2256 | { | 2594 | { |
2257 | direc.Z *= 3.0f; | 2595 | if(m_animator.m_animTickJump == -1) |
2258 | 2596 | { | |
2259 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2597 | direc.Z *= 3.0f; // jump |
2260 | Animator.TrySetMovementAnimation("PREJUMP"); | 2598 | } |
2261 | Animator.TrySetMovementAnimation("JUMP"); | 2599 | else |
2600 | { | ||
2601 | direc.Z *= 0.1f; // prejump | ||
2602 | } | ||
2603 | / * Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs | ||
2604 | Animator.TrySetMovementAnimation("PREJUMP"); | ||
2605 | Animator.TrySetMovementAnimation("JUMP"); | ||
2606 | * / | ||
2262 | } | 2607 | } |
2263 | } | 2608 | } */ |
2264 | } | 2609 | } |
2265 | 2610 | ||
2266 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2611 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2267 | m_forceToApply = direc; | 2612 | m_forceToApply = direc; |
2268 | 2613 | m_isNudging = Nudging; | |
2269 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2614 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2270 | } | 2615 | } |
2271 | 2616 | ||
@@ -2280,7 +2625,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2280 | const float POSITION_TOLERANCE = 0.05f; | 2625 | const float POSITION_TOLERANCE = 0.05f; |
2281 | //const int TIME_MS_TOLERANCE = 3000; | 2626 | //const int TIME_MS_TOLERANCE = 3000; |
2282 | 2627 | ||
2283 | SendPrimUpdates(); | 2628 | |
2284 | 2629 | ||
2285 | if (m_isChildAgent == false) | 2630 | if (m_isChildAgent == false) |
2286 | { | 2631 | { |
@@ -2310,6 +2655,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2310 | CheckForBorderCrossing(); | 2655 | CheckForBorderCrossing(); |
2311 | CheckForSignificantMovement(); // sends update to the modules. | 2656 | CheckForSignificantMovement(); // sends update to the modules. |
2312 | } | 2657 | } |
2658 | |||
2659 | //Sending prim updates AFTER the avatar terse updates are sent | ||
2660 | SendPrimUpdates(); | ||
2313 | } | 2661 | } |
2314 | 2662 | ||
2315 | #endregion | 2663 | #endregion |
@@ -3093,6 +3441,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3093 | m_callbackURI = cAgent.CallbackURI; | 3441 | m_callbackURI = cAgent.CallbackURI; |
3094 | 3442 | ||
3095 | m_pos = cAgent.Position; | 3443 | m_pos = cAgent.Position; |
3444 | |||
3096 | m_velocity = cAgent.Velocity; | 3445 | m_velocity = cAgent.Velocity; |
3097 | m_CameraCenter = cAgent.Center; | 3446 | m_CameraCenter = cAgent.Center; |
3098 | //m_avHeight = cAgent.Size.Z; | 3447 | //m_avHeight = cAgent.Size.Z; |
@@ -3201,17 +3550,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3201 | /// </summary> | 3550 | /// </summary> |
3202 | public override void UpdateMovement() | 3551 | public override void UpdateMovement() |
3203 | { | 3552 | { |
3204 | if (m_forceToApply.HasValue) | 3553 | if (Animator!=null) // add for jumping |
3205 | { | 3554 | { // add for jumping |
3206 | Vector3 force = m_forceToApply.Value; | 3555 | // if (!m_animator.m_jumping) // add for jumping |
3556 | // { // add for jumping | ||
3207 | 3557 | ||
3208 | m_updateflag = true; | 3558 | if (m_forceToApply.HasValue) // this section realigned |
3209 | // movementvector = force; | 3559 | { |
3210 | Velocity = force; | ||
3211 | 3560 | ||
3212 | m_forceToApply = null; | 3561 | Vector3 force = m_forceToApply.Value; |
3213 | } | 3562 | m_updateflag = true; |
3214 | } | 3563 | if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping |
3564 | Velocity = force; | ||
3565 | //Console.WriteLine("UM1 {0}", Velocity); | ||
3566 | m_forceToApply = null; | ||
3567 | } | ||
3568 | else | ||
3569 | { | ||
3570 | if (m_isNudging) | ||
3571 | { | ||
3572 | Vector3 force = Vector3.Zero; | ||
3573 | |||
3574 | m_updateflag = true; | ||
3575 | if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping | ||
3576 | Velocity = force; | ||
3577 | //Console.WriteLine("UM2 {0}", Velocity); | ||
3578 | m_isNudging = false; | ||
3579 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" | ||
3580 | } | ||
3581 | else // add for jumping | ||
3582 | { // add for jumping | ||
3583 | Vector3 force = Vector3.Zero; // add for jumping | ||
3584 | if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for jumping | ||
3585 | //Console.WriteLine("UM3 {0}", Velocity); | ||
3586 | Velocity = force; // add for jumping | ||
3587 | } | ||
3588 | |||
3589 | } | ||
3590 | // } // end realign | ||
3591 | } // add for jumping | ||
3592 | } // add for jumping | ||
3215 | 3593 | ||
3216 | /// <summary> | 3594 | /// <summary> |
3217 | /// Adds a physical representation of the avatar to the Physics plugin | 3595 | /// Adds a physical representation of the avatar to the Physics plugin |
@@ -3256,18 +3634,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
3256 | { | 3634 | { |
3257 | if (e == null) | 3635 | if (e == null) |
3258 | return; | 3636 | return; |
3259 | 3637 | ||
3260 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3638 | // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( |
3261 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | ||
3262 | // as of this comment the interval is set in AddToPhysicalScene | 3639 | // as of this comment the interval is set in AddToPhysicalScene |
3263 | if (Animator!=null) | 3640 | if (Animator!=null) |
3264 | Animator.UpdateMovementAnimations(); | 3641 | { |
3642 | if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, | ||
3643 | { // else its will lock out other animation changes, like ground sit. | ||
3644 | Animator.UpdateMovementAnimations(); | ||
3645 | m_updateCount--; | ||
3646 | } | ||
3647 | } | ||
3265 | 3648 | ||
3266 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3649 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3267 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3650 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3268 | 3651 | ||
3269 | CollisionPlane = Vector4.UnitW; | 3652 | CollisionPlane = Vector4.UnitW; |
3270 | 3653 | ||
3654 | if (m_lastColCount != coldata.Count) | ||
3655 | { | ||
3656 | m_updateCount = UPDATE_COUNT; | ||
3657 | m_lastColCount = coldata.Count; | ||
3658 | } | ||
3659 | |||
3271 | if (coldata.Count != 0 && Animator != null) | 3660 | if (coldata.Count != 0 && Animator != null) |
3272 | { | 3661 | { |
3273 | switch (Animator.CurrentMovementAnimation) | 3662 | switch (Animator.CurrentMovementAnimation) |
@@ -3297,6 +3686,148 @@ namespace OpenSim.Region.Framework.Scenes | |||
3297 | } | 3686 | } |
3298 | } | 3687 | } |
3299 | 3688 | ||
3689 | List<uint> thisHitColliders = new List<uint>(); | ||
3690 | List<uint> endedColliders = new List<uint>(); | ||
3691 | List<uint> startedColliders = new List<uint>(); | ||
3692 | |||
3693 | foreach (uint localid in coldata.Keys) | ||
3694 | { | ||
3695 | thisHitColliders.Add(localid); | ||
3696 | if (!m_lastColliders.Contains(localid)) | ||
3697 | { | ||
3698 | startedColliders.Add(localid); | ||
3699 | } | ||
3700 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3701 | } | ||
3702 | |||
3703 | // calculate things that ended colliding | ||
3704 | foreach (uint localID in m_lastColliders) | ||
3705 | { | ||
3706 | if (!thisHitColliders.Contains(localID)) | ||
3707 | { | ||
3708 | endedColliders.Add(localID); | ||
3709 | } | ||
3710 | } | ||
3711 | //add the items that started colliding this time to the last colliders list. | ||
3712 | foreach (uint localID in startedColliders) | ||
3713 | { | ||
3714 | m_lastColliders.Add(localID); | ||
3715 | } | ||
3716 | // remove things that ended colliding from the last colliders list | ||
3717 | foreach (uint localID in endedColliders) | ||
3718 | { | ||
3719 | m_lastColliders.Remove(localID); | ||
3720 | } | ||
3721 | |||
3722 | // do event notification | ||
3723 | if (startedColliders.Count > 0) | ||
3724 | { | ||
3725 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3726 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3727 | foreach (uint localId in startedColliders) | ||
3728 | { | ||
3729 | if (localId == 0) | ||
3730 | continue; | ||
3731 | |||
3732 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3733 | string data = ""; | ||
3734 | if (obj != null) | ||
3735 | { | ||
3736 | DetectedObject detobj = new DetectedObject(); | ||
3737 | detobj.keyUUID = obj.UUID; | ||
3738 | detobj.nameStr = obj.Name; | ||
3739 | detobj.ownerUUID = obj.OwnerID; | ||
3740 | detobj.posVector = obj.AbsolutePosition; | ||
3741 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3742 | detobj.velVector = obj.Velocity; | ||
3743 | detobj.colliderType = 0; | ||
3744 | detobj.groupUUID = obj.GroupID; | ||
3745 | colliding.Add(detobj); | ||
3746 | } | ||
3747 | } | ||
3748 | |||
3749 | if (colliding.Count > 0) | ||
3750 | { | ||
3751 | StartCollidingMessage.Colliders = colliding; | ||
3752 | |||
3753 | foreach (SceneObjectGroup att in Attachments) | ||
3754 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3755 | } | ||
3756 | } | ||
3757 | |||
3758 | if (endedColliders.Count > 0) | ||
3759 | { | ||
3760 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3761 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3762 | foreach (uint localId in endedColliders) | ||
3763 | { | ||
3764 | if (localId == 0) | ||
3765 | continue; | ||
3766 | |||
3767 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3768 | string data = ""; | ||
3769 | if (obj != null) | ||
3770 | { | ||
3771 | DetectedObject detobj = new DetectedObject(); | ||
3772 | detobj.keyUUID = obj.UUID; | ||
3773 | detobj.nameStr = obj.Name; | ||
3774 | detobj.ownerUUID = obj.OwnerID; | ||
3775 | detobj.posVector = obj.AbsolutePosition; | ||
3776 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3777 | detobj.velVector = obj.Velocity; | ||
3778 | detobj.colliderType = 0; | ||
3779 | detobj.groupUUID = obj.GroupID; | ||
3780 | colliding.Add(detobj); | ||
3781 | } | ||
3782 | } | ||
3783 | |||
3784 | if (colliding.Count > 0) | ||
3785 | { | ||
3786 | EndCollidingMessage.Colliders = colliding; | ||
3787 | |||
3788 | foreach (SceneObjectGroup att in Attachments) | ||
3789 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3790 | } | ||
3791 | } | ||
3792 | |||
3793 | if (thisHitColliders.Count > 0) | ||
3794 | { | ||
3795 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3796 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3797 | foreach (uint localId in thisHitColliders) | ||
3798 | { | ||
3799 | if (localId == 0) | ||
3800 | continue; | ||
3801 | |||
3802 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3803 | string data = ""; | ||
3804 | if (obj != null) | ||
3805 | { | ||
3806 | DetectedObject detobj = new DetectedObject(); | ||
3807 | detobj.keyUUID = obj.UUID; | ||
3808 | detobj.nameStr = obj.Name; | ||
3809 | detobj.ownerUUID = obj.OwnerID; | ||
3810 | detobj.posVector = obj.AbsolutePosition; | ||
3811 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3812 | detobj.velVector = obj.Velocity; | ||
3813 | detobj.colliderType = 0; | ||
3814 | detobj.groupUUID = obj.GroupID; | ||
3815 | colliding.Add(detobj); | ||
3816 | } | ||
3817 | } | ||
3818 | |||
3819 | if (colliding.Count > 0) | ||
3820 | { | ||
3821 | CollidingMessage.Colliders = colliding; | ||
3822 | |||
3823 | lock (m_attachments) | ||
3824 | { | ||
3825 | foreach (SceneObjectGroup att in m_attachments) | ||
3826 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3827 | } | ||
3828 | } | ||
3829 | } | ||
3830 | |||
3300 | if (m_invulnerable) | 3831 | if (m_invulnerable) |
3301 | return; | 3832 | return; |
3302 | 3833 | ||
@@ -3492,7 +4023,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3492 | m_scene = scene; | 4023 | m_scene = scene; |
3493 | 4024 | ||
3494 | RegisterToEvents(); | 4025 | RegisterToEvents(); |
3495 | 4026 | if (m_controllingClient != null) | |
4027 | { | ||
4028 | m_controllingClient.ProcessPendingPackets(); | ||
4029 | } | ||
3496 | /* | 4030 | /* |
3497 | AbsolutePosition = client.StartPos; | 4031 | AbsolutePosition = client.StartPos; |
3498 | 4032 | ||
@@ -3722,6 +4256,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3722 | return; | 4256 | return; |
3723 | } | 4257 | } |
3724 | 4258 | ||
4259 | XmlDocument doc = new XmlDocument(); | ||
4260 | string stateData = String.Empty; | ||
4261 | |||
4262 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
4263 | if (attServ != null) | ||
4264 | { | ||
4265 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
4266 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | ||
4267 | if (stateData != String.Empty) | ||
4268 | { | ||
4269 | try | ||
4270 | { | ||
4271 | doc.LoadXml(stateData); | ||
4272 | } | ||
4273 | catch { } | ||
4274 | } | ||
4275 | } | ||
4276 | |||
4277 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
4278 | |||
4279 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
4280 | if (nodes.Count > 0) | ||
4281 | { | ||
4282 | foreach (XmlNode n in nodes) | ||
4283 | { | ||
4284 | XmlElement elem = (XmlElement)n; | ||
4285 | string itemID = elem.GetAttribute("ItemID"); | ||
4286 | string xml = elem.InnerXml; | ||
4287 | |||
4288 | itemData[new UUID(itemID)] = xml; | ||
4289 | } | ||
4290 | } | ||
4291 | |||
3725 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4292 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3726 | foreach (int p in attPoints) | 4293 | foreach (int p in attPoints) |
3727 | { | 4294 | { |
@@ -3741,7 +4308,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3741 | 4308 | ||
3742 | try | 4309 | try |
3743 | { | 4310 | { |
3744 | m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); | 4311 | string xmlData; |
4312 | XmlDocument d = new XmlDocument(); | ||
4313 | UUID asset; | ||
4314 | if (itemData.TryGetValue(itemID, out xmlData)) | ||
4315 | { | ||
4316 | d.LoadXml(xmlData); | ||
4317 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | ||
4318 | |||
4319 | // Rez from inventory | ||
4320 | asset | ||
4321 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | ||
4322 | |||
4323 | } | ||
4324 | else | ||
4325 | { | ||
4326 | // Rez from inventory (with a null doc to let | ||
4327 | // CHANGED_OWNER happen) | ||
4328 | asset | ||
4329 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | ||
4330 | } | ||
4331 | |||
4332 | m_log.InfoFormat( | ||
4333 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2}", | ||
4334 | p, itemID, asset); | ||
3745 | } | 4335 | } |
3746 | catch (Exception e) | 4336 | catch (Exception e) |
3747 | { | 4337 | { |
@@ -3774,5 +4364,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3774 | m_reprioritization_called = false; | 4364 | m_reprioritization_called = false; |
3775 | } | 4365 | } |
3776 | } | 4366 | } |
4367 | |||
4368 | private Vector3 Quat2Euler(Quaternion rot){ | ||
4369 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , | ||
4370 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); | ||
4371 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); | ||
4372 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | ||
4373 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); | ||
4374 | return(new Vector3(x,y,z)); | ||
4375 | } | ||
4376 | |||
4377 | |||
3777 | } | 4378 | } |
3778 | } | 4379 | } |