aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 14:54:35 +0100
committerUbitUmarov2015-09-01 14:54:35 +0100
commit371c9dd2af01a2e7422ec901ee1f80757284a78c (patch)
tree058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Region/Framework/Scenes/ScenePresence.cs
parentremove lixo (diff)
parentdont change camera on crossings (diff)
downloadopensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz
bad merge?
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs2325
1 files changed, 2061 insertions, 264 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 2f19b50..4bccb7d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -90,7 +90,17 @@ namespace OpenSim.Region.Framework.Scenes
90 m_scene.EventManager.TriggerScenePresenceUpdated(this); 90 m_scene.EventManager.TriggerScenePresenceUpdated(this);
91 } 91 }
92 92
93 public PresenceType PresenceType { get; private set; } 93 public bool isNPC { get; private set; }
94
95 private PresenceType m_presenceType;
96 public PresenceType PresenceType {
97 get {return m_presenceType;}
98 private set
99 {
100 m_presenceType = value;
101 isNPC = (m_presenceType == PresenceType.Npc);
102 }
103 }
94 104
95 private ScenePresenceStateMachine m_stateMachine; 105 private ScenePresenceStateMachine m_stateMachine;
96 106
@@ -142,13 +152,100 @@ namespace OpenSim.Region.Framework.Scenes
142 /// </summary> 152 /// </summary>
143 public static readonly float SIGNIFICANT_MOVEMENT = 2.0f; 153 public static readonly float SIGNIFICANT_MOVEMENT = 2.0f;
144 154
145 public UUID currentParcelUUID = UUID.Zero; 155 private UUID m_previusParcelUUID = UUID.Zero;
156 private UUID m_currentParcelUUID = UUID.Zero;
157 private bool m_previusParcelHide = false;
158 private bool m_currentParcelHide = false;
159 private object parcelLock = new Object();
160
161 public UUID currentParcelUUID
162 {
163 get { return m_currentParcelUUID; }
164 set
165 {
166 lock (parcelLock)
167 {
168 bool oldhide = m_currentParcelHide;
169 bool checksame = true;
170 if (value != m_currentParcelUUID)
171 {
172 m_previusParcelHide = m_currentParcelHide;
173 m_previusParcelUUID = m_currentParcelUUID;
174 checksame = false;
175 }
176 m_currentParcelUUID = value;
177 m_currentParcelHide = false;
178
179 ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y);
180 if (land != null && !land.LandData.SeeAVs)
181 m_currentParcelHide = true;
182
183 if (m_previusParcelUUID != UUID.Zero || checksame)
184 ParcelCrossCheck(m_currentParcelUUID,m_previusParcelUUID,m_currentParcelHide, m_previusParcelHide, oldhide,checksame);
185 }
186 }
187 }
188
189 public void sitSOGmoved()
190 {
191 if (IsDeleted || !IsSatOnObject)
192 //what me? nahh
193 return;
194 if (IsInTransit)
195 return;
196
197 ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y);
198 if (land == null)
199 return; //??
200 UUID parcelID = land.LandData.GlobalID;
201 if (m_currentParcelUUID != parcelID)
202 currentParcelUUID = parcelID;
203 }
204
205
206 public bool ParcelAllowThisAvatarSounds
207 {
208 get
209 {
210 try
211 {
212 lock (parcelLock)
213 {
214 ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y);
215 if (land == null)
216 return true;
217 if (land.LandData.AnyAVSounds)
218 return true;
219 if (!land.LandData.GroupAVSounds)
220 return false;
221 return land.LandData.GroupID == ControllingClient.ActiveGroupId;
222 }
223 }
224 catch
225 {
226 return true;
227 }
228 }
229 }
146 230
231 public bool ParcelHideThisAvatar
232 {
233 get
234 {
235 return m_currentParcelHide;
236 }
237 }
238
147 /// <value> 239 /// <value>
148 /// The animator for this avatar 240 /// The animator for this avatar
149 /// </value> 241 /// </value>
150 public ScenePresenceAnimator Animator { get; private set; } 242 public ScenePresenceAnimator Animator { get; private set; }
151 243
244 /// <value>
245 /// Server Side Animation Override
246 /// </value>
247 public MovementAnimationOverrides Overrides { get; private set; }
248 public String sitAnimation = "SIT";
152 /// <summary> 249 /// <summary>
153 /// Attachments recorded on this avatar. 250 /// Attachments recorded on this avatar.
154 /// </summary> 251 /// </summary>
@@ -192,14 +289,7 @@ namespace OpenSim.Region.Framework.Scenes
192 set { PhysicsActor.Flying = value; } 289 set { PhysicsActor.Flying = value; }
193 } 290 }
194 291
195 // add for fly velocity control 292 public bool IsColliding
196 private bool FlyingOld {get; set;}
197 public bool WasFlying
198 {
199 get; private set;
200 }
201
202 public bool IsColliding
203 { 293 {
204 get { return PhysicsActor != null && PhysicsActor.IsColliding; } 294 get { return PhysicsActor != null && PhysicsActor.IsColliding; }
205 // We would expect setting IsColliding to be private but it's used by a hack in Scene 295 // We would expect setting IsColliding to be private but it's used by a hack in Scene
@@ -247,7 +337,7 @@ namespace OpenSim.Region.Framework.Scenes
247 337
248 protected ulong crossingFromRegion; 338 protected ulong crossingFromRegion;
249 339
250 private readonly Vector3[] Dir_Vectors = new Vector3[11]; 340 private readonly Vector3[] Dir_Vectors = new Vector3[12];
251 341
252 protected Timer m_reprioritization_timer; 342 protected Timer m_reprioritization_timer;
253 protected bool m_reprioritizing; 343 protected bool m_reprioritizing;
@@ -303,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes
303 /// <summary> 393 /// <summary>
304 /// Implemented Control Flags 394 /// Implemented Control Flags
305 /// </summary> 395 /// </summary>
306 private enum Dir_ControlFlags 396 private enum Dir_ControlFlags:uint
307 { 397 {
308 DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, 398 DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
309 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, 399 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG,
@@ -315,6 +405,7 @@ namespace OpenSim.Region.Framework.Scenes
315 DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, 405 DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
316 DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, 406 DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS,
317 DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, 407 DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG,
408 DIR_CONTROL_FLAG_UP_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS,
318 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG 409 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
319 } 410 }
320 411
@@ -413,11 +504,18 @@ namespace OpenSim.Region.Framework.Scenes
413 } 504 }
414 505
415 private ulong m_rootRegionHandle; 506 private ulong m_rootRegionHandle;
507 private Vector3 m_rootRegionPosition = new Vector3();
416 508
417 public ulong RegionHandle 509 public ulong RegionHandle
418 { 510 {
419 get { return m_rootRegionHandle; } 511 get { return m_rootRegionHandle; }
420 private set { m_rootRegionHandle = value; } 512 private set
513 {
514 m_rootRegionHandle = value;
515 // position rounded to lower multiple of 256m
516 m_rootRegionPosition.X = (float)((m_rootRegionHandle >> 32) & 0xffffff00);
517 m_rootRegionPosition.Y = (float)(m_rootRegionHandle & 0xffffff00);
518 }
421 } 519 }
422 520
423 #region Client Camera 521 #region Client Camera
@@ -449,11 +547,8 @@ namespace OpenSim.Region.Framework.Scenes
449 get 547 get
450 { 548 {
451 Vector3 a = new Vector3(CameraAtAxis.X, CameraAtAxis.Y, 0); 549 Vector3 a = new Vector3(CameraAtAxis.X, CameraAtAxis.Y, 0);
452 550 a.Normalize();
453 if (a == Vector3.Zero) 551 return a;
454 return a;
455
456 return Util.GetNormalizedVector(a);
457 } 552 }
458 } 553 }
459 #endregion 554 #endregion
@@ -505,6 +600,7 @@ namespace OpenSim.Region.Framework.Scenes
505 } 600 }
506 } 601 }
507 602
603
508 public byte State { get; set; } 604 public byte State { get; set; }
509 605
510 private AgentManager.ControlFlags m_AgentControlFlags; 606 private AgentManager.ControlFlags m_AgentControlFlags;
@@ -557,10 +653,21 @@ namespace OpenSim.Region.Framework.Scenes
557 // in the sim unless the avatar is on a sit target. While 653 // in the sim unless the avatar is on a sit target. While
558 // on a sit target, m_pos will contain the desired offset 654 // on a sit target, m_pos will contain the desired offset
559 // without the parent rotation applied. 655 // without the parent rotation applied.
656<<<<<<< HEAD
560 SceneObjectPart sitPart = ParentPart; 657 SceneObjectPart sitPart = ParentPart;
561 658
562 if (sitPart != null) 659 if (sitPart != null)
563 return sitPart.ParentGroup.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); 660 return sitPart.ParentGroup.AbsolutePosition + (m_pos * sitPart.GetWorldRotation());
661=======
662 if (ParentPart != null)
663 {
664 SceneObjectPart rootPart = ParentPart.ParentGroup.RootPart;
665 // if (sitPart != null)
666 // return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation());
667 if (rootPart != null)
668 return rootPart.AbsolutePosition + (m_pos * rootPart.GetWorldRotation());
669 }
670>>>>>>> avn/ubitvar
564 } 671 }
565 672
566 return m_pos; 673 return m_pos;
@@ -661,24 +768,7 @@ namespace OpenSim.Region.Framework.Scenes
661 m_velocity = value; 768 m_velocity = value;
662 } 769 }
663 } 770 }
664/*
665 public override Vector3 AngularVelocity
666 {
667 get
668 {
669 if (PhysicsActor != null)
670 {
671 m_rotationalvelocity = PhysicsActor.RotationalVelocity;
672
673 // m_log.DebugFormat(
674 // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
675 // m_velocity, Name, Scene.RegionInfo.RegionName);
676 }
677 771
678 return m_rotationalvelocity;
679 }
680 }
681*/
682 private Quaternion m_bodyRot = Quaternion.Identity; 772 private Quaternion m_bodyRot = Quaternion.Identity;
683 773
684 /// <summary> 774 /// <summary>
@@ -794,22 +884,29 @@ namespace OpenSim.Region.Framework.Scenes
794 else 884 else
795 seeds = new Dictionary<ulong, string>(); 885 seeds = new Dictionary<ulong, string>();
796 886
887/* we can't do this anymore
797 List<ulong> old = new List<ulong>(); 888 List<ulong> old = new List<ulong>();
798 foreach (ulong handle in seeds.Keys) 889 foreach (ulong handle in seeds.Keys)
799 { 890 {
800 uint x, y; 891 uint x, y;
801 Util.RegionHandleToRegionLoc(handle, out x, out y); 892 Util.RegionHandleToRegionLoc(handle, out x, out y);
893<<<<<<< HEAD
802 894
803 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) 895 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
896=======
897no information to check this
898// if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY,))
899>>>>>>> avn/ubitvar
804 { 900 {
805 old.Add(handle); 901 old.Add(handle);
806 } 902 }
807 } 903 }
904
808 DropOldNeighbours(old); 905 DropOldNeighbours(old);
809 906
810 if (Scene.CapsModule != null) 907 if (Scene.CapsModule != null)
811 Scene.CapsModule.SetChildrenSeed(UUID, seeds); 908 Scene.CapsModule.SetChildrenSeed(UUID, seeds);
812 909*/
813 KnownRegions = seeds; 910 KnownRegions = seeds;
814 //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); 911 //m_log.Debug(" ++++++++++AFTER+++++++++++++ ");
815 //DumpKnownRegions(); 912 //DumpKnownRegions();
@@ -852,13 +949,6 @@ namespace OpenSim.Region.Framework.Scenes
852 } 949 }
853 } 950 }
854 951
855 private float m_speedModifier = 1.0f;
856
857 public float SpeedModifier
858 {
859 get { return m_speedModifier; }
860 set { m_speedModifier = value; }
861 }
862 952
863 /// <summary> 953 /// <summary>
864 /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running 954 /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running
@@ -866,7 +956,20 @@ namespace OpenSim.Region.Framework.Scenes
866 /// <remarks> 956 /// <remarks>
867 /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. 957 /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers.
868 /// </remarks> 958 /// </remarks>
869 private float AgentControlStopSlowWhilstMoving = 0.5f; 959 private const float AgentControlStopSlowVel = 0.2f;
960 // velocities
961 public const float AgentControlNudgeVel = 1.0f; // setting this diferent from normal as no effect currently
962 public const float AgentControlNormalVel = 1.0f;
963
964 // old normal speed was tuned to match sl normal plus Fast modifiers
965 // so we need to rescale it
966 private float m_speedModifier = 1.0f;
967
968 public float SpeedModifier
969 {
970 get { return m_speedModifier; }
971 set { m_speedModifier = value; }
972 }
870 973
871 private bool m_forceFly; 974 private bool m_forceFly;
872 975
@@ -907,6 +1010,7 @@ namespace OpenSim.Region.Framework.Scenes
907 IsLoggingIn = false; 1010 IsLoggingIn = false;
908 m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; 1011 m_sendCoarseLocationsMethod = SendCoarseLocationsDefault;
909 Animator = new ScenePresenceAnimator(this); 1012 Animator = new ScenePresenceAnimator(this);
1013 Overrides = new MovementAnimationOverrides();
910 PresenceType = type; 1014 PresenceType = type;
911 // DrawDistance = world.DefaultDrawDistance; 1015 // DrawDistance = world.DefaultDrawDistance;
912 DrawDistance = Constants.RegionSize; 1016 DrawDistance = Constants.RegionSize;
@@ -917,7 +1021,7 @@ namespace OpenSim.Region.Framework.Scenes
917 m_name = String.Format("{0} {1}", Firstname, Lastname); 1021 m_name = String.Format("{0} {1}", Firstname, Lastname);
918 m_scene = world; 1022 m_scene = world;
919 m_uuid = client.AgentId; 1023 m_uuid = client.AgentId;
920 LocalId = m_scene.AllocateLocalId(); 1024 LocalId = m_scene.AllocatePresenceLocalId();
921 1025
922 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); 1026 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
923 if (account != null) 1027 if (account != null)
@@ -930,7 +1034,7 @@ namespace OpenSim.Region.Framework.Scenes
930 1034
931 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 1035 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
932 if (gm != null) 1036 if (gm != null)
933 Grouptitle = gm.GetGroupTitle(m_uuid); 1037 Grouptitle = gm.GetGroupTitle(m_uuid);
934 1038
935 m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); 1039 m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>();
936 1040
@@ -988,8 +1092,10 @@ namespace OpenSim.Region.Framework.Scenes
988 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; 1092 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
989 ControllingClient.OnStartAnim += HandleStartAnim; 1093 ControllingClient.OnStartAnim += HandleStartAnim;
990 ControllingClient.OnStopAnim += HandleStopAnim; 1094 ControllingClient.OnStopAnim += HandleStopAnim;
1095 ControllingClient.OnChangeAnim += avnHandleChangeAnim;
991 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; 1096 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls;
992 ControllingClient.OnAutoPilotGo += MoveToTarget; 1097 ControllingClient.OnAutoPilotGo += MoveToTarget;
1098 ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles;
993 1099
994 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 1100 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
995 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 1101 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@@ -997,6 +1103,7 @@ namespace OpenSim.Region.Framework.Scenes
997 1103
998 private void SetDirectionVectors() 1104 private void SetDirectionVectors()
999 { 1105 {
1106<<<<<<< HEAD
1000 Dir_Vectors[0] = Vector3.UnitX; //FORWARD 1107 Dir_Vectors[0] = Vector3.UnitX; //FORWARD
1001 Dir_Vectors[1] = -Vector3.UnitX; //BACK 1108 Dir_Vectors[1] = -Vector3.UnitX; //BACK
1002 Dir_Vectors[2] = Vector3.UnitY; //LEFT 1109 Dir_Vectors[2] = Vector3.UnitY; //LEFT
@@ -1010,6 +1117,41 @@ namespace OpenSim.Region.Framework.Scenes
1010 Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge 1117 Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
1011 } 1118 }
1012 1119
1120=======
1121 Dir_Vectors[0] = new Vector3(AgentControlNormalVel,0,0); //FORWARD
1122 Dir_Vectors[1] = new Vector3(-AgentControlNormalVel,0,0);; //BACK
1123 Dir_Vectors[2] = new Vector3(0,AgentControlNormalVel,0); //LEFT
1124 Dir_Vectors[3] = new Vector3(0,-AgentControlNormalVel,0); //RIGHT
1125 Dir_Vectors[4] = new Vector3(0,0,AgentControlNormalVel); //UP
1126 Dir_Vectors[5] = new Vector3(0,0,-AgentControlNormalVel); //DOWN
1127 Dir_Vectors[6] = new Vector3(AgentControlNudgeVel, 0f, 0f); //FORWARD_NUDGE
1128 Dir_Vectors[7] = new Vector3(-AgentControlNudgeVel, 0f, 0f); //BACK_NUDGE
1129 Dir_Vectors[8] = new Vector3(0f, AgentControlNudgeVel, 0f); //LEFT_NUDGE
1130 Dir_Vectors[9] = new Vector3(0f, -AgentControlNudgeVel, 0f); //RIGHT_NUDGE
1131 Dir_Vectors[10] = new Vector3(0f, 0f, AgentControlNudgeVel); //UP_Nudge
1132 Dir_Vectors[11] = new Vector3(0f, 0f, -AgentControlNudgeVel); //DOWN_Nudge
1133 }
1134
1135/* dont see any use for this
1136 private Vector3[] GetWalkDirectionVectors()
1137 {
1138 Vector3[] vector = new Vector3[12];
1139 vector[0] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD
1140 vector[1] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK
1141 vector[2] = Vector3.UnitY; //LEFT
1142 vector[3] = -Vector3.UnitY; //RIGHT
1143 vector[4] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP
1144 vector[5] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN
1145 vector[6] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD_NUDGE
1146 vector[7] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK_NUDGE
1147 vector[8] = Vector3.UnitY; //LEFT_NUDGE
1148 vector[9] = -Vector3.UnitY; //RIGHT_NUDGE
1149 vector[10] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP_NUDGE
1150 vector[11] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE
1151 return vector;
1152 }
1153*/
1154>>>>>>> avn/ubitvar
1013 #endregion 1155 #endregion
1014 1156
1015 #region Status Methods 1157 #region Status Methods
@@ -1026,18 +1168,25 @@ namespace OpenSim.Region.Framework.Scenes
1026 /// This method is on the critical path for transferring an avatar from one region to another. Delay here 1168 /// This method is on the critical path for transferring an avatar from one region to another. Delay here
1027 /// delays that crossing. 1169 /// delays that crossing.
1028 /// </remarks> 1170 /// </remarks>
1171
1172
1173 // only in use as part of completemovement
1174 // other uses need fix
1029 private bool MakeRootAgent(Vector3 pos, bool isFlying) 1175 private bool MakeRootAgent(Vector3 pos, bool isFlying)
1030 { 1176 {
1177 int ts = Util.EnvironmentTickCount();
1178
1031 lock (m_completeMovementLock) 1179 lock (m_completeMovementLock)
1032 { 1180 {
1033 if (!IsChildAgent) 1181 if (!IsChildAgent)
1034 return false; 1182 return false;
1035 1183
1184 m_log.DebugFormat("[MakeRootAgent] enter lock: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1036 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); 1185 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
1037 1186
1038 // m_log.InfoFormat( 1187 // m_log.InfoFormat(
1039 // "[SCENE]: Upgrading child to root agent for {0} in {1}", 1188 // "[SCENE]: Upgrading child to root agent for {0} in {1}",
1040 // Name, m_scene.RegionInfo.RegionName); 1189 // Name, m_scene.RegionInfo.RegionName);
1041 1190
1042 if (ParentUUID != UUID.Zero) 1191 if (ParentUUID != UUID.Zero)
1043 { 1192 {
@@ -1046,20 +1195,28 @@ namespace OpenSim.Region.Framework.Scenes
1046 if (part == null) 1195 if (part == null)
1047 { 1196 {
1048 m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); 1197 m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID);
1198 ParentID = 0;
1199 ParentPart = null;
1200 PrevSitOffset = Vector3.Zero;
1201 HandleForceReleaseControls(ControllingClient, UUID); // needs testing
1202 IsLoggingIn = false;
1049 } 1203 }
1050 else 1204 else
1051 { 1205 {
1206<<<<<<< HEAD
1052 part.AddSittingAvatar(this); 1207 part.AddSittingAvatar(this);
1053 // ParentPosition = part.GetWorldPosition(); 1208 // ParentPosition = part.GetWorldPosition();
1209=======
1210 part.ParentGroup.AddAvatar(UUID);
1211 if (part.SitTargetPosition != Vector3.Zero)
1212 part.SitTargetAvatar = UUID;
1213>>>>>>> avn/ubitvar
1054 ParentID = part.LocalId; 1214 ParentID = part.LocalId;
1055 ParentPart = part; 1215 ParentPart = part;
1056 m_pos = PrevSitOffset; 1216 m_pos = PrevSitOffset;
1057 // pos = ParentPosition;
1058 pos = part.GetWorldPosition(); 1217 pos = part.GetWorldPosition();
1059 } 1218 }
1060 ParentUUID = UUID.Zero; 1219 ParentUUID = UUID.Zero;
1061
1062 // Animator.TrySetMovementAnimation("SIT");
1063 } 1220 }
1064 else 1221 else
1065 { 1222 {
@@ -1069,15 +1226,18 @@ namespace OpenSim.Region.Framework.Scenes
1069 IsChildAgent = false; 1226 IsChildAgent = false;
1070 } 1227 }
1071 1228
1229 m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1230
1072 // Must reset this here so that a teleport to a region next to an existing region does not keep the flag 1231 // Must reset this here so that a teleport to a region next to an existing region does not keep the flag
1073 // set and prevent the close of the connection on a subsequent re-teleport. 1232 // set and prevent the close of the connection on a subsequent re-teleport.
1074 // Should not be needed if we are not trying to tell this region to close 1233 // Should not be needed if we are not trying to tell this region to close
1075// DoNotCloseAfterTeleport = false; 1234 // DoNotCloseAfterTeleport = false;
1076 1235
1077 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 1236 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
1078 if (gm != null) 1237 if (gm != null)
1079 Grouptitle = gm.GetGroupTitle(m_uuid); 1238 Grouptitle = gm.GetGroupTitle(m_uuid);
1080 1239
1240<<<<<<< HEAD
1081 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode); 1241 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode);
1082 uint teleportFlags = (aCircuit == null) ? 0 : aCircuit.teleportFlags; 1242 uint teleportFlags = (aCircuit == null) ? 0 : aCircuit.teleportFlags;
1083 if ((teleportFlags & (uint)TeleportFlags.ViaHGLogin) != 0) 1243 if ((teleportFlags & (uint)TeleportFlags.ViaHGLogin) != 0)
@@ -1088,11 +1248,16 @@ namespace OpenSim.Region.Framework.Scenes
1088 // But we have a trick that can force them to update the name anyway. 1248 // But we have a trick that can force them to update the name anyway.
1089 ForceViewersUpdateName(); 1249 ForceViewersUpdateName();
1090 } 1250 }
1251=======
1252 m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1253>>>>>>> avn/ubitvar
1091 1254
1092 RegionHandle = m_scene.RegionInfo.RegionHandle; 1255 RegionHandle = m_scene.RegionInfo.RegionHandle;
1093 1256
1094 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 1257 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
1258 m_log.DebugFormat("[MakeRootAgent] TriggerSetRootAgentScene: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1095 1259
1260<<<<<<< HEAD
1096 UUID groupUUID = ControllingClient.ActiveGroupId; 1261 UUID groupUUID = ControllingClient.ActiveGroupId;
1097 string groupName = string.Empty; 1262 string groupName = string.Empty;
1098 ulong groupPowers = 0; 1263 ulong groupPowers = 0;
@@ -1145,6 +1310,11 @@ namespace OpenSim.Region.Framework.Scenes
1145 } 1310 }
1146 */ 1311 */
1147 1312
1313=======
1314
1315 if (ParentID == 0)
1316 {
1317>>>>>>> avn/ubitvar
1148 CheckAndAdjustLandingPoint(ref pos); 1318 CheckAndAdjustLandingPoint(ref pos);
1149 1319
1150 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 1320 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
@@ -1166,7 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes
1166 1336
1167 if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY) 1337 if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY)
1168 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 1338 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
1169 1339
1170 float newPosZ = posZLimit + localAVHeight / 2; 1340 float newPosZ = posZLimit + localAVHeight / 2;
1171 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) 1341 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
1172 { 1342 {
@@ -1190,6 +1360,7 @@ namespace OpenSim.Region.Framework.Scenes
1190 else 1360 else
1191 { 1361 {
1192 AddToPhysicalScene(isFlying); 1362 AddToPhysicalScene(isFlying);
1363<<<<<<< HEAD
1193 } 1364 }
1194 1365
1195 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a 1366 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a
@@ -1198,6 +1369,11 @@ namespace OpenSim.Region.Framework.Scenes
1198 // the value to a negative position which does not trigger the border cross. 1369 // the value to a negative position which does not trigger the border cross.
1199 // This may not be the best location for this. 1370 // This may not be the best location for this.
1200 CheckForBorderCrossing(); 1371 CheckForBorderCrossing();
1372=======
1373 // reset camera to avatar pos
1374 CameraPosition = pos;
1375 }
1376>>>>>>> avn/ubitvar
1201 1377
1202 if (ForceFly) 1378 if (ForceFly)
1203 { 1379 {
@@ -1207,6 +1383,7 @@ namespace OpenSim.Region.Framework.Scenes
1207 { 1383 {
1208 Flying = false; 1384 Flying = false;
1209 } 1385 }
1386<<<<<<< HEAD
1210 } 1387 }
1211 1388
1212 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 1389 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
@@ -1239,8 +1416,24 @@ namespace OpenSim.Region.Framework.Scenes
1239 string.Format("Start attachment scripts for {0} in {1}", Name, Scene.Name), 1416 string.Format("Start attachment scripts for {0} in {1}", Name, Scene.Name),
1240 true); 1417 true);
1241 } 1418 }
1419=======
1420
1421 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a
1422 // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it
1423 // since it requires a physics actor to be present. If it is left any later, then physics appears to reset
1424 // the value to a negative position which does not trigger the border cross.
1425 // This may not be the best location for this.
1426
1427
1428 // its not
1429// CheckForBorderCrossing();
1430>>>>>>> avn/ubitvar
1242 } 1431 }
1432
1433 m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1434 m_scene.SwapRootAgentCount(false);
1243 1435
1436<<<<<<< HEAD
1244 SendAvatarDataToAllClients(); 1437 SendAvatarDataToAllClients();
1245 1438
1246 // send the animations of the other presences to me 1439 // send the animations of the other presences to me
@@ -1249,6 +1442,8 @@ namespace OpenSim.Region.Framework.Scenes
1249 if (presence != this) 1442 if (presence != this)
1250 presence.Animator.SendAnimPackToClient(ControllingClient); 1443 presence.Animator.SendAnimPackToClient(ControllingClient);
1251 }); 1444 });
1445=======
1446>>>>>>> avn/ubitvar
1252 1447
1253 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will 1448 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will
1254 // stall on the border crossing since the existing child agent will still have the last movement 1449 // stall on the border crossing since the existing child agent will still have the last movement
@@ -1256,6 +1451,7 @@ namespace OpenSim.Region.Framework.Scenes
1256 MovementFlag = ForceUpdateMovementFlagValue; 1451 MovementFlag = ForceUpdateMovementFlagValue;
1257 1452
1258 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1453 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1454 m_log.DebugFormat("[MakeRootAgent] TriggerOnMakeRootAgent and done: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1259 1455
1260 return true; 1456 return true;
1261 } 1457 }
@@ -1347,11 +1543,19 @@ namespace OpenSim.Region.Framework.Scenes
1347 /// It doesn't get called for a teleport. Reason being, an agent that 1543 /// It doesn't get called for a teleport. Reason being, an agent that
1348 /// teleports out may not end up anywhere near this region 1544 /// teleports out may not end up anywhere near this region
1349 /// </remarks> 1545 /// </remarks>
1350 public void MakeChildAgent() 1546 public void MakeChildAgent(ulong newRegionHandle)
1351 { 1547 {
1352 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; 1548 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
1353 1549
1354 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); 1550 RegionHandle = newRegionHandle;
1551
1552 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1} from root region {2}",
1553 Name, Scene.RegionInfo.RegionName, newRegionHandle);
1554
1555 // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating
1556 // from the source simulator has completed on a V2 teleport.
1557 lock (m_originRegionIDAccessLock)
1558 m_originRegionID = UUID.Zero;
1355 1559
1356 // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating 1560 // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating
1357 // from the source simulator has completed on a V2 teleport. 1561 // from the source simulator has completed on a V2 teleport.
@@ -1371,7 +1575,7 @@ namespace OpenSim.Region.Framework.Scenes
1371 else 1575 else
1372 Animator.ResetAnimations(); 1576 Animator.ResetAnimations();
1373 1577
1374 1578
1375// m_log.DebugFormat( 1579// m_log.DebugFormat(
1376// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 1580// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
1377// Name, UUID, m_scene.RegionInfo.RegionName); 1581// Name, UUID, m_scene.RegionInfo.RegionName);
@@ -1385,8 +1589,15 @@ namespace OpenSim.Region.Framework.Scenes
1385 RemoveFromPhysicalScene(); 1589 RemoveFromPhysicalScene();
1386 ParentID = 0; // Child agents can't be sitting 1590 ParentID = 0; // Child agents can't be sitting
1387 1591
1592// we dont have land information for child
1593 m_previusParcelHide = false;
1594 m_previusParcelUUID = UUID.Zero;
1595 m_currentParcelHide = false;
1596 m_currentParcelUUID = UUID.Zero;
1388 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into 1597 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into
1389 1598
1599 CollisionPlane = Vector4.UnitW;
1600
1390 m_scene.EventManager.TriggerOnMakeChildAgent(this); 1601 m_scene.EventManager.TriggerOnMakeChildAgent(this);
1391 } 1602 }
1392 1603
@@ -1473,6 +1684,9 @@ namespace OpenSim.Region.Framework.Scenes
1473 1684
1474 public void StopFlying() 1685 public void StopFlying()
1475 { 1686 {
1687 if (IsInTransit)
1688 return;
1689
1476 Vector3 pos = AbsolutePosition; 1690 Vector3 pos = AbsolutePosition;
1477 if (Appearance.AvatarHeight != 127.0f) 1691 if (Appearance.AvatarHeight != 127.0f)
1478 pos += new Vector3(0f, 0f, (Appearance.AvatarHeight / 6f)); 1692 pos += new Vector3(0f, 0f, (Appearance.AvatarHeight / 6f));
@@ -1492,7 +1706,7 @@ namespace OpenSim.Region.Framework.Scenes
1492 else 1706 else
1493 CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f / 6f)); 1707 CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f / 6f));
1494 1708
1495 ControllingClient.SendAgentTerseUpdate(this); 1709 SendAgentTerseUpdate(this);
1496 } 1710 }
1497 1711
1498 /// <summary> 1712 /// <summary>
@@ -1578,15 +1792,46 @@ namespace OpenSim.Region.Framework.Scenes
1578 // holds the seed cap for the child agent in that region 1792 // holds the seed cap for the child agent in that region
1579 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 1793 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
1580 1794
1581 public void AddNeighbourRegion(ulong regionHandle, string cap) 1795 struct spRegionSizeInfo
1796 {
1797 public int sizeX;
1798 public int sizeY;
1799 }
1800
1801 private Dictionary<ulong, spRegionSizeInfo> m_knownChildRegionsSizeInfo = new Dictionary<ulong, spRegionSizeInfo>();
1802
1803
1804 public void AddNeighbourRegionSizeInfo(GridRegion region)
1582 { 1805 {
1583 lock (m_knownChildRegions) 1806 lock (m_knownChildRegions)
1584 { 1807 {
1585 if (!m_knownChildRegions.ContainsKey(regionHandle)) 1808 spRegionSizeInfo sizeInfo = new spRegionSizeInfo();
1809 sizeInfo.sizeX = region.RegionSizeX;
1810 sizeInfo.sizeY = region.RegionSizeY;
1811 ulong regionHandle = region.RegionHandle;
1812
1813 if (!m_knownChildRegionsSizeInfo.ContainsKey(regionHandle))
1586 { 1814 {
1587 uint x, y; 1815 m_knownChildRegionsSizeInfo.Add(regionHandle, sizeInfo);
1588 Utils.LongToUInts(regionHandle, out x, out y); 1816
1589 m_knownChildRegions.Add(regionHandle, cap); 1817 }
1818 else
1819 m_knownChildRegionsSizeInfo[regionHandle] = sizeInfo;
1820 }
1821 }
1822
1823 public void SetNeighbourRegionSizeInfo(List<GridRegion> regionsList)
1824 {
1825 lock (m_knownChildRegions)
1826 {
1827 m_knownChildRegionsSizeInfo.Clear();
1828 foreach (GridRegion region in regionsList)
1829 {
1830 spRegionSizeInfo sizeInfo = new spRegionSizeInfo();
1831 sizeInfo.sizeX = region.RegionSizeX;
1832 sizeInfo.sizeY = region.RegionSizeY;
1833 ulong regionHandle = region.RegionHandle;
1834 m_knownChildRegionsSizeInfo.Add(regionHandle, sizeInfo);
1590 } 1835 }
1591 } 1836 }
1592 } 1837 }
@@ -1600,6 +1845,7 @@ namespace OpenSim.Region.Framework.Scenes
1600 //if (m_knownChildRegions.ContainsKey(regionHandle)) 1845 //if (m_knownChildRegions.ContainsKey(regionHandle))
1601 // m_log.DebugFormat(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); 1846 // m_log.DebugFormat(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count);
1602 m_knownChildRegions.Remove(regionHandle); 1847 m_knownChildRegions.Remove(regionHandle);
1848 m_knownChildRegionsSizeInfo.Remove(regionHandle);
1603 } 1849 }
1604 } 1850 }
1605 1851
@@ -1612,6 +1858,13 @@ namespace OpenSim.Region.Framework.Scenes
1612 } 1858 }
1613 } 1859 }
1614 1860
1861 public void DropThisRootRegionFromNeighbours()
1862 {
1863 ulong handle = m_scene.RegionInfo.RegionHandle;
1864 RemoveNeighbourRegion(handle);
1865 Scene.CapsModule.DropChildSeed(UUID, handle);
1866 }
1867
1615 public Dictionary<ulong, string> KnownRegions 1868 public Dictionary<ulong, string> KnownRegions
1616 { 1869 {
1617 get 1870 get
@@ -1662,12 +1915,17 @@ namespace OpenSim.Region.Framework.Scenes
1662 public void SetSize(Vector3 size, float feetoffset) 1915 public void SetSize(Vector3 size, float feetoffset)
1663 { 1916 {
1664 if (PhysicsActor != null && !IsChildAgent) 1917 if (PhysicsActor != null && !IsChildAgent)
1918<<<<<<< HEAD
1665 { 1919 {
1666 // Eventually there will be a physics call that sets avatar size that includes offset info. 1920 // Eventually there will be a physics call that sets avatar size that includes offset info.
1667 // For the moment, just set the size as passed. 1921 // For the moment, just set the size as passed.
1668 PhysicsActor.Size = size; 1922 PhysicsActor.Size = size;
1669 // PhysicsActor.setAvatarSize(size, feetoffset); 1923 // PhysicsActor.setAvatarSize(size, feetoffset);
1670 } 1924 }
1925=======
1926 PhysicsActor.setAvatarSize(size, feetoffset);
1927
1928>>>>>>> avn/ubitvar
1671 } 1929 }
1672 1930
1673 private bool WaitForUpdateAgent(IClientAPI client) 1931 private bool WaitForUpdateAgent(IClientAPI client)
@@ -1704,12 +1962,15 @@ namespace OpenSim.Region.Framework.Scenes
1704 /// </param> 1962 /// </param>
1705 public void CompleteMovement(IClientAPI client, bool openChildAgents) 1963 public void CompleteMovement(IClientAPI client, bool openChildAgents)
1706 { 1964 {
1707// DateTime startTime = DateTime.Now; 1965 int ts = Util.EnvironmentTickCount();
1708 1966
1709 m_log.InfoFormat( 1967 m_log.InfoFormat(
1710 "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", 1968 "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}",
1711 client.Name, Scene.Name, AbsolutePosition); 1969 client.Name, Scene.Name, AbsolutePosition);
1970
1971 m_inTransit = true;
1712 1972
1973<<<<<<< HEAD
1713 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); // Get this ahead of time because IsInTransit modifies 'm_AgentControlFlags' 1974 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); // Get this ahead of time because IsInTransit modifies 'm_AgentControlFlags'
1714 1975
1715 IsInTransit = true; 1976 IsInTransit = true;
@@ -1742,16 +2003,38 @@ namespace OpenSim.Region.Framework.Scenes
1742 pos.Z = ground + 1.5f; 2003 pos.Z = ground + 1.5f;
1743 AbsolutePosition = pos; 2004 AbsolutePosition = pos;
1744 } 2005 }
2006=======
2007 try
2008 {
2009 // Make sure it's not a login agent. We don't want to wait for updates during login
2010 if (!isNPC && (m_teleportFlags & TeleportFlags.ViaLogin) == 0)
2011 {
2012
2013 // Let's wait until UpdateAgent (called by departing region) is done
2014 if (!WaitForUpdateAgent(client))
2015 // The sending region never sent the UpdateAgent data, we have to refuse
2016 return;
2017 }
2018
2019 m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2020
2021 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
2022>>>>>>> avn/ubitvar
1745 2023
1746 if (!MakeRootAgent(AbsolutePosition, flying)) 2024 if (!MakeRootAgent(AbsolutePosition, flying))
1747 { 2025 {
1748 m_log.DebugFormat( 2026 m_log.DebugFormat(
2027<<<<<<< HEAD
1749 "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", 2028 "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root",
2029=======
2030 "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root",
2031>>>>>>> avn/ubitvar
1750 Name, Scene.Name); 2032 Name, Scene.Name);
1751 2033
1752 return; 2034 return;
1753 } 2035 }
1754 2036
2037<<<<<<< HEAD
1755 // Tell the client that we're totally ready 2038 // Tell the client that we're totally ready
1756 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 2039 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1757 2040
@@ -1832,6 +2115,249 @@ namespace OpenSim.Region.Framework.Scenes
1832 sog.ScheduleGroupForFullUpdate(); 2115 sog.ScheduleGroupForFullUpdate();
1833 } 2116 }
1834 } 2117 }
2118=======
2119 m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2120
2121 Vector3 look = Lookat;
2122 if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01))
2123 {
2124 look = Velocity;
2125 look.Z = 0;
2126 look.Normalize();
2127 if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) )
2128 look = new Vector3(0.99f, 0.042f, 0);
2129 }
2130
2131// start sending terrain patchs
2132 if (!isNPC)
2133 Scene.SendLayerData(ControllingClient);
2134
2135 if (!IsChildAgent && !isNPC)
2136 {
2137 InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
2138 if (cof == null)
2139 COF = UUID.Zero;
2140 else
2141 COF = cof.ID;
2142
2143 m_log.DebugFormat("[ScenePresence]: CompleteMovement COF for {0} is {1}", client.AgentId, COF);
2144 }
2145
2146 // Tell the client that we're totally ready
2147 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
2148
2149 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2150
2151 if (!string.IsNullOrEmpty(m_callbackURI))
2152 {
2153 // We cannot sleep here since this would hold up the inbound packet processing thread, as
2154 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
2155 // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete
2156 // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this
2157 // region as the current region, meaning that a close sent before then will fail the teleport.
2158 // System.Threading.Thread.Sleep(2000);
2159
2160 m_log.DebugFormat(
2161 "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}",
2162 client.Name, client.AgentId, m_callbackURI);
2163
2164 UUID originID;
2165
2166 lock (m_originRegionIDAccessLock)
2167 originID = m_originRegionID;
2168
2169 Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI);
2170 m_callbackURI = null;
2171 }
2172// else
2173// {
2174// m_log.DebugFormat(
2175// "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}",
2176// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
2177// }
2178
2179 m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2180
2181 m_previusParcelHide = false;
2182 m_previusParcelUUID = UUID.Zero;
2183 m_currentParcelHide = false;
2184 m_currentParcelUUID = UUID.Zero;
2185
2186 // send initial land overlay and parcel
2187 ILandChannel landch = m_scene.LandChannel;
2188 if (landch != null)
2189 landch.sendClientInitialLandInfo(client);
2190
2191 if (!IsChildAgent)
2192 {
2193
2194 // ValidateAndSendAppearanceAndAgentData();
2195
2196 // do it here in line
2197 // so sequence is clear
2198
2199 // verify baked textures and cache
2200>>>>>>> avn/ubitvar
2201
2202
2203 bool cachedbaked = false;
2204
2205 if (isNPC)
2206 cachedbaked = true;
2207 else
2208 {
2209 if (m_scene.AvatarFactory != null)
2210 cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
2211
2212 // not sure we need this
2213 if (!cachedbaked)
2214 {
2215 if (m_scene.AvatarFactory != null)
2216 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2217 }
2218 }
2219
2220 List<ScenePresence> allpresences = m_scene.GetScenePresences();
2221
2222 // send avatar object to all presences including us, so they cross it into region
2223 // then hide if necessary
2224 SendInitialAvatarDataToAllAgents(allpresences);
2225
2226 // send this look
2227 SendAppearanceToAgent(this);
2228
2229 // send this animations
2230
2231 UUID[] animIDs = null;
2232 int[] animseqs = null;
2233 UUID[] animsobjs = null;
2234
2235 if (Animator != null)
2236 Animator.GetArrays(out animIDs, out animseqs, out animsobjs);
2237
2238 bool haveAnims = (animIDs != null && animseqs != null && animsobjs != null);
2239
2240 if (haveAnims)
2241 SendAnimPackToAgent(this, animIDs, animseqs, animsobjs);
2242
2243 // we should be able to receive updates, etc
2244 // so release them
2245 m_inTransit = false;
2246
2247 // send look and animations to others
2248 // if not cached we send greys
2249 // uncomented if will wait till avatar does baking
2250 //if (cachedbaked)
2251 {
2252 foreach (ScenePresence p in allpresences)
2253 {
2254 if (p == this)
2255 continue;
2256
2257 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
2258 continue;
2259
2260 SendAppearanceToAgentNF(p);
2261 if (haveAnims)
2262 SendAnimPackToAgentNF(p, animIDs, animseqs, animsobjs);
2263 }
2264 } // greys if
2265
2266 m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2267
2268 // attachments
2269
2270 if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
2271 {
2272 if (Scene.AttachmentsModule != null)
2273 // Util.FireAndForget(
2274 // o =>
2275 // {
2276 if (!isNPC)
2277 Scene.AttachmentsModule.RezAttachments(this);
2278 else
2279 Util.FireAndForget(x =>
2280 {
2281 Scene.AttachmentsModule.RezAttachments(this);
2282 });
2283 // });
2284 }
2285 else
2286 {
2287 if (m_attachments.Count > 0)
2288 {
2289 m_log.DebugFormat(
2290 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
2291
2292 foreach (SceneObjectGroup sog in m_attachments)
2293 {
2294 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
2295 sog.ResumeScripts();
2296 }
2297
2298 foreach (ScenePresence p in allpresences)
2299 {
2300 if (p == this)
2301 {
2302 SendTerseUpdateToAgentNF(this);
2303 SendAttachmentsToAgentNF(this);
2304 continue;
2305 }
2306
2307 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
2308 continue;
2309
2310 SendTerseUpdateToAgentNF(p);
2311 SendAttachmentsToAgentNF(p);
2312 }
2313 }
2314 }
2315
2316 m_log.DebugFormat("[CompleteMovement] attachments: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2317 if (openChildAgents)
2318 {
2319 // Create child agents in neighbouring regions
2320 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2321 if (m_agentTransfer != null)
2322 {
2323 m_agentTransfer.EnableChildAgents(this);
2324 }
2325 }
2326 }
2327
2328 m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2329
2330 // send the rest of the world
2331 if (m_teleportFlags > 0 && !isNPC || m_currentParcelHide)
2332 SendInitialDataToMe();
2333
2334 m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2335
2336 if (!IsChildAgent && openChildAgents)
2337 {
2338 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
2339 if (friendsModule != null)
2340 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
2341
2342 m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2343
2344 }
2345 }
2346 finally
2347 {
2348 m_inTransit = false;
2349 }
2350 // if hide force a check
2351 // if (!IsChildAgent && newhide)
2352 // {
2353 // ParcelLoginCheck(m_currentParcelUUID);
2354 // m_currentParcelHide = newhide;
2355 // }
2356
2357 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
2358
2359 m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2360 }
1835 2361
1836 /// <summary> 2362 /// <summary>
1837 /// Callback for the Camera view block check. Gets called with the results of the camera view block test 2363 /// Callback for the Camera view block check. Gets called with the results of the camera view block test
@@ -1921,6 +2447,9 @@ namespace OpenSim.Region.Framework.Scenes
1921 return; 2447 return;
1922 } 2448 }
1923 2449
2450 if (IsInTransit)
2451 return;
2452
1924 #region Sanity Checking 2453 #region Sanity Checking
1925 2454
1926 // This is irritating. Really. 2455 // This is irritating. Really.
@@ -1955,8 +2484,15 @@ namespace OpenSim.Region.Framework.Scenes
1955 // When we get to the point of re-computing neighbors everytime this 2484 // When we get to the point of re-computing neighbors everytime this
1956 // changes, then start using the agent's drawdistance rather than the 2485 // changes, then start using the agent's drawdistance rather than the
1957 // region's draw distance. 2486 // region's draw distance.
2487<<<<<<< HEAD
1958 DrawDistance = agentData.Far; 2488 DrawDistance = agentData.Far;
1959 // DrawDistance = Scene.DefaultDrawDistance; 2489 // DrawDistance = Scene.DefaultDrawDistance;
2490=======
2491
2492 DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance);
2493
2494// DrawDistance = Scene.DefaultDrawDistance;
2495>>>>>>> avn/ubitvar
1960 2496
1961 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; 2497 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
1962 2498
@@ -1977,6 +2513,7 @@ namespace OpenSim.Region.Framework.Scenes
1977// (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) 2513// (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
1978// m_updateCount = UPDATE_COUNT; 2514// m_updateCount = UPDATE_COUNT;
1979 2515
2516
1980 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) 2517 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
1981 { 2518 {
1982 StandUp(); 2519 StandUp();
@@ -2032,7 +2569,7 @@ namespace OpenSim.Region.Framework.Scenes
2032 2569
2033 // We need to send this back to the client in order to stop the edit beams 2570 // We need to send this back to the client in order to stop the edit beams
2034 if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None) 2571 if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None)
2035 ControllingClient.SendAgentTerseUpdate(this); 2572 SendAgentTerseUpdate(this);
2036 2573
2037 PhysicsActor actor = PhysicsActor; 2574 PhysicsActor actor = PhysicsActor;
2038 2575
@@ -2045,10 +2582,8 @@ namespace OpenSim.Region.Framework.Scenes
2045 2582
2046 if (AllowMovement && !SitGround) 2583 if (AllowMovement && !SitGround)
2047 { 2584 {
2048// m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name); 2585// m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name);
2049
2050 bool update_rotation = false; 2586 bool update_rotation = false;
2051
2052 if (agentData.BodyRotation != Rotation) 2587 if (agentData.BodyRotation != Rotation)
2053 { 2588 {
2054 Rotation = agentData.BodyRotation; 2589 Rotation = agentData.BodyRotation;
@@ -2075,7 +2610,7 @@ namespace OpenSim.Region.Framework.Scenes
2075 bool DCFlagKeyPressed = false; 2610 bool DCFlagKeyPressed = false;
2076 Vector3 agent_control_v3 = Vector3.Zero; 2611 Vector3 agent_control_v3 = Vector3.Zero;
2077 2612
2078 bool newFlying = actor.Flying; 2613 bool newFlying = false;
2079 2614
2080 if (ForceFly) 2615 if (ForceFly)
2081 newFlying = true; 2616 newFlying = true;
@@ -2096,6 +2631,19 @@ namespace OpenSim.Region.Framework.Scenes
2096 { 2631 {
2097 bool bAllowUpdateMoveToPosition = false; 2632 bool bAllowUpdateMoveToPosition = false;
2098 2633
2634<<<<<<< HEAD
2635=======
2636 Vector3[] dirVectors;
2637
2638 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
2639 // this prevents 'jumping' in inappropriate situations.
2640// if (!Flying && (m_mouseLook || m_leftButtonDown))
2641// dirVectors = GetWalkDirectionVectors();
2642// else
2643 dirVectors = Dir_Vectors;
2644
2645
2646>>>>>>> avn/ubitvar
2099 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. 2647 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction.
2100 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) 2648 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
2101 { 2649 {
@@ -2115,10 +2663,10 @@ namespace OpenSim.Region.Framework.Scenes
2115 // Why did I get this? 2663 // Why did I get this?
2116 } 2664 }
2117 2665
2118 if (((MovementFlag & (uint)DCF) == 0) & !AgentControlStopActive) 2666 if (((MovementFlag & (uint)DCF) == 0))
2119 { 2667 {
2120 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 2668 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
2121 MovementFlag += (uint)DCF; 2669 MovementFlag |= (uint)DCF;
2122 update_movementflag = true; 2670 update_movementflag = true;
2123 } 2671 }
2124 } 2672 }
@@ -2127,7 +2675,7 @@ namespace OpenSim.Region.Framework.Scenes
2127 if ((MovementFlag & (uint)DCF) != 0) 2675 if ((MovementFlag & (uint)DCF) != 0)
2128 { 2676 {
2129 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 2677 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
2130 MovementFlag -= (uint)DCF; 2678 MovementFlag &= (uint)~DCF;
2131 update_movementflag = true; 2679 update_movementflag = true;
2132 2680
2133 /* 2681 /*
@@ -2180,11 +2728,11 @@ namespace OpenSim.Region.Framework.Scenes
2180 if (Flying && !ForceFly) 2728 if (Flying && !ForceFly)
2181 { 2729 {
2182 // Need to stop in mid air if user holds down AGENT_CONTROL_STOP 2730 // Need to stop in mid air if user holds down AGENT_CONTROL_STOP
2183 if (AgentControlStopActive) 2731 // if (AgentControlStopActive)
2184 { 2732 // {
2185 agent_control_v3 = Vector3.Zero; 2733 // agent_control_v3 = Vector3.Zero;
2186 } 2734 // }
2187 else 2735 // else
2188 { 2736 {
2189 // Landing detection code 2737 // Landing detection code
2190 2738
@@ -2192,38 +2740,44 @@ namespace OpenSim.Region.Framework.Scenes
2192 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 2740 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
2193 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 2741 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
2194 2742
2195 //m_log.Debug("[CONTROL]: " +flags); 2743 //m_log.Debug("[CONTROL]: " +flags);
2196 // Applies a satisfying roll effect to the avatar when flying. 2744 // Applies a satisfying roll effect to the avatar when flying.
2197 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) 2745 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
2198 { 2746 {
2199 ApplyFlyingRoll( 2747 ApplyFlyingRoll(
2200 FLY_ROLL_RADIANS_PER_UPDATE, 2748 FLY_ROLL_RADIANS_PER_UPDATE,
2201 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, 2749 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
2202 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); 2750 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
2203 } 2751 }
2204 else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && 2752 else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 &&
2205 (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) 2753 (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
2206 { 2754 {
2207 ApplyFlyingRoll( 2755 ApplyFlyingRoll(
2208 -FLY_ROLL_RADIANS_PER_UPDATE, 2756 -FLY_ROLL_RADIANS_PER_UPDATE,
2209 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, 2757 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
2210 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); 2758 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
2211 } 2759 }
2212 else 2760 else
2213 { 2761 {
2214 if (m_AngularVelocity.Z != 0) 2762 if (m_AngularVelocity.Z != 0)
2215 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); 2763 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
2216 }
2217
2218 if (Flying && IsColliding && controlland)
2219 {
2220 // nesting this check because LengthSquared() is expensive and we don't
2221 // want to do it every step when flying.
2222 if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX))
2223 StopFlying();
2224 } 2764 }
2765
2766 /*
2767 if (Flying && IsColliding && controlland)
2768 {
2769 // nesting this check because LengthSquared() is expensive and we don't
2770 // want to do it every step when flying.
2771 if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX))
2772 StopFlying();
2773 }
2774 */
2225 } 2775 }
2226 } 2776 }
2777 else if (IsColliding && agent_control_v3.Z < 0f)
2778 agent_control_v3.Z = 0;
2779// else if(AgentControlStopActive %% Velocity.Z <0.01f)
2780
2227 2781
2228// m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); 2782// m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name);
2229 2783
@@ -2236,32 +2790,23 @@ namespace OpenSim.Region.Framework.Scenes
2236 if (update_movementflag 2790 if (update_movementflag
2237 || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) 2791 || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0)))
2238 { 2792 {
2239// if (update_movementflag || !AgentControlStopActive || MovementFlag != 0)
2240// {
2241// m_log.DebugFormat(
2242// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, mf = {4}, ur = {5}",
2243// m_scene.RegionInfo.RegionName, agent_control_v3, Name,
2244// update_movementflag, MovementFlag, update_rotation);
2245
2246 float speedModifier;
2247 2793
2248 if (AgentControlStopActive) 2794 if (AgentControlStopActive)
2249 speedModifier = AgentControlStopSlowWhilstMoving; 2795 {
2796 // if (MovementFlag == 0 && Animator.Falling)
2797 if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling)
2798 {
2799 AddNewMovement(agent_control_v3, AgentControlStopSlowVel, true);
2800 }
2250 else 2801 else
2251 speedModifier = 1; 2802 AddNewMovement(agent_control_v3, AgentControlStopSlowVel);
2803 }
2804 else
2805 {
2806 AddNewMovement(agent_control_v3);
2807 }
2252 2808
2253 AddNewMovement(agent_control_v3, speedModifier);
2254// }
2255 } 2809 }
2256// else
2257// {
2258// if (!update_movementflag)
2259// {
2260// m_log.DebugFormat(
2261// "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false",
2262// m_scene.RegionInfo.RegionName, agent_control_v3, Name);
2263// }
2264// }
2265 2810
2266 if (update_movementflag && ParentID == 0) 2811 if (update_movementflag && ParentID == 0)
2267 { 2812 {
@@ -2274,7 +2819,7 @@ namespace OpenSim.Region.Framework.Scenes
2274 2819
2275 // We need to send this back to the client in order to see the edit beams 2820 // We need to send this back to the client in order to see the edit beams
2276 if ((State & (uint)AgentState.Editing) != 0) 2821 if ((State & (uint)AgentState.Editing) != 0)
2277 ControllingClient.SendAgentTerseUpdate(this); 2822 SendAgentTerseUpdate(this);
2278 2823
2279 m_scene.EventManager.TriggerOnClientMovement(this); 2824 m_scene.EventManager.TriggerOnClientMovement(this);
2280 } 2825 }
@@ -2320,8 +2865,12 @@ namespace OpenSim.Region.Framework.Scenes
2320 // When we get to the point of re-computing neighbors everytime this 2865 // When we get to the point of re-computing neighbors everytime this
2321 // changes, then start using the agent's drawdistance rather than the 2866 // changes, then start using the agent's drawdistance rather than the
2322 // region's draw distance. 2867 // region's draw distance.
2868<<<<<<< HEAD
2323 DrawDistance = agentData.Far; 2869 DrawDistance = agentData.Far;
2324 // DrawDistance = Scene.DefaultDrawDistance; 2870 // DrawDistance = Scene.DefaultDrawDistance;
2871=======
2872 DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance);
2873>>>>>>> avn/ubitvar
2325 2874
2326 // Check if Client has camera in 'follow cam' or 'build' mode. 2875 // Check if Client has camera in 'follow cam' or 'build' mode.
2327 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); 2876 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
@@ -2358,11 +2907,13 @@ namespace OpenSim.Region.Framework.Scenes
2358 2907
2359 bool updated = false; 2908 bool updated = false;
2360 2909
2910 Vector3 LocalVectorToTarget3D = MoveToPositionTarget - AbsolutePosition;
2911
2361// m_log.DebugFormat( 2912// m_log.DebugFormat(
2362// "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", 2913// "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}",
2363// allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); 2914// allowUpdate, m_moveToPositionInProgress, m_autopilotMoving);
2364 2915
2365 double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); 2916 double distanceToTarget = LocalVectorToTarget3D.Length();
2366 2917
2367// m_log.DebugFormat( 2918// m_log.DebugFormat(
2368// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", 2919// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}",
@@ -2385,11 +2936,11 @@ namespace OpenSim.Region.Framework.Scenes
2385 // Theoretically we might need a more complex PID approach here if other 2936 // Theoretically we might need a more complex PID approach here if other
2386 // unknown forces are acting on the avatar and we need to adaptively respond 2937 // unknown forces are acting on the avatar and we need to adaptively respond
2387 // to such forces, but the following simple approach seems to works fine. 2938 // to such forces, but the following simple approach seems to works fine.
2388 Vector3 LocalVectorToTarget3D = 2939
2389 (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords 2940 LocalVectorToTarget3D = LocalVectorToTarget3D * Quaternion.Inverse(Rotation); // change to avatar coords
2390 * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords
2391 // Ignore z component of vector 2941 // Ignore z component of vector
2392// Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); 2942// Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f);
2943
2393 LocalVectorToTarget3D.Normalize(); 2944 LocalVectorToTarget3D.Normalize();
2394 2945
2395 // update avatar movement flags. the avatar coordinate system is as follows: 2946 // update avatar movement flags. the avatar coordinate system is as follows:
@@ -2413,28 +2964,37 @@ namespace OpenSim.Region.Framework.Scenes
2413 2964
2414 // based on the above avatar coordinate system, classify the movement into 2965 // based on the above avatar coordinate system, classify the movement into
2415 // one of left/right/back/forward. 2966 // one of left/right/back/forward.
2967
2968 const uint noMovFlagsMask = (uint)(~(Dir_ControlFlags.DIR_CONTROL_FLAG_BACK |
2969 Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD | Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT |
2970 Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT | Dir_ControlFlags.DIR_CONTROL_FLAG_UP |
2971 Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN));
2972
2973 MovementFlag &= noMovFlagsMask;
2974 AgentControlFlags &= noMovFlagsMask;
2975
2416 if (LocalVectorToTarget3D.X < 0) //MoveBack 2976 if (LocalVectorToTarget3D.X < 0) //MoveBack
2417 { 2977 {
2418 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; 2978 MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
2419 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; 2979 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
2420 updated = true; 2980 updated = true;
2421 } 2981 }
2422 else if (LocalVectorToTarget3D.X > 0) //Move Forward 2982 else if (LocalVectorToTarget3D.X > 0) //Move Forward
2423 { 2983 {
2424 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; 2984 MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
2425 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; 2985 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
2426 updated = true; 2986 updated = true;
2427 } 2987 }
2428 2988
2429 if (LocalVectorToTarget3D.Y > 0) //MoveLeft 2989 if (LocalVectorToTarget3D.Y > 0) //MoveLeft
2430 { 2990 {
2431 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; 2991 MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
2432 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; 2992 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
2433 updated = true; 2993 updated = true;
2434 } 2994 }
2435 else if (LocalVectorToTarget3D.Y < 0) //MoveRight 2995 else if (LocalVectorToTarget3D.Y < 0) //MoveRight
2436 { 2996 {
2437 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; 2997 MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
2438 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; 2998 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
2439 updated = true; 2999 updated = true;
2440 } 3000 }
@@ -2518,6 +3078,17 @@ namespace OpenSim.Region.Framework.Scenes
2518// } 3078// }
2519 3079
2520 // Get terrain height for sub-region in a megaregion if necessary 3080 // Get terrain height for sub-region in a megaregion if necessary
3081<<<<<<< HEAD
3082=======
3083 int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X);
3084 int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
3085 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
3086 // If X and Y is NaN, target_region will be null
3087 if (target_region == null)
3088 return;
3089 UUID target_regionID = target_region.RegionID;
3090 Scene targetScene = m_scene;
3091>>>>>>> avn/ubitvar
2521 3092
2522 //COMMENT: If its only nessesary in a megaregion, why do it on normal region's too? 3093 //COMMENT: If its only nessesary in a megaregion, why do it on normal region's too?
2523 3094
@@ -2527,6 +3098,7 @@ namespace OpenSim.Region.Framework.Scenes
2527 int y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y); 3098 int y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
2528 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); 3099 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
2529 3100
3101<<<<<<< HEAD
2530 // If X and Y is NaN, target_region will be null 3102 // If X and Y is NaN, target_region will be null
2531 if (target_region == null) 3103 if (target_region == null)
2532 return; 3104 return;
@@ -2535,6 +3107,11 @@ namespace OpenSim.Region.Framework.Scenes
2535 } 3107 }
2536 3108
2537 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; 3109 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
3110=======
3111 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
3112 // dont try to land underground
3113 terrainHeight += Appearance.AvatarHeight / 2;
3114>>>>>>> avn/ubitvar
2538 pos.Z = Math.Max(terrainHeight, pos.Z); 3115 pos.Z = Math.Max(terrainHeight, pos.Z);
2539 3116
2540 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 3117 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
@@ -2543,9 +3120,17 @@ namespace OpenSim.Region.Framework.Scenes
2543 if (pos.Z - terrainHeight < 0.2) 3120 if (pos.Z - terrainHeight < 0.2)
2544 pos.Z = terrainHeight; 3121 pos.Z = terrainHeight;
2545 3122
3123<<<<<<< HEAD
3124=======
3125// m_log.DebugFormat(
3126// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
3127// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
3128
3129
3130>>>>>>> avn/ubitvar
2546 if (noFly) 3131 if (noFly)
2547 Flying = false; 3132 Flying = false;
2548 else if (pos.Z > terrainHeight) 3133 else if (pos.Z > terrainHeight + Appearance.AvatarHeight / 2 || Flying)
2549 Flying = true; 3134 Flying = true;
2550 3135
2551// m_log.DebugFormat( 3136// m_log.DebugFormat(
@@ -2629,29 +3214,41 @@ namespace OpenSim.Region.Framework.Scenes
2629 } 3214 }
2630 } 3215 }
2631 3216
3217<<<<<<< HEAD
3218=======
3219 part.ParentGroup.DeleteAvatar(UUID);
3220
3221 Quaternion standRotation = part.ParentGroup.RootPart.RotationOffset;
3222 Vector3 sitPartWorldPosition = part.ParentGroup.AbsolutePosition + m_pos * standRotation;
3223>>>>>>> avn/ubitvar
2632 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 3224 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
2633 3225
2634 ParentID = 0; 3226 ParentID = 0;
2635 ParentPart = null; 3227 ParentPart = null;
2636 3228
2637 Quaternion standRotation;
2638
2639 if (part.SitTargetAvatar == UUID) 3229 if (part.SitTargetAvatar == UUID)
2640 { 3230 standRotation = standRotation * part.SitTargetOrientation;
2641 standRotation = part.GetWorldRotation(); 3231 else
3232 standRotation = standRotation * m_bodyRot;
2642 3233
2643 if (!part.IsRoot) 3234 m_bodyRot = standRotation;
2644 standRotation = standRotation * part.SitTargetOrientation; 3235
2645// standRotation = part.RotationOffset * part.SitTargetOrientation; 3236 Quaternion standRotationZ = new Quaternion(0,0,standRotation.Z,standRotation.W);
2646// else
2647// standRotation = part.SitTargetOrientation;
2648 3237
3238 float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z;
3239 if (t > 0)
3240 {
3241 t = 1.0f / (float)Math.Sqrt(t);
3242 standRotationZ.W *= t;
3243 standRotationZ.Z *= t;
2649 } 3244 }
2650 else 3245 else
2651 { 3246 {
2652 standRotation = Rotation; 3247 standRotationZ.W = 1.0f;
3248 standRotationZ.Z = 0f;
2653 } 3249 }
2654 3250
3251<<<<<<< HEAD
2655 //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); 3252 //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
2656 //Vector3 standPos = ParentPosition; 3253 //Vector3 standPos = ParentPosition;
2657 3254
@@ -2664,13 +3261,13 @@ namespace OpenSim.Region.Framework.Scenes
2664 Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation; 3261 Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation;
2665 3262
2666 Vector3 standPos = part.ParentGroup.AbsolutePosition + adjustmentForSitPosition + adjustmentForSitPose; 3263 Vector3 standPos = part.ParentGroup.AbsolutePosition + adjustmentForSitPosition + adjustmentForSitPose;
3264=======
3265 Vector3 adjustmentForSitPose = new Vector3(0.75f, 0, m_sitAvatarHeight + .3f) * standRotationZ;
2667 3266
2668// m_log.DebugFormat( 3267 Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose;
2669// "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", 3268>>>>>>> avn/ubitvar
2670// standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name);
2671 3269
2672 Rotation = standRotation; 3270 m_pos = standPos;
2673 AbsolutePosition = standPos;
2674 } 3271 }
2675 3272
2676 // We need to wait until we have calculated proper stand positions before sitting up the physical 3273 // We need to wait until we have calculated proper stand positions before sitting up the physical
@@ -2680,18 +3277,27 @@ namespace OpenSim.Region.Framework.Scenes
2680 3277
2681 if (satOnObject) 3278 if (satOnObject)
2682 { 3279 {
3280<<<<<<< HEAD
2683 SendAvatarDataToAllClients(); 3281 SendAvatarDataToAllClients();
2684 m_requestedSitTargetID = 0; 3282 m_requestedSitTargetID = 0;
2685 3283
2686 part.RemoveSittingAvatar(this); 3284 part.RemoveSittingAvatar(this);
2687 3285
3286=======
3287 m_requestedSitTargetID = 0;
3288 part.RemoveSittingAvatar(UUID);
3289>>>>>>> avn/ubitvar
2688 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3290 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3291
3292 SendAvatarDataToAllAgents();
2689 } 3293 }
2690 3294
2691 else if (PhysicsActor == null) 3295 // reset to default sitAnimation
2692 AddToPhysicalScene(false); 3296 sitAnimation = "SIT";
3297
3298// Animator.TrySetMovementAnimation("STAND");
3299 Animator.SetMovementAnimations("STAND");
2693 3300
2694 Animator.TrySetMovementAnimation("STAND");
2695 TriggerScenePresenceUpdated(); 3301 TriggerScenePresenceUpdated();
2696 } 3302 }
2697 3303
@@ -2739,6 +3345,7 @@ namespace OpenSim.Region.Framework.Scenes
2739 if (part == null) 3345 if (part == null)
2740 return; 3346 return;
2741 3347
3348
2742 if (PhysicsActor != null) 3349 if (PhysicsActor != null)
2743 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; 3350 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
2744 3351
@@ -2746,23 +3353,9 @@ namespace OpenSim.Region.Framework.Scenes
2746 3353
2747 if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) 3354 if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
2748 { 3355 {
2749// m_log.DebugFormat(
2750// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied",
2751// Name, part.Name, part.LocalId);
2752
2753 offset = part.SitTargetPosition; 3356 offset = part.SitTargetPosition;
2754 sitOrientation = part.SitTargetOrientation; 3357 sitOrientation = part.SitTargetOrientation;
2755 3358
2756 if (!part.IsRoot)
2757 {
2758 // m_log.DebugFormat("Old sit orient {0}", sitOrientation);
2759 sitOrientation = part.RotationOffset * sitOrientation;
2760 // m_log.DebugFormat("New sit orient {0}", sitOrientation);
2761// m_log.DebugFormat("Old sit offset {0}", offset);
2762 offset = offset * part.RotationOffset;
2763// m_log.DebugFormat("New sit offset {0}", offset);
2764 }
2765
2766 canSit = true; 3359 canSit = true;
2767 } 3360 }
2768 else 3361 else
@@ -2826,9 +3419,26 @@ namespace OpenSim.Region.Framework.Scenes
2826 3419
2827 forceMouselook = part.GetForceMouselook(); 3420 forceMouselook = part.GetForceMouselook();
2828 3421
2829 // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is 3422 if (!part.IsRoot)
2830 // being sat upon. 3423 {
2831 offset += part.OffsetPosition; 3424 sitOrientation = part.RotationOffset * sitOrientation;
3425 offset = offset * part.RotationOffset;
3426 offset += part.OffsetPosition;
3427
3428 if (CameraAtAxis == Vector3.Zero && cameraEyeOffset == Vector3.Zero)
3429 {
3430 CameraAtAxis = part.ParentGroup.RootPart.GetCameraAtOffset();
3431 cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
3432 }
3433 else
3434 {
3435 cameraAtOffset = cameraAtOffset * part.RotationOffset;
3436 cameraAtOffset += part.OffsetPosition;
3437 cameraEyeOffset = cameraEyeOffset * part.RotationOffset;
3438 cameraEyeOffset += part.OffsetPosition;
3439 }
3440 }
3441
2832 3442
2833 ControllingClient.SendSitResponse( 3443 ControllingClient.SendSitResponse(
2834 part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 3444 part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
@@ -2875,9 +3485,6 @@ namespace OpenSim.Region.Framework.Scenes
2875 // returns false if does not suport so older sit can be tried 3485 // returns false if does not suport so older sit can be tried
2876 public bool PhysicsSit(SceneObjectPart part, Vector3 offset) 3486 public bool PhysicsSit(SceneObjectPart part, Vector3 offset)
2877 { 3487 {
2878// TODO: Pull in these bits
2879 return false;
2880/*
2881 if (part == null || part.ParentGroup.IsAttachment) 3488 if (part == null || part.ParentGroup.IsAttachment)
2882 { 3489 {
2883 return true; 3490 return true;
@@ -2907,7 +3514,6 @@ namespace OpenSim.Region.Framework.Scenes
2907 return true; 3514 return true;
2908 3515
2909 return false; 3516 return false;
2910*/
2911 } 3517 }
2912 3518
2913 3519
@@ -2952,6 +3558,7 @@ namespace OpenSim.Region.Framework.Scenes
2952 ResetMoveToTarget(); 3558 ResetMoveToTarget();
2953 3559
2954 Velocity = Vector3.Zero; 3560 Velocity = Vector3.Zero;
3561 m_AngularVelocity = Vector3.Zero;
2955 3562
2956 part.AddSittingAvatar(this); 3563 part.AddSittingAvatar(this);
2957 3564
@@ -2959,23 +3566,58 @@ namespace OpenSim.Region.Framework.Scenes
2959 Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); 3566 Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
2960 bool forceMouselook = part.GetForceMouselook(); 3567 bool forceMouselook = part.GetForceMouselook();
2961 3568
2962 ControllingClient.SendSitResponse( 3569 m_bodyRot = Orientation;
2963 part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 3570
3571 if (!part.IsRoot)
3572 {
3573 Orientation = part.RotationOffset * Orientation;
3574 offset = offset * part.RotationOffset;
3575 offset += part.OffsetPosition;
3576
3577 if (CameraAtAxis == Vector3.Zero && cameraEyeOffset == Vector3.Zero)
3578 {
3579 CameraAtAxis = part.ParentGroup.RootPart.GetCameraAtOffset();
3580 cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
3581 }
3582 else
3583 {
3584 cameraAtOffset = cameraAtOffset * part.RotationOffset;
3585 cameraAtOffset += part.OffsetPosition;
3586 cameraEyeOffset = cameraEyeOffset * part.RotationOffset;
3587 cameraEyeOffset += part.OffsetPosition;
3588 }
2964 3589
2965 // not using autopilot 3590 }
2966 3591
2967 Rotation = Orientation;
2968 m_pos = offset; 3592 m_pos = offset;
2969 3593
3594 ControllingClient.SendSitResponse(
3595 part.ParentGroup.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
3596
3597
2970 m_requestedSitTargetID = 0; 3598 m_requestedSitTargetID = 0;
2971 3599
2972 ParentPart = part; 3600 ParentPart = part;
2973 ParentID = part.LocalId; 3601 ParentID = part.LocalId;
3602
3603 SendAvatarDataToAllAgents();
3604
3605/*
2974 if(status == 3) 3606 if(status == 3)
2975 Animator.TrySetMovementAnimation("SIT_GROUND"); 3607 Animator.TrySetMovementAnimation("SIT_GROUND");
2976 else 3608 else
2977 Animator.TrySetMovementAnimation("SIT"); 3609 Animator.TrySetMovementAnimation("SIT");
3610<<<<<<< HEAD
2978 SendAvatarDataToAllClients(); 3611 SendAvatarDataToAllClients();
3612=======
3613*/
3614 if (status == 3)
3615 sitAnimation = "SIT_GROUND";
3616 else
3617 sitAnimation = "SIT";
3618
3619 Animator.SetMovementAnimations("SIT");
3620>>>>>>> avn/ubitvar
2979 3621
2980 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3622 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
2981 } 3623 }
@@ -3084,13 +3726,20 @@ namespace OpenSim.Region.Framework.Scenes
3084 Velocity = Vector3.Zero; 3726 Velocity = Vector3.Zero;
3085 RemoveFromPhysicalScene(); 3727 RemoveFromPhysicalScene();
3086 3728
3087 String sitAnimation = "SIT"; 3729 SendAvatarDataToAllAgents();
3730
3731 sitAnimation = "SIT";
3088 if (!String.IsNullOrEmpty(part.SitAnimation)) 3732 if (!String.IsNullOrEmpty(part.SitAnimation))
3089 { 3733 {
3090 sitAnimation = part.SitAnimation; 3734 sitAnimation = part.SitAnimation;
3091 } 3735 }
3736<<<<<<< HEAD
3092 Animator.TrySetMovementAnimation(sitAnimation); 3737 Animator.TrySetMovementAnimation(sitAnimation);
3093 SendAvatarDataToAllClients(); 3738 SendAvatarDataToAllClients();
3739=======
3740// Animator.TrySetMovementAnimation(sitAnimation);
3741 Animator.SetMovementAnimations("SIT");
3742>>>>>>> avn/ubitvar
3094 TriggerScenePresenceUpdated(); 3743 TriggerScenePresenceUpdated();
3095 } 3744 }
3096 } 3745 }
@@ -3102,10 +3751,14 @@ namespace OpenSim.Region.Framework.Scenes
3102 3751
3103// m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. 3752// m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick..
3104 m_AngularVelocity = Vector3.Zero; 3753 m_AngularVelocity = Vector3.Zero;
3105 Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); 3754 sitAnimation = "SIT_GROUND_CONSTRAINED";
3106 TriggerScenePresenceUpdated(); 3755// Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
3756// TriggerScenePresenceUpdated();
3107 SitGround = true; 3757 SitGround = true;
3108 RemoveFromPhysicalScene(); 3758 RemoveFromPhysicalScene();
3759
3760 Animator.SetMovementAnimations("SITGROUND");
3761 TriggerScenePresenceUpdated();
3109 } 3762 }
3110 3763
3111 /// <summary> 3764 /// <summary>
@@ -3129,18 +3782,26 @@ namespace OpenSim.Region.Framework.Scenes
3129 TriggerScenePresenceUpdated(); 3782 TriggerScenePresenceUpdated();
3130 } 3783 }
3131 3784
3785 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack)
3786 {
3787 Animator.avnChangeAnim(animID, addRemove, sendPack);
3788 }
3789
3790
3791
3132 /// <summary> 3792 /// <summary>
3133 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector 3793 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector
3134 /// </summary> 3794 /// </summary>
3135 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> 3795 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
3136 /// <param name="thisAddSpeedModifier"> 3796 /// <param name="thisAddSpeedModifier">
3137 /// Optional additional speed modifier for this particular add. Default is 1</param> 3797 /// Optional additional speed modifier for this particular add. Default is 1</param>
3138 public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1) 3798 public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1, bool breaking = false)
3139 { 3799 {
3140// m_log.DebugFormat( 3800 // m_log.DebugFormat(
3141// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", 3801 // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}",
3142// vec, Rotation, thisAddSpeedModifier, Name); 3802 // vec, Rotation, thisAddSpeedModifier, Name);
3143 3803
3804<<<<<<< HEAD
3144 Quaternion rot = Rotation; 3805 Quaternion rot = Rotation;
3145 if (!Flying && PresenceType != PresenceType.Npc) 3806 if (!Flying && PresenceType != PresenceType.Npc)
3146 { 3807 {
@@ -3153,61 +3814,51 @@ namespace OpenSim.Region.Framework.Scenes
3153 } 3814 }
3154 3815
3155 Vector3 direc = vec * rot; 3816 Vector3 direc = vec * rot;
3817=======
3818 // rotate from avatar coord space to world
3819 // for now all controls assume this is only a rotation around Z
3820 // if not all checks below need to be done before this rotation
3821 Vector3 direc = vec * Rotation;
3822>>>>>>> avn/ubitvar
3156 direc.Normalize(); 3823 direc.Normalize();
3157 3824
3158 if (Flying != FlyingOld) // add for fly velocity control 3825 // mouse look situation ?
3159 {
3160 FlyingOld = Flying; // add for fly velocity control
3161 if (!Flying)
3162 WasFlying = true; // add for fly velocity control
3163 }
3164
3165 if (IsColliding)
3166 WasFlying = false; // add for fly velocity control
3167
3168 if ((vec.Z == 0f) && !Flying) 3826 if ((vec.Z == 0f) && !Flying)
3169 direc.Z = 0f; // Prevent camera WASD up. 3827 direc.Z = 0f; // Prevent camera WASD up.
3170 3828
3829 // odd rescalings
3171 direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; 3830 direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier;
3172 3831
3173// m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); 3832 // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name);
3174 3833
3175 if (PhysicsActor != null) 3834 if (Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling)
3176 { 3835 {
3177 if (Flying) 3836 if (breaking)
3178 { 3837 direc.Z = -9999f; //hack to tell physics to stop on Z
3838 else
3839 direc = Vector3.Zero;
3840 }
3841 else if (Flying)
3842 {
3843 if (IsColliding && direc.Z < 0)
3844 // landing situation, prevent avatar moving or it may fail to land
3845 // animator will handle this condition and do the land
3846 direc = Vector3.Zero;
3847 else
3179 direc *= 4.0f; 3848 direc *= 4.0f;
3180 //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 3849 }
3181 //if (controlland) 3850 else if (IsColliding)
3182 // m_log.Info("[AGENT]: landCommand"); 3851 {
3183 //if (IsColliding) 3852 if (direc.Z > 2.0f) // reinforce jumps
3184 // m_log.Info("[AGENT]: colliding");
3185 //if (Flying && IsColliding && controlland)
3186 //{
3187 // StopFlying();
3188 // m_log.Info("[AGENT]: Stop Flying");
3189 //}
3190 }
3191 if (Animator.Falling && WasFlying) // if falling from flying, disable motion add
3192 {
3193 direc *= 0.0f;
3194 }
3195 else if (!Flying && IsColliding)
3196 { 3853 {
3197 if (direc.Z > 2.0f) 3854 direc.Z *= 2.6f;
3198 {
3199 direc.Z *= 2.6f;
3200
3201 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored.
3202// Animator.TrySetMovementAnimation("PREJUMP");
3203// Animator.TrySetMovementAnimation("JUMP");
3204 }
3205 } 3855 }
3856 else if (direc.Z < 0) // on a surface moving down (pg down) only changes animation
3857 direc.Z = 0;
3206 } 3858 }
3207 3859
3208// m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); 3860 // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name);
3209 3861
3210 // TODO: Add the force instead of only setting it to support multiple forces per frame?
3211 m_forceToApply = direc; 3862 m_forceToApply = direc;
3212 Animator.UpdateMovementAnimations(); 3863 Animator.UpdateMovementAnimations();
3213 } 3864 }
@@ -3220,6 +3871,11 @@ namespace OpenSim.Region.Framework.Scenes
3220 { 3871 {
3221 if (IsChildAgent == false) 3872 if (IsChildAgent == false)
3222 { 3873 {
3874 CheckForBorderCrossing();
3875
3876 if (IsInTransit)
3877 return;
3878
3223 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to 3879 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to
3224 // grab the latest PhysicsActor velocity, whereas m_velocity is often 3880 // grab the latest PhysicsActor velocity, whereas m_velocity is often
3225 // storing a requested force instead of an actual traveling velocity 3881 // storing a requested force instead of an actual traveling velocity
@@ -3248,9 +3904,12 @@ namespace OpenSim.Region.Framework.Scenes
3248 m_lastVelocity = Velocity; 3904 m_lastVelocity = Velocity;
3249 } 3905 }
3250 3906
3907<<<<<<< HEAD
3251 if (Scene.AllowAvatarCrossing) 3908 if (Scene.AllowAvatarCrossing)
3252 CheckForBorderCrossing(); 3909 CheckForBorderCrossing();
3253 3910
3911=======
3912>>>>>>> avn/ubitvar
3254 CheckForSignificantMovement(); // sends update to the modules. 3913 CheckForSignificantMovement(); // sends update to the modules.
3255 } 3914 }
3256 } 3915 }
@@ -3259,8 +3918,41 @@ namespace OpenSim.Region.Framework.Scenes
3259 3918
3260 #region Update Client(s) 3919 #region Update Client(s)
3261 3920
3921<<<<<<< HEAD
3922=======
3923 public void SendUpdateToAgent(ScenePresence p)
3924 {
3925 IClientAPI remoteClient = p.ControllingClient;
3926
3927 if (remoteClient.IsActive)
3928 {
3929 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
3930 remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate);
3931 m_scene.StatsReporter.AddAgentUpdates(1);
3932 }
3933 }
3934
3935 public void SendFullUpdateToClient(IClientAPI remoteClient)
3936 {
3937 if (remoteClient.IsActive)
3938 {
3939 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
3940 remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate);
3941 m_scene.StatsReporter.AddAgentUpdates(1);
3942 }
3943 }
3944
3945 // this is diferente from SendTerseUpdateToClient
3946 // this sends bypassing entities updates
3947 public void SendAgentTerseUpdate(ISceneEntity p)
3948 {
3949 ControllingClient.SendAgentTerseUpdate(p);
3950 }
3951
3952>>>>>>> avn/ubitvar
3262 /// <summary> 3953 /// <summary>
3263 /// Sends a location update to the client connected to this scenePresence 3954 /// Sends a location update to the client connected to this scenePresence
3955 /// via entity updates
3264 /// </summary> 3956 /// </summary>
3265 /// <param name="remoteClient"></param> 3957 /// <param name="remoteClient"></param>
3266 public void SendTerseUpdateToClient(IClientAPI remoteClient) 3958 public void SendTerseUpdateToClient(IClientAPI remoteClient)
@@ -3293,7 +3985,6 @@ namespace OpenSim.Region.Framework.Scenes
3293 return; 3985 return;
3294 3986
3295 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); 3987 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
3296
3297 remoteClient.SendEntityUpdate( 3988 remoteClient.SendEntityUpdate(
3298 this, 3989 this,
3299 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity 3990 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
@@ -3303,6 +3994,38 @@ namespace OpenSim.Region.Framework.Scenes
3303 } 3994 }
3304 } 3995 }
3305 3996
3997 public void SendTerseUpdateToAgent(ScenePresence p)
3998 {
3999 IClientAPI remoteClient = p.ControllingClient;
4000
4001 if (!remoteClient.IsActive)
4002 return;
4003
4004 if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200)
4005 return;
4006
4007 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
4008 remoteClient.SendEntityUpdate(
4009 this,
4010 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4011 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity);
4012
4013 m_scene.StatsReporter.AddAgentUpdates(1);
4014 }
4015
4016 public void SendTerseUpdateToAgentNF(ScenePresence p)
4017 {
4018 IClientAPI remoteClient = p.ControllingClient;
4019 if (remoteClient.IsActive)
4020 {
4021 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
4022 remoteClient.SendEntityUpdate(this,
4023 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4024 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity);
4025 m_scene.StatsReporter.AddAgentUpdates(1);
4026 }
4027 }
4028
3306 4029
3307 // vars to support reduced update frequency when velocity is unchanged 4030 // vars to support reduced update frequency when velocity is unchanged
3308 private Vector3 lastVelocitySentToAllClients = Vector3.Zero; 4031 private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
@@ -3354,7 +4077,8 @@ namespace OpenSim.Region.Framework.Scenes
3354 m_terseUpdateCount++; 4077 m_terseUpdateCount++;
3355 4078
3356// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name); 4079// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name);
3357 m_scene.ForEachClient(SendTerseUpdateToClient); 4080// m_scene.ForEachClient(SendTerseUpdateToClient);
4081 m_scene.ForEachScenePresence(SendTerseUpdateToAgent);
3358 } 4082 }
3359 TriggerScenePresenceUpdated(); 4083 TriggerScenePresenceUpdated();
3360 } 4084 }
@@ -3393,22 +4117,40 @@ namespace OpenSim.Region.Framework.Scenes
3393 // we created a new ScenePresence (a new child agent) in a fresh region. 4117 // we created a new ScenePresence (a new child agent) in a fresh region.
3394 // Request info about all the (root) agents in this region 4118 // Request info about all the (root) agents in this region
3395 // Note: This won't send data *to* other clients in that region (children don't send) 4119 // Note: This won't send data *to* other clients in that region (children don't send)
4120<<<<<<< HEAD
3396 SendOtherAgentsAvatarDataToClient(); 4121 SendOtherAgentsAvatarDataToClient();
3397 SendOtherAgentsAppearanceToClient(); 4122 SendOtherAgentsAppearanceToClient();
4123=======
4124 if (m_teleportFlags <= 0)
4125 {
4126 ILandChannel landch = m_scene.LandChannel;
4127 if (landch != null)
4128 {
4129 landch.sendClientInitialLandInfo(ControllingClient);
4130 }
4131 }
4132>>>>>>> avn/ubitvar
3398 4133
4134 SendOtherAgentsAvatarFullToMe();
3399 EntityBase[] entities = Scene.Entities.GetEntities(); 4135 EntityBase[] entities = Scene.Entities.GetEntities();
3400 foreach (EntityBase e in entities) 4136 foreach (EntityBase e in entities)
3401 { 4137 {
3402 if (e != null && e is SceneObjectGroup) 4138 if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment)
3403 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); 4139 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
3404 } 4140 }
4141<<<<<<< HEAD
3405 }, null, string.Format("SendInitialDataToClient ({0} in {1})", Name, Scene.Name), false, true); 4142 }, null, string.Format("SendInitialDataToClient ({0} in {1})", Name, Scene.Name), false, true);
4143=======
4144 });
4145>>>>>>> avn/ubitvar
3406 } 4146 }
3407 4147
3408 /// <summary> 4148 /// <summary>
3409 /// Do everything required once a client completes its movement into a region and becomes 4149 /// Do everything required once a client completes its movement into a region and becomes
3410 /// a root agent. 4150 /// a root agent.
3411 /// </summary> 4151 /// </summary>
4152 ///
4153/* only called from on place, do done inline there
3412 private void ValidateAndSendAppearanceAndAgentData() 4154 private void ValidateAndSendAppearanceAndAgentData()
3413 { 4155 {
3414 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); 4156 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID);
@@ -3422,14 +4164,14 @@ namespace OpenSim.Region.Framework.Scenes
3422 // to see if all the baked textures are already here. 4164 // to see if all the baked textures are already here.
3423 if (m_scene.AvatarFactory != null) 4165 if (m_scene.AvatarFactory != null)
3424 cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(this); 4166 cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
3425 4167
3426 // If we aren't using a cached appearance, then clear out the baked textures 4168 // If we aren't using a cached appearance, then clear out the baked textures
3427 if (!cachedappearance) 4169 if (!cachedappearance)
3428 { 4170 {
3429 Appearance.ResetAppearance();
3430 if (m_scene.AvatarFactory != null) 4171 if (m_scene.AvatarFactory != null)
3431 m_scene.AvatarFactory.QueueAppearanceSave(UUID); 4172 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
3432 } 4173 }
4174<<<<<<< HEAD
3433 4175
3434 // This agent just became root. We are going to tell everyone about it. The process of 4176 // This agent just became root. We are going to tell everyone about it. The process of
3435 // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it 4177 // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it
@@ -3439,17 +4181,66 @@ namespace OpenSim.Region.Framework.Scenes
3439 4181
3440 // This invocation always shows up in the viewer logs as an error. Is it needed? 4182 // This invocation always shows up in the viewer logs as an error. Is it needed?
3441 SendAppearanceToClient(this); 4183 SendAppearanceToClient(this);
4184=======
4185
4186 // send avatar object to all viewers so they cross it into region
4187 bool newhide = m_currentParcelHide;
4188 m_currentParcelHide = false;
4189
4190 SendAvatarDataToAllAgents();
4191
4192 // now hide
4193 if (newhide)
4194 {
4195 ParcelLoginCheck(m_currentParcelUUID);
4196 m_currentParcelHide = true;
4197 }
4198
4199 SendAppearanceToAgent(this);
4200>>>>>>> avn/ubitvar
4201
4202 m_inTransit = false;
3442 4203
3443 // If we are using the the cached appearance then send it out to everyone 4204 SendAppearanceToAllOtherAgents();
3444 if (cachedappearance) 4205
4206 if(Animator!= null)
4207 Animator.SendAnimPack();
4208 }
4209*/
4210 /// <summary>
4211 /// Send avatar full data appearance and animations for all other root agents to this agent, this agent
4212 /// can be either a child or root
4213 /// </summary>
4214 public void SendOtherAgentsAvatarFullToMe()
4215 {
4216 int count = 0;
4217 m_scene.ForEachRootScenePresence(delegate(ScenePresence p)
3445 { 4218 {
3446 m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); 4219 // only send information about other root agents
4220 if (p.UUID == UUID)
4221 return;
3447 4222
4223<<<<<<< HEAD
3448 // If the avatars baked textures are all in the cache, then we have a 4224 // If the avatars baked textures are all in the cache, then we have a
3449 // complete appearance... send it out, if not, then we'll send it when 4225 // complete appearance... send it out, if not, then we'll send it when
3450 // the avatar finishes updating its appearance 4226 // the avatar finishes updating its appearance
3451 SendAppearanceToAllOtherClients(); 4227 SendAppearanceToAllOtherClients();
3452 } 4228 }
4229=======
4230 // get the avatar, then a kill if can't see it
4231 p.SendInitialAvatarDataToAgent(this);
4232
4233 if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodLevel < 200)
4234 return;
4235
4236 p.SendAppearanceToAgentNF(this);
4237 p.SendAnimPackToAgentNF(this);
4238 p.SendAttachmentsToAgentNF(this);
4239 count++;
4240 });
4241
4242 m_scene.StatsReporter.AddAgentUpdates(count);
4243>>>>>>> avn/ubitvar
3453 } 4244 }
3454 4245
3455 public void SendAvatarDataToAllClients() 4246 public void SendAvatarDataToAllClients()
@@ -3470,32 +4261,43 @@ namespace OpenSim.Region.Framework.Scenes
3470 m_log.WarnFormat( 4261 m_log.WarnFormat(
3471 "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}", 4262 "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}",
3472 Name, Scene.RegionInfo.RegionName); 4263 Name, Scene.RegionInfo.RegionName);
3473
3474 return; 4264 return;
3475 } 4265 }
3476 4266
3477 m_lastSize = Appearance.AvatarSize; 4267 m_lastSize = Appearance.AvatarSize;
3478
3479 int count = 0; 4268 int count = 0;
4269
3480 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 4270 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
3481 { 4271 {
4272<<<<<<< HEAD
3482 if (full) 4273 if (full)
3483 SendAvatarDataToClient(scenePresence); 4274 SendAvatarDataToClient(scenePresence);
3484 else 4275 else
3485 scenePresence.ControllingClient.SendAvatarDataImmediate(this); 4276 scenePresence.ControllingClient.SendAvatarDataImmediate(this);
4277=======
4278 SendAvatarDataToAgent(scenePresence);
4279>>>>>>> avn/ubitvar
3486 count++; 4280 count++;
3487 }); 4281 });
3488 4282
3489 m_scene.StatsReporter.AddAgentUpdates(count); 4283 m_scene.StatsReporter.AddAgentUpdates(count);
3490 } 4284 }
3491 4285
4286<<<<<<< HEAD
3492 /// <summary> 4287 /// <summary>
3493 /// Send avatar data for all other root agents to this agent, this agent 4288 /// Send avatar data for all other root agents to this agent, this agent
3494 /// can be either a child or root 4289 /// can be either a child or root
3495 /// </summary> 4290 /// </summary>
3496 public void SendOtherAgentsAvatarDataToClient() 4291 public void SendOtherAgentsAvatarDataToClient()
4292=======
4293 // sends avatar object to all clients so they cross it into region
4294 // then sends kills to hide
4295 public void SendInitialAvatarDataToAllAgents(List<ScenePresence> presences)
4296>>>>>>> avn/ubitvar
3497 { 4297 {
4298 m_lastSize = Appearance.AvatarSize;
3498 int count = 0; 4299 int count = 0;
4300<<<<<<< HEAD
3499 m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) 4301 m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
3500 { 4302 {
3501 // only send information about other root agents 4303 // only send information about other root agents
@@ -3505,29 +4307,65 @@ namespace OpenSim.Region.Framework.Scenes
3505 scenePresence.SendAvatarDataToClient(this); 4307 scenePresence.SendAvatarDataToClient(this);
3506 count++; 4308 count++;
3507 }); 4309 });
4310=======
4311>>>>>>> avn/ubitvar
3508 4312
4313 foreach (ScenePresence p in presences)
4314 {
4315 p.ControllingClient.SendAvatarDataImmediate(this);
4316 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
4317 // either just kill the object
4318 // p.ControllingClient.SendKillObject(new List<uint> {LocalId});
4319 // or also attachments viewer may still know about
4320 SendKillTo(p);
4321 count++;
4322 }
3509 m_scene.StatsReporter.AddAgentUpdates(count); 4323 m_scene.StatsReporter.AddAgentUpdates(count);
3510 } 4324 }
3511 4325
4326 public void SendInitialAvatarDataToAgent(ScenePresence p)
4327 {
4328 p.ControllingClient.SendAvatarDataImmediate(this);
4329 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
4330 // either just kill the object
4331 // p.ControllingClient.SendKillObject(new List<uint> {LocalId});
4332 // or also attachments viewer may still know about
4333 SendKillTo(p);
4334 }
4335
3512 /// <summary> 4336 /// <summary>
3513 /// Send avatar data to an agent. 4337 /// Send avatar data to an agent.
3514 /// </summary> 4338 /// </summary>
3515 /// <param name="avatar"></param> 4339 /// <param name="avatar"></param>
3516 public void SendAvatarDataToClient(ScenePresence avatar) 4340 public void SendAvatarDataToClient(ScenePresence avatar)
3517 { 4341 {
4342<<<<<<< HEAD
3518 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToClient from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); 4343 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToClient from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
3519 4344
4345=======
4346 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
4347 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200)
4348 return;
4349>>>>>>> avn/ubitvar
3520 avatar.ControllingClient.SendAvatarDataImmediate(this); 4350 avatar.ControllingClient.SendAvatarDataImmediate(this);
3521 Animator.SendAnimPackToClient(avatar.ControllingClient);
3522 } 4351 }
3523 4352
4353 public void SendAvatarDataToAgentNF(ScenePresence avatar)
4354 {
4355 avatar.ControllingClient.SendAvatarDataImmediate(this);
4356 }
4357
3524 /// <summary> 4358 /// <summary>
3525 /// Send this agent's appearance to all other root and child agents in the scene 4359 /// Send this agent's appearance to all other root and child agents in the scene
3526 /// This agent must be root. 4360 /// This agent must be root.
3527 /// </summary> 4361 /// </summary>
3528 public void SendAppearanceToAllOtherClients() 4362 public void SendAppearanceToAllOtherClients()
3529 { 4363 {
4364<<<<<<< HEAD
3530// m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherClients: {0} {1}", Name, UUID); 4365// m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherClients: {0} {1}", Name, UUID);
4366=======
4367 // m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} {1}", Name, UUID);
4368>>>>>>> avn/ubitvar
3531 4369
3532 // only send update from root agents to other clients; children are only "listening posts" 4370 // only send update from root agents to other clients; children are only "listening posts"
3533 if (IsChildAgent) 4371 if (IsChildAgent)
@@ -3538,7 +4376,7 @@ namespace OpenSim.Region.Framework.Scenes
3538 4376
3539 return; 4377 return;
3540 } 4378 }
3541 4379
3542 int count = 0; 4380 int count = 0;
3543 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 4381 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
3544 { 4382 {
@@ -3549,6 +4387,7 @@ namespace OpenSim.Region.Framework.Scenes
3549 SendAppearanceToClient(scenePresence); 4387 SendAppearanceToClient(scenePresence);
3550 count++; 4388 count++;
3551 }); 4389 });
4390<<<<<<< HEAD
3552 4391
3553 m_scene.StatsReporter.AddAgentUpdates(count); 4392 m_scene.StatsReporter.AddAgentUpdates(count);
3554 } 4393 }
@@ -3572,6 +4411,8 @@ namespace OpenSim.Region.Framework.Scenes
3572 count++; 4411 count++;
3573 }); 4412 });
3574 4413
4414=======
4415>>>>>>> avn/ubitvar
3575 m_scene.StatsReporter.AddAgentUpdates(count); 4416 m_scene.StatsReporter.AddAgentUpdates(count);
3576 } 4417 }
3577 4418
@@ -3583,11 +4424,62 @@ namespace OpenSim.Region.Framework.Scenes
3583 { 4424 {
3584// m_log.DebugFormat( 4425// m_log.DebugFormat(
3585// "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); 4426// "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID);
4427 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200)
4428 return;
4429 SendAppearanceToAgentNF(avatar);
4430 }
3586 4431
4432 public void SendAppearanceToAgentNF(ScenePresence avatar)
4433 {
3587 avatar.ControllingClient.SendAppearance( 4434 avatar.ControllingClient.SendAppearance(
3588 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); 4435 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
4436 }
3589 4437
3590 4438 public void SendAnimPackToAgent(ScenePresence p)
4439 {
4440 if (IsChildAgent || Animator == null)
4441 return;
4442
4443 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
4444 return;
4445
4446 Animator.SendAnimPackToClient(p.ControllingClient);
4447 }
4448
4449 public void SendAnimPackToAgent(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs)
4450 {
4451 if (IsChildAgent)
4452 return;
4453
4454 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
4455 return;
4456
4457 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
4458 }
4459
4460 public void SendAnimPackToAgentNF(ScenePresence p)
4461 {
4462 if (IsChildAgent || Animator == null)
4463 return;
4464 Animator.SendAnimPackToClient(p.ControllingClient);
4465 }
4466
4467 public void SendAnimPackToAgentNF(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs)
4468 {
4469 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
4470 }
4471
4472 public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs)
4473 {
4474 if (IsChildAgent)
4475 return;
4476
4477 m_scene.ForEachScenePresence(delegate(ScenePresence p)
4478 {
4479 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
4480 return;
4481 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
4482 });
3591 } 4483 }
3592 4484
3593 #endregion 4485 #endregion
@@ -3611,6 +4503,7 @@ namespace OpenSim.Region.Framework.Scenes
3611 m_lastChildAgentUpdatePosition = AbsolutePosition; 4503 m_lastChildAgentUpdatePosition = AbsolutePosition;
3612// m_lastChildAgentUpdateCamPosition = CameraPosition; 4504// m_lastChildAgentUpdateCamPosition = CameraPosition;
3613 4505
4506/* cadu is not used
3614 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 4507 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
3615 cadu.ActiveGroupID = UUID.Zero.Guid; 4508 cadu.ActiveGroupID = UUID.Zero.Guid;
3616 cadu.AgentID = UUID.Guid; 4509 cadu.AgentID = UUID.Guid;
@@ -3624,6 +4517,7 @@ namespace OpenSim.Region.Framework.Scenes
3624 4517
3625 // Throttles 4518 // Throttles
3626 float multiplier = 1; 4519 float multiplier = 1;
4520
3627 int childRegions = KnownRegionCount; 4521 int childRegions = KnownRegionCount;
3628 if (childRegions != 0) 4522 if (childRegions != 0)
3629 multiplier = 1f / childRegions; 4523 multiplier = 1f / childRegions;
@@ -3634,9 +4528,22 @@ namespace OpenSim.Region.Framework.Scenes
3634 4528
3635 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 4529 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
3636 cadu.Velocity = Velocity; 4530 cadu.Velocity = Velocity;
3637 4531*/
3638 AgentPosition agentpos = new AgentPosition(); 4532 AgentPosition agentpos = new AgentPosition();
3639 agentpos.CopyFrom(cadu, ControllingClient.SessionId); 4533// agentpos.CopyFrom(cadu, ControllingClient.SessionId);
4534
4535 agentpos.AgentID = new UUID(UUID.Guid);
4536 agentpos.SessionID = ControllingClient.SessionId;
4537
4538 agentpos.Size = Appearance.AvatarSize;
4539
4540 agentpos.Center = CameraPosition;
4541 agentpos.Far = DrawDistance;
4542 agentpos.Position = AbsolutePosition;
4543 agentpos.Velocity = Velocity;
4544 agentpos.RegionHandle = RegionHandle;
4545 agentpos.Throttles = ControllingClient.GetThrottlesPacked(1);
4546
3640 4547
3641 // Let's get this out of the update loop 4548 // Let's get this out of the update loop
3642 Util.FireAndForget( 4549 Util.FireAndForget(
@@ -3657,7 +4564,7 @@ namespace OpenSim.Region.Framework.Scenes
3657 protected void CheckForBorderCrossing() 4564 protected void CheckForBorderCrossing()
3658 { 4565 {
3659 // Check that we we are not a child 4566 // Check that we we are not a child
3660 if (IsChildAgent) 4567 if (IsChildAgent || IsInTransit)
3661 return; 4568 return;
3662 4569
3663 // If we don't have a PhysActor, we can't cross anyway 4570 // If we don't have a PhysActor, we can't cross anyway
@@ -3667,6 +4574,7 @@ namespace OpenSim.Region.Framework.Scenes
3667 if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) 4574 if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero)
3668 return; 4575 return;
3669 4576
4577<<<<<<< HEAD
3670 if (IsInTransit) 4578 if (IsInTransit)
3671 return; 4579 return;
3672 4580
@@ -3740,6 +4648,70 @@ namespace OpenSim.Region.Framework.Scenes
3740 ret.Y = extentY - borderFudge; 4648 ret.Y = extentY - borderFudge;
3741 4649
3742 return ret; 4650 return ret;
4651=======
4652 Vector3 pos2 = AbsolutePosition;
4653 Vector3 vel = Velocity;
4654
4655 float timeStep = 0.1f;
4656 pos2.X += vel.X * timeStep;
4657 pos2.Y += vel.Y * timeStep;
4658 pos2.Z += vel.Z * timeStep;
4659
4660// m_log.DebugFormat(
4661// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}",
4662// pos2, Name, Scene.Name);
4663
4664 if (Scene.PositionIsInCurrentRegion(pos2))
4665 return;
4666
4667 if (!CrossToNewRegion() && m_requestedSitTargetUUID == UUID.Zero)
4668 {
4669 // we don't have entity transfer module
4670 Vector3 pos = AbsolutePosition;
4671 float px = pos.X;
4672 if (px < 0)
4673 pos.X += Velocity.X * 2;
4674 else if (px > m_scene.RegionInfo.RegionSizeX)
4675 pos.X -= Velocity.X * 2;
4676
4677 float py = pos.Y;
4678 if (py < 0)
4679 pos.Y += Velocity.Y * 2;
4680 else if (py > m_scene.RegionInfo.RegionSizeY)
4681 pos.Y -= Velocity.Y * 2;
4682
4683 Velocity = Vector3.Zero;
4684 AbsolutePosition = pos;
4685 }
4686 }
4687
4688 public void CrossToNewRegionFail()
4689 {
4690 if (m_requestedSitTargetUUID == UUID.Zero)
4691 {
4692 bool isFlying = Flying;
4693 RemoveFromPhysicalScene();
4694
4695 Vector3 pos = AbsolutePosition;
4696 float px = pos.X;
4697 if (px < 0)
4698 pos.X += Velocity.X * 2;
4699 else if (px > m_scene.RegionInfo.RegionSizeX)
4700 pos.X -= Velocity.X * 2;
4701
4702 float py = pos.Y;
4703 if (py < 0)
4704 pos.Y += Velocity.Y * 2;
4705 else if (py > m_scene.RegionInfo.RegionSizeY)
4706 pos.Y -= Velocity.Y * 2;
4707
4708 Velocity = Vector3.Zero;
4709 AbsolutePosition = pos;
4710
4711 AddToPhysicalScene(isFlying);
4712 }
4713
4714>>>>>>> avn/ubitvar
3743 } 4715 }
3744 4716
3745 /// <summary> 4717 /// <summary>
@@ -3750,16 +4722,25 @@ namespace OpenSim.Region.Framework.Scenes
3750 /// </summary> 4722 /// </summary>
3751 protected bool CrossToNewRegion() 4723 protected bool CrossToNewRegion()
3752 { 4724 {
4725 bool result = false;
4726// parcelRegionCross(false);
3753 try 4727 try
3754 { 4728 {
3755 return m_scene.CrossAgentToNewRegion(this, Flying); 4729 result = m_scene.CrossAgentToNewRegion(this, Flying);
3756 } 4730 }
3757 catch 4731 catch
3758 { 4732 {
3759 return m_scene.CrossAgentToNewRegion(this, false); 4733// result = m_scene.CrossAgentToNewRegion(this, false);
4734 return false;
3760 } 4735 }
4736 // if(!result)
4737 // parcelRegionCross(true);
4738
4739 return result;
4740
3761 } 4741 }
3762 4742
4743/* useless. Either use MakeChild or delete the presence
3763 public void Reset() 4744 public void Reset()
3764 { 4745 {
3765// m_log.DebugFormat("[SCENE PRESENCE]: Resetting {0} in {1}", Name, Scene.RegionInfo.RegionName); 4746// m_log.DebugFormat("[SCENE PRESENCE]: Resetting {0} in {1}", Name, Scene.RegionInfo.RegionName);
@@ -3770,7 +4751,7 @@ namespace OpenSim.Region.Framework.Scenes
3770 4751
3771 Animator.ResetAnimations(); 4752 Animator.ResetAnimations();
3772 } 4753 }
3773 4754*/
3774 /// <summary> 4755 /// <summary>
3775 /// Computes which child agents to close when the scene presence moves to another region. 4756 /// Computes which child agents to close when the scene presence moves to another region.
3776 /// Removes those regions from m_knownRegions. 4757 /// Removes those regions from m_knownRegions.
@@ -3778,8 +4759,9 @@ namespace OpenSim.Region.Framework.Scenes
3778 /// <param name="newRegionX">The new region's x on the map</param> 4759 /// <param name="newRegionX">The new region's x on the map</param>
3779 /// <param name="newRegionY">The new region's y on the map</param> 4760 /// <param name="newRegionY">The new region's y on the map</param>
3780 /// <returns></returns> 4761 /// <returns></returns>
3781 public void CloseChildAgents(uint newRegionX, uint newRegionY) 4762 public void CloseChildAgents(ulong newRegionHandle, int newRegionSizeX, int newRegionSizeY)
3782 { 4763 {
4764 uint newRegionX, newRegionY;
3783 List<ulong> byebyeRegions = new List<ulong>(); 4765 List<ulong> byebyeRegions = new List<ulong>();
3784 List<ulong> knownRegions = KnownRegionHandles; 4766 List<ulong> knownRegions = KnownRegionHandles;
3785 m_log.DebugFormat( 4767 m_log.DebugFormat(
@@ -3787,11 +4769,17 @@ namespace OpenSim.Region.Framework.Scenes
3787 knownRegions.Count, Scene.RegionInfo.RegionName); 4769 knownRegions.Count, Scene.RegionInfo.RegionName);
3788 //DumpKnownRegions(); 4770 //DumpKnownRegions();
3789 4771
4772 Util.RegionHandleToRegionLoc(newRegionHandle, out newRegionX, out newRegionY);
4773
4774 uint x, y;
4775 spRegionSizeInfo regInfo;
4776
3790 foreach (ulong handle in knownRegions) 4777 foreach (ulong handle in knownRegions)
3791 { 4778 {
3792 // Don't close the agent on this region yet 4779 // Don't close the agent on this region yet
3793 if (handle != Scene.RegionInfo.RegionHandle) 4780 if (handle != Scene.RegionInfo.RegionHandle)
3794 { 4781 {
4782<<<<<<< HEAD
3795 uint x, y; 4783 uint x, y;
3796 Util.RegionHandleToRegionLoc(handle, out x, out y); 4784 Util.RegionHandleToRegionLoc(handle, out x, out y);
3797 4785
@@ -3800,8 +4788,27 @@ namespace OpenSim.Region.Framework.Scenes
3800 float dist = (float)Math.Max(Scene.DefaultDrawDistance, 4788 float dist = (float)Math.Max(Scene.DefaultDrawDistance,
3801 (float)Math.Max(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY)); 4789 (float)Math.Max(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY));
3802 if (Util.IsOutsideView(dist, x, newRegionX, y, newRegionY)) 4790 if (Util.IsOutsideView(dist, x, newRegionX, y, newRegionY))
4791=======
4792 Util.RegionHandleToRegionLoc(handle, out x, out y);
4793 if (m_knownChildRegionsSizeInfo.TryGetValue(handle, out regInfo))
3803 { 4794 {
3804 byebyeRegions.Add(handle); 4795
4796 // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
4797 // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
4798 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY,
4799 regInfo.sizeX, regInfo.sizeY, newRegionSizeX, newRegionSizeY))
4800 {
4801 byebyeRegions.Add(handle);
4802 }
4803 }
4804 else
4805>>>>>>> avn/ubitvar
4806 {
4807 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY,
4808 (int)Constants.RegionSize, (int)Constants.RegionSize, newRegionSizeX, newRegionSizeY))
4809 {
4810 byebyeRegions.Add(handle);
4811 }
3805 } 4812 }
3806 } 4813 }
3807 } 4814 }
@@ -3820,6 +4827,7 @@ namespace OpenSim.Region.Framework.Scenes
3820 foreach (ulong handle in byebyeRegions) 4827 foreach (ulong handle in byebyeRegions)
3821 { 4828 {
3822 RemoveNeighbourRegion(handle); 4829 RemoveNeighbourRegion(handle);
4830 Scene.CapsModule.DropChildSeed(UUID, handle);
3823 } 4831 }
3824 } 4832 }
3825 4833
@@ -3831,6 +4839,8 @@ namespace OpenSim.Region.Framework.Scenes
3831 /// </summary> 4839 /// </summary>
3832 public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) 4840 public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus)
3833 { 4841 {
4842 int oldgodlevel = GodLevel;
4843
3834 if (godStatus) 4844 if (godStatus)
3835 { 4845 {
3836 // For now, assign god level 200 to anyone 4846 // For now, assign god level 200 to anyone
@@ -3851,6 +4861,9 @@ namespace OpenSim.Region.Framework.Scenes
3851 } 4861 }
3852 4862
3853 ControllingClient.SendAdminResponse(token, (uint)GodLevel); 4863 ControllingClient.SendAdminResponse(token, (uint)GodLevel);
4864
4865 if(oldgodlevel != GodLevel)
4866 parcelGodCheck(m_currentParcelUUID, GodLevel >= 200);
3854 } 4867 }
3855 4868
3856 #region Child Agent Updates 4869 #region Child Agent Updates
@@ -3868,6 +4881,11 @@ namespace OpenSim.Region.Framework.Scenes
3868 4881
3869 private static Vector3 marker = new Vector3(-1f, -1f, -1f); 4882 private static Vector3 marker = new Vector3(-1f, -1f, -1f);
3870 4883
4884 private void RaiseUpdateThrottles()
4885 {
4886 m_scene.EventManager.TriggerThrottleUpdate(this);
4887 }
4888
3871 /// <summary> 4889 /// <summary>
3872 /// This updates important decision making data about a child agent 4890 /// This updates important decision making data about a child agent
3873 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region 4891 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
@@ -3877,6 +4895,7 @@ namespace OpenSim.Region.Framework.Scenes
3877 if (!IsChildAgent) 4895 if (!IsChildAgent)
3878 return; 4896 return;
3879 4897
4898<<<<<<< HEAD
3880// m_log.DebugFormat( 4899// m_log.DebugFormat(
3881// "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}", 4900// "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}",
3882// Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position); 4901// Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position);
@@ -3886,6 +4905,13 @@ namespace OpenSim.Region.Framework.Scenes
3886 // uint 4905 // uint
3887 int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize); 4906 int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize);
3888 int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize); 4907 int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize);
4908=======
4909 RegionHandle = cAgentData.RegionHandle;
4910
4911 //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY);
4912 int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize;
4913 int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize;
4914>>>>>>> avn/ubitvar
3889 4915
3890 Vector3 offset = new Vector3(shiftx, shifty, 0f); 4916 Vector3 offset = new Vector3(shiftx, shifty, 0f);
3891 4917
@@ -3893,7 +4919,11 @@ namespace OpenSim.Region.Framework.Scenes
3893 // changes, then start using the agent's drawdistance rather than the 4919 // changes, then start using the agent's drawdistance rather than the
3894 // region's draw distance. 4920 // region's draw distance.
3895 DrawDistance = cAgentData.Far; 4921 DrawDistance = cAgentData.Far;
4922<<<<<<< HEAD
3896 // DrawDistance = Scene.DefaultDrawDistance; 4923 // DrawDistance = Scene.DefaultDrawDistance;
4924=======
4925// DrawDistance = Scene.DefaultDrawDistance;
4926>>>>>>> avn/ubitvar
3897 4927
3898 if (cAgentData.Position != marker) // UGH!! 4928 if (cAgentData.Position != marker) // UGH!!
3899 m_pos = cAgentData.Position + offset; 4929 m_pos = cAgentData.Position + offset;
@@ -3907,10 +4937,36 @@ namespace OpenSim.Region.Framework.Scenes
3907 CameraPosition = cAgentData.Center + offset; 4937 CameraPosition = cAgentData.Center + offset;
3908 4938
3909 if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) 4939 if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0)
3910 ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); 4940 {
4941 // some scaling factor
4942 float x = m_pos.X;
4943 if (x > m_scene.RegionInfo.RegionSizeX)
4944 x -= m_scene.RegionInfo.RegionSizeX;
4945 float y = m_pos.Y;
4946 if (y > m_scene.RegionInfo.RegionSizeY)
4947 y -= m_scene.RegionInfo.RegionSizeY;
4948
4949 x = x * x + y * y;
4950
4951 const float distScale = 0.4f / Constants.RegionSize / Constants.RegionSize;
4952 float factor = 1.0f - distScale * x;
4953 if (factor < 0.2f)
4954 factor = 0.2f;
4955
4956 ControllingClient.SetChildAgentThrottle(cAgentData.Throttles,factor);
4957 }
4958
4959 if(cAgentData.ChildrenCapSeeds != null && cAgentData.ChildrenCapSeeds.Count >0)
4960 {
4961 if (Scene.CapsModule != null)
4962 {
4963 Scene.CapsModule.SetChildrenSeed(UUID, cAgentData.ChildrenCapSeeds);
4964 }
4965
4966 KnownRegions = cAgentData.ChildrenCapSeeds;
4967 }
3911 4968
3912 //cAgentData.AVHeight; 4969 //cAgentData.AVHeight;
3913 RegionHandle = cAgentData.RegionHandle;
3914 //m_velocity = cAgentData.Velocity; 4970 //m_velocity = cAgentData.Velocity;
3915 } 4971 }
3916 4972
@@ -3932,16 +4988,7 @@ namespace OpenSim.Region.Framework.Scenes
3932 cAgent.Far = DrawDistance; 4988 cAgent.Far = DrawDistance;
3933 4989
3934 // Throttles 4990 // Throttles
3935 float multiplier = 1; 4991 cAgent.Throttles = ControllingClient.GetThrottlesPacked(1);
3936 int childRegions = KnownRegionCount;
3937 if (childRegions != 0)
3938 multiplier = 1f / childRegions;
3939
3940 // Minimum throttle for a child region is 1/4 of the root region throttle
3941 if (multiplier <= 0.25f)
3942 multiplier = 0.25f;
3943
3944 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier);
3945 4992
3946 cAgent.HeadRotation = m_headrotation; 4993 cAgent.HeadRotation = m_headrotation;
3947 cAgent.BodyRotation = Rotation; 4994 cAgent.BodyRotation = Rotation;
@@ -3954,7 +5001,8 @@ namespace OpenSim.Region.Framework.Scenes
3954 5001
3955 cAgent.AlwaysRun = SetAlwaysRun; 5002 cAgent.AlwaysRun = SetAlwaysRun;
3956 5003
3957 cAgent.Appearance = new AvatarAppearance(Appearance); 5004 // make clear we want the all thing
5005 cAgent.Appearance = new AvatarAppearance(Appearance,true,true);
3958 5006
3959 cAgent.ParentPart = ParentUUID; 5007 cAgent.ParentPart = ParentUUID;
3960 cAgent.SitOffset = PrevSitOffset; 5008 cAgent.SitOffset = PrevSitOffset;
@@ -3980,12 +5028,20 @@ namespace OpenSim.Region.Framework.Scenes
3980 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; 5028 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation;
3981 cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation; 5029 cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation;
3982 5030
5031 cAgent.MovementAnimationOverRides = Overrides.CloneAOPairs();
5032
5033 cAgent.MotionState = (byte)Animator.currentControlState;
5034
3983 if (Scene.AttachmentsModule != null) 5035 if (Scene.AttachmentsModule != null)
3984 Scene.AttachmentsModule.CopyAttachments(this, cAgent); 5036 Scene.AttachmentsModule.CopyAttachments(this, cAgent);
3985 } 5037 }
3986 5038
3987 private void CopyFrom(AgentData cAgent) 5039 private void CopyFrom(AgentData cAgent)
3988 { 5040 {
5041<<<<<<< HEAD
5042=======
5043
5044>>>>>>> avn/ubitvar
3989 m_callbackURI = cAgent.CallbackURI; 5045 m_callbackURI = cAgent.CallbackURI;
3990// m_log.DebugFormat( 5046// m_log.DebugFormat(
3991// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", 5047// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()",
@@ -4004,7 +5060,20 @@ namespace OpenSim.Region.Framework.Scenes
4004 // changes, then start using the agent's drawdistance rather than the 5060 // changes, then start using the agent's drawdistance rather than the
4005 // region's draw distance. 5061 // region's draw distance.
4006 DrawDistance = cAgent.Far; 5062 DrawDistance = cAgent.Far;
5063<<<<<<< HEAD
4007 // DrawDistance = Scene.DefaultDrawDistance; 5064 // DrawDistance = Scene.DefaultDrawDistance;
5065=======
5066 //DrawDistance = Scene.DefaultDrawDistance;
5067
5068 if (cAgent.ChildrenCapSeeds != null && cAgent.ChildrenCapSeeds.Count > 0)
5069 {
5070 if (Scene.CapsModule != null)
5071 {
5072 Scene.CapsModule.SetChildrenSeed(UUID, cAgent.ChildrenCapSeeds);
5073 }
5074 KnownRegions = cAgent.ChildrenCapSeeds;
5075 }
5076>>>>>>> avn/ubitvar
4008 5077
4009 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) 5078 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0)
4010 ControllingClient.SetChildAgentThrottle(cAgent.Throttles); 5079 ControllingClient.SetChildAgentThrottle(cAgent.Throttles);
@@ -4017,14 +5086,17 @@ namespace OpenSim.Region.Framework.Scenes
4017 GodLevel = cAgent.GodLevel; 5086 GodLevel = cAgent.GodLevel;
4018 SetAlwaysRun = cAgent.AlwaysRun; 5087 SetAlwaysRun = cAgent.AlwaysRun;
4019 5088
5089
4020 Appearance = new AvatarAppearance(cAgent.Appearance); 5090 Appearance = new AvatarAppearance(cAgent.Appearance);
5091/*
5092 bool isFlying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
5093
4021 if (PhysicsActor != null) 5094 if (PhysicsActor != null)
4022 { 5095 {
4023 bool isFlying = Flying;
4024 RemoveFromPhysicalScene(); 5096 RemoveFromPhysicalScene();
4025 AddToPhysicalScene(isFlying); 5097 AddToPhysicalScene(isFlying);
4026 } 5098 }
4027 5099*/
4028 try 5100 try
4029 { 5101 {
4030 lock (scriptedcontrols) 5102 lock (scriptedcontrols)
@@ -4048,15 +5120,22 @@ namespace OpenSim.Region.Framework.Scenes
4048 } 5120 }
4049 catch { } 5121 catch { }
4050 5122
5123 Animator.ResetAnimations();
5124
5125 Overrides.CopyAOPairsFrom(cAgent.MovementAnimationOverRides);
5126
4051 // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? 5127 // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object?
4052 if (cAgent.Anims != null)
4053 Animator.Animations.FromArray(cAgent.Anims);
4054 if (cAgent.DefaultAnim != null) 5128 if (cAgent.DefaultAnim != null)
4055 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); 5129 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero);
4056 if (cAgent.AnimState != null) 5130 if (cAgent.AnimState != null)
4057 Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); 5131 Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero);
5132 if (cAgent.Anims != null)
5133 Animator.Animations.FromArray(cAgent.Anims);
5134 if (cAgent.MotionState != 0)
5135 Animator.currentControlState = (ScenePresenceAnimator.motionControlStates) cAgent.MotionState;
4058 5136
4059 if (Scene.AttachmentsModule != null) 5137 if (Scene.AttachmentsModule != null)
5138<<<<<<< HEAD
4060 { 5139 {
4061 // If the JobEngine is running we can schedule this job now and continue rather than waiting for all 5140 // If the JobEngine is running we can schedule this job now and continue rather than waiting for all
4062 // attachments to copy, which might take a long time in the Hypergrid case as the entire inventory 5141 // attachments to copy, which might take a long time in the Hypergrid case as the entire inventory
@@ -4078,6 +5157,13 @@ namespace OpenSim.Region.Framework.Scenes
4078 // script attachments can outrace this thread. 5157 // script attachments can outrace this thread.
4079 lock (m_originRegionIDAccessLock) 5158 lock (m_originRegionIDAccessLock)
4080 m_originRegionID = cAgent.RegionID; 5159 m_originRegionID = cAgent.RegionID;
5160=======
5161 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
5162
5163 lock (m_originRegionIDAccessLock)
5164 m_originRegionID = cAgent.RegionID;
5165
5166>>>>>>> avn/ubitvar
4081 } 5167 }
4082 5168
4083 public bool CopyAgent(out IAgentData agent) 5169 public bool CopyAgent(out IAgentData agent)
@@ -4094,6 +5180,8 @@ namespace OpenSim.Region.Framework.Scenes
4094 /// </summary> 5180 /// </summary>
4095 public void UpdateMovement() 5181 public void UpdateMovement()
4096 { 5182 {
5183 if (IsInTransit)
5184 return;
4097 if (m_forceToApply.HasValue) 5185 if (m_forceToApply.HasValue)
4098 { 5186 {
4099 Vector3 force = m_forceToApply.Value; 5187 Vector3 force = m_forceToApply.Value;
@@ -4131,9 +5219,15 @@ namespace OpenSim.Region.Framework.Scenes
4131 new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); 5219 new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying);
4132*/ 5220*/
4133 5221
5222<<<<<<< HEAD
4134 PhysicsActor = m_scene.PhysicsScene.AddAvatar( 5223 PhysicsActor = m_scene.PhysicsScene.AddAvatar(
4135 LocalId, Firstname + "." + Lastname, AbsolutePosition, Velocity, 5224 LocalId, Firstname + "." + Lastname, AbsolutePosition, Velocity,
4136 Appearance.AvatarBoxSize, isFlying); 5225 Appearance.AvatarBoxSize, isFlying);
5226=======
5227 PhysicsActor = scene.AddAvatar(
5228 LocalId, Firstname + "." + Lastname, pVec,
5229 Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying);
5230>>>>>>> avn/ubitvar
4137 5231
4138 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 5232 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
4139 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 5233 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
@@ -4168,7 +5262,9 @@ namespace OpenSim.Region.Framework.Scenes
4168 { 5262 {
4169 if (IsChildAgent || Animator == null) 5263 if (IsChildAgent || Animator == null)
4170 return; 5264 return;
4171 5265
5266 if(IsInTransit)
5267 return;
4172 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) 5268 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
4173 // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( 5269 // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
4174 // as of this comment the interval is set in AddToPhysicalScene 5270 // as of this comment the interval is set in AddToPhysicalScene
@@ -4192,7 +5288,49 @@ namespace OpenSim.Region.Framework.Scenes
4192// m_lastColCount = coldata.Count; 5288// m_lastColCount = coldata.Count;
4193// } 5289// }
4194 5290
4195 CollisionPlane = Vector4.UnitW; 5291 if (coldata.Count != 0)
5292 {
5293/*
5294 switch (Animator.CurrentMovementAnimation)
5295 {
5296 case "STAND":
5297 case "WALK":
5298 case "RUN":
5299 case "CROUCH":
5300 case "CROUCHWALK":
5301 {
5302 */
5303 ContactPoint lowest;
5304 lowest.SurfaceNormal = Vector3.Zero;
5305 lowest.Position = Vector3.Zero;
5306 lowest.Position.Z = float.MaxValue;
5307
5308 foreach (ContactPoint contact in coldata.Values)
5309 {
5310
5311 if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z)
5312 {
5313 lowest = contact;
5314 }
5315 }
5316
5317 if (lowest.Position.Z != float.MaxValue)
5318 {
5319 lowest.SurfaceNormal = -lowest.SurfaceNormal;
5320 CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal));
5321 }
5322 else
5323 CollisionPlane = Vector4.UnitW;
5324/*
5325 }
5326 break;
5327 }
5328*/
5329 }
5330 else
5331 CollisionPlane = Vector4.UnitW;
5332
5333 RaiseCollisionScriptEvents(coldata);
4196 5334
4197 // Gods do not take damage and Invulnerable is set depending on parcel/region flags 5335 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
4198 if (Invulnerable || GodLevel > 0) 5336 if (Invulnerable || GodLevel > 0)
@@ -4311,6 +5449,10 @@ namespace OpenSim.Region.Framework.Scenes
4311 5449
4312 m_attachments.Add(gobj); 5450 m_attachments.Add(gobj);
4313 } 5451 }
5452
5453 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
5454 if (bakedModule != null)
5455 bakedModule.UpdateMeshAvatar(m_uuid);
4314 } 5456 }
4315 5457
4316 /// <summary> 5458 /// <summary>
@@ -4474,6 +5616,287 @@ namespace OpenSim.Region.Framework.Scenes
4474 return validated; 5616 return validated;
4475 } 5617 }
4476 5618
5619 public void SendAttachmentsToAllAgents()
5620 {
5621 lock (m_attachments)
5622 {
5623 foreach (SceneObjectGroup sog in m_attachments)
5624 {
5625 m_scene.ForEachScenePresence(delegate(ScenePresence p)
5626 {
5627 if (p != this && sog.HasPrivateAttachmentPoint)
5628 return;
5629
5630 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
5631 return;
5632
5633 SendTerseUpdateToAgentNF(p);
5634 SendAttachmentFullUpdateToAgentNF(sog, p);
5635 });
5636 }
5637 }
5638 }
5639
5640 // send attachments to a client without filters except for huds
5641 // for now they are checked in several places down the line...
5642 public void SendAttachmentsToAgentNF(ScenePresence p)
5643 {
5644 SendTerseUpdateToAgentNF(p);
5645 lock (m_attachments)
5646 {
5647 foreach (SceneObjectGroup sog in m_attachments)
5648 {
5649 SendAttachmentFullUpdateToAgentNF(sog, p);
5650 }
5651 }
5652 }
5653
5654 public void SendAttachmentFullUpdateToAgentNF(SceneObjectGroup sog, ScenePresence p)
5655 {
5656 if (p != this && sog.HasPrivateAttachmentPoint)
5657 return;
5658
5659 SceneObjectPart[] parts = sog.Parts;
5660 SceneObjectPart rootpart = sog.RootPart;
5661
5662 p.ControllingClient.SendEntityUpdate(rootpart, PrimUpdateFlags.FullUpdate);
5663
5664 for (int i = 0; i < parts.Length; i++)
5665 {
5666 SceneObjectPart part = parts[i];
5667 if (part == rootpart)
5668 continue;
5669 p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate);
5670 }
5671 }
5672
5673 public void SendAttachmentScheduleUpdate(SceneObjectGroup sog)
5674 {
5675 if (IsChildAgent || IsInTransit)
5676 return;
5677
5678 SceneObjectPart[] origparts = sog.Parts;
5679 SceneObjectPart[] parts = new SceneObjectPart[origparts.Length];
5680 PrimUpdateFlags[] flags = new PrimUpdateFlags[origparts.Length];
5681
5682 SceneObjectPart rootpart = sog.RootPart;
5683 UpdateRequired rootreq = sog.RootPart.UpdateFlag;
5684
5685 int j = 0;
5686 bool allterse = true;
5687 for (int i = 0; i < origparts.Length; i++)
5688 {
5689 if (origparts[i] != rootpart)
5690 {
5691 switch (origparts[i].UpdateFlag)
5692 {
5693 case UpdateRequired.NONE:
5694 break;
5695
5696 case UpdateRequired.TERSE:
5697 flags[j] = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
5698 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
5699 parts[j] = origparts[i];
5700 j++;
5701 break;
5702
5703 case UpdateRequired.FULL:
5704 flags[j] = PrimUpdateFlags.FullUpdate;
5705 allterse = false;
5706 parts[j] = origparts[i];
5707 j++;
5708 break;
5709 }
5710 }
5711 origparts[i].UpdateFlag = 0;
5712 }
5713
5714 if (j == 0 && rootreq == UpdateRequired.NONE)
5715 return;
5716
5717 PrimUpdateFlags rootflag = PrimUpdateFlags.FullUpdate;
5718
5719 if (rootreq != UpdateRequired.FULL && allterse)
5720 {
5721 rootflag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
5722 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
5723 }
5724
5725 int nparts = j;
5726
5727 ControllingClient.SendEntityUpdate(rootpart, rootflag);
5728
5729 for (int i = 0; i < nparts; i++)
5730 {
5731 ControllingClient.SendEntityUpdate(parts[i], flags[i]);
5732 }
5733
5734 if (sog.HasPrivateAttachmentPoint)
5735 return;
5736
5737 List<ScenePresence> allPresences = m_scene.GetScenePresences();
5738 foreach (ScenePresence p in allPresences)
5739 {
5740 if (p == this)
5741 continue;
5742
5743 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
5744 continue;
5745
5746 p.ControllingClient.SendEntityUpdate(rootpart, rootflag);
5747
5748 for (int i = 0; i < nparts; i++)
5749 {
5750 p.ControllingClient.SendEntityUpdate(parts[i], flags[i]);
5751 }
5752 }
5753 }
5754
5755 public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag)
5756 {
5757 if (IsChildAgent || IsInTransit)
5758 return;
5759
5760 PrimUpdateFlags flag;
5761 switch (UpdateFlag)
5762 {
5763 case UpdateRequired.TERSE:
5764 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
5765 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
5766 break;
5767
5768 case UpdateRequired.FULL:
5769 flag = PrimUpdateFlags.FullUpdate;
5770 break;
5771
5772 default:
5773 return;
5774 }
5775
5776 SceneObjectPart[] parts = sog.Parts;
5777 SceneObjectPart rootpart = sog.RootPart;
5778
5779// rootpart.UpdateFlag = 0;
5780
5781 ControllingClient.SendEntityUpdate(rootpart, flag);
5782
5783 for (int i = 0; i < parts.Length; i++)
5784 {
5785 SceneObjectPart part = parts[i];
5786 if (part == rootpart)
5787 continue;
5788 ControllingClient.SendEntityUpdate(part, flag);
5789// part.UpdateFlag = 0;
5790 }
5791
5792 if (sog.HasPrivateAttachmentPoint)
5793 return;
5794
5795
5796 List<ScenePresence> allPresences = m_scene.GetScenePresences();
5797 foreach (ScenePresence p in allPresences)
5798 {
5799 if (p == this)
5800 continue;
5801
5802 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
5803 continue;
5804
5805 p.ControllingClient.SendEntityUpdate(rootpart, flag);
5806
5807 for (int i = 0; i < parts.Length; i++)
5808 {
5809 SceneObjectPart part = parts[i];
5810 if (part == rootpart)
5811 continue;
5812 p.ControllingClient.SendEntityUpdate(part, flag);
5813 }
5814 }
5815 }
5816
5817 public void SendAttachmentScheduleUpdate(SceneObjectPart part)
5818 {
5819 if (IsChildAgent || IsInTransit)
5820 return;
5821
5822
5823 PrimUpdateFlags flag;
5824 switch (part.UpdateFlag)
5825 {
5826 case UpdateRequired.TERSE:
5827 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
5828 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
5829 break;
5830
5831 case UpdateRequired.FULL:
5832 flag = PrimUpdateFlags.FullUpdate;
5833 break;
5834
5835 default:
5836 return;
5837 }
5838
5839 part.UpdateFlag = 0;
5840
5841 ControllingClient.SendEntityUpdate(part, flag);
5842
5843 if (part.ParentGroup.HasPrivateAttachmentPoint)
5844 return;
5845
5846 List<ScenePresence> allPresences = m_scene.GetScenePresences();
5847 foreach (ScenePresence p in allPresences)
5848 {
5849 if (p == this)
5850 continue;
5851
5852 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
5853 continue;
5854
5855 p.ControllingClient.SendEntityUpdate(part, flag);
5856 }
5857 }
5858
5859
5860 public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag)
5861 {
5862 if (IsChildAgent || IsInTransit)
5863 return;
5864
5865 PrimUpdateFlags flag;
5866 switch (UpdateFlag)
5867 {
5868 case UpdateRequired.TERSE:
5869 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
5870 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
5871 break;
5872
5873 case UpdateRequired.FULL:
5874 flag = PrimUpdateFlags.FullUpdate;
5875 break;
5876
5877 default:
5878 return;
5879 }
5880
5881// part.UpdateFlag = 0;
5882
5883 ControllingClient.SendEntityUpdate(part, flag);
5884
5885 if (part.ParentGroup.HasPrivateAttachmentPoint)
5886 return;
5887
5888 List<ScenePresence> allPresences = m_scene.GetScenePresences();
5889 foreach (ScenePresence p in allPresences)
5890 {
5891 if (p == this)
5892 continue;
5893 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
5894 continue;
5895
5896 p.ControllingClient.SendEntityUpdate(part, flag);
5897 }
5898 }
5899
4477 /// <summary> 5900 /// <summary>
4478 /// Send a script event to this scene presence's attachments 5901 /// Send a script event to this scene presence's attachments
4479 /// </summary> 5902 /// </summary>
@@ -4592,6 +6015,15 @@ namespace OpenSim.Region.Framework.Scenes
4592 ControllingClient.SendTakeControls(int.MaxValue, false, false); 6015 ControllingClient.SendTakeControls(int.MaxValue, false, false);
4593 } 6016 }
4594 6017
6018 public void ClearControls()
6019 {
6020 IgnoredControls = ScriptControlled.CONTROL_ZERO;
6021 lock (scriptedcontrols)
6022 {
6023 scriptedcontrols.Clear();
6024 }
6025 }
6026
4595 private void UnRegisterSeatControls(UUID obj) 6027 private void UnRegisterSeatControls(UUID obj)
4596 { 6028 {
4597 List<UUID> takers = new List<UUID>(); 6029 List<UUID> takers = new List<UUID>();
@@ -4833,11 +6265,8 @@ namespace OpenSim.Region.Framework.Scenes
4833 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); 6265 SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray();
4834 if (spawnPoints.Length == 0) 6266 if (spawnPoints.Length == 0)
4835 { 6267 {
4836 if(m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) 6268 pos.X = 128.0f;
4837 { 6269 pos.Y = 128.0f;
4838 pos.X = 128.0f;
4839 pos.Y = 128.0f;
4840 }
4841 return; 6270 return;
4842 } 6271 }
4843 6272
@@ -4982,8 +6411,8 @@ namespace OpenSim.Region.Framework.Scenes
4982 pos = land.LandData.UserLocation; 6411 pos = land.LandData.UserLocation;
4983 } 6412 }
4984 } 6413 }
4985 6414// this is now done in completeMovement for all cases and not just this
4986 land.SendLandUpdateToClient(ControllingClient); 6415// land.SendLandUpdateToClient(ControllingClient);
4987 } 6416 }
4988 } 6417 }
4989 6418
@@ -4998,6 +6427,7 @@ namespace OpenSim.Region.Framework.Scenes
4998 detobj.velVector = obj.Velocity; 6427 detobj.velVector = obj.Velocity;
4999 detobj.colliderType = 0; 6428 detobj.colliderType = 0;
5000 detobj.groupUUID = obj.GroupID; 6429 detobj.groupUUID = obj.GroupID;
6430 detobj.linkNumber = 0;
5001 6431
5002 return detobj; 6432 return detobj;
5003 } 6433 }
@@ -5013,6 +6443,7 @@ namespace OpenSim.Region.Framework.Scenes
5013 detobj.velVector = av.Velocity; 6443 detobj.velVector = av.Velocity;
5014 detobj.colliderType = 0; 6444 detobj.colliderType = 0;
5015 detobj.groupUUID = av.ControllingClient.ActiveGroupId; 6445 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
6446 detobj.linkNumber = 0;
5016 6447
5017 return detobj; 6448 return detobj;
5018 } 6449 }
@@ -5028,7 +6459,7 @@ namespace OpenSim.Region.Framework.Scenes
5028 detobj.velVector = Vector3.Zero; 6459 detobj.velVector = Vector3.Zero;
5029 detobj.colliderType = 0; 6460 detobj.colliderType = 0;
5030 detobj.groupUUID = UUID.Zero; 6461 detobj.groupUUID = UUID.Zero;
5031 6462 detobj.linkNumber = 0;
5032 return detobj; 6463 return detobj;
5033 } 6464 }
5034 6465
@@ -5095,6 +6526,95 @@ namespace OpenSim.Region.Framework.Scenes
5095 } 6526 }
5096 } 6527 }
5097 6528
6529 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
6530 {
6531 try
6532 {
6533 List<uint> thisHitColliders = new List<uint>();
6534 List<uint> endedColliders = new List<uint>();
6535 List<uint> startedColliders = new List<uint>();
6536 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
6537 CollisionForSoundInfo soundinfo;
6538 ContactPoint curcontact;
6539
6540 if (coldata.Count == 0)
6541 {
6542 if (m_lastColliders.Count == 0)
6543 return; // nothing to do
6544
6545 foreach (uint localID in m_lastColliders)
6546 {
6547 endedColliders.Add(localID);
6548 }
6549 m_lastColliders.Clear();
6550 }
6551
6552 else
6553 {
6554 bool candoparcelSound = ParcelAllowThisAvatarSounds;
6555
6556 foreach (uint id in coldata.Keys)
6557 {
6558 thisHitColliders.Add(id);
6559 if (!m_lastColliders.Contains(id))
6560 {
6561 startedColliders.Add(id);
6562 curcontact = coldata[id];
6563 if (candoparcelSound && Math.Abs(curcontact.RelativeSpeed) > 0.2)
6564 {
6565 soundinfo = new CollisionForSoundInfo();
6566 soundinfo.colliderID = id;
6567 soundinfo.position = curcontact.Position;
6568 soundinfo.relativeVel = curcontact.RelativeSpeed;
6569 soundinfolist.Add(soundinfo);
6570 }
6571 }
6572 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
6573 }
6574
6575 // calculate things that ended colliding
6576 foreach (uint localID in m_lastColliders)
6577 {
6578 if (!thisHitColliders.Contains(localID))
6579 {
6580 endedColliders.Add(localID);
6581 }
6582 }
6583 //add the items that started colliding this time to the last colliders list.
6584 foreach (uint localID in startedColliders)
6585 {
6586 m_lastColliders.Add(localID);
6587 }
6588 // remove things that ended colliding from the last colliders list
6589 foreach (uint localID in endedColliders)
6590 {
6591 m_lastColliders.Remove(localID);
6592 }
6593
6594 if (soundinfolist.Count > 0)
6595 CollisionSounds.AvatarCollisionSound(this, soundinfolist);
6596 }
6597
6598 foreach (SceneObjectGroup att in GetAttachments())
6599 {
6600 SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart);
6601 SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding);
6602 SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd);
6603
6604 if (startedColliders.Contains(0))
6605 SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart);
6606 if (m_lastColliders.Contains(0))
6607 SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding);
6608 if (endedColliders.Contains(0))
6609 SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd);
6610 }
6611 }
6612 finally
6613 {
6614 m_collisionEventFlag = false;
6615 }
6616 }
6617
5098 private void TeleportFlagsDebug() { 6618 private void TeleportFlagsDebug() {
5099 6619
5100 // Some temporary debugging help to show all the TeleportFlags we have... 6620 // Some temporary debugging help to show all the TeleportFlags we have...
@@ -5119,5 +6639,282 @@ namespace OpenSim.Region.Framework.Scenes
5119 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); 6639 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
5120 6640
5121 } 6641 }
6642
6643 private void parcelGodCheck(UUID currentParcelID, bool isGod)
6644 {
6645 List<ScenePresence> allpresences = m_scene.GetScenePresences();
6646
6647 foreach (ScenePresence p in allpresences)
6648 {
6649 if (p.IsDeleted || p.IsChildAgent || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
6650 continue;
6651
6652 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID)
6653 {
6654 if (isGod)
6655 p.SendViewTo(this);
6656 else
6657 p.SendKillTo(this);
6658 }
6659 }
6660 }
6661
6662 private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID,
6663 bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check)
6664 {
6665 List<ScenePresence> killsToSendto = new List<ScenePresence>();
6666 List<ScenePresence> killsToSendme = new List<ScenePresence>();
6667 List<ScenePresence> viewsToSendto = new List<ScenePresence>();
6668 List<ScenePresence> viewsToSendme = new List<ScenePresence>();
6669 List<ScenePresence> allpresences = null;
6670
6671 if (IsInTransit || IsChildAgent)
6672 return;
6673
6674 if (check)
6675 {
6676 // check is relative to current parcel only
6677 if (currentParcelUUID == null || oldhide == currentParcelHide)
6678 return;
6679
6680 allpresences = m_scene.GetScenePresences();
6681
6682 if (oldhide)
6683 { // where private
6684 foreach (ScenePresence p in allpresences)
6685 {
6686 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
6687 continue;
6688
6689 // those on not on parcel see me
6690 if (currentParcelID != p.currentParcelUUID)
6691 {
6692 viewsToSendto.Add(p); // they see me
6693 }
6694 }
6695 } // where private end
6696
6697 else
6698 { // where public
6699 foreach (ScenePresence p in allpresences)
6700 {
6701 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
6702 continue;
6703
6704 // those not on parcel dont see me
6705 if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200)
6706 {
6707 killsToSendto.Add(p); // they dont see me
6708 }
6709 }
6710 } // where public end
6711
6712 allpresences.Clear();
6713 }
6714 else
6715 {
6716 if (currentParcelHide)
6717 {
6718 // now on a private parcel
6719 allpresences = m_scene.GetScenePresences();
6720
6721 if (previusParcelHide && previusParcelID != UUID.Zero)
6722 {
6723 foreach (ScenePresence p in allpresences)
6724 {
6725 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
6726 continue;
6727
6728 // only those on previus parcel need receive kills
6729 if (previusParcelID == p.currentParcelUUID)
6730 {
6731 if(p.GodLevel < 200)
6732 killsToSendto.Add(p); // they dont see me
6733 if(GodLevel < 200)
6734 killsToSendme.Add(p); // i dont see them
6735 }
6736 // only those on new parcel need see
6737 if (currentParcelID == p.currentParcelUUID)
6738 {
6739 viewsToSendto.Add(p); // they see me
6740 viewsToSendme.Add(p); // i see them
6741 }
6742 }
6743 }
6744 else
6745 {
6746 //was on a public area
6747 allpresences = m_scene.GetScenePresences();
6748
6749 foreach (ScenePresence p in allpresences)
6750 {
6751 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
6752 continue;
6753
6754 // those not on new parcel dont see me
6755 if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200)
6756 {
6757 killsToSendto.Add(p); // they dont see me
6758 }
6759 else
6760 {
6761 viewsToSendme.Add(p); // i see those on it
6762 }
6763 }
6764 }
6765 allpresences.Clear();
6766 } // now on a private parcel end
6767
6768 else
6769 {
6770 // now on public parcel
6771 if (previusParcelHide && previusParcelID != UUID.Zero)
6772 {
6773 // was on private area
6774 allpresences = m_scene.GetScenePresences();
6775
6776 foreach (ScenePresence p in allpresences)
6777 {
6778 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
6779 continue;
6780 // only those old parcel need kills
6781 if (previusParcelID == p.currentParcelUUID && GodLevel < 200)
6782 {
6783 killsToSendme.Add(p); // i dont see them
6784 }
6785 else
6786 {
6787 viewsToSendto.Add(p); // they see me
6788 }
6789 }
6790 }
6791 else
6792 return; // was on a public area also
6793 } // now on public parcel end
6794 }
6795
6796 // send the things
6797
6798 if (killsToSendto.Count > 0)
6799 {
6800 foreach (ScenePresence p in killsToSendto)
6801 {
6802 m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname);
6803 SendKillTo(p);
6804 }
6805 }
6806
6807 if (killsToSendme.Count > 0)
6808 {
6809 foreach (ScenePresence p in killsToSendme)
6810 {
6811 m_log.Debug("[AVATAR]: killToMe: " + Lastname + " " + p.Lastname);
6812 p.SendKillTo(this);
6813 }
6814 }
6815
6816 if (viewsToSendto.Count > 0)
6817 {
6818 foreach (ScenePresence p in viewsToSendto)
6819 {
6820 SendViewTo(p);
6821 }
6822 }
6823
6824 if (viewsToSendme.Count > 0 )
6825 {
6826 foreach (ScenePresence p in viewsToSendme)
6827 {
6828 if (p.IsChildAgent)
6829 continue;
6830// m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname);
6831 p.SendViewTo(this);
6832 }
6833 }
6834 }
6835
6836 public void HasMovedAway(bool nearRegion)
6837 {
6838
6839 if (nearRegion)
6840 {
6841 if (Scene.AttachmentsModule != null)
6842 Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true);
6843
6844 if (!ParcelHideThisAvatar || GodLevel >= 200)
6845 return;
6846
6847 List<ScenePresence> allpresences = m_scene.GetScenePresences();
6848 foreach (ScenePresence p in allpresences)
6849 {
6850 if (p.IsDeleted || p == this || p.IsChildAgent || p.ControllingClient == null || !p.ControllingClient.IsActive)
6851 continue;
6852
6853 if (p.currentParcelUUID == m_currentParcelUUID)
6854 {
6855 p.SendKillTo(this);
6856 }
6857 }
6858 }
6859 else
6860 {
6861 List<ScenePresence> allpresences = m_scene.GetScenePresences();
6862 foreach (ScenePresence p in allpresences)
6863 {
6864 if (p == this)
6865 continue;
6866 SendKillTo(p);
6867 if (!p.IsChildAgent)
6868 p.SendKillTo(this);
6869 }
6870
6871 if (Scene.AttachmentsModule != null)
6872 Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true);
6873 }
6874 }
6875
6876
6877// kill with attachs root kills
6878 public void SendKillTo(ScenePresence p)
6879 {
6880 List<uint> ids = new List<uint>(m_attachments.Count + 1);
6881 foreach (SceneObjectGroup sog in m_attachments)
6882 {
6883 ids.Add(sog.RootPart.LocalId);
6884 }
6885
6886 ids.Add(LocalId);
6887 p.ControllingClient.SendKillObject(ids);
6888 }
6889
6890/*
6891// kill with hack
6892 public void SendKillTo(ScenePresence p)
6893 {
6894 foreach (SceneObjectGroup sog in m_attachments)
6895 p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1);
6896 p.ControllingClient.SendKillObject(new List<uint> { LocalId });
6897 }
6898*/
6899 public void SendViewTo(ScenePresence p)
6900 {
6901 SendAvatarDataToAgentNF(p);
6902 SendAppearanceToAgent(p);
6903 if (Animator != null)
6904 Animator.SendAnimPackToClient(p.ControllingClient);
6905 SendAttachmentsToAgentNF(p);
6906 }
6907
6908 public void SetAnimationOverride(string animState, UUID animID)
6909 {
6910 Overrides.SetOverride(animState, animID);
6911// Animator.SendAnimPack();
6912 Animator.ForceUpdateMovementAnimations();
6913 }
6914
6915 public UUID GetAnimationOverride(string animState)
6916 {
6917 return Overrides.GetOverriddenAnimation(animState);
6918 }
5122 } 6919 }
5123} 6920}