aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs393
1 files changed, 197 insertions, 196 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 6d51fbc..64c6eaa 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -27,7 +27,6 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
31using Axiom.Math; 30using Axiom.Math;
32using libsecondlife; 31using libsecondlife;
33using libsecondlife.Packets; 32using libsecondlife.Packets;
@@ -72,7 +71,8 @@ namespace OpenSim.Region.Environment.Scenes
72 private IScenePresenceBody m_body; 71 private IScenePresenceBody m_body;
73 72
74 private Vector3[] Dir_Vectors = new Vector3[6]; 73 private Vector3[] Dir_Vectors = new Vector3[6];
75 private libsecondlife.LLVector3 lastPhysPos = new libsecondlife.LLVector3(); 74 private LLVector3 lastPhysPos = new LLVector3();
75
76 private enum Dir_ControlFlags 76 private enum Dir_ControlFlags
77 { 77 {
78 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, 78 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS,
@@ -82,48 +82,39 @@ namespace OpenSim.Region.Environment.Scenes
82 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS, 82 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS,
83 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG 83 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG
84 } 84 }
85
85 /// <summary> 86 /// <summary>
86 /// Position at which a significant movement was made 87 /// Position at which a significant movement was made
87 /// </summary> 88 /// </summary>
88 private LLVector3 posLastSignificantMove = new LLVector3(); 89 private LLVector3 posLastSignificantMove = new LLVector3();
89 90
90 public delegate void SignificantClientMovement(IClientAPI remote_client); 91 public delegate void SignificantClientMovement(IClientAPI remote_client);
92
91 public event SignificantClientMovement OnSignificantClientMovement; 93 public event SignificantClientMovement OnSignificantClientMovement;
92 94
93 //public List<SceneObjectGroup> InterestList = new List<SceneObjectGroup>(); 95 //public List<SceneObjectGroup> InterestList = new List<SceneObjectGroup>();
94 96
95 // private Queue<SceneObjectGroup> m_fullGroupUpdates = new Queue<SceneObjectGroup>(); 97 // private Queue<SceneObjectGroup> m_fullGroupUpdates = new Queue<SceneObjectGroup>();
96 // private Queue<SceneObjectGroup> m_terseGroupUpdates = new Queue<SceneObjectGroup>(); 98 // private Queue<SceneObjectGroup> m_terseGroupUpdates = new Queue<SceneObjectGroup>();
97 99
98 private Queue<SceneObjectPart> m_fullPartUpdates = new Queue<SceneObjectPart>(); 100 private Queue<SceneObjectPart> m_fullPartUpdates = new Queue<SceneObjectPart>();
99 private Queue<SceneObjectPart> m_tersePartUpdates = new Queue<SceneObjectPart>(); 101 private Queue<SceneObjectPart> m_tersePartUpdates = new Queue<SceneObjectPart>();
100 102
101 #region Properties 103 #region Properties
104
102 /// <summary> 105 /// <summary>
103 /// 106 ///
104 /// </summary> 107 /// </summary>
105 public PhysicsActor PhysActor 108 public PhysicsActor PhysActor
106 { 109 {
107 set 110 set { _physActor = value; }
108 { 111 get { return _physActor; }
109 this._physActor = value;
110 }
111 get
112 {
113 return _physActor;
114 }
115 } 112 }
116 113
117 public bool Updated 114 public bool Updated
118 { 115 {
119 set 116 set { updateflag = value; }
120 { 117 get { return updateflag; }
121 this.updateflag = value;
122 }
123 get
124 {
125 return this.updateflag;
126 }
127 } 118 }
128 119
129 public ulong RegionHandle 120 public ulong RegionHandle
@@ -132,12 +123,14 @@ namespace OpenSim.Region.Environment.Scenes
132 } 123 }
133 124
134 private string m_firstname; 125 private string m_firstname;
126
135 public string Firstname 127 public string Firstname
136 { 128 {
137 get { return m_firstname; } 129 get { return m_firstname; }
138 } 130 }
139 131
140 private string m_lastname; 132 private string m_lastname;
133
141 public string Lastname 134 public string Lastname
142 { 135 {
143 get { return m_lastname; } 136 get { return m_lastname; }
@@ -146,6 +139,7 @@ namespace OpenSim.Region.Environment.Scenes
146 #endregion 139 #endregion
147 140
148 #region Constructor(s) 141 #region Constructor(s)
142
149 /// <summary> 143 /// <summary>
150 /// 144 ///
151 /// </summary> 145 /// </summary>
@@ -155,19 +149,18 @@ namespace OpenSim.Region.Environment.Scenes
155 /// <param name="regionDat"></param> 149 /// <param name="regionDat"></param>
156 public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo) 150 public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo)
157 { 151 {
158
159 m_scene = world; 152 m_scene = world;
160 this.m_uuid = theClient.AgentId; 153 m_uuid = theClient.AgentId;
161 154
162 m_regionInfo = reginfo; 155 m_regionInfo = reginfo;
163 m_regionHandle = reginfo.RegionHandle; 156 m_regionHandle = reginfo.RegionHandle;
164 MainLog.Instance.Verbose("Avatar.cs "); 157 MainLog.Instance.Verbose("Avatar.cs ");
165 ControllingClient = theClient; 158 ControllingClient = theClient;
166 this.m_firstname = ControllingClient.FirstName; 159 m_firstname = ControllingClient.FirstName;
167 this.m_lastname = ControllingClient.LastName; 160 m_lastname = ControllingClient.LastName;
168 m_localId = m_scene.NextLocalId; 161 m_localId = m_scene.NextLocalId;
169 AbsolutePosition = ControllingClient.StartPos; 162 AbsolutePosition = ControllingClient.StartPos;
170 163
171 visualParams = new byte[218]; 164 visualParams = new byte[218];
172 for (int i = 0; i < 218; i++) 165 for (int i = 0; i < 218; i++)
173 { 166 {
@@ -175,37 +168,37 @@ namespace OpenSim.Region.Environment.Scenes
175 } 168 }
176 169
177 Wearables = AvatarWearable.DefaultWearables; 170 Wearables = AvatarWearable.DefaultWearables;
178 Animations = new ScenePresence.AvatarAnimations(); 171 Animations = new AvatarAnimations();
179 Animations.LoadAnims(); 172 Animations.LoadAnims();
180 173
181 //register for events 174 //register for events
182 ControllingClient.OnRequestWearables += this.SendOurAppearance; 175 ControllingClient.OnRequestWearables += SendOurAppearance;
183 ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); 176 ControllingClient.OnSetAppearance += new SetAppearance(SetAppearance);
184 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement; 177 ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
185 ControllingClient.OnCompleteMovementToRegion += this.SendInitialData; 178 ControllingClient.OnCompleteMovementToRegion += SendInitialData;
186 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate; 179 ControllingClient.OnAgentUpdate += HandleAgentUpdate;
187 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); 180 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
188 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 181 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
189 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 182 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
190 183
191 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD 184 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD
192 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK 185 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK
193 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT 186 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT
194 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT 187 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT
195 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP 188 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP
196 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN 189 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN
197 190
198 this.m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length); 191 m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length);
199 192
200 //temporary until we move some code into the body classes 193 //temporary until we move some code into the body classes
201 this.m_body = new ChildAgent(); 194 m_body = new ChildAgent();
202 195
203 if (newAvatar) 196 if (newAvatar)
204 { 197 {
205 //do we need to use newAvatar? not sure so have added this to kill the compile warning 198 //do we need to use newAvatar? not sure so have added this to kill the compile warning
206 } 199 }
207
208 } 200 }
201
209 #endregion 202 #endregion
210 203
211 public void AddTersePart(SceneObjectPart part) 204 public void AddTersePart(SceneObjectPart part)
@@ -228,10 +221,10 @@ namespace OpenSim.Region.Environment.Scenes
228 while (terse) 221 while (terse)
229 { 222 {
230 SceneObjectPart part = m_tersePartUpdates.Dequeue(); 223 SceneObjectPart part = m_tersePartUpdates.Dequeue();
231 part.SendTerseUpdate(this.ControllingClient); 224 part.SendTerseUpdate(ControllingClient);
232 terseCount++; 225 terseCount++;
233 226
234 if ((m_tersePartUpdates.Count < 1) |(terseCount > 30)) 227 if ((m_tersePartUpdates.Count < 1) | (terseCount > 30))
235 { 228 {
236 terse = false; 229 terse = false;
237 } 230 }
@@ -245,31 +238,30 @@ namespace OpenSim.Region.Environment.Scenes
245 while (full) 238 while (full)
246 { 239 {
247 SceneObjectPart part = m_fullPartUpdates.Dequeue(); 240 SceneObjectPart part = m_fullPartUpdates.Dequeue();
248 part.SendFullUpdate(this.ControllingClient); 241 part.SendFullUpdate(ControllingClient);
249 fullCount++; 242 fullCount++;
250 if ((m_fullPartUpdates.Count < 1) | (fullCount > 40)) 243 if ((m_fullPartUpdates.Count < 1) | (fullCount > 40))
251 { 244 {
252 full = false; 245 full = false;
253 } 246 }
254
255 } 247 }
256 } 248 }
257 } 249 }
258 250
259 #region Status Methods 251 #region Status Methods
252
260 /// <summary> 253 /// <summary>
261 /// Not Used, most likely can be deleted 254 /// Not Used, most likely can be deleted
262 /// </summary> 255 /// </summary>
263 /// <param name="status"></param> 256 /// <param name="status"></param>
264 public void ChildStatusChange(bool status) 257 public void ChildStatusChange(bool status)
265 { 258 {
266 this.childAgent = status; 259 childAgent = status;
267 260
268 if (this.childAgent == true) 261 if (childAgent == true)
269 { 262 {
270 this.Velocity = new LLVector3(0, 0, 0); 263 Velocity = new LLVector3(0, 0, 0);
271 this.AbsolutePosition = new LLVector3(128, 128, 70); 264 AbsolutePosition = new LLVector3(128, 128, 70);
272
273 } 265 }
274 } 266 }
275 267
@@ -280,17 +272,17 @@ namespace OpenSim.Region.Environment.Scenes
280 public void MakeAvatar(LLVector3 pos, bool isFlying) 272 public void MakeAvatar(LLVector3 pos, bool isFlying)
281 { 273 {
282 //this.childAvatar = false; 274 //this.childAvatar = false;
283 this.AbsolutePosition = pos; 275 AbsolutePosition = pos;
284 this._physActor.Flying = isFlying; 276 _physActor.Flying = isFlying;
285 this.newAvatar = true; 277 newAvatar = true;
286 this.childAgent = false; 278 childAgent = false;
287 this.m_scene.SendAllSceneObjectsToClient(this); 279 m_scene.SendAllSceneObjectsToClient(this);
288 } 280 }
289 281
290 protected void MakeChildAgent() 282 protected void MakeChildAgent()
291 { 283 {
292 this.Velocity = new LLVector3(0, 0, 0); 284 Velocity = new LLVector3(0, 0, 0);
293 this.childAgent = true; 285 childAgent = true;
294 //this.Pos = new LLVector3(128, 128, 70); 286 //this.Pos = new LLVector3(128, 128, 70);
295 } 287 }
296 288
@@ -300,8 +292,8 @@ namespace OpenSim.Region.Environment.Scenes
300 /// <param name="pos"></param> 292 /// <param name="pos"></param>
301 public void Teleport(LLVector3 pos) 293 public void Teleport(LLVector3 pos)
302 { 294 {
303 this.AbsolutePosition = pos; 295 AbsolutePosition = pos;
304 this.SendTerseUpdateToALLClients(); 296 SendTerseUpdateToALLClients();
305 } 297 }
306 298
307 /// <summary> 299 /// <summary>
@@ -309,11 +301,12 @@ namespace OpenSim.Region.Environment.Scenes
309 /// </summary> 301 /// </summary>
310 public void StopMovement() 302 public void StopMovement()
311 { 303 {
312
313 } 304 }
305
314 #endregion 306 #endregion
315 307
316 #region Event Handlers 308 #region Event Handlers
309
317 /// <summary> 310 /// <summary>
318 /// 311 ///
319 /// </summary> 312 /// </summary>
@@ -322,14 +315,14 @@ namespace OpenSim.Region.Environment.Scenes
322 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) 315 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
323 { 316 {
324 LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length); 317 LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length);
325 this.m_textureEntry = textureEnt; 318 m_textureEntry = textureEnt;
326 319
327 for (int i = 0; i < visualParam.Length; i++) 320 for (int i = 0; i < visualParam.Length; i++)
328 { 321 {
329 this.visualParams[i] = visualParam[i].ParamValue; 322 visualParams[i] = visualParam[i].ParamValue;
330 } 323 }
331 324
332 this.SendArrearanceToAllOtherAgents(); 325 SendArrearanceToAllOtherAgents();
333 } 326 }
334 327
335 /// <summary> 328 /// <summary>
@@ -337,16 +330,16 @@ namespace OpenSim.Region.Environment.Scenes
337 /// </summary> 330 /// </summary>
338 public void CompleteMovement() 331 public void CompleteMovement()
339 { 332 {
340 LLVector3 look = this.Velocity; 333 LLVector3 look = Velocity;
341 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 334 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
342 { 335 {
343 look = new LLVector3(0.99f, 0.042f, 0); 336 look = new LLVector3(0.99f, 0.042f, 0);
344 } 337 }
345 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 338 ControllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
346 if (this.childAgent) 339 if (childAgent)
347 { 340 {
348 this.childAgent = false; 341 childAgent = false;
349 342
350 //this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient); 343 //this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient);
351 } 344 }
352 } 345 }
@@ -363,47 +356,45 @@ namespace OpenSim.Region.Environment.Scenes
363 bool DCFlagKeyPressed = false; 356 bool DCFlagKeyPressed = false;
364 Vector3 agent_control_v3 = new Vector3(0, 0, 0); 357 Vector3 agent_control_v3 = new Vector3(0, 0, 0);
365 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); 358 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
366 bool oldflying = this.PhysActor.Flying; 359 bool oldflying = PhysActor.Flying;
367 this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); 360 PhysActor.Flying = ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0);
368 if (this.PhysActor.Flying != oldflying) 361 if (PhysActor.Flying != oldflying)
369 { 362 {
370 update_movementflag = true; 363 update_movementflag = true;
371 } 364 }
372 365
373 if (q != this.bodyRot) 366 if (q != bodyRot)
374 { 367 {
375 this.bodyRot = q; 368 bodyRot = q;
376 update_rotation = true; 369 update_rotation = true;
377 } 370 }
378 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) 371 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags)))
379 { 372 {
380 if ((flags & (uint)DCF) != 0) 373 if ((flags & (uint) DCF) != 0)
381 { 374 {
382 DCFlagKeyPressed = true; 375 DCFlagKeyPressed = true;
383 agent_control_v3 += Dir_Vectors[i]; 376 agent_control_v3 += Dir_Vectors[i];
384 if ((movementflag & (uint)DCF) == 0) 377 if ((movementflag & (uint) DCF) == 0)
385 { 378 {
386 movementflag += (byte)(uint)DCF; 379 movementflag += (byte) (uint) DCF;
387 update_movementflag = true; 380 update_movementflag = true;
388 } 381 }
389 } 382 }
390 else 383 else
391 { 384 {
392 if ((movementflag & (uint)DCF) != 0) 385 if ((movementflag & (uint) DCF) != 0)
393 { 386 {
394 movementflag -= (byte)(uint)DCF; 387 movementflag -= (byte) (uint) DCF;
395 update_movementflag = true; 388 update_movementflag = true;
396
397 } 389 }
398 } 390 }
399 i++; 391 i++;
400 } 392 }
401 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed)) 393 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed))
402 { 394 {
403 this.AddNewMovement(agent_control_v3, q); 395 AddNewMovement(agent_control_v3, q);
404 } 396 }
405 UpdateMovementAnimations(update_movementflag); 397 UpdateMovementAnimations(update_movementflag);
406
407 } 398 }
408 399
409 protected void UpdateMovementAnimations(bool update_movementflag) 400 protected void UpdateMovementAnimations(bool update_movementflag)
@@ -412,49 +403,48 @@ namespace OpenSim.Region.Environment.Scenes
412 { 403 {
413 if (movementflag != 0) 404 if (movementflag != 0)
414 { 405 {
415 if (this._physActor.Flying) 406 if (_physActor.Flying)
416 { 407 {
417 this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1); 408 SendAnimPack(Animations.AnimsLLUUID["FLY"], 1);
418 } 409 }
419 else 410 else
420 { 411 {
421 this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); 412 SendAnimPack(Animations.AnimsLLUUID["WALK"], 1);
422 } 413 }
423 } 414 }
424 else 415 else
425 { 416 {
426 this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); 417 SendAnimPack(Animations.AnimsLLUUID["STAND"], 1);
427 } 418 }
428 } 419 }
429
430 } 420 }
431 421
432 422
433 protected void AddNewMovement(Vector3 vec, Quaternion rotation) 423 protected void AddNewMovement(Vector3 vec, Quaternion rotation)
434 { 424 {
435 NewForce newVelocity = new NewForce(); 425 NewForce newVelocity = new NewForce();
436 Vector3 direc = rotation * vec; 426 Vector3 direc = rotation*vec;
437 direc.Normalize(); 427 direc.Normalize();
438 428
439 direc = direc * ((0.03f) * 128f); 429 direc = direc*((0.03f)*128f);
440 if (this._physActor.Flying) 430 if (_physActor.Flying)
441 direc *= 4; 431 direc *= 4;
442 432
443 newVelocity.X = direc.x; 433 newVelocity.X = direc.x;
444 newVelocity.Y = direc.y; 434 newVelocity.Y = direc.y;
445 newVelocity.Z = direc.z; 435 newVelocity.Z = direc.z;
446 this.forcesList.Add(newVelocity); 436 forcesList.Add(newVelocity);
447 } 437 }
448 438
449 #endregion 439 #endregion
450 440
451 #region Overridden Methods 441 #region Overridden Methods
442
452 /// <summary> 443 /// <summary>
453 /// 444 ///
454 /// </summary> 445 /// </summary>
455 public override void LandRenegerated() 446 public override void LandRenegerated()
456 { 447 {
457
458 } 448 }
459 449
460 /// <summary> 450 /// <summary>
@@ -462,63 +452,65 @@ namespace OpenSim.Region.Environment.Scenes
462 /// </summary> 452 /// </summary>
463 public override void Update() 453 public override void Update()
464 { 454 {
465 this.SendPrimUpdates(); 455 SendPrimUpdates();
466 456
467 if (this.newCoarseLocations) { 457 if (newCoarseLocations)
468 this.SendCoarseLocations(); 458 {
469 this.newCoarseLocations = false; 459 SendCoarseLocations();
460 newCoarseLocations = false;
470 } 461 }
471 462
472 if (this.childAgent == false) 463 if (childAgent == false)
473 { 464 {
474
475 /// check for user movement 'forces' (ie commands to move) 465 /// check for user movement 'forces' (ie commands to move)
476 if (this.newForce) 466 if (newForce)
477 { 467 {
478 this.SendTerseUpdateToALLClients(); 468 SendTerseUpdateToALLClients();
479 _updateCount = 0; 469 _updateCount = 0;
480 } 470 }
481 471
482 /// check for scripted movement (?) 472 /// check for scripted movement (?)
483 else if (movementflag != 0) 473 else if (movementflag != 0)
484 { 474 {
485 _updateCount++; 475 _updateCount++;
486 if (_updateCount > 3) 476 if (_updateCount > 3)
487 { 477 {
488 this.SendTerseUpdateToALLClients(); 478 SendTerseUpdateToALLClients();
489 _updateCount = 0; 479 _updateCount = 0;
490 } 480 }
491 } 481 }
492 482
493 /// check for physics-related movement 483 /// check for physics-related movement
494 else if (this.lastPhysPos.GetDistanceTo(this.AbsolutePosition) > 0.02 ) 484 else if (lastPhysPos.GetDistanceTo(AbsolutePosition) > 0.02)
495 { 485 {
496 this.SendTerseUpdateToALLClients(); 486 SendTerseUpdateToALLClients();
497 _updateCount = 0; 487 _updateCount = 0;
498 this.lastPhysPos = this.AbsolutePosition; 488 lastPhysPos = AbsolutePosition;
499 } 489 }
500 this.CheckForSignificantMovement(); 490 CheckForSignificantMovement();
501 this.CheckForBorderCrossing(); 491 CheckForBorderCrossing();
502
503 } 492 }
504 } 493 }
494
505 #endregion 495 #endregion
506 496
507 #region Update Client(s) 497 #region Update Client(s)
498
508 /// <summary> 499 /// <summary>
509 /// 500 ///
510 /// </summary> 501 /// </summary>
511 /// <param name="RemoteClient"></param> 502 /// <param name="RemoteClient"></param>
512 public void SendTerseUpdateToClient(IClientAPI RemoteClient) 503 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
513 { 504 {
514 LLVector3 pos = this.AbsolutePosition; 505 LLVector3 pos = AbsolutePosition;
515 LLVector3 vel = this.Velocity; 506 LLVector3 vel = Velocity;
516 LLQuaternion rot; 507 LLQuaternion rot;
517 rot.X = this.bodyRot.x; 508 rot.X = bodyRot.x;
518 rot.Y = this.bodyRot.y; 509 rot.Y = bodyRot.y;
519 rot.Z = this.bodyRot.z; 510 rot.Z = bodyRot.z;
520 rot.W = this.bodyRot.w; 511 rot.W = bodyRot.w;
521 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z), rot); 512 RemoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z),
513 new LLVector3(vel.X, vel.Y, vel.Z), rot);
522 } 514 }
523 515
524 /// <summary> 516 /// <summary>
@@ -526,42 +518,44 @@ namespace OpenSim.Region.Environment.Scenes
526 /// </summary> 518 /// </summary>
527 public void SendTerseUpdateToALLClients() 519 public void SendTerseUpdateToALLClients()
528 { 520 {
529 List<ScenePresence> avatars = this.m_scene.RequestAvatarList(); 521 List<ScenePresence> avatars = m_scene.RequestAvatarList();
530 for (int i = 0; i < avatars.Count; i++) 522 for (int i = 0; i < avatars.Count; i++)
531 { 523 {
532 this.SendTerseUpdateToClient(avatars[i].ControllingClient); 524 SendTerseUpdateToClient(avatars[i].ControllingClient);
533 } 525 }
534 } 526 }
535 527
536 528
537 public void SendCoarseLocations() 529 public void SendCoarseLocations()
538 { 530 {
539 List<LLVector3> CoarseLocations = new List<LLVector3>(); 531 List<LLVector3> CoarseLocations = new List<LLVector3>();
540 List<ScenePresence> avatars = this.m_scene.RequestAvatarList(); 532 List<ScenePresence> avatars = m_scene.RequestAvatarList();
541 for (int i = 0; i < avatars.Count; i++) 533 for (int i = 0; i < avatars.Count; i++)
542 { 534 {
543 if (avatars[i] != this && (!avatars[i].childAgent) ) { 535 if (avatars[i] != this && (!avatars[i].childAgent))
544 CoarseLocations.Add(avatars[i].AbsolutePosition); 536 {
545 } 537 CoarseLocations.Add(avatars[i].AbsolutePosition);
538 }
546 } 539 }
547 this.ControllingClient.SendCoarseLocationUpdate(CoarseLocations); 540 ControllingClient.SendCoarseLocationUpdate(CoarseLocations);
548 } 541 }
549 542
550 public void CoarseLocationChange(ScenePresence avatar) 543 public void CoarseLocationChange(ScenePresence avatar)
551 { 544 {
552 newCoarseLocations = true; 545 newCoarseLocations = true;
553 } 546 }
554 547
555 private void NotifyMyCoarseLocationChange() 548 private void NotifyMyCoarseLocationChange()
556 { 549 {
557 List<ScenePresence> avatars = this.m_scene.RequestAvatarList(); 550 List<ScenePresence> avatars = m_scene.RequestAvatarList();
558 for (int i = 0; i < avatars.Count; i++) { 551 for (int i = 0; i < avatars.Count; i++)
559 if (avatars[i] != this) { 552 {
560 avatars[i].CoarseLocationChange(this); 553 if (avatars[i] != this)
561 } 554 {
555 avatars[i].CoarseLocationChange(this);
556 }
562 } 557 }
563 558 }
564 }
565 559
566 560
567 /// <summary> 561 /// <summary>
@@ -570,16 +564,17 @@ namespace OpenSim.Region.Environment.Scenes
570 /// <param name="remoteAvatar"></param> 564 /// <param name="remoteAvatar"></param>
571 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) 565 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
572 { 566 {
573 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.m_firstname, this.m_lastname, this.m_uuid, this.LocalId, this.AbsolutePosition, this.m_textureEntry.ToBytes()); 567 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid,
568 LocalId, AbsolutePosition, m_textureEntry.ToBytes());
574 } 569 }
575 570
576 public void SendFullUpdateToALLClients() 571 public void SendFullUpdateToALLClients()
577 { 572 {
578 List<ScenePresence> avatars = this.m_scene.RequestAvatarList(); 573 List<ScenePresence> avatars = m_scene.RequestAvatarList();
579 foreach (ScenePresence avatar in this.m_scene.RequestAvatarList()) 574 foreach (ScenePresence avatar in m_scene.RequestAvatarList())
580 { 575 {
581 this.SendFullUpdateToOtherClient(avatar); 576 SendFullUpdateToOtherClient(avatar);
582 if (avatar.LocalId != this.LocalId) 577 if (avatar.LocalId != LocalId)
583 { 578 {
584 if (!avatar.childAgent) 579 if (!avatar.childAgent)
585 { 580 {
@@ -595,15 +590,16 @@ namespace OpenSim.Region.Environment.Scenes
595 /// </summary> 590 /// </summary>
596 public void SendInitialData() 591 public void SendInitialData()
597 { 592 {
598 this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.m_firstname, this.m_lastname, this.m_uuid, this.LocalId, this.AbsolutePosition, this.m_textureEntry.ToBytes()); 593 ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId,
599 if (!this.childAgent) 594 AbsolutePosition, m_textureEntry.ToBytes());
595 if (!childAgent)
600 { 596 {
601 this.m_scene.InformClientOfNeighbours(this.ControllingClient); 597 m_scene.InformClientOfNeighbours(ControllingClient);
602 this.newAvatar = false; 598 newAvatar = false;
603 } 599 }
604 600
605 this.SendFullUpdateToALLClients(); 601 SendFullUpdateToALLClients();
606 this.SendArrearanceToAllOtherAgents(); 602 SendArrearanceToAllOtherAgents();
607 } 603 }
608 604
609 /// <summary> 605 /// <summary>
@@ -612,13 +608,13 @@ namespace OpenSim.Region.Environment.Scenes
612 /// <param name="OurClient"></param> 608 /// <param name="OurClient"></param>
613 public void SendOurAppearance(IClientAPI OurClient) 609 public void SendOurAppearance(IClientAPI OurClient)
614 { 610 {
615 this.ControllingClient.SendWearables(this.Wearables); 611 ControllingClient.SendWearables(Wearables);
616 612
617 //this.SendFullUpdateToALLClients(); 613 //this.SendFullUpdateToALLClients();
618 //this.SendArrearanceToAllOtherAgents(); 614 //this.SendArrearanceToAllOtherAgents();
619 615
620 this.m_scene.SendAllSceneObjectsToClient(this); 616 m_scene.SendAllSceneObjectsToClient(this);
621 this.ControllingClient.SendViewerTime(this.m_scene.TimePhase); 617 ControllingClient.SendViewerTime(m_scene.TimePhase);
622 618
623 //Please don't remove the following code (at least not yet), just leave it commented out 619 //Please don't remove the following code (at least not yet), just leave it commented out
624 //gives the user god powers, should help with debuging things in the future 620 //gives the user god powers, should help with debuging things in the future
@@ -636,10 +632,10 @@ namespace OpenSim.Region.Environment.Scenes
636 /// </summary> 632 /// </summary>
637 public void SendArrearanceToAllOtherAgents() 633 public void SendArrearanceToAllOtherAgents()
638 { 634 {
639 List<ScenePresence> avatars = this.m_scene.RequestAvatarList(); 635 List<ScenePresence> avatars = m_scene.RequestAvatarList();
640 foreach (ScenePresence avatar in this.m_scene.RequestAvatarList()) 636 foreach (ScenePresence avatar in m_scene.RequestAvatarList())
641 { 637 {
642 this.SendAppearanceToOtherAgent(avatar); 638 SendAppearanceToOtherAgent(avatar);
643 } 639 }
644 } 640 }
645 641
@@ -649,7 +645,8 @@ namespace OpenSim.Region.Environment.Scenes
649 /// <param name="avatarInfo"></param> 645 /// <param name="avatarInfo"></param>
650 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) 646 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
651 { 647 {
652 avatarInfo.ControllingClient.SendAppearance(this.ControllingClient.AgentId, this.visualParams, this.m_textureEntry.ToBytes()); 648 avatarInfo.ControllingClient.SendAppearance(ControllingClient.AgentId, visualParams,
649 m_textureEntry.ToBytes());
653 } 650 }
654 651
655 /// <summary> 652 /// <summary>
@@ -659,12 +656,12 @@ namespace OpenSim.Region.Environment.Scenes
659 /// <param name="seq"></param> 656 /// <param name="seq"></param>
660 public void SendAnimPack(LLUUID animID, int seq) 657 public void SendAnimPack(LLUUID animID, int seq)
661 { 658 {
662 this.current_anim = animID; 659 current_anim = animID;
663 this.anim_seq = seq; 660 anim_seq = seq;
664 List<ScenePresence> avatars = this.m_scene.RequestAvatarList(); 661 List<ScenePresence> avatars = m_scene.RequestAvatarList();
665 for (int i = 0; i < avatars.Count; i++) 662 for (int i = 0; i < avatars.Count; i++)
666 { 663 {
667 avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId); 664 avatars[i].ControllingClient.SendAnimation(animID, seq, ControllingClient.AgentId);
668 } 665 }
669 } 666 }
670 667
@@ -673,48 +670,51 @@ namespace OpenSim.Region.Environment.Scenes
673 /// </summary> 670 /// </summary>
674 public void SendAnimPack() 671 public void SendAnimPack()
675 { 672 {
676 this.SendAnimPack(this.current_anim, this.anim_seq); 673 SendAnimPack(current_anim, anim_seq);
677 } 674 }
675
678 #endregion 676 #endregion
679 677
680 #region Significant Movement Method 678 #region Significant Movement Method
681 679
682 protected void CheckForSignificantMovement() 680 protected void CheckForSignificantMovement()
683 { 681 {
684 if (libsecondlife.Helpers.VecDist(this.AbsolutePosition, this.posLastSignificantMove) > 2.0) 682 if (Helpers.VecDist(AbsolutePosition, posLastSignificantMove) > 2.0)
685 { 683 {
686 this.posLastSignificantMove = this.AbsolutePosition; 684 posLastSignificantMove = AbsolutePosition;
687 if (OnSignificantClientMovement != null) 685 if (OnSignificantClientMovement != null)
688 { 686 {
689 OnSignificantClientMovement(this.ControllingClient); 687 OnSignificantClientMovement(ControllingClient);
690 NotifyMyCoarseLocationChange(); 688 NotifyMyCoarseLocationChange();
691 } 689 }
692 } 690 }
693 } 691 }
692
694 #endregion 693 #endregion
695 694
696 #region Border Crossing Methods 695 #region Border Crossing Methods
696
697 /// <summary> 697 /// <summary>
698 /// 698 ///
699 /// </summary> 699 /// </summary>
700 protected void CheckForBorderCrossing() 700 protected void CheckForBorderCrossing()
701 { 701 {
702 LLVector3 pos2 = this.AbsolutePosition; 702 LLVector3 pos2 = AbsolutePosition;
703 LLVector3 vel = this.Velocity; 703 LLVector3 vel = Velocity;
704 704
705 float timeStep = 0.1f; 705 float timeStep = 0.1f;
706 pos2.X = pos2.X + (vel.X * timeStep); 706 pos2.X = pos2.X + (vel.X*timeStep);
707 pos2.Y = pos2.Y + (vel.Y * timeStep); 707 pos2.Y = pos2.Y + (vel.Y*timeStep);
708 pos2.Z = pos2.Z + (vel.Z * timeStep); 708 pos2.Z = pos2.Z + (vel.Z*timeStep);
709 709
710 if ((pos2.X < 0) || (pos2.X > 256)) 710 if ((pos2.X < 0) || (pos2.X > 256))
711 { 711 {
712 this.CrossToNewRegion(); 712 CrossToNewRegion();
713 } 713 }
714 714
715 if ((pos2.Y < 0) || (pos2.Y > 256)) 715 if ((pos2.Y < 0) || (pos2.Y > 256))
716 { 716 {
717 this.CrossToNewRegion(); 717 CrossToNewRegion();
718 } 718 }
719 } 719 }
720 720
@@ -723,10 +723,10 @@ namespace OpenSim.Region.Environment.Scenes
723 /// </summary> 723 /// </summary>
724 protected void CrossToNewRegion() 724 protected void CrossToNewRegion()
725 { 725 {
726 LLVector3 pos = this.AbsolutePosition; 726 LLVector3 pos = AbsolutePosition;
727 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z); 727 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z);
728 uint neighbourx = this.m_regionInfo.RegionLocX; 728 uint neighbourx = m_regionInfo.RegionLocX;
729 uint neighboury = this.m_regionInfo.RegionLocY; 729 uint neighboury = m_regionInfo.RegionLocY;
730 730
731 if (pos.X < 1.7F) 731 if (pos.X < 1.7F)
732 { 732 {
@@ -749,24 +749,28 @@ namespace OpenSim.Region.Environment.Scenes
749 newpos.Y = 0.1F; 749 newpos.Y = 0.1F;
750 } 750 }
751 751
752 LLVector3 vel = this.m_velocity; 752 LLVector3 vel = m_velocity;
753 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); 753 ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256));
754 RegionInfo neighbourRegion = this.m_scene.RequestNeighbouringRegionInfo(neighbourHandle); 754 RegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
755 if (neighbourRegion != null) 755 if (neighbourRegion != null)
756 { 756 {
757 bool res = this.m_scene.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos, this._physActor.Flying); 757 bool res =
758 m_scene.InformNeighbourOfCrossing(neighbourHandle, ControllingClient.AgentId, newpos,
759 _physActor.Flying);
758 if (res) 760 if (res)
759 { 761 {
760 //TODO: following line is hard coded to port 9000, really need to change this as soon as possible 762 //TODO: following line is hard coded to port 9000, really need to change this as soon as possible
761 AgentCircuitData circuitdata = this.ControllingClient.RequestClientInfo(); 763 AgentCircuitData circuitdata = ControllingClient.RequestClientInfo();
762 string capsPath = Util.GetCapsURL(this.ControllingClient.AgentId); 764 string capsPath = Util.GetCapsURL(ControllingClient.AgentId);
763 this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, capsPath); 765 ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint,
764 this.MakeChildAgent(); 766 capsPath);
765 this.m_scene.SendKillObject(this.m_localId); 767 MakeChildAgent();
766 this.NotifyMyCoarseLocationChange(); 768 m_scene.SendKillObject(m_localId);
769 NotifyMyCoarseLocationChange();
767 } 770 }
768 } 771 }
769 } 772 }
773
770 #endregion 774 #endregion
771 775
772 /// <summary> 776 /// <summary>
@@ -774,7 +778,6 @@ namespace OpenSim.Region.Environment.Scenes
774 /// </summary> 778 /// </summary>
775 public static void LoadAnims() 779 public static void LoadAnims()
776 { 780 {
777
778 } 781 }
779 782
780 /// <summary> 783 /// <summary>
@@ -783,21 +786,21 @@ namespace OpenSim.Region.Environment.Scenes
783 public override void UpdateMovement() 786 public override void UpdateMovement()
784 { 787 {
785 newForce = false; 788 newForce = false;
786 lock (this.forcesList) 789 lock (forcesList)
787 { 790 {
788 if (this.forcesList.Count > 0) 791 if (forcesList.Count > 0)
789 { 792 {
790 for (int i = 0; i < this.forcesList.Count; i++) 793 for (int i = 0; i < forcesList.Count; i++)
791 { 794 {
792 NewForce force = this.forcesList[i]; 795 NewForce force = forcesList[i];
793 796
794 this.updateflag = true; 797 updateflag = true;
795 this.Velocity = new LLVector3(force.X, force.Y, force.Z); 798 Velocity = new LLVector3(force.X, force.Y, force.Z);
796 this.newForce = true; 799 newForce = true;
797 } 800 }
798 for (int i = 0; i < this.forcesList.Count; i++) 801 for (int i = 0; i < forcesList.Count; i++)
799 { 802 {
800 this.forcesList.RemoveAt(0); 803 forcesList.RemoveAt(0);
801 } 804 }
802 } 805 }
803 } 806 }
@@ -824,7 +827,6 @@ namespace OpenSim.Region.Environment.Scenes
824 827
825 public NewForce() 828 public NewForce()
826 { 829 {
827
828 } 830 }
829 } 831 }
830 832
@@ -833,5 +835,4 @@ namespace OpenSim.Region.Environment.Scenes
833 throw new Exception("The method or operation is not implemented."); 835 throw new Exception("The method or operation is not implemented.");
834 } 836 }
835 } 837 }
836 838} \ No newline at end of file
837}