diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1395 |
1 files changed, 970 insertions, 425 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f049b78..925a4f3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Timers; | 32 | using System.Timers; |
@@ -72,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
72 | // { | 73 | // { |
73 | // m_log.Debug("[SCENE PRESENCE] Destructor called"); | 74 | // m_log.Debug("[SCENE PRESENCE] Destructor called"); |
74 | // } | 75 | // } |
75 | 76 | ||
76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 77 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
77 | 78 | ||
78 | public PresenceType PresenceType { get; private set; } | 79 | public PresenceType PresenceType { get; private set; } |
@@ -89,7 +90,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
89 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 90 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
90 | /// issue #1716 | 91 | /// issue #1716 |
91 | /// </summary> | 92 | /// </summary> |
92 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | 93 | // private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); |
94 | // Value revised by KF 091121 by comparison with SL. | ||
95 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | ||
93 | 96 | ||
94 | /// <summary> | 97 | /// <summary> |
95 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 98 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -100,16 +103,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
100 | 103 | ||
101 | public UUID currentParcelUUID = UUID.Zero; | 104 | public UUID currentParcelUUID = UUID.Zero; |
102 | 105 | ||
103 | private ISceneViewer m_sceneViewer; | 106 | protected ScenePresenceAnimator m_animator; |
104 | |||
105 | /// <value> | 107 | /// <value> |
106 | /// The animator for this avatar | 108 | /// The animator for this avatar |
107 | /// </value> | 109 | /// </value> |
108 | public ScenePresenceAnimator Animator | 110 | public ScenePresenceAnimator Animator |
109 | { | 111 | { |
110 | get { return m_animator; } | 112 | get { return m_animator; } |
113 | private set { m_animator = value; } | ||
111 | } | 114 | } |
112 | protected ScenePresenceAnimator m_animator; | ||
113 | 115 | ||
114 | /// <summary> | 116 | /// <summary> |
115 | /// Attachments recorded on this avatar. | 117 | /// Attachments recorded on this avatar. |
@@ -118,6 +120,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
118 | /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is | 120 | /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is |
119 | /// necessary. | 121 | /// necessary. |
120 | /// </remarks> | 122 | /// </remarks> |
123 | |||
121 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | 124 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); |
122 | 125 | ||
123 | public Object AttachmentsSyncLock { get; private set; } | 126 | public Object AttachmentsSyncLock { get; private set; } |
@@ -131,15 +134,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
131 | public Vector3 lastKnownAllowedPosition; | 134 | public Vector3 lastKnownAllowedPosition; |
132 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 135 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
133 | public Vector4 CollisionPlane = Vector4.UnitW; | 136 | public Vector4 CollisionPlane = Vector4.UnitW; |
134 | 137 | ||
138 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | ||
139 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims | ||
135 | private Vector3 m_lastPosition; | 140 | private Vector3 m_lastPosition; |
141 | private Vector3 m_lastWorldPosition; | ||
136 | private Quaternion m_lastRotation; | 142 | private Quaternion m_lastRotation; |
137 | private Vector3 m_lastVelocity; | 143 | private Vector3 m_lastVelocity; |
138 | //private int m_lastTerseSent; | 144 | //private int m_lastTerseSent; |
139 | 145 | ||
140 | private bool m_updateflag; | ||
141 | private byte m_movementflag; | ||
142 | private Vector3? m_forceToApply; | 146 | private Vector3? m_forceToApply; |
147 | private int m_userFlags; | ||
148 | public int UserFlags | ||
149 | { | ||
150 | get { return m_userFlags; } | ||
151 | } | ||
143 | private TeleportFlags m_teleportFlags; | 152 | private TeleportFlags m_teleportFlags; |
144 | public TeleportFlags TeleportFlags | 153 | public TeleportFlags TeleportFlags |
145 | { | 154 | { |
@@ -159,24 +168,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
159 | 168 | ||
160 | private float m_sitAvatarHeight = 2.0f; | 169 | private float m_sitAvatarHeight = 2.0f; |
161 | 170 | ||
162 | private int m_godLevel; | ||
163 | private int m_userLevel; | ||
164 | |||
165 | private bool m_invulnerable = true; | ||
166 | |||
167 | private Vector3 m_lastChildAgentUpdatePosition; | 171 | private Vector3 m_lastChildAgentUpdatePosition; |
168 | private Vector3 m_lastChildAgentUpdateCamPosition; | 172 | private Vector3 m_lastChildAgentUpdateCamPosition; |
169 | 173 | ||
170 | private int m_perfMonMS; | 174 | private int m_perfMonMS; |
171 | 175 | ||
172 | private bool m_setAlwaysRun; | 176 | private bool m_flyingOld; // add for fly velocity control |
173 | 177 | public bool m_wasFlying; // add for fly velocity control | |
174 | private bool m_forceFly; | ||
175 | private bool m_flyDisabled; | ||
176 | |||
177 | private float m_speedModifier = 1.0f; | ||
178 | |||
179 | private Quaternion m_bodyRot = Quaternion.Identity; | ||
180 | 178 | ||
181 | private const int LAND_VELOCITYMAG_MAX = 12; | 179 | private const int LAND_VELOCITYMAG_MAX = 12; |
182 | 180 | ||
@@ -188,24 +186,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
188 | 186 | ||
189 | protected ulong crossingFromRegion; | 187 | protected ulong crossingFromRegion; |
190 | 188 | ||
191 | private readonly Vector3[] Dir_Vectors = new Vector3[9]; | 189 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
190 | private bool m_isNudging = false; | ||
192 | 191 | ||
193 | // Position of agent's camera in world (region cordinates) | ||
194 | protected Vector3 m_CameraCenter; | ||
195 | protected Vector3 m_lastCameraCenter; | ||
196 | 192 | ||
197 | protected Timer m_reprioritization_timer; | 193 | protected Timer m_reprioritization_timer; |
198 | protected bool m_reprioritizing; | 194 | protected bool m_reprioritizing; |
199 | protected bool m_reprioritization_called; | 195 | protected bool m_reprioritization_called; |
200 | 196 | ||
201 | // Use these three vectors to figure out what the agent is looking at | ||
202 | // Convert it to a Matrix and/or Quaternion | ||
203 | protected Vector3 m_CameraAtAxis; | ||
204 | protected Vector3 m_CameraLeftAxis; | ||
205 | protected Vector3 m_CameraUpAxis; | ||
206 | private AgentManager.ControlFlags m_AgentControlFlags; | ||
207 | private Quaternion m_headrotation = Quaternion.Identity; | 197 | private Quaternion m_headrotation = Quaternion.Identity; |
208 | private byte m_state; | ||
209 | 198 | ||
210 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method | 199 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method |
211 | // private Vector3 movementvector; | 200 | // private Vector3 movementvector; |
@@ -213,12 +202,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
213 | private bool m_autopilotMoving; | 202 | private bool m_autopilotMoving; |
214 | private Vector3 m_autoPilotTarget; | 203 | private Vector3 m_autoPilotTarget; |
215 | private bool m_sitAtAutoTarget; | 204 | private bool m_sitAtAutoTarget; |
205 | private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit | ||
216 | 206 | ||
217 | private string m_nextSitAnimation = String.Empty; | 207 | private string m_nextSitAnimation = String.Empty; |
218 | 208 | ||
219 | //PauPaw:Proper PID Controler for autopilot************ | 209 | //PauPaw:Proper PID Controler for autopilot************ |
220 | public bool MovingToTarget { get; private set; } | 210 | public bool MovingToTarget { get; private set; } |
221 | public Vector3 MoveToPositionTarget { get; private set; } | 211 | public Vector3 MoveToPositionTarget { get; private set; } |
212 | private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
222 | 213 | ||
223 | /// <summary> | 214 | /// <summary> |
224 | /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying). | 215 | /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying). |
@@ -228,17 +219,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
228 | private bool m_followCamAuto; | 219 | private bool m_followCamAuto; |
229 | 220 | ||
230 | private int m_movementUpdateCount; | 221 | private int m_movementUpdateCount; |
222 | private int m_lastColCount = -1; //KF: Look for Collision chnages | ||
223 | private int m_updateCount = 0; //KF: Update Anims for a while | ||
224 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | ||
231 | private const int NumMovementsBetweenRayCast = 5; | 225 | private const int NumMovementsBetweenRayCast = 5; |
226 | private List<uint> m_lastColliders = new List<uint>(); | ||
227 | |||
228 | private object m_syncRoot = new Object(); | ||
232 | 229 | ||
233 | private bool CameraConstraintActive; | 230 | private bool CameraConstraintActive; |
234 | //private int m_moveToPositionStateStatus; | 231 | //private int m_moveToPositionStateStatus; |
235 | //***************************************************** | 232 | //***************************************************** |
236 | 233 | ||
237 | // Agent's Draw distance. | ||
238 | protected float m_DrawDistance; | ||
239 | |||
240 | protected AvatarAppearance m_appearance; | 234 | protected AvatarAppearance m_appearance; |
241 | 235 | ||
236 | public AvatarAppearance Appearance | ||
237 | { | ||
238 | get { return m_appearance; } | ||
239 | set | ||
240 | { | ||
241 | m_appearance = value; | ||
242 | // m_log.DebugFormat("[SCENE PRESENCE]: Set appearance for {0} to {1}", Name, value); | ||
243 | } | ||
244 | } | ||
245 | |||
246 | |||
242 | // neighbouring regions we have enabled a child agent in | 247 | // neighbouring regions we have enabled a child agent in |
243 | // holds the seed cap for the child agent in that region | 248 | // holds the seed cap for the child agent in that region |
244 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); | 249 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); |
@@ -250,6 +255,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
250 | public List<string> InTransitScriptStates | 255 | public List<string> InTransitScriptStates |
251 | { | 256 | { |
252 | get { return m_InTransitScriptStates; } | 257 | get { return m_InTransitScriptStates; } |
258 | private set { m_InTransitScriptStates = value; } | ||
253 | } | 259 | } |
254 | private List<string> m_InTransitScriptStates = new List<string>(); | 260 | private List<string> m_InTransitScriptStates = new List<string>(); |
255 | 261 | ||
@@ -265,7 +271,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 271 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
266 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 272 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, |
267 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, | 273 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, |
268 | DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, | 274 | DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, |
275 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, | ||
276 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, | ||
269 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 277 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
270 | } | 278 | } |
271 | 279 | ||
@@ -278,8 +286,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
278 | string m_callbackURI; | 286 | string m_callbackURI; |
279 | UUID m_originRegionID; | 287 | UUID m_originRegionID; |
280 | 288 | ||
281 | ulong m_rootRegionHandle; | ||
282 | |||
283 | /// <value> | 289 | /// <value> |
284 | /// Script engines present in the scene | 290 | /// Script engines present in the scene |
285 | /// </value> | 291 | /// </value> |
@@ -287,6 +293,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
287 | 293 | ||
288 | #region Properties | 294 | #region Properties |
289 | 295 | ||
296 | protected PhysicsActor m_physicsActor; | ||
297 | |||
290 | /// <summary> | 298 | /// <summary> |
291 | /// Physical scene representation of this Avatar. | 299 | /// Physical scene representation of this Avatar. |
292 | /// </summary> | 300 | /// </summary> |
@@ -296,69 +304,102 @@ namespace OpenSim.Region.Framework.Scenes | |||
296 | get { return m_physicsActor; } | 304 | get { return m_physicsActor; } |
297 | } | 305 | } |
298 | 306 | ||
307 | private byte m_movementflag; | ||
308 | |||
299 | public byte MovementFlag | 309 | public byte MovementFlag |
300 | { | 310 | { |
301 | set { m_movementflag = value; } | 311 | set { m_movementflag = value; } |
302 | get { return m_movementflag; } | 312 | get { return m_movementflag; } |
303 | } | 313 | } |
304 | 314 | ||
315 | private bool m_updateflag; | ||
316 | |||
305 | public bool Updated | 317 | public bool Updated |
306 | { | 318 | { |
307 | set { m_updateflag = value; } | 319 | set { m_updateflag = value; } |
308 | get { return m_updateflag; } | 320 | get { return m_updateflag; } |
309 | } | 321 | } |
310 | 322 | ||
323 | private bool m_invulnerable = true; | ||
324 | |||
311 | public bool Invulnerable | 325 | public bool Invulnerable |
312 | { | 326 | { |
313 | set { m_invulnerable = value; } | 327 | set { m_invulnerable = value; } |
314 | get { return m_invulnerable; } | 328 | get { return m_invulnerable; } |
315 | } | 329 | } |
316 | 330 | ||
331 | private int m_userLevel; | ||
332 | |||
317 | public int UserLevel | 333 | public int UserLevel |
318 | { | 334 | { |
319 | get { return m_userLevel; } | 335 | get { return m_userLevel; } |
336 | private set { m_userLevel = value; } | ||
320 | } | 337 | } |
321 | 338 | ||
339 | private int m_godLevel; | ||
340 | |||
322 | public int GodLevel | 341 | public int GodLevel |
323 | { | 342 | { |
324 | get { return m_godLevel; } | 343 | get { return m_godLevel; } |
344 | private set { m_godLevel = value; } | ||
325 | } | 345 | } |
326 | 346 | ||
347 | private ulong m_rootRegionHandle; | ||
348 | |||
327 | public ulong RegionHandle | 349 | public ulong RegionHandle |
328 | { | 350 | { |
329 | get { return m_rootRegionHandle; } | 351 | get { return m_rootRegionHandle; } |
352 | private set { m_rootRegionHandle = value; } | ||
330 | } | 353 | } |
331 | 354 | ||
355 | #region Client Camera | ||
356 | // Position of agent's camera in world (region cordinates) | ||
357 | protected Vector3 m_lastCameraPosition; | ||
358 | |||
359 | protected Vector3 m_CameraPosition; | ||
360 | |||
332 | public Vector3 CameraPosition | 361 | public Vector3 CameraPosition |
333 | { | 362 | { |
334 | get { return m_CameraCenter; } | 363 | get { return m_CameraPosition; } |
364 | private set { m_CameraPosition = value; } | ||
335 | } | 365 | } |
336 | 366 | ||
337 | public Quaternion CameraRotation | 367 | public Quaternion CameraRotation |
338 | { | 368 | { |
339 | get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } | 369 | get { return Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis); } |
340 | } | 370 | } |
341 | 371 | ||
372 | // Use these three vectors to figure out what the agent is looking at | ||
373 | // Convert it to a Matrix and/or Quaternion | ||
374 | // | ||
375 | protected Vector3 m_CameraAtAxis; | ||
376 | protected Vector3 m_CameraLeftAxis; | ||
377 | protected Vector3 m_CameraUpAxis; | ||
378 | |||
342 | public Vector3 CameraAtAxis | 379 | public Vector3 CameraAtAxis |
343 | { | 380 | { |
344 | get { return m_CameraAtAxis; } | 381 | get { return m_CameraAtAxis; } |
382 | private set { m_CameraAtAxis = value; } | ||
345 | } | 383 | } |
346 | 384 | ||
385 | |||
347 | public Vector3 CameraLeftAxis | 386 | public Vector3 CameraLeftAxis |
348 | { | 387 | { |
349 | get { return m_CameraLeftAxis; } | 388 | get { return m_CameraLeftAxis; } |
389 | private set { m_CameraLeftAxis = value; } | ||
350 | } | 390 | } |
351 | 391 | ||
352 | public Vector3 CameraUpAxis | 392 | public Vector3 CameraUpAxis |
353 | { | 393 | { |
354 | get { return m_CameraUpAxis; } | 394 | get { return m_CameraUpAxis; } |
395 | private set { m_CameraUpAxis = value; } | ||
355 | } | 396 | } |
356 | 397 | ||
357 | public Vector3 Lookat | 398 | public Vector3 Lookat |
358 | { | 399 | { |
359 | get | 400 | get |
360 | { | 401 | { |
361 | Vector3 a = new Vector3(m_CameraAtAxis.X, m_CameraAtAxis.Y, 0); | 402 | Vector3 a = new Vector3(CameraAtAxis.X, CameraAtAxis.Y, 0); |
362 | 403 | ||
363 | if (a == Vector3.Zero) | 404 | if (a == Vector3.Zero) |
364 | return a; | 405 | return a; |
@@ -366,20 +407,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
366 | return Util.GetNormalizedVector(a); | 407 | return Util.GetNormalizedVector(a); |
367 | } | 408 | } |
368 | } | 409 | } |
410 | #endregion | ||
369 | 411 | ||
370 | private readonly string m_firstname; | 412 | public readonly string Firstname; |
371 | 413 | public readonly string Lastname; | |
372 | public string Firstname | ||
373 | { | ||
374 | get { return m_firstname; } | ||
375 | } | ||
376 | |||
377 | private readonly string m_lastname; | ||
378 | |||
379 | public string Lastname | ||
380 | { | ||
381 | get { return m_lastname; } | ||
382 | } | ||
383 | 414 | ||
384 | private string m_grouptitle; | 415 | private string m_grouptitle; |
385 | 416 | ||
@@ -389,9 +420,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | set { m_grouptitle = value; } | 420 | set { m_grouptitle = value; } |
390 | } | 421 | } |
391 | 422 | ||
423 | // Agent's Draw distance. | ||
424 | protected float m_DrawDistance; | ||
425 | |||
392 | public float DrawDistance | 426 | public float DrawDistance |
393 | { | 427 | { |
394 | get { return m_DrawDistance; } | 428 | get { return m_DrawDistance; } |
429 | private set { m_DrawDistance = value; } | ||
395 | } | 430 | } |
396 | 431 | ||
397 | protected bool m_allowMovement = true; | 432 | protected bool m_allowMovement = true; |
@@ -402,6 +437,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
402 | set { m_allowMovement = value; } | 437 | set { m_allowMovement = value; } |
403 | } | 438 | } |
404 | 439 | ||
440 | private bool m_setAlwaysRun; | ||
441 | |||
405 | public bool SetAlwaysRun | 442 | public bool SetAlwaysRun |
406 | { | 443 | { |
407 | get | 444 | get |
@@ -425,12 +462,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
425 | } | 462 | } |
426 | } | 463 | } |
427 | 464 | ||
465 | private byte m_state; | ||
466 | |||
428 | public byte State | 467 | public byte State |
429 | { | 468 | { |
430 | get { return m_state; } | 469 | get { return m_state; } |
431 | set { m_state = value; } | 470 | set { m_state = value; } |
432 | } | 471 | } |
433 | 472 | ||
473 | private AgentManager.ControlFlags m_AgentControlFlags; | ||
474 | |||
434 | public uint AgentControlFlags | 475 | public uint AgentControlFlags |
435 | { | 476 | { |
436 | get { return (uint)m_AgentControlFlags; } | 477 | get { return (uint)m_AgentControlFlags; } |
@@ -442,11 +483,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
442 | /// </summary> | 483 | /// </summary> |
443 | private IClientAPI m_controllingClient; | 484 | private IClientAPI m_controllingClient; |
444 | 485 | ||
445 | protected PhysicsActor m_physicsActor; | ||
446 | |||
447 | public IClientAPI ControllingClient | 486 | public IClientAPI ControllingClient |
448 | { | 487 | { |
449 | get { return m_controllingClient; } | 488 | get { return m_controllingClient; } |
489 | private set { m_controllingClient = value; } | ||
450 | } | 490 | } |
451 | 491 | ||
452 | public IClientCore ClientView | 492 | public IClientCore ClientView |
@@ -455,6 +495,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
455 | } | 495 | } |
456 | 496 | ||
457 | protected Vector3 m_parentPosition; | 497 | protected Vector3 m_parentPosition; |
498 | |||
458 | public Vector3 ParentPosition | 499 | public Vector3 ParentPosition |
459 | { | 500 | { |
460 | get { return m_parentPosition; } | 501 | get { return m_parentPosition; } |
@@ -469,8 +510,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
469 | get | 510 | get |
470 | { | 511 | { |
471 | PhysicsActor actor = m_physicsActor; | 512 | PhysicsActor actor = m_physicsActor; |
472 | if (actor != null) | 513 | // if (actor != null) |
473 | { | 514 | if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! |
515 | { | ||
474 | m_pos = actor.Position; | 516 | m_pos = actor.Position; |
475 | 517 | ||
476 | // m_log.DebugFormat( | 518 | // m_log.DebugFormat( |
@@ -484,7 +526,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
484 | // the avatar is seated, this value will also | 526 | // the avatar is seated, this value will also |
485 | // be used as the location to unsit to. | 527 | // be used as the location to unsit to. |
486 | // | 528 | // |
487 | // If m_parentID is not 0, assume we are a seated avatar | 529 | // If ParentID is not 0, assume we are a seated avatar |
488 | // and we should return the position based on the sittarget | 530 | // and we should return the position based on the sittarget |
489 | // offset and rotation of the prim we are seated on. | 531 | // offset and rotation of the prim we are seated on. |
490 | // | 532 | // |
@@ -492,16 +534,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
492 | // in the sim unless the avatar is on a sit target. While | 534 | // in the sim unless the avatar is on a sit target. While |
493 | // on a sit target, m_pos will contain the desired offset | 535 | // on a sit target, m_pos will contain the desired offset |
494 | // without the parent rotation applied. | 536 | // without the parent rotation applied. |
495 | if (m_parentID != 0) | 537 | if (ParentID != 0) |
496 | { | 538 | { |
497 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | 539 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); |
498 | if (part != null) | 540 | if (part != null) |
499 | { | 541 | { |
500 | return m_parentPosition + (m_pos * part.GetWorldRotation()); | 542 | return part.AbsolutePosition + (m_pos * part.GetWorldRotation()); |
501 | } | 543 | } |
502 | else | 544 | else |
503 | { | 545 | { |
504 | return m_parentPosition + m_pos; | 546 | return ParentPosition + m_pos; |
505 | } | 547 | } |
506 | } | 548 | } |
507 | } | 549 | } |
@@ -510,13 +552,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
510 | } | 552 | } |
511 | set | 553 | set |
512 | { | 554 | { |
513 | PhysicsActor actor = m_physicsActor; | 555 | if (PhysicsActor != null) |
514 | if (actor != null) | ||
515 | { | 556 | { |
516 | try | 557 | try |
517 | { | 558 | { |
518 | lock (m_scene.SyncRoot) | 559 | lock (m_scene.SyncRoot) |
519 | m_physicsActor.Position = value; | 560 | PhysicsActor.Position = value; |
520 | } | 561 | } |
521 | catch (Exception e) | 562 | catch (Exception e) |
522 | { | 563 | { |
@@ -524,7 +565,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
524 | } | 565 | } |
525 | } | 566 | } |
526 | 567 | ||
527 | m_pos = value; | 568 | // Changed this to update unconditionally to make npose work |
569 | // if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! | ||
570 | m_pos = value; | ||
528 | m_parentPosition = Vector3.Zero; | 571 | m_parentPosition = Vector3.Zero; |
529 | 572 | ||
530 | // m_log.DebugFormat( | 573 | // m_log.DebugFormat( |
@@ -549,10 +592,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
549 | { | 592 | { |
550 | get | 593 | get |
551 | { | 594 | { |
552 | PhysicsActor actor = m_physicsActor; | 595 | if (PhysicsActor != null) |
553 | if (actor != null) | ||
554 | { | 596 | { |
555 | m_velocity = actor.Velocity; | 597 | m_velocity = PhysicsActor.Velocity; |
556 | 598 | ||
557 | // m_log.DebugFormat( | 599 | // m_log.DebugFormat( |
558 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | 600 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", |
@@ -563,13 +605,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
563 | } | 605 | } |
564 | set | 606 | set |
565 | { | 607 | { |
566 | PhysicsActor actor = m_physicsActor; | 608 | if (PhysicsActor != null) |
567 | if (actor != null) | ||
568 | { | 609 | { |
569 | try | 610 | try |
570 | { | 611 | { |
571 | lock (m_scene.SyncRoot) | 612 | lock (m_scene.SyncRoot) |
572 | actor.Velocity = value; | 613 | PhysicsActor.Velocity = value; |
573 | } | 614 | } |
574 | catch (Exception e) | 615 | catch (Exception e) |
575 | { | 616 | { |
@@ -585,13 +626,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
585 | } | 626 | } |
586 | } | 627 | } |
587 | 628 | ||
629 | public Quaternion OffsetRotation | ||
630 | { | ||
631 | get { return m_offsetRotation; } | ||
632 | set { m_offsetRotation = value; } | ||
633 | } | ||
634 | private Quaternion m_bodyRot = Quaternion.Identity; | ||
635 | |||
588 | public Quaternion Rotation | 636 | public Quaternion Rotation |
589 | { | 637 | { |
590 | get { return m_bodyRot; } | 638 | get { |
591 | set | 639 | if (m_parentID != 0) |
592 | { | 640 | { |
641 | if (m_offsetRotation != null) | ||
642 | { | ||
643 | return m_offsetRotation; | ||
644 | } | ||
645 | else | ||
646 | { | ||
647 | return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
648 | } | ||
649 | |||
650 | } | ||
651 | else | ||
652 | { | ||
653 | return m_bodyRot; | ||
654 | } | ||
655 | } | ||
656 | set { | ||
593 | m_bodyRot = value; | 657 | m_bodyRot = value; |
594 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 658 | if (m_parentID != 0) |
659 | { | ||
660 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
661 | } | ||
595 | } | 662 | } |
596 | } | 663 | } |
597 | 664 | ||
@@ -611,11 +678,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
611 | 678 | ||
612 | private uint m_parentID; | 679 | private uint m_parentID; |
613 | 680 | ||
681 | |||
682 | private UUID m_linkedPrim; | ||
683 | |||
614 | public uint ParentID | 684 | public uint ParentID |
615 | { | 685 | { |
616 | get { return m_parentID; } | 686 | get { return m_parentID; } |
617 | set { m_parentID = value; } | 687 | set { m_parentID = value; } |
618 | } | 688 | } |
689 | |||
690 | public UUID LinkedPrim | ||
691 | { | ||
692 | get { return m_linkedPrim; } | ||
693 | set { m_linkedPrim = value; } | ||
694 | } | ||
695 | |||
619 | public float Health | 696 | public float Health |
620 | { | 697 | { |
621 | get { return m_health; } | 698 | get { return m_health; } |
@@ -645,9 +722,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
645 | } | 722 | } |
646 | } | 723 | } |
647 | 724 | ||
725 | private ISceneViewer m_sceneViewer; | ||
726 | |||
648 | public ISceneViewer SceneViewer | 727 | public ISceneViewer SceneViewer |
649 | { | 728 | { |
650 | get { return m_sceneViewer; } | 729 | get { return m_sceneViewer; } |
730 | private set { m_sceneViewer = value; } | ||
651 | } | 731 | } |
652 | 732 | ||
653 | public void AdjustKnownSeeds() | 733 | public void AdjustKnownSeeds() |
@@ -694,28 +774,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
694 | } | 774 | } |
695 | } | 775 | } |
696 | 776 | ||
697 | private bool m_inTransit; | ||
698 | private bool m_mouseLook; | 777 | private bool m_mouseLook; |
699 | private bool m_leftButtonDown; | 778 | private bool m_leftButtonDown; |
700 | 779 | ||
780 | private bool m_inTransit; | ||
781 | |||
701 | public bool IsInTransit | 782 | public bool IsInTransit |
702 | { | 783 | { |
703 | get { return m_inTransit; } | 784 | get { return m_inTransit; } |
704 | set { m_inTransit = value; } | 785 | set { |
786 | if(value) | ||
787 | { | ||
788 | if ((PhysicsActor != null) && PhysicsActor.Flying) | ||
789 | m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
790 | else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) | ||
791 | m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
792 | } | ||
793 | m_inTransit = value; | ||
794 | } | ||
705 | } | 795 | } |
706 | 796 | ||
797 | private float m_speedModifier = 1.0f; | ||
798 | |||
707 | public float SpeedModifier | 799 | public float SpeedModifier |
708 | { | 800 | { |
709 | get { return m_speedModifier; } | 801 | get { return m_speedModifier; } |
710 | set { m_speedModifier = value; } | 802 | set { m_speedModifier = value; } |
711 | } | 803 | } |
712 | 804 | ||
805 | private bool m_forceFly; | ||
806 | |||
713 | public bool ForceFly | 807 | public bool ForceFly |
714 | { | 808 | { |
715 | get { return m_forceFly; } | 809 | get { return m_forceFly; } |
716 | set { m_forceFly = value; } | 810 | set { m_forceFly = value; } |
717 | } | 811 | } |
718 | 812 | ||
813 | private bool m_flyDisabled; | ||
814 | |||
719 | public bool FlyDisabled | 815 | public bool FlyDisabled |
720 | { | 816 | { |
721 | get { return m_flyDisabled; } | 817 | get { return m_flyDisabled; } |
@@ -737,42 +833,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
737 | AttachmentsSyncLock = new Object(); | 833 | AttachmentsSyncLock = new Object(); |
738 | 834 | ||
739 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 835 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
740 | m_sceneViewer = new SceneViewer(this); | 836 | SceneViewer = new SceneViewer(this); |
741 | m_animator = new ScenePresenceAnimator(this); | 837 | Animator = new ScenePresenceAnimator(this); |
742 | PresenceType = type; | 838 | PresenceType = type; |
743 | m_DrawDistance = world.DefaultDrawDistance; | 839 | DrawDistance = world.DefaultDrawDistance; |
744 | m_rootRegionHandle = world.RegionInfo.RegionHandle; | 840 | RegionHandle = world.RegionInfo.RegionHandle; |
745 | m_controllingClient = client; | 841 | ControllingClient = client; |
746 | m_firstname = m_controllingClient.FirstName; | 842 | Firstname = ControllingClient.FirstName; |
747 | m_lastname = m_controllingClient.LastName; | 843 | Lastname = ControllingClient.LastName; |
748 | m_name = String.Format("{0} {1}", m_firstname, m_lastname); | 844 | m_name = String.Format("{0} {1}", Firstname, Lastname); |
749 | m_scene = world; | 845 | m_scene = world; |
750 | m_uuid = client.AgentId; | 846 | m_uuid = client.AgentId; |
751 | m_localId = m_scene.AllocateLocalId(); | 847 | m_localId = m_scene.AllocateLocalId(); |
752 | 848 | ||
753 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | 849 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); |
850 | m_userFlags = account.UserFlags; | ||
754 | 851 | ||
755 | if (account != null) | 852 | if (account != null) |
756 | m_userLevel = account.UserLevel; | 853 | UserLevel = account.UserLevel; |
757 | 854 | ||
758 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 855 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
759 | if (gm != null) | 856 | if (gm != null) |
760 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 857 | Grouptitle = gm.GetGroupTitle(m_uuid); |
761 | 858 | ||
762 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); | 859 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); |
763 | 860 | ||
764 | AbsolutePosition = posLastSignificantMove = m_CameraCenter = | 861 | AbsolutePosition = posLastSignificantMove = CameraPosition = |
765 | m_lastCameraCenter = m_controllingClient.StartPos; | 862 | m_lastCameraPosition = ControllingClient.StartPos; |
766 | 863 | ||
767 | m_reprioritization_timer = new Timer(world.ReprioritizationInterval); | 864 | m_reprioritization_timer = new Timer(world.ReprioritizationInterval); |
768 | m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); | 865 | m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); |
769 | m_reprioritization_timer.AutoReset = false; | 866 | m_reprioritization_timer.AutoReset = false; |
770 | 867 | ||
771 | AdjustKnownSeeds(); | 868 | AdjustKnownSeeds(); |
772 | |||
773 | // TODO: I think, this won't send anything, as we are still a child here... | ||
774 | Animator.TrySetMovementAnimation("STAND"); | 869 | Animator.TrySetMovementAnimation("STAND"); |
775 | |||
776 | // we created a new ScenePresence (a new child agent) in a fresh region. | 870 | // we created a new ScenePresence (a new child agent) in a fresh region. |
777 | // Request info about all the (root) agents in this region | 871 | // Request info about all the (root) agents in this region |
778 | // Note: This won't send data *to* other clients in that region (children don't send) | 872 | // Note: This won't send data *to* other clients in that region (children don't send) |
@@ -785,21 +879,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
785 | RegisterToEvents(); | 879 | RegisterToEvents(); |
786 | SetDirectionVectors(); | 880 | SetDirectionVectors(); |
787 | 881 | ||
788 | m_appearance = appearance; | 882 | Appearance = appearance; |
789 | } | 883 | } |
790 | 884 | ||
791 | public void RegisterToEvents() | 885 | public void RegisterToEvents() |
792 | { | 886 | { |
793 | m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; | 887 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
794 | //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; | 888 | //ControllingClient.OnCompleteMovementToRegion += SendInitialData; |
795 | m_controllingClient.OnAgentUpdate += HandleAgentUpdate; | 889 | ControllingClient.OnAgentUpdate += HandleAgentUpdate; |
796 | m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; | 890 | ControllingClient.OnAgentRequestSit += HandleAgentRequestSit; |
797 | m_controllingClient.OnAgentSit += HandleAgentSit; | 891 | ControllingClient.OnAgentSit += HandleAgentSit; |
798 | m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 892 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
799 | m_controllingClient.OnStartAnim += HandleStartAnim; | 893 | ControllingClient.OnStartAnim += HandleStartAnim; |
800 | m_controllingClient.OnStopAnim += HandleStopAnim; | 894 | ControllingClient.OnStopAnim += HandleStopAnim; |
801 | m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 895 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
802 | m_controllingClient.OnAutoPilotGo += MoveToTarget; | 896 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
803 | 897 | ||
804 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 898 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
805 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 899 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -813,25 +907,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
813 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT | 907 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
814 | Dir_Vectors[4] = Vector3.UnitZ; //UP | 908 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
815 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN | 909 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
816 | Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 910 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE |
817 | Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD | 911 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE |
818 | Dir_Vectors[7] = -Vector3.UnitX; //BACK | 912 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE |
913 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE | ||
914 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | ||
819 | } | 915 | } |
820 | 916 | ||
821 | private Vector3[] GetWalkDirectionVectors() | 917 | private Vector3[] GetWalkDirectionVectors() |
822 | { | 918 | { |
823 | Vector3[] vector = new Vector3[9]; | 919 | Vector3[] vector = new Vector3[11]; |
824 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD | 920 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
825 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK | 921 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
826 | vector[2] = Vector3.UnitY; //LEFT | 922 | vector[2] = Vector3.UnitY; //LEFT |
827 | vector[3] = -Vector3.UnitY; //RIGHT | 923 | vector[3] = -Vector3.UnitY; //RIGHT |
828 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP | 924 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
829 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN | 925 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
830 | vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge | 926 | vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE |
831 | vector[6] = (new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z) * 2); //FORWARD Nudge | 927 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE |
832 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK Nudge | 928 | vector[8] = Vector3.UnitY; //LEFT_NUDGE |
929 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | ||
930 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE | ||
833 | return vector; | 931 | return vector; |
834 | } | 932 | } |
933 | |||
934 | private bool[] GetDirectionIsNudge() | ||
935 | { | ||
936 | bool[] isNudge = new bool[11]; | ||
937 | isNudge[0] = false; //FORWARD | ||
938 | isNudge[1] = false; //BACK | ||
939 | isNudge[2] = false; //LEFT | ||
940 | isNudge[3] = false; //RIGHT | ||
941 | isNudge[4] = false; //UP | ||
942 | isNudge[5] = false; //DOWN | ||
943 | isNudge[6] = true; //FORWARD_NUDGE | ||
944 | isNudge[7] = true; //BACK_NUDGE | ||
945 | isNudge[8] = true; //LEFT_NUDGE | ||
946 | isNudge[9] = true; //RIGHT_NUDGE | ||
947 | isNudge[10] = true; //DOWN_Nudge | ||
948 | return isNudge; | ||
949 | } | ||
950 | |||
835 | 951 | ||
836 | #endregion | 952 | #endregion |
837 | 953 | ||
@@ -848,6 +964,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
848 | public void SendPrimUpdates() | 964 | public void SendPrimUpdates() |
849 | { | 965 | { |
850 | m_sceneViewer.SendPrimUpdates(); | 966 | m_sceneViewer.SendPrimUpdates(); |
967 | |||
968 | SceneViewer.SendPrimUpdates(); | ||
851 | } | 969 | } |
852 | 970 | ||
853 | #region Status Methods | 971 | #region Status Methods |
@@ -865,21 +983,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
865 | 983 | ||
866 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | 984 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); |
867 | 985 | ||
868 | bool wasChild = m_isChildAgent; | 986 | bool wasChild = IsChildAgent; |
869 | m_isChildAgent = false; | 987 | IsChildAgent = false; |
870 | 988 | ||
871 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 989 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
872 | if (gm != null) | 990 | if (gm != null) |
873 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 991 | Grouptitle = gm.GetGroupTitle(m_uuid); |
874 | 992 | ||
875 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; | 993 | RegionHandle = m_scene.RegionInfo.RegionHandle; |
876 | 994 | ||
877 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 995 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
878 | 996 | ||
879 | // Moved this from SendInitialData to ensure that m_appearance is initialized | 997 | // Moved this from SendInitialData to ensure that Appearance is initialized |
880 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 998 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
881 | // related to the handling of attachments | 999 | // related to the handling of attachments |
882 | //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); | 1000 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); |
883 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 1001 | if (m_scene.TestBorderCross(pos, Cardinals.E)) |
884 | { | 1002 | { |
885 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 1003 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); |
@@ -892,6 +1010,62 @@ namespace OpenSim.Region.Framework.Scenes | |||
892 | pos.Y = crossedBorder.BorderLine.Z - 1; | 1010 | pos.Y = crossedBorder.BorderLine.Z - 1; |
893 | } | 1011 | } |
894 | 1012 | ||
1013 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
1014 | if (land != null) | ||
1015 | { | ||
1016 | // If we come in via login, landmark or map, we want to | ||
1017 | // honor landing points. If we come in via Lure, we want | ||
1018 | // to ignore them. | ||
1019 | if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || | ||
1020 | (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || | ||
1021 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0) | ||
1022 | { | ||
1023 | // Don't restrict gods, estate managers, or land owners to | ||
1024 | // the TP point. This behaviour mimics agni. | ||
1025 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
1026 | land.LandData.UserLocation != Vector3.Zero && | ||
1027 | GodLevel < 200 && | ||
1028 | ((land.LandData.OwnerID != m_uuid && | ||
1029 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
1030 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) | ||
1031 | { | ||
1032 | pos = land.LandData.UserLocation; | ||
1033 | } | ||
1034 | } | ||
1035 | |||
1036 | land.SendLandUpdateToClient(ControllingClient); | ||
1037 | } | ||
1038 | |||
1039 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | ||
1040 | { | ||
1041 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | ||
1042 | |||
1043 | if (pos.X < 0) | ||
1044 | { | ||
1045 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | ||
1046 | if (!(pos.Y < 0)) | ||
1047 | emergencyPos.Y = pos.Y; | ||
1048 | if (!(pos.Z < 0)) | ||
1049 | emergencyPos.Z = pos.Z; | ||
1050 | } | ||
1051 | if (pos.Y < 0) | ||
1052 | { | ||
1053 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | ||
1054 | if (!(pos.X < 0)) | ||
1055 | emergencyPos.X = pos.X; | ||
1056 | if (!(pos.Z < 0)) | ||
1057 | emergencyPos.Z = pos.Z; | ||
1058 | } | ||
1059 | if (pos.Z < 0) | ||
1060 | { | ||
1061 | emergencyPos.Z = 128; | ||
1062 | if (!(pos.Y < 0)) | ||
1063 | emergencyPos.Y = pos.Y; | ||
1064 | if (!(pos.X < 0)) | ||
1065 | emergencyPos.X = pos.X; | ||
1066 | } | ||
1067 | } | ||
1068 | |||
895 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 1069 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
896 | { | 1070 | { |
897 | m_log.WarnFormat( | 1071 | m_log.WarnFormat( |
@@ -904,8 +1078,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
904 | } | 1078 | } |
905 | 1079 | ||
906 | float localAVHeight = 1.56f; | 1080 | float localAVHeight = 1.56f; |
907 | if (m_appearance.AvatarHeight > 0) | 1081 | if (Appearance.AvatarHeight > 0) |
908 | localAVHeight = m_appearance.AvatarHeight; | 1082 | localAVHeight = Appearance.AvatarHeight; |
909 | 1083 | ||
910 | float posZLimit = 0; | 1084 | float posZLimit = 0; |
911 | 1085 | ||
@@ -921,13 +1095,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
921 | 1095 | ||
922 | AddToPhysicalScene(isFlying); | 1096 | AddToPhysicalScene(isFlying); |
923 | 1097 | ||
924 | if (m_forceFly) | 1098 | if (ForceFly) |
925 | { | 1099 | { |
926 | m_physicsActor.Flying = true; | 1100 | PhysicsActor.Flying = true; |
927 | } | 1101 | } |
928 | else if (m_flyDisabled) | 1102 | else if (FlyDisabled) |
929 | { | 1103 | { |
930 | m_physicsActor.Flying = false; | 1104 | PhysicsActor.Flying = false; |
931 | } | 1105 | } |
932 | 1106 | ||
933 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1107 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
@@ -965,7 +1139,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
965 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1139 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
966 | // stall on the border crossing since the existing child agent will still have the last movement | 1140 | // stall on the border crossing since the existing child agent will still have the last movement |
967 | // recorded, which stops the input from being processed. | 1141 | // recorded, which stops the input from being processed. |
968 | m_movementflag = 0; | 1142 | MovementFlag = 0; |
969 | 1143 | ||
970 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1144 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
971 | } | 1145 | } |
@@ -995,12 +1169,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
995 | { | 1169 | { |
996 | // Reset these so that teleporting in and walking out isn't seen | 1170 | // Reset these so that teleporting in and walking out isn't seen |
997 | // as teleporting back | 1171 | // as teleporting back |
998 | m_teleportFlags = TeleportFlags.Default; | 1172 | TeleportFlags = TeleportFlags.Default; |
999 | 1173 | ||
1000 | // It looks like m_animator is set to null somewhere, and MakeChild | 1174 | // It looks like Animator is set to null somewhere, and MakeChild |
1001 | // is called after that. Probably in aborted teleports. | 1175 | // is called after that. Probably in aborted teleports. |
1002 | if (m_animator == null) | 1176 | if (Animator == null) |
1003 | m_animator = new ScenePresenceAnimator(this); | 1177 | Animator = new ScenePresenceAnimator(this); |
1004 | else | 1178 | else |
1005 | Animator.ResetAnimations(); | 1179 | Animator.ResetAnimations(); |
1006 | 1180 | ||
@@ -1012,11 +1186,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1012 | // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. | 1186 | // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. |
1013 | //Velocity = new Vector3(0, 0, 0); | 1187 | //Velocity = new Vector3(0, 0, 0); |
1014 | 1188 | ||
1015 | m_isChildAgent = true; | 1189 | IsChildAgent = true; |
1016 | m_scene.SwapRootAgentCount(true); | 1190 | m_scene.SwapRootAgentCount(true); |
1017 | RemoveFromPhysicalScene(); | 1191 | RemoveFromPhysicalScene(); |
1018 | 1192 | ||
1019 | // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into | 1193 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
1020 | 1194 | ||
1021 | m_scene.EventManager.TriggerOnMakeChildAgent(this); | 1195 | m_scene.EventManager.TriggerOnMakeChildAgent(this); |
1022 | } | 1196 | } |
@@ -1024,16 +1198,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1024 | /// <summary> | 1198 | /// <summary> |
1025 | /// Removes physics plugin scene representation of this agent if it exists. | 1199 | /// Removes physics plugin scene representation of this agent if it exists. |
1026 | /// </summary> | 1200 | /// </summary> |
1027 | private void RemoveFromPhysicalScene() | 1201 | public void RemoveFromPhysicalScene() |
1028 | { | 1202 | { |
1029 | if (PhysicsActor != null) | 1203 | if (PhysicsActor != null) |
1030 | { | 1204 | { |
1031 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1205 | try |
1032 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1206 | { |
1033 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | 1207 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
1034 | m_physicsActor.UnSubscribeEvents(); | 1208 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; |
1035 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1209 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1036 | PhysicsActor = null; | 1210 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); |
1211 | m_physicsActor.UnSubscribeEvents(); | ||
1212 | PhysicsActor = null; | ||
1213 | } | ||
1214 | catch | ||
1215 | { } | ||
1037 | } | 1216 | } |
1038 | } | 1217 | } |
1039 | 1218 | ||
@@ -1044,24 +1223,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1044 | public void Teleport(Vector3 pos) | 1223 | public void Teleport(Vector3 pos) |
1045 | { | 1224 | { |
1046 | bool isFlying = false; | 1225 | bool isFlying = false; |
1047 | if (m_physicsActor != null) | 1226 | if (PhysicsActor != null) |
1048 | isFlying = m_physicsActor.Flying; | 1227 | isFlying = PhysicsActor.Flying; |
1049 | 1228 | ||
1050 | RemoveFromPhysicalScene(); | 1229 | RemoveFromPhysicalScene(); |
1051 | Velocity = Vector3.Zero; | 1230 | Velocity = Vector3.Zero; |
1231 | CheckLandingPoint(ref pos); | ||
1052 | AbsolutePosition = pos; | 1232 | AbsolutePosition = pos; |
1053 | AddToPhysicalScene(isFlying); | 1233 | AddToPhysicalScene(isFlying); |
1054 | 1234 | ||
1055 | SendTerseUpdateToAllClients(); | 1235 | SendTerseUpdateToAllClients(); |
1236 | |||
1056 | } | 1237 | } |
1057 | 1238 | ||
1058 | public void TeleportWithMomentum(Vector3 pos) | 1239 | public void TeleportWithMomentum(Vector3 pos) |
1059 | { | 1240 | { |
1060 | bool isFlying = false; | 1241 | bool isFlying = false; |
1061 | if (m_physicsActor != null) | 1242 | if (PhysicsActor != null) |
1062 | isFlying = m_physicsActor.Flying; | 1243 | isFlying = PhysicsActor.Flying; |
1063 | 1244 | ||
1064 | RemoveFromPhysicalScene(); | 1245 | RemoveFromPhysicalScene(); |
1246 | CheckLandingPoint(ref pos); | ||
1065 | AbsolutePosition = pos; | 1247 | AbsolutePosition = pos; |
1066 | AddToPhysicalScene(isFlying); | 1248 | AddToPhysicalScene(isFlying); |
1067 | 1249 | ||
@@ -1174,11 +1356,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1174 | 1356 | ||
1175 | //m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); | 1357 | //m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); |
1176 | 1358 | ||
1177 | m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | 1359 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |
1178 | SendInitialData(); | 1360 | SendInitialData(); |
1179 | 1361 | ||
1180 | // Create child agents in neighbouring regions | 1362 | // Create child agents in neighbouring regions |
1181 | if (openChildAgents && !m_isChildAgent) | 1363 | if (openChildAgents && !IsChildAgent) |
1182 | { | 1364 | { |
1183 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1365 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1184 | if (m_agentTransfer != null) | 1366 | if (m_agentTransfer != null) |
@@ -1222,7 +1404,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1222 | { | 1404 | { |
1223 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1405 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
1224 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1406 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
1225 | !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1407 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) |
1226 | { | 1408 | { |
1227 | if (CameraConstraintActive) | 1409 | if (CameraConstraintActive) |
1228 | { | 1410 | { |
@@ -1237,13 +1419,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1237 | /// <summary> | 1419 | /// <summary> |
1238 | /// This is the event handler for client movement. If a client is moving, this event is triggering. | 1420 | /// This is the event handler for client movement. If a client is moving, this event is triggering. |
1239 | /// </summary> | 1421 | /// </summary> |
1422 | /// <summary> | ||
1423 | /// This is the event handler for client movement. If a client is moving, this event is triggering. | ||
1424 | /// </summary> | ||
1240 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 1425 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
1241 | { | 1426 | { |
1242 | // m_log.DebugFormat( | 1427 | // m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); |
1243 | // "[SCENE PRESENCE]: In {0} received agent update from {1}", | ||
1244 | // Scene.RegionInfo.RegionName, remoteClient.Name); | ||
1245 | 1428 | ||
1246 | //if (m_isChildAgent) | 1429 | //if (IsChildAgent) |
1247 | //{ | 1430 | //{ |
1248 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); | 1431 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); |
1249 | // return; | 1432 | // return; |
@@ -1287,28 +1470,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1287 | 1470 | ||
1288 | // Camera location in world. We'll need to raytrace | 1471 | // Camera location in world. We'll need to raytrace |
1289 | // from this location from time to time. | 1472 | // from this location from time to time. |
1290 | m_CameraCenter = agentData.CameraCenter; | 1473 | CameraPosition = agentData.CameraCenter; |
1291 | if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) | 1474 | if (Vector3.Distance(m_lastCameraPosition, CameraPosition) >= Scene.RootReprioritizationDistance) |
1292 | { | 1475 | { |
1293 | ReprioritizeUpdates(); | 1476 | ReprioritizeUpdates(); |
1294 | m_lastCameraCenter = m_CameraCenter; | 1477 | m_lastCameraPosition = CameraPosition; |
1295 | } | 1478 | } |
1296 | 1479 | ||
1297 | // Use these three vectors to figure out what the agent is looking at | 1480 | // Use these three vectors to figure out what the agent is looking at |
1298 | // Convert it to a Matrix and/or Quaternion | 1481 | // Convert it to a Matrix and/or Quaternion |
1299 | m_CameraAtAxis = agentData.CameraAtAxis; | 1482 | CameraAtAxis = agentData.CameraAtAxis; |
1300 | m_CameraLeftAxis = agentData.CameraLeftAxis; | 1483 | CameraLeftAxis = agentData.CameraLeftAxis; |
1301 | m_CameraUpAxis = agentData.CameraUpAxis; | 1484 | m_CameraUpAxis = agentData.CameraUpAxis; |
1302 | 1485 | ||
1303 | // The Agent's Draw distance setting | 1486 | // The Agent's Draw distance setting |
1304 | // When we get to the point of re-computing neighbors everytime this | 1487 | // When we get to the point of re-computing neighbors everytime this |
1305 | // changes, then start using the agent's drawdistance rather than the | 1488 | // changes, then start using the agent's drawdistance rather than the |
1306 | // region's draw distance. | 1489 | // region's draw distance. |
1307 | // m_DrawDistance = agentData.Far; | 1490 | // DrawDistance = agentData.Far; |
1308 | m_DrawDistance = Scene.DefaultDrawDistance; | 1491 | DrawDistance = Scene.DefaultDrawDistance; |
1309 | 1492 | ||
1310 | // Check if Client has camera in 'follow cam' or 'build' mode. | 1493 | // Check if Client has camera in 'follow cam' or 'build' mode. |
1311 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); | 1494 | Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); |
1312 | 1495 | ||
1313 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) | 1496 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) |
1314 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | 1497 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; |
@@ -1330,7 +1513,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1330 | if (m_followCamAuto) | 1513 | if (m_followCamAuto) |
1331 | { | 1514 | { |
1332 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1515 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1333 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1516 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1334 | } | 1517 | } |
1335 | } | 1518 | } |
1336 | 1519 | ||
@@ -1359,7 +1542,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | // Here's where you get them. | 1542 | // Here's where you get them. |
1360 | m_AgentControlFlags = flags; | 1543 | m_AgentControlFlags = flags; |
1361 | m_headrotation = agentData.HeadRotation; | 1544 | m_headrotation = agentData.HeadRotation; |
1362 | m_state = agentData.State; | 1545 | State = agentData.State; |
1363 | 1546 | ||
1364 | PhysicsActor actor = PhysicsActor; | 1547 | PhysicsActor actor = PhysicsActor; |
1365 | if (actor == null) | 1548 | if (actor == null) |
@@ -1367,12 +1550,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1367 | return; | 1550 | return; |
1368 | } | 1551 | } |
1369 | 1552 | ||
1370 | if (m_allowMovement && !SitGround) | 1553 | if (AllowMovement && !SitGround) |
1371 | { | 1554 | { |
1372 | Quaternion bodyRotation = agentData.BodyRotation; | 1555 | Quaternion bodyRotation = agentData.BodyRotation; |
1373 | bool update_rotation = false; | 1556 | bool update_rotation = false; |
1374 | 1557 | ||
1375 | if (bodyRotation != m_bodyRot) | 1558 | if (bodyRotation != Rotation) |
1376 | { | 1559 | { |
1377 | Rotation = bodyRotation; | 1560 | Rotation = bodyRotation; |
1378 | update_rotation = true; | 1561 | update_rotation = true; |
@@ -1392,9 +1575,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1392 | 1575 | ||
1393 | bool oldflying = PhysicsActor.Flying; | 1576 | bool oldflying = PhysicsActor.Flying; |
1394 | 1577 | ||
1395 | if (m_forceFly) | 1578 | if (ForceFly) |
1396 | actor.Flying = true; | 1579 | actor.Flying = true; |
1397 | else if (m_flyDisabled) | 1580 | else if (FlyDisabled) |
1398 | actor.Flying = false; | 1581 | actor.Flying = false; |
1399 | else | 1582 | else |
1400 | actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1583 | actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
@@ -1402,7 +1585,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1402 | if (actor.Flying != oldflying) | 1585 | if (actor.Flying != oldflying) |
1403 | update_movementflag = true; | 1586 | update_movementflag = true; |
1404 | 1587 | ||
1405 | if (m_parentID == 0) | 1588 | if (ParentID == 0) |
1406 | { | 1589 | { |
1407 | bool bAllowUpdateMoveToPosition = false; | 1590 | bool bAllowUpdateMoveToPosition = false; |
1408 | 1591 | ||
@@ -1410,12 +1593,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1410 | 1593 | ||
1411 | // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying | 1594 | // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying |
1412 | // this prevents 'jumping' in inappropriate situations. | 1595 | // this prevents 'jumping' in inappropriate situations. |
1413 | if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) | 1596 | if ((m_mouseLook && !PhysicsActor.Flying) || (m_leftButtonDown && !PhysicsActor.Flying)) |
1414 | dirVectors = GetWalkDirectionVectors(); | 1597 | dirVectors = GetWalkDirectionVectors(); |
1415 | else | 1598 | else |
1416 | dirVectors = Dir_Vectors; | 1599 | dirVectors = Dir_Vectors; |
1417 | 1600 | ||
1418 | // The fact that m_movementflag is a byte needs to be fixed | 1601 | // The fact that MovementFlag is a byte needs to be fixed |
1419 | // it really should be a uint | 1602 | // it really should be a uint |
1420 | // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. | 1603 | // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. |
1421 | uint nudgehack = 250; | 1604 | uint nudgehack = 250; |
@@ -1435,32 +1618,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1435 | // Why did I get this? | 1618 | // Why did I get this? |
1436 | } | 1619 | } |
1437 | 1620 | ||
1438 | if ((m_movementflag & (byte)(uint)DCF) == 0) | 1621 | if ((MovementFlag & (byte)(uint)DCF) == 0) |
1439 | { | 1622 | { |
1440 | if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | 1623 | if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) |
1441 | { | 1624 | { |
1442 | m_movementflag |= (byte)nudgehack; | 1625 | MovementFlag |= (byte)nudgehack; |
1443 | } | 1626 | } |
1444 | 1627 | ||
1445 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with {1}", Name, DCF); | 1628 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); |
1446 | m_movementflag += (byte)(uint)DCF; | 1629 | MovementFlag += (byte)(uint)DCF; |
1447 | update_movementflag = true; | 1630 | update_movementflag = true; |
1448 | } | 1631 | } |
1449 | } | 1632 | } |
1450 | else | 1633 | else |
1451 | { | 1634 | { |
1452 | if ((m_movementflag & (byte)(uint)DCF) != 0 || | 1635 | if ((m_movementflag & (byte)(uint)DCF) != 0 || |
1453 | ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | 1636 | ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) |
1454 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | 1637 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) |
1455 | ) // This or is for Nudge forward | 1638 | ) // This or is for Nudge forward |
1456 | { | 1639 | { |
1457 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with lack of {1}", Name, DCF); | 1640 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with lack of {1}", Name, DCF); |
1458 | m_movementflag -= ((byte)(uint)DCF); | 1641 | m_movementflag -= ((byte)(uint)DCF); |
1459 | update_movementflag = true; | 1642 | update_movementflag = true; |
1460 | 1643 | ||
1461 | /* | 1644 | /* |
1462 | if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | 1645 | if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) |
1463 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | 1646 | && ((MovementFlag & (byte)nudgehack) == nudgehack)) |
1464 | { | 1647 | { |
1465 | m_log.Debug("Removed Hack flag"); | 1648 | m_log.Debug("Removed Hack flag"); |
1466 | } | 1649 | } |
@@ -1495,7 +1678,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1495 | // with something with the down arrow pressed. | 1678 | // with something with the down arrow pressed. |
1496 | 1679 | ||
1497 | // Only do this if we're flying | 1680 | // Only do this if we're flying |
1498 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) | 1681 | if (PhysicsActor != null && PhysicsActor.Flying && !ForceFly) |
1499 | { | 1682 | { |
1500 | // Landing detection code | 1683 | // Landing detection code |
1501 | 1684 | ||
@@ -1503,10 +1686,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1503 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1686 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1504 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1687 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1505 | 1688 | ||
1506 | // Are the collision requirements fulfilled? | 1689 | if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland) |
1507 | bool colliding = (m_physicsActor.IsColliding == true); | ||
1508 | |||
1509 | if (m_physicsActor.Flying && colliding && controlland) | ||
1510 | { | 1690 | { |
1511 | // nesting this check because LengthSquared() is expensive and we don't | 1691 | // nesting this check because LengthSquared() is expensive and we don't |
1512 | // want to do it every step when flying. | 1692 | // want to do it every step when flying. |
@@ -1519,23 +1699,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1519 | // which occurs later in the main scene loop | 1699 | // which occurs later in the main scene loop |
1520 | if (update_movementflag || (update_rotation && DCFlagKeyPressed)) | 1700 | if (update_movementflag || (update_rotation && DCFlagKeyPressed)) |
1521 | { | 1701 | { |
1522 | // m_log.DebugFormat( | 1702 | // m_log.DebugFormat( |
1523 | // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", | 1703 | // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", |
1524 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); | 1704 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); |
1525 | 1705 | ||
1526 | AddNewMovement(agent_control_v3); | 1706 | AddNewMovement(agent_control_v3); |
1527 | } | 1707 | } |
1528 | // else | 1708 | // else |
1529 | // { | 1709 | // { |
1530 | // if (!update_movementflag) | 1710 | // if (!update_movementflag) |
1531 | // { | 1711 | // { |
1532 | // m_log.DebugFormat( | 1712 | // m_log.DebugFormat( |
1533 | // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", | 1713 | // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", |
1534 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name); | 1714 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name); |
1535 | // } | 1715 | // } |
1536 | // } | 1716 | // } |
1537 | 1717 | ||
1538 | if (update_movementflag && m_parentID == 0) | 1718 | if (update_movementflag && ParentID == 0) |
1539 | Animator.UpdateMovementAnimations(); | 1719 | Animator.UpdateMovementAnimations(); |
1540 | } | 1720 | } |
1541 | 1721 | ||
@@ -1555,20 +1735,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1555 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> | 1735 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> |
1556 | public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3) | 1736 | public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3) |
1557 | { | 1737 | { |
1558 | // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); | 1738 | // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); |
1559 | 1739 | ||
1560 | bool updated = false; | 1740 | bool updated = false; |
1561 | 1741 | ||
1562 | // m_log.DebugFormat( | 1742 | // m_log.DebugFormat( |
1563 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", | 1743 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", |
1564 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); | 1744 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); |
1565 | 1745 | ||
1566 | if (!m_autopilotMoving) | 1746 | if (!m_autopilotMoving) |
1567 | { | 1747 | { |
1568 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); | 1748 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); |
1569 | // m_log.DebugFormat( | 1749 | // m_log.DebugFormat( |
1570 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", | 1750 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", |
1571 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); | 1751 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); |
1572 | 1752 | ||
1573 | // Check the error term of the current position in relation to the target position | 1753 | // Check the error term of the current position in relation to the target position |
1574 | if (distanceToTarget <= 1) | 1754 | if (distanceToTarget <= 1) |
@@ -1591,7 +1771,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1591 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | 1771 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords |
1592 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords | 1772 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords |
1593 | // Ignore z component of vector | 1773 | // Ignore z component of vector |
1594 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1774 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1595 | LocalVectorToTarget3D.Normalize(); | 1775 | LocalVectorToTarget3D.Normalize(); |
1596 | 1776 | ||
1597 | // update avatar movement flags. the avatar coordinate system is as follows: | 1777 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1617,26 +1797,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1617 | // one of left/right/back/forward. | 1797 | // one of left/right/back/forward. |
1618 | if (LocalVectorToTarget3D.X < 0) //MoveBack | 1798 | if (LocalVectorToTarget3D.X < 0) //MoveBack |
1619 | { | 1799 | { |
1620 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 1800 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; |
1621 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 1801 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; |
1622 | updated = true; | 1802 | updated = true; |
1623 | } | 1803 | } |
1624 | else if (LocalVectorToTarget3D.X > 0) //Move Forward | 1804 | else if (LocalVectorToTarget3D.X > 0) //Move Forward |
1625 | { | 1805 | { |
1626 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 1806 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; |
1627 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 1807 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; |
1628 | updated = true; | 1808 | updated = true; |
1629 | } | 1809 | } |
1630 | 1810 | ||
1631 | if (LocalVectorToTarget3D.Y > 0) //MoveLeft | 1811 | if (LocalVectorToTarget3D.Y > 0) //MoveLeft |
1632 | { | 1812 | { |
1633 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 1813 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
1634 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 1814 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
1635 | updated = true; | 1815 | updated = true; |
1636 | } | 1816 | } |
1637 | else if (LocalVectorToTarget3D.Y < 0) //MoveRight | 1817 | else if (LocalVectorToTarget3D.Y < 0) //MoveRight |
1638 | { | 1818 | { |
1639 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 1819 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
1640 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 1820 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
1641 | updated = true; | 1821 | updated = true; |
1642 | } | 1822 | } |
@@ -1645,21 +1825,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1645 | { | 1825 | { |
1646 | // Don't set these flags for up or down - doing so will make the avatar crouch or | 1826 | // Don't set these flags for up or down - doing so will make the avatar crouch or |
1647 | // keep trying to jump even if walking along level ground | 1827 | // keep trying to jump even if walking along level ground |
1648 | //m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; | 1828 | //MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; |
1649 | //AgentControlFlags | 1829 | //AgentControlFlags |
1650 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; | 1830 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; |
1651 | updated = true; | 1831 | updated = true; |
1652 | } | 1832 | } |
1653 | else if (LocalVectorToTarget3D.Z < 0) //Down | 1833 | else if (LocalVectorToTarget3D.Z < 0) //Down |
1654 | { | 1834 | { |
1655 | //m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; | 1835 | //MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; |
1656 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; | 1836 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; |
1657 | updated = true; | 1837 | updated = true; |
1658 | } | 1838 | } |
1659 | 1839 | ||
1660 | // m_log.DebugFormat( | 1840 | // m_log.DebugFormat( |
1661 | // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", | 1841 | // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", |
1662 | // LocalVectorToTarget3D, agent_control_v3, Name); | 1842 | // LocalVectorToTarget3D, agent_control_v3, Name); |
1663 | 1843 | ||
1664 | agent_control_v3 += LocalVectorToTarget3D; | 1844 | agent_control_v3 += LocalVectorToTarget3D; |
1665 | } | 1845 | } |
@@ -1780,7 +1960,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1780 | Velocity = Vector3.Zero; | 1960 | Velocity = Vector3.Zero; |
1781 | SendAvatarDataToAllAgents(); | 1961 | SendAvatarDataToAllAgents(); |
1782 | 1962 | ||
1783 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1963 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1784 | } | 1964 | } |
1785 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1965 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1786 | m_requestedSitTargetUUID = UUID.Zero; | 1966 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1815,49 +1995,84 @@ namespace OpenSim.Region.Framework.Scenes | |||
1815 | { | 1995 | { |
1816 | SitGround = false; | 1996 | SitGround = false; |
1817 | 1997 | ||
1818 | if (m_parentID != 0) | 1998 | if (ParentID != 0) |
1819 | { | 1999 | { |
1820 | m_log.Debug("StandupCode Executed"); | 2000 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
1821 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | ||
1822 | if (part != null) | 2001 | if (part != null) |
1823 | { | 2002 | { |
2003 | part.TaskInventory.LockItemsForRead(true); | ||
1824 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 2004 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1825 | if (taskIDict != null) | 2005 | if (taskIDict != null) |
1826 | { | 2006 | { |
1827 | lock (taskIDict) | 2007 | foreach (UUID taskID in taskIDict.Keys) |
1828 | { | 2008 | { |
1829 | foreach (UUID taskID in taskIDict.Keys) | 2009 | UnRegisterControlEventsToScript(LocalId, taskID); |
1830 | { | 2010 | taskIDict[taskID].PermsMask &= ~( |
1831 | UnRegisterControlEventsToScript(LocalId, taskID); | 2011 | 2048 | //PERMISSION_CONTROL_CAMERA |
1832 | taskIDict[taskID].PermsMask &= ~( | 2012 | 4); // PERMISSION_TAKE_CONTROLS |
1833 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1834 | 4); // PERMISSION_TAKE_CONTROLS | ||
1835 | } | ||
1836 | } | 2013 | } |
1837 | |||
1838 | } | 2014 | } |
2015 | part.TaskInventory.LockItemsForRead(false); | ||
1839 | // Reset sit target. | 2016 | // Reset sit target. |
1840 | if (part.GetAvatarOnSitTarget() == UUID) | 2017 | if (part.GetAvatarOnSitTarget() == UUID) |
1841 | part.SitTargetAvatar = UUID.Zero; | 2018 | part.SitTargetAvatar = UUID.Zero; |
1842 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2019 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1843 | 2020 | ||
1844 | m_parentPosition = part.GetWorldPosition(); | 2021 | ParentPosition = part.GetWorldPosition(); |
1845 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 2022 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1846 | } | 2023 | } |
2024 | // part.GetWorldRotation() is the rotation of the object being sat on | ||
2025 | // Rotation is the sittiing Av's rotation | ||
2026 | |||
2027 | Quaternion partRot; | ||
2028 | // if (part.LinkNum == 1) | ||
2029 | // { // Root prim of linkset | ||
2030 | // partRot = part.ParentGroup.RootPart.RotationOffset; | ||
2031 | // } | ||
2032 | // else | ||
2033 | // { // single or child prim | ||
2034 | |||
2035 | // } | ||
2036 | if (part == null) //CW: Part may be gone. llDie() for example. | ||
2037 | { | ||
2038 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
2039 | } | ||
2040 | else | ||
2041 | { | ||
2042 | partRot = part.GetWorldRotation(); | ||
2043 | } | ||
1847 | 2044 | ||
2045 | Quaternion partIRot = Quaternion.Inverse(partRot); | ||
2046 | |||
2047 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av | ||
2048 | Vector3 avStandUp = new Vector3(0.3f, 0f, 0f) * avatarRot; // 0.3M infront of av | ||
2049 | |||
2050 | |||
1848 | if (m_physicsActor == null) | 2051 | if (m_physicsActor == null) |
1849 | { | 2052 | { |
1850 | AddToPhysicalScene(false); | 2053 | AddToPhysicalScene(false); |
1851 | } | 2054 | } |
1852 | 2055 | //CW: If the part isn't null then we can set the current position | |
1853 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 2056 | if (part != null) |
1854 | m_parentPosition = Vector3.Zero; | 2057 | { |
1855 | 2058 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! | |
1856 | m_parentID = 0; | 2059 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. |
2060 | part.IsOccupied = false; | ||
2061 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); | ||
2062 | } | ||
2063 | else | ||
2064 | { | ||
2065 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue | ||
2066 | AbsolutePosition = m_lastWorldPosition; | ||
2067 | } | ||
2068 | |||
2069 | m_parentPosition = Vector3.Zero; | ||
2070 | m_parentID = 0; | ||
2071 | m_linkedPrim = UUID.Zero; | ||
2072 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1857 | SendAvatarDataToAllAgents(); | 2073 | SendAvatarDataToAllAgents(); |
1858 | m_requestedSitTargetID = 0; | 2074 | m_requestedSitTargetID = 0; |
1859 | } | 2075 | } |
1860 | |||
1861 | Animator.TrySetMovementAnimation("STAND"); | 2076 | Animator.TrySetMovementAnimation("STAND"); |
1862 | } | 2077 | } |
1863 | 2078 | ||
@@ -1888,13 +2103,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1888 | Vector3 avSitOffSet = part.SitTargetPosition; | 2103 | Vector3 avSitOffSet = part.SitTargetPosition; |
1889 | Quaternion avSitOrientation = part.SitTargetOrientation; | 2104 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1890 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 2105 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1891 | 2106 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); | |
1892 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 2107 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1893 | bool SitTargetisSet = | 2108 | if (SitTargetisSet && !SitTargetOccupied) |
1894 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | ||
1895 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | ||
1896 | |||
1897 | if (SitTargetisSet && SitTargetUnOccupied) | ||
1898 | { | 2109 | { |
1899 | //switch the target to this prim | 2110 | //switch the target to this prim |
1900 | return part; | 2111 | return part; |
@@ -1908,85 +2119,168 @@ namespace OpenSim.Region.Framework.Scenes | |||
1908 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 2119 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) |
1909 | { | 2120 | { |
1910 | bool autopilot = true; | 2121 | bool autopilot = true; |
2122 | Vector3 autopilotTarget = new Vector3(); | ||
2123 | Quaternion sitOrientation = Quaternion.Identity; | ||
1911 | Vector3 pos = new Vector3(); | 2124 | Vector3 pos = new Vector3(); |
1912 | Quaternion sitOrientation = pSitOrientation; | ||
1913 | Vector3 cameraEyeOffset = Vector3.Zero; | 2125 | Vector3 cameraEyeOffset = Vector3.Zero; |
1914 | Vector3 cameraAtOffset = Vector3.Zero; | 2126 | Vector3 cameraAtOffset = Vector3.Zero; |
1915 | bool forceMouselook = false; | 2127 | bool forceMouselook = false; |
1916 | 2128 | ||
1917 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 2129 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1918 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 2130 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1919 | if (part != null) | 2131 | if (part == null) return; |
2132 | |||
2133 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
2134 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
2135 | |||
2136 | // part is the prim to sit on | ||
2137 | // offset is the world-ref vector distance from that prim center to the click-spot | ||
2138 | // UUID is the UUID of the Avatar doing the clicking | ||
2139 | |||
2140 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | ||
2141 | |||
2142 | // Is a sit target available? | ||
2143 | Vector3 avSitOffSet = part.SitTargetPosition; | ||
2144 | Quaternion avSitOrientation = part.SitTargetOrientation; | ||
2145 | |||
2146 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. | ||
2147 | // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2148 | Quaternion partRot; | ||
2149 | // if (part.LinkNum == 1) | ||
2150 | // { // Root prim of linkset | ||
2151 | // partRot = part.ParentGroup.RootPart.RotationOffset; | ||
2152 | // } | ||
2153 | // else | ||
2154 | // { // single or child prim | ||
2155 | partRot = part.GetWorldRotation(); | ||
2156 | // } | ||
2157 | Quaternion partIRot = Quaternion.Inverse(partRot); | ||
2158 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); | ||
2159 | // Sit analysis rewritten by KF 091125 | ||
2160 | if (SitTargetisSet) // scipted sit | ||
1920 | { | 2161 | { |
1921 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 2162 | if (!part.IsOccupied) |
1922 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 2163 | { |
1923 | 2164 | //Console.WriteLine("Scripted, unoccupied"); | |
1924 | // Is a sit target available? | 2165 | part.SitTargetAvatar = UUID; // set that Av will be on it |
1925 | Vector3 avSitOffSet = part.SitTargetPosition; | 2166 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1926 | Quaternion avSitOrientation = part.SitTargetOrientation; | 2167 | |
1927 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 2168 | Quaternion nrot = avSitOrientation; |
1928 | 2169 | if (!part.IsRoot) | |
1929 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | ||
1930 | bool SitTargetisSet = | ||
1931 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && | ||
1932 | ( | ||
1933 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 1f // Valid Zero Rotation quaternion | ||
1934 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point | ||
1935 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion | ||
1936 | ) | ||
1937 | )); | ||
1938 | |||
1939 | if (SitTargetisSet && SitTargetUnOccupied) | ||
1940 | { | ||
1941 | part.SitTargetAvatar = UUID; | ||
1942 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | ||
1943 | sitOrientation = avSitOrientation; | ||
1944 | autopilot = false; | ||
1945 | } | ||
1946 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
1947 | |||
1948 | pos = part.AbsolutePosition + offset; | ||
1949 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | ||
1950 | //{ | ||
1951 | // offset = pos; | ||
1952 | //autopilot = false; | ||
1953 | //} | ||
1954 | if (m_physicsActor != null) | ||
1955 | { | ||
1956 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | ||
1957 | // We can remove the physicsActor until they stand up. | ||
1958 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
1959 | |||
1960 | if (autopilot) | ||
1961 | { | 2170 | { |
1962 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 2171 | nrot = part.RotationOffset * avSitOrientation; |
1963 | { | ||
1964 | autopilot = false; | ||
1965 | |||
1966 | RemoveFromPhysicalScene(); | ||
1967 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | ||
1968 | } | ||
1969 | } | 2172 | } |
1970 | else | 2173 | sitOrientation = nrot; // Change rotatione to the scripted one |
2174 | OffsetRotation = nrot; | ||
2175 | autopilot = false; // Jump direct to scripted llSitPos() | ||
2176 | } | ||
2177 | else | ||
2178 | { | ||
2179 | //Console.WriteLine("Scripted, occupied"); | ||
2180 | return; | ||
2181 | } | ||
2182 | } | ||
2183 | else // Not Scripted | ||
2184 | { | ||
2185 | if ( (Math.Abs(offset.X) > 0.1f) || (Math.Abs(offset.Y) > 0.1f) ) // Changed 0.5M to 0.1M as they want to be able to sit close together | ||
2186 | { | ||
2187 | // large prim & offset, ignore if other Avs sitting | ||
2188 | // offset.Z -= 0.05f; | ||
2189 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked | ||
2190 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point | ||
2191 | |||
2192 | //Console.WriteLine(" offset ={0}", offset); | ||
2193 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); | ||
2194 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); | ||
2195 | |||
2196 | } | ||
2197 | else // small offset | ||
2198 | { | ||
2199 | //Console.WriteLine("Small offset"); | ||
2200 | if (!part.IsOccupied) | ||
2201 | { | ||
2202 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | ||
2203 | autopilotTarget = part.AbsolutePosition; | ||
2204 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
2205 | } | ||
2206 | else return; // occupied small | ||
2207 | } // end large/small | ||
2208 | } // end Scripted/not | ||
2209 | |||
2210 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2211 | |||
2212 | cameraAtOffset = part.GetCameraAtOffset(); | ||
2213 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2214 | forceMouselook = part.GetForceMouselook(); | ||
2215 | if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // | ||
2216 | if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // | ||
2217 | |||
2218 | if (m_physicsActor != null) | ||
2219 | { | ||
2220 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | ||
2221 | // We can remove the physicsActor until they stand up. | ||
2222 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
2223 | if (autopilot) | ||
2224 | { // its not a scripted sit | ||
2225 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | ||
2226 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) | ||
1971 | { | 2227 | { |
2228 | autopilot = false; // close enough | ||
2229 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2230 | Not using the part's position because returning the AV to the last known standing | ||
2231 | position is likely to be more friendly, isn't it? */ | ||
1972 | RemoveFromPhysicalScene(); | 2232 | RemoveFromPhysicalScene(); |
1973 | } | 2233 | Velocity = Vector3.Zero; |
2234 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target | ||
2235 | } // else the autopilot will get us close | ||
2236 | } | ||
2237 | else | ||
2238 | { // its a scripted sit | ||
2239 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2240 | I *am* using the part's position this time because we have no real idea how far away | ||
2241 | the avatar is from the sit target. */ | ||
2242 | RemoveFromPhysicalScene(); | ||
2243 | Velocity = Vector3.Zero; | ||
1974 | } | 2244 | } |
1975 | |||
1976 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1977 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1978 | forceMouselook = part.GetForceMouselook(); | ||
1979 | } | 2245 | } |
1980 | 2246 | else return; // physactor is null! | |
1981 | ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2247 | |
1982 | m_requestedSitTargetUUID = targetID; | 2248 | Vector3 offsetr; // = offset * partIRot; |
2249 | // KF: In a linkset, offsetr needs to be relative to the group root! 091208 | ||
2250 | // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); | ||
2251 | // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. | ||
2252 | // { // Single, or Root prim of linkset, target is ClickOffset * RootRot | ||
2253 | //offsetr = offset * partIRot; | ||
2254 | // | ||
2255 | // } | ||
2256 | // else | ||
2257 | // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) | ||
2258 | // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + | ||
2259 | // (offset * partRot); | ||
2260 | // } | ||
2261 | |||
2262 | //Console.WriteLine(" "); | ||
2263 | //Console.WriteLine("link number ={0}", part.LinkNum); | ||
2264 | //Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); | ||
2265 | //Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); | ||
2266 | //Console.WriteLine("Click offst ={0}", offset); | ||
2267 | //Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); | ||
2268 | //Console.WriteLine("offsetr ={0}", offsetr); | ||
2269 | //Console.WriteLine("Camera At ={0}", cameraAtOffset); | ||
2270 | //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); | ||
2271 | |||
2272 | //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child | ||
2273 | ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2274 | |||
2275 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target | ||
1983 | // This calls HandleAgentSit twice, once from here, and the client calls | 2276 | // This calls HandleAgentSit twice, once from here, and the client calls |
1984 | // HandleAgentSit itself after it gets to the location | 2277 | // HandleAgentSit itself after it gets to the location |
1985 | // It doesn't get to the location until we've moved them there though | 2278 | // It doesn't get to the location until we've moved them there though |
1986 | // which happens in HandleAgentSit :P | 2279 | // which happens in HandleAgentSit :P |
1987 | m_autopilotMoving = autopilot; | 2280 | m_autopilotMoving = autopilot; |
1988 | m_autoPilotTarget = pos; | 2281 | m_autoPilotTarget = autopilotTarget; |
1989 | m_sitAtAutoTarget = autopilot; | 2282 | m_sitAtAutoTarget = autopilot; |
2283 | m_initialSitTarget = autopilotTarget; | ||
1990 | if (!autopilot) | 2284 | if (!autopilot) |
1991 | HandleAgentSit(remoteClient, UUID); | 2285 | HandleAgentSit(remoteClient, UUID); |
1992 | } | 2286 | } |
@@ -1994,7 +2288,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1994 | // public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) | 2288 | // public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) |
1995 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2289 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1996 | { | 2290 | { |
1997 | if (m_parentID != 0) | 2291 | if (ParentID != 0) |
1998 | { | 2292 | { |
1999 | StandUp(); | 2293 | StandUp(); |
2000 | } | 2294 | } |
@@ -2251,47 +2545,131 @@ namespace OpenSim.Region.Framework.Scenes | |||
2251 | { | 2545 | { |
2252 | if (part != null) | 2546 | if (part != null) |
2253 | { | 2547 | { |
2548 | //Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); | ||
2254 | if (part.GetAvatarOnSitTarget() == UUID) | 2549 | if (part.GetAvatarOnSitTarget() == UUID) |
2255 | { | 2550 | { |
2551 | //Console.WriteLine("Scripted Sit"); | ||
2552 | // Scripted sit | ||
2256 | Vector3 sitTargetPos = part.SitTargetPosition; | 2553 | Vector3 sitTargetPos = part.SitTargetPosition; |
2257 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 2554 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
2258 | |||
2259 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
2260 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
2261 | |||
2262 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
2263 | |||
2264 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 2555 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
2265 | m_pos += SIT_TARGET_ADJUSTMENT; | 2556 | m_pos += SIT_TARGET_ADJUSTMENT; |
2557 | if (!part.IsRoot) | ||
2558 | { | ||
2559 | m_pos *= part.RotationOffset; | ||
2560 | } | ||
2266 | m_bodyRot = sitTargetOrient; | 2561 | m_bodyRot = sitTargetOrient; |
2267 | //Rotation = sitTargetOrient; | ||
2268 | m_parentPosition = part.AbsolutePosition; | 2562 | m_parentPosition = part.AbsolutePosition; |
2269 | 2563 | part.IsOccupied = true; | |
2270 | //SendTerseUpdateToAllClients(); | 2564 | part.ParentGroup.AddAvatar(agentID); |
2271 | } | 2565 | } |
2272 | else | 2566 | else |
2273 | { | 2567 | { |
2274 | m_pos -= part.AbsolutePosition; | 2568 | // if m_avUnscriptedSitPos is zero then Av sits above center |
2569 | // Else Av sits at m_avUnscriptedSitPos | ||
2570 | |||
2571 | // Non-scripted sit by Kitto Flora 21Nov09 | ||
2572 | // Calculate angle of line from prim to Av | ||
2573 | Quaternion partIRot; | ||
2574 | // if (part.LinkNum == 1) | ||
2575 | // { // Root prim of linkset | ||
2576 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2577 | // } | ||
2578 | // else | ||
2579 | // { // single or child prim | ||
2580 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2581 | // } | ||
2582 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | ||
2583 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | ||
2584 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | ||
2585 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
2586 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
2587 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
2588 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
2589 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
2590 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
2591 | |||
2275 | m_parentPosition = part.AbsolutePosition; | 2592 | m_parentPosition = part.AbsolutePosition; |
2276 | } | 2593 | part.IsOccupied = true; |
2594 | part.ParentGroup.AddAvatar(agentID); | ||
2595 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation | ||
2596 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center | ||
2597 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + | ||
2598 | m_avUnscriptedSitPos; // adds click offset, if any | ||
2599 | //Set up raytrace to find top surface of prim | ||
2600 | Vector3 size = part.Scale; | ||
2601 | float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
2602 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
2603 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
2604 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); | ||
2605 | m_scene.PhysicsScene.RaycastWorld( | ||
2606 | start, // Vector3 position, | ||
2607 | down, // Vector3 direction, | ||
2608 | mag, // float length, | ||
2609 | SitAltitudeCallback); // retMethod | ||
2610 | } // end scripted/not | ||
2277 | } | 2611 | } |
2278 | else | 2612 | else // no Av |
2279 | { | 2613 | { |
2280 | return; | 2614 | return; |
2281 | } | 2615 | } |
2282 | } | 2616 | } |
2283 | m_parentID = m_requestedSitTargetID; | 2617 | ParentID = m_requestedSitTargetID; |
2284 | 2618 | ||
2619 | //We want our offsets to reference the root prim, not the child we may have sat on | ||
2620 | if (!part.IsRoot) | ||
2621 | { | ||
2622 | m_parentID = part.ParentGroup.RootPart.LocalId; | ||
2623 | m_pos += part.OffsetPosition; | ||
2624 | } | ||
2625 | else | ||
2626 | { | ||
2627 | m_parentID = m_requestedSitTargetID; | ||
2628 | } | ||
2629 | |||
2630 | m_linkedPrim = part.UUID; | ||
2631 | if (part.GetAvatarOnSitTarget() != UUID) | ||
2632 | { | ||
2633 | m_offsetRotation = m_offsetRotation / part.RotationOffset; | ||
2634 | } | ||
2285 | Velocity = Vector3.Zero; | 2635 | Velocity = Vector3.Zero; |
2286 | RemoveFromPhysicalScene(); | 2636 | RemoveFromPhysicalScene(); |
2287 | |||
2288 | Animator.TrySetMovementAnimation(sitAnimation); | 2637 | Animator.TrySetMovementAnimation(sitAnimation); |
2289 | SendAvatarDataToAllAgents(); | 2638 | SendAvatarDataToAllAgents(); |
2290 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | ||
2291 | // So we're also sending a terse update (which has avatar rotation) | ||
2292 | // [Update] We do now. | ||
2293 | //SendTerseUpdateToAllClients(); | 2639 | //SendTerseUpdateToAllClients(); |
2294 | } | 2640 | } |
2641 | |||
2642 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) | ||
2643 | { | ||
2644 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer | ||
2645 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. | ||
2646 | if(hitYN) | ||
2647 | { | ||
2648 | // m_pos = Av offset from prim center to make look like on center | ||
2649 | // m_parentPosition = Actual center pos of prim | ||
2650 | // collisionPoint = spot on prim where we want to sit | ||
2651 | // collisionPoint.Z = global sit surface height | ||
2652 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
2653 | Quaternion partIRot; | ||
2654 | // if (part.LinkNum == 1) | ||
2655 | /// { // Root prim of linkset | ||
2656 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2657 | // } | ||
2658 | // else | ||
2659 | // { // single or child prim | ||
2660 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2661 | // } | ||
2662 | if (m_initialSitTarget != null) | ||
2663 | { | ||
2664 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | ||
2665 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction | ||
2666 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); | ||
2667 | m_pos += offset; | ||
2668 | // ControllingClient.SendClearFollowCamProperties(part.UUID); | ||
2669 | } | ||
2670 | |||
2671 | } | ||
2672 | } // End SitAltitudeCallback KF. | ||
2295 | 2673 | ||
2296 | /// <summary> | 2674 | /// <summary> |
2297 | /// Event handler for the 'Always run' setting on the client | 2675 | /// Event handler for the 'Always run' setting on the client |
@@ -2299,11 +2677,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2299 | /// </summary> | 2677 | /// </summary> |
2300 | public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) | 2678 | public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) |
2301 | { | 2679 | { |
2302 | m_setAlwaysRun = pSetAlwaysRun; | 2680 | SetAlwaysRun = pSetAlwaysRun; |
2303 | if (PhysicsActor != null) | ||
2304 | { | ||
2305 | PhysicsActor.SetAlwaysRun = pSetAlwaysRun; | ||
2306 | } | ||
2307 | } | 2681 | } |
2308 | 2682 | ||
2309 | public void HandleStartAnim(IClientAPI remoteClient, UUID animID) | 2683 | public void HandleStartAnim(IClientAPI remoteClient, UUID animID) |
@@ -2325,27 +2699,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2325 | Vector3 direc = vec * Rotation; | 2699 | Vector3 direc = vec * Rotation; |
2326 | direc.Normalize(); | 2700 | direc.Normalize(); |
2327 | 2701 | ||
2328 | direc *= 0.03f * 128f * m_speedModifier; | 2702 | direc *= 0.03f * 128f * SpeedModifier; |
2329 | 2703 | ||
2330 | PhysicsActor actor = m_physicsActor; | 2704 | if (PhysicsActor != null) |
2331 | if (actor != null) | ||
2332 | { | 2705 | { |
2333 | if (actor.Flying) | 2706 | if (PhysicsActor.Flying) |
2334 | { | 2707 | { |
2335 | direc *= 4.0f; | 2708 | direc *= 4.0f; |
2336 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2709 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2337 | //bool colliding = (m_physicsActor.IsColliding==true); | ||
2338 | //if (controlland) | 2710 | //if (controlland) |
2339 | // m_log.Info("[AGENT]: landCommand"); | 2711 | // m_log.Info("[AGENT]: landCommand"); |
2340 | //if (colliding) | 2712 | //if (PhysicsActor.IsColliding) |
2341 | // m_log.Info("[AGENT]: colliding"); | 2713 | // m_log.Info("[AGENT]: colliding"); |
2342 | //if (m_physicsActor.Flying && colliding && controlland) | 2714 | //if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland) |
2343 | //{ | 2715 | //{ |
2344 | // StopFlying(); | 2716 | // StopFlying(); |
2345 | // m_log.Info("[AGENT]: Stop FLying"); | 2717 | // m_log.Info("[AGENT]: Stop Flying"); |
2346 | //} | 2718 | //} |
2347 | } | 2719 | } |
2348 | else if (!actor.Flying && actor.IsColliding) | 2720 | else if (!PhysicsActor.Flying && PhysicsActor.IsColliding) |
2349 | { | 2721 | { |
2350 | if (direc.Z > 2.0f) | 2722 | if (direc.Z > 2.0f) |
2351 | { | 2723 | { |
@@ -2378,16 +2750,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2378 | if (!sendingPrims) | 2750 | if (!sendingPrims) |
2379 | Util.FireAndForget(delegate { sendingPrims = true; SendPrimUpdates(); sendingPrims = false; }); | 2751 | Util.FireAndForget(delegate { sendingPrims = true; SendPrimUpdates(); sendingPrims = false; }); |
2380 | 2752 | ||
2381 | if (m_isChildAgent == false) | 2753 | if (IsChildAgent == false) |
2382 | { | 2754 | { |
2383 | // PhysicsActor actor = m_physicsActor; | ||
2384 | |||
2385 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2755 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2386 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2756 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2387 | // storing a requested force instead of an actual traveling velocity | 2757 | // storing a requested force instead of an actual traveling velocity |
2388 | 2758 | ||
2389 | // Throw away duplicate or insignificant updates | 2759 | // Throw away duplicate or insignificant updates |
2390 | if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || | 2760 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2391 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 2761 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2392 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) | 2762 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2393 | //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 2763 | //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) |
@@ -2396,17 +2766,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
2396 | 2766 | ||
2397 | // Update the "last" values | 2767 | // Update the "last" values |
2398 | m_lastPosition = m_pos; | 2768 | m_lastPosition = m_pos; |
2399 | m_lastRotation = m_bodyRot; | 2769 | m_lastRotation = Rotation; |
2400 | m_lastVelocity = Velocity; | 2770 | m_lastVelocity = Velocity; |
2401 | //m_lastTerseSent = Environment.TickCount; | 2771 | //m_lastTerseSent = Environment.TickCount; |
2402 | } | 2772 | } |
2403 | 2773 | ||
2404 | // followed suggestion from mic bowman. reversed the two lines below. | 2774 | // followed suggestion from mic bowman. reversed the two lines below. |
2405 | if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something | 2775 | if (ParentID == 0 && PhysicsActor != null || ParentID != 0) // Check that we have a physics actor or we're sitting on something |
2406 | CheckForBorderCrossing(); | 2776 | CheckForBorderCrossing(); |
2407 | 2777 | ||
2408 | CheckForSignificantMovement(); // sends update to the modules. | 2778 | CheckForSignificantMovement(); // sends update to the modules. |
2409 | } | 2779 | } |
2780 | |||
2781 | //Sending prim updates AFTER the avatar terse updates are sent | ||
2782 | SendPrimUpdates(); | ||
2410 | } | 2783 | } |
2411 | 2784 | ||
2412 | #endregion | 2785 | #endregion |
@@ -2425,9 +2798,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2425 | if (remoteClient.IsActive) | 2798 | if (remoteClient.IsActive) |
2426 | { | 2799 | { |
2427 | Vector3 pos = m_pos; | 2800 | Vector3 pos = m_pos; |
2428 | pos.Z += m_appearance.HipOffset; | 2801 | pos.Z += Appearance.HipOffset; |
2429 | 2802 | ||
2430 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); | 2803 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); |
2431 | 2804 | ||
2432 | remoteClient.SendPrimUpdate( | 2805 | remoteClient.SendPrimUpdate( |
2433 | this, | 2806 | this, |
@@ -2499,7 +2872,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2499 | 2872 | ||
2500 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) | 2873 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
2501 | { | 2874 | { |
2502 | m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); | 2875 | ControllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); |
2503 | } | 2876 | } |
2504 | 2877 | ||
2505 | /// <summary> | 2878 | /// <summary> |
@@ -2509,21 +2882,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
2509 | private void SendInitialData() | 2882 | private void SendInitialData() |
2510 | { | 2883 | { |
2511 | //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); | 2884 | //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); |
2512 | // Moved this into CompleteMovement to ensure that m_appearance is initialized before | 2885 | // Moved this into CompleteMovement to ensure that Appearance is initialized before |
2513 | // the inventory arrives | 2886 | // the inventory arrives |
2514 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); | 2887 | // m_scene.GetAvatarAppearance(ControllingClient, out Appearance); |
2515 | 2888 | ||
2516 | bool cachedappearance = false; | 2889 | bool cachedappearance = false; |
2517 | 2890 | ||
2518 | // We have an appearance but we may not have the baked textures. Check the asset cache | 2891 | // We have an appearance but we may not have the baked textures. Check the asset cache |
2519 | // to see if all the baked textures are already here. | 2892 | // to see if all the baked textures are already here. |
2520 | if (m_scene.AvatarFactory != null) | 2893 | if (m_scene.AvatarFactory != null) |
2521 | cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient); | 2894 | cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(ControllingClient); |
2522 | 2895 | ||
2523 | // If we aren't using a cached appearance, then clear out the baked textures | 2896 | // If we aren't using a cached appearance, then clear out the baked textures |
2524 | if (!cachedappearance) | 2897 | if (!cachedappearance) |
2525 | { | 2898 | { |
2526 | m_appearance.ResetAppearance(); | 2899 | Appearance.ResetAppearance(); |
2527 | if (m_scene.AvatarFactory != null) | 2900 | if (m_scene.AvatarFactory != null) |
2528 | m_scene.AvatarFactory.QueueAppearanceSave(UUID); | 2901 | m_scene.AvatarFactory.QueueAppearanceSave(UUID); |
2529 | } | 2902 | } |
@@ -2671,17 +3044,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2671 | // "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); | 3044 | // "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); |
2672 | 3045 | ||
2673 | avatar.ControllingClient.SendAppearance( | 3046 | avatar.ControllingClient.SendAppearance( |
2674 | UUID, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); | 3047 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
2675 | } | ||
2676 | |||
2677 | public AvatarAppearance Appearance | ||
2678 | { | ||
2679 | get { return m_appearance; } | ||
2680 | set | ||
2681 | { | ||
2682 | m_appearance = value; | ||
2683 | // m_log.DebugFormat("[SCENE PRESENCE]: Set appearance for {0} to {1}", Name, value); | ||
2684 | } | ||
2685 | } | 3048 | } |
2686 | 3049 | ||
2687 | #endregion | 3050 | #endregion |
@@ -2709,14 +3072,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2709 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 3072 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2710 | cadu.ActiveGroupID = UUID.Zero.Guid; | 3073 | cadu.ActiveGroupID = UUID.Zero.Guid; |
2711 | cadu.AgentID = UUID.Guid; | 3074 | cadu.AgentID = UUID.Guid; |
2712 | cadu.alwaysrun = m_setAlwaysRun; | 3075 | cadu.alwaysrun = SetAlwaysRun; |
2713 | cadu.AVHeight = m_appearance.AvatarHeight; | 3076 | cadu.AVHeight = Appearance.AvatarHeight; |
2714 | Vector3 tempCameraCenter = m_CameraCenter; | 3077 | cadu.cameraPosition = CameraPosition; |
2715 | cadu.cameraPosition = tempCameraCenter; | 3078 | cadu.drawdistance = DrawDistance; |
2716 | cadu.drawdistance = m_DrawDistance; | ||
2717 | cadu.GroupAccess = 0; | 3079 | cadu.GroupAccess = 0; |
2718 | cadu.Position = AbsolutePosition; | 3080 | cadu.Position = AbsolutePosition; |
2719 | cadu.regionHandle = m_rootRegionHandle; | 3081 | cadu.regionHandle = RegionHandle; |
2720 | 3082 | ||
2721 | // Throttles | 3083 | // Throttles |
2722 | float multiplier = 1; | 3084 | float multiplier = 1; |
@@ -2822,7 +3184,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2822 | { | 3184 | { |
2823 | if (m_requestedSitTargetUUID == UUID.Zero) | 3185 | if (m_requestedSitTargetUUID == UUID.Zero) |
2824 | { | 3186 | { |
2825 | bool isFlying = m_physicsActor.Flying; | 3187 | bool isFlying = PhysicsActor.Flying; |
2826 | RemoveFromPhysicalScene(); | 3188 | RemoveFromPhysicalScene(); |
2827 | 3189 | ||
2828 | Vector3 pos = AbsolutePosition; | 3190 | Vector3 pos = AbsolutePosition; |
@@ -2847,7 +3209,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2847 | { | 3209 | { |
2848 | if (m_requestedSitTargetUUID == UUID.Zero) | 3210 | if (m_requestedSitTargetUUID == UUID.Zero) |
2849 | { | 3211 | { |
2850 | bool isFlying = m_physicsActor.Flying; | 3212 | bool isFlying = PhysicsActor.Flying; |
2851 | RemoveFromPhysicalScene(); | 3213 | RemoveFromPhysicalScene(); |
2852 | 3214 | ||
2853 | Vector3 pos = AbsolutePosition; | 3215 | Vector3 pos = AbsolutePosition; |
@@ -2937,7 +3299,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2937 | { | 3299 | { |
2938 | try | 3300 | try |
2939 | { | 3301 | { |
2940 | return m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); | 3302 | return m_scene.CrossAgentToNewRegion(this, PhysicsActor.Flying); |
2941 | } | 3303 | } |
2942 | catch | 3304 | catch |
2943 | { | 3305 | { |
@@ -2945,19 +3307,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2945 | } | 3307 | } |
2946 | } | 3308 | } |
2947 | 3309 | ||
2948 | public void InTransit() | ||
2949 | { | ||
2950 | m_inTransit = true; | ||
2951 | |||
2952 | if ((m_physicsActor != null) && m_physicsActor.Flying) | ||
2953 | m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
2954 | else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) | ||
2955 | m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
2956 | } | ||
2957 | |||
2958 | public void NotInTransit() | 3310 | public void NotInTransit() |
2959 | { | 3311 | { |
2960 | m_inTransit = false; | 3312 | IsInTransit = false; |
2961 | } | 3313 | } |
2962 | 3314 | ||
2963 | public void RestoreInCurrentScene() | 3315 | public void RestoreInCurrentScene() |
@@ -3013,7 +3365,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3013 | if (byebyeRegions.Count > 0) | 3365 | if (byebyeRegions.Count > 0) |
3014 | { | 3366 | { |
3015 | m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); | 3367 | m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); |
3016 | m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); | 3368 | m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions); |
3017 | } | 3369 | } |
3018 | 3370 | ||
3019 | foreach (ulong handle in byebyeRegions) | 3371 | foreach (ulong handle in byebyeRegions) |
@@ -3039,17 +3391,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3039 | if (account != null) | 3391 | if (account != null) |
3040 | { | 3392 | { |
3041 | if (account.UserLevel > 0) | 3393 | if (account.UserLevel > 0) |
3042 | m_godLevel = account.UserLevel; | 3394 | GodLevel = account.UserLevel; |
3043 | else | 3395 | else |
3044 | m_godLevel = 200; | 3396 | GodLevel = 200; |
3045 | } | 3397 | } |
3046 | } | 3398 | } |
3047 | else | 3399 | else |
3048 | { | 3400 | { |
3049 | m_godLevel = 0; | 3401 | GodLevel = 0; |
3050 | } | 3402 | } |
3051 | 3403 | ||
3052 | ControllingClient.SendAdminResponse(token, (uint)m_godLevel); | 3404 | ControllingClient.SendAdminResponse(token, (uint)GodLevel); |
3053 | } | 3405 | } |
3054 | 3406 | ||
3055 | #region Child Agent Updates | 3407 | #region Child Agent Updates |
@@ -3081,8 +3433,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3081 | // When we get to the point of re-computing neighbors everytime this | 3433 | // When we get to the point of re-computing neighbors everytime this |
3082 | // changes, then start using the agent's drawdistance rather than the | 3434 | // changes, then start using the agent's drawdistance rather than the |
3083 | // region's draw distance. | 3435 | // region's draw distance. |
3084 | // m_DrawDistance = cAgentData.Far; | 3436 | // DrawDistance = cAgentData.Far; |
3085 | m_DrawDistance = Scene.DefaultDrawDistance; | 3437 | DrawDistance = Scene.DefaultDrawDistance; |
3086 | 3438 | ||
3087 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! | 3439 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! |
3088 | m_pos = cAgentData.Position + offset; | 3440 | m_pos = cAgentData.Position + offset; |
@@ -3093,7 +3445,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3093 | ReprioritizeUpdates(); | 3445 | ReprioritizeUpdates(); |
3094 | } | 3446 | } |
3095 | 3447 | ||
3096 | m_CameraCenter = cAgentData.Center + offset; | 3448 | CameraPosition = cAgentData.Center + offset; |
3097 | 3449 | ||
3098 | //SetHeight(cAgentData.AVHeight); | 3450 | //SetHeight(cAgentData.AVHeight); |
3099 | 3451 | ||
@@ -3101,7 +3453,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3101 | ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); | 3453 | ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); |
3102 | 3454 | ||
3103 | //cAgentData.AVHeight; | 3455 | //cAgentData.AVHeight; |
3104 | m_rootRegionHandle = cAgentData.RegionHandle; | 3456 | RegionHandle = cAgentData.RegionHandle; |
3105 | //m_velocity = cAgentData.Velocity; | 3457 | //m_velocity = cAgentData.Velocity; |
3106 | } | 3458 | } |
3107 | 3459 | ||
@@ -3114,12 +3466,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3114 | 3466 | ||
3115 | cAgent.Position = AbsolutePosition; | 3467 | cAgent.Position = AbsolutePosition; |
3116 | cAgent.Velocity = m_velocity; | 3468 | cAgent.Velocity = m_velocity; |
3117 | cAgent.Center = m_CameraCenter; | 3469 | cAgent.Center = CameraPosition; |
3118 | cAgent.AtAxis = m_CameraAtAxis; | 3470 | cAgent.AtAxis = CameraAtAxis; |
3119 | cAgent.LeftAxis = m_CameraLeftAxis; | 3471 | cAgent.LeftAxis = CameraLeftAxis; |
3120 | cAgent.UpAxis = m_CameraUpAxis; | 3472 | cAgent.UpAxis = m_CameraUpAxis; |
3121 | 3473 | ||
3122 | cAgent.Far = m_DrawDistance; | 3474 | cAgent.Far = DrawDistance; |
3123 | 3475 | ||
3124 | // Throttles | 3476 | // Throttles |
3125 | float multiplier = 1; | 3477 | float multiplier = 1; |
@@ -3134,17 +3486,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3134 | cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); | 3486 | cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); |
3135 | 3487 | ||
3136 | cAgent.HeadRotation = m_headrotation; | 3488 | cAgent.HeadRotation = m_headrotation; |
3137 | cAgent.BodyRotation = m_bodyRot; | 3489 | cAgent.BodyRotation = Rotation; |
3138 | cAgent.ControlFlags = (uint)m_AgentControlFlags; | 3490 | cAgent.ControlFlags = (uint)m_AgentControlFlags; |
3139 | 3491 | ||
3140 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3492 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3141 | cAgent.GodLevel = (byte)m_godLevel; | 3493 | cAgent.GodLevel = (byte)GodLevel; |
3142 | else | 3494 | else |
3143 | cAgent.GodLevel = (byte) 0; | 3495 | cAgent.GodLevel = (byte) 0; |
3144 | 3496 | ||
3145 | cAgent.AlwaysRun = m_setAlwaysRun; | 3497 | cAgent.AlwaysRun = SetAlwaysRun; |
3146 | 3498 | ||
3147 | cAgent.Appearance = new AvatarAppearance(m_appearance); | 3499 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3148 | 3500 | ||
3149 | lock (scriptedcontrols) | 3501 | lock (scriptedcontrols) |
3150 | { | 3502 | { |
@@ -3173,7 +3525,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3173 | cAgent.AttachmentObjects = new List<ISceneObject>(); | 3525 | cAgent.AttachmentObjects = new List<ISceneObject>(); |
3174 | cAgent.AttachmentObjectStates = new List<string>(); | 3526 | cAgent.AttachmentObjectStates = new List<string>(); |
3175 | // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); | 3527 | // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); |
3176 | m_InTransitScriptStates.Clear(); | 3528 | InTransitScriptStates.Clear(); |
3177 | 3529 | ||
3178 | foreach (SceneObjectGroup sog in m_attachments) | 3530 | foreach (SceneObjectGroup sog in m_attachments) |
3179 | { | 3531 | { |
@@ -3186,7 +3538,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3186 | cAgent.AttachmentObjects.Add(clone); | 3538 | cAgent.AttachmentObjects.Add(clone); |
3187 | string state = sog.GetStateSnapshot(); | 3539 | string state = sog.GetStateSnapshot(); |
3188 | cAgent.AttachmentObjectStates.Add(state); | 3540 | cAgent.AttachmentObjectStates.Add(state); |
3189 | m_InTransitScriptStates.Add(state); | 3541 | InTransitScriptStates.Add(state); |
3190 | // Let's remove the scripts of the original object here | 3542 | // Let's remove the scripts of the original object here |
3191 | sog.RemoveScriptInstances(true); | 3543 | sog.RemoveScriptInstances(true); |
3192 | } | 3544 | } |
@@ -3201,33 +3553,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3201 | m_callbackURI = cAgent.CallbackURI; | 3553 | m_callbackURI = cAgent.CallbackURI; |
3202 | 3554 | ||
3203 | m_pos = cAgent.Position; | 3555 | m_pos = cAgent.Position; |
3556 | |||
3204 | m_velocity = cAgent.Velocity; | 3557 | m_velocity = cAgent.Velocity; |
3205 | m_CameraCenter = cAgent.Center; | 3558 | CameraPosition = cAgent.Center; |
3206 | m_CameraAtAxis = cAgent.AtAxis; | 3559 | CameraAtAxis = cAgent.AtAxis; |
3207 | m_CameraLeftAxis = cAgent.LeftAxis; | 3560 | CameraLeftAxis = cAgent.LeftAxis; |
3208 | m_CameraUpAxis = cAgent.UpAxis; | 3561 | m_CameraUpAxis = cAgent.UpAxis; |
3209 | 3562 | ||
3210 | // When we get to the point of re-computing neighbors everytime this | 3563 | // When we get to the point of re-computing neighbors everytime this |
3211 | // changes, then start using the agent's drawdistance rather than the | 3564 | // changes, then start using the agent's drawdistance rather than the |
3212 | // region's draw distance. | 3565 | // region's draw distance. |
3213 | // m_DrawDistance = cAgent.Far; | 3566 | // DrawDistance = cAgent.Far; |
3214 | m_DrawDistance = Scene.DefaultDrawDistance; | 3567 | DrawDistance = Scene.DefaultDrawDistance; |
3215 | 3568 | ||
3216 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) | 3569 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) |
3217 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); | 3570 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); |
3218 | 3571 | ||
3219 | m_headrotation = cAgent.HeadRotation; | 3572 | m_headrotation = cAgent.HeadRotation; |
3220 | m_bodyRot = cAgent.BodyRotation; | 3573 | Rotation = cAgent.BodyRotation; |
3221 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; | 3574 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; |
3222 | 3575 | ||
3223 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3576 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3224 | m_godLevel = cAgent.GodLevel; | 3577 | GodLevel = cAgent.GodLevel; |
3225 | m_setAlwaysRun = cAgent.AlwaysRun; | 3578 | SetAlwaysRun = cAgent.AlwaysRun; |
3226 | 3579 | ||
3227 | m_appearance = new AvatarAppearance(cAgent.Appearance); | 3580 | Appearance = new AvatarAppearance(cAgent.Appearance); |
3228 | if (m_physicsActor != null) | 3581 | if (PhysicsActor != null) |
3229 | { | 3582 | { |
3230 | bool isFlying = m_physicsActor.Flying; | 3583 | bool isFlying = PhysicsActor.Flying; |
3231 | RemoveFromPhysicalScene(); | 3584 | RemoveFromPhysicalScene(); |
3232 | AddToPhysicalScene(isFlying); | 3585 | AddToPhysicalScene(isFlying); |
3233 | } | 3586 | } |
@@ -3293,7 +3646,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3293 | { | 3646 | { |
3294 | Vector3 force = m_forceToApply.Value; | 3647 | Vector3 force = m_forceToApply.Value; |
3295 | 3648 | ||
3296 | m_updateflag = true; | 3649 | Updated = true; |
3297 | 3650 | ||
3298 | Velocity = force; | 3651 | Velocity = force; |
3299 | 3652 | ||
@@ -3310,30 +3663,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3310 | // "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}", | 3663 | // "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}", |
3311 | // Name, isFlying, Scene.RegionInfo.RegionName); | 3664 | // Name, isFlying, Scene.RegionInfo.RegionName); |
3312 | 3665 | ||
3313 | if (m_appearance.AvatarHeight == 0) | 3666 | if (Appearance.AvatarHeight == 0) |
3314 | m_appearance.SetHeight(); | 3667 | Appearance.SetHeight(); |
3315 | 3668 | ||
3316 | PhysicsScene scene = m_scene.PhysicsScene; | 3669 | PhysicsScene scene = m_scene.PhysicsScene; |
3317 | 3670 | ||
3318 | Vector3 pVec = AbsolutePosition; | 3671 | Vector3 pVec = AbsolutePosition; |
3319 | 3672 | ||
3320 | // Old bug where the height was in centimeters instead of meters | 3673 | // Old bug where the height was in centimeters instead of meters |
3321 | m_physicsActor = scene.AddAvatar(LocalId, Firstname + "." + Lastname, pVec, | 3674 | PhysicsActor = scene.AddAvatar(LocalId, Firstname + "." + Lastname, pVec, |
3322 | new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying); | 3675 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); |
3323 | 3676 | ||
3324 | scene.AddPhysicsActorTaint(m_physicsActor); | 3677 | scene.AddPhysicsActorTaint(PhysicsActor); |
3325 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3678 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3326 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3679 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3327 | m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3680 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3328 | m_physicsActor.SubscribeEvents(500); | 3681 | PhysicsActor.SubscribeEvents(500); |
3329 | m_physicsActor.LocalID = LocalId; | 3682 | PhysicsActor.LocalID = LocalId; |
3330 | 3683 | ||
3331 | SetHeight(m_appearance.AvatarHeight); | 3684 | SetHeight(Appearance.AvatarHeight); |
3332 | } | 3685 | } |
3333 | 3686 | ||
3334 | private void OutOfBoundsCall(Vector3 pos) | 3687 | private void OutOfBoundsCall(Vector3 pos) |
3335 | { | 3688 | { |
3336 | //bool flying = m_physicsActor.Flying; | 3689 | //bool flying = PhysicsActor.Flying; |
3337 | //RemoveFromPhysicalScene(); | 3690 | //RemoveFromPhysicalScene(); |
3338 | 3691 | ||
3339 | //AddToPhysicalScene(flying); | 3692 | //AddToPhysicalScene(flying); |
@@ -3348,16 +3701,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
3348 | return; | 3701 | return; |
3349 | 3702 | ||
3350 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3703 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
3351 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | 3704 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( |
3352 | // as of this comment the interval is set in AddToPhysicalScene | 3705 | // as of this comment the interval is set in AddToPhysicalScene |
3353 | if (Animator != null) | 3706 | if (Animator!=null) |
3354 | Animator.UpdateMovementAnimations(); | 3707 | { |
3708 | if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, | ||
3709 | { // else its will lock out other animation changes, like ground sit. | ||
3710 | Animator.UpdateMovementAnimations(); | ||
3711 | m_updateCount--; | ||
3712 | } | ||
3713 | } | ||
3355 | 3714 | ||
3356 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3715 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3357 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3716 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3358 | 3717 | ||
3359 | CollisionPlane = Vector4.UnitW; | 3718 | CollisionPlane = Vector4.UnitW; |
3360 | 3719 | ||
3720 | if (m_lastColCount != coldata.Count) | ||
3721 | { | ||
3722 | m_updateCount = UPDATE_COUNT; | ||
3723 | m_lastColCount = coldata.Count; | ||
3724 | } | ||
3725 | |||
3361 | if (coldata.Count != 0 && Animator != null) | 3726 | if (coldata.Count != 0 && Animator != null) |
3362 | { | 3727 | { |
3363 | switch (Animator.CurrentMovementAnimation) | 3728 | switch (Animator.CurrentMovementAnimation) |
@@ -3387,7 +3752,149 @@ namespace OpenSim.Region.Framework.Scenes | |||
3387 | } | 3752 | } |
3388 | } | 3753 | } |
3389 | 3754 | ||
3390 | if (m_invulnerable) | 3755 | List<uint> thisHitColliders = new List<uint>(); |
3756 | List<uint> endedColliders = new List<uint>(); | ||
3757 | List<uint> startedColliders = new List<uint>(); | ||
3758 | |||
3759 | foreach (uint localid in coldata.Keys) | ||
3760 | { | ||
3761 | thisHitColliders.Add(localid); | ||
3762 | if (!m_lastColliders.Contains(localid)) | ||
3763 | { | ||
3764 | startedColliders.Add(localid); | ||
3765 | } | ||
3766 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3767 | } | ||
3768 | |||
3769 | // calculate things that ended colliding | ||
3770 | foreach (uint localID in m_lastColliders) | ||
3771 | { | ||
3772 | if (!thisHitColliders.Contains(localID)) | ||
3773 | { | ||
3774 | endedColliders.Add(localID); | ||
3775 | } | ||
3776 | } | ||
3777 | //add the items that started colliding this time to the last colliders list. | ||
3778 | foreach (uint localID in startedColliders) | ||
3779 | { | ||
3780 | m_lastColliders.Add(localID); | ||
3781 | } | ||
3782 | // remove things that ended colliding from the last colliders list | ||
3783 | foreach (uint localID in endedColliders) | ||
3784 | { | ||
3785 | m_lastColliders.Remove(localID); | ||
3786 | } | ||
3787 | |||
3788 | // do event notification | ||
3789 | if (startedColliders.Count > 0) | ||
3790 | { | ||
3791 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3792 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3793 | foreach (uint localId in startedColliders) | ||
3794 | { | ||
3795 | if (localId == 0) | ||
3796 | continue; | ||
3797 | |||
3798 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3799 | string data = ""; | ||
3800 | if (obj != null) | ||
3801 | { | ||
3802 | DetectedObject detobj = new DetectedObject(); | ||
3803 | detobj.keyUUID = obj.UUID; | ||
3804 | detobj.nameStr = obj.Name; | ||
3805 | detobj.ownerUUID = obj.OwnerID; | ||
3806 | detobj.posVector = obj.AbsolutePosition; | ||
3807 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3808 | detobj.velVector = obj.Velocity; | ||
3809 | detobj.colliderType = 0; | ||
3810 | detobj.groupUUID = obj.GroupID; | ||
3811 | colliding.Add(detobj); | ||
3812 | } | ||
3813 | } | ||
3814 | |||
3815 | if (colliding.Count > 0) | ||
3816 | { | ||
3817 | StartCollidingMessage.Colliders = colliding; | ||
3818 | |||
3819 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3820 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3821 | } | ||
3822 | } | ||
3823 | |||
3824 | if (endedColliders.Count > 0) | ||
3825 | { | ||
3826 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3827 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3828 | foreach (uint localId in endedColliders) | ||
3829 | { | ||
3830 | if (localId == 0) | ||
3831 | continue; | ||
3832 | |||
3833 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3834 | string data = ""; | ||
3835 | if (obj != null) | ||
3836 | { | ||
3837 | DetectedObject detobj = new DetectedObject(); | ||
3838 | detobj.keyUUID = obj.UUID; | ||
3839 | detobj.nameStr = obj.Name; | ||
3840 | detobj.ownerUUID = obj.OwnerID; | ||
3841 | detobj.posVector = obj.AbsolutePosition; | ||
3842 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3843 | detobj.velVector = obj.Velocity; | ||
3844 | detobj.colliderType = 0; | ||
3845 | detobj.groupUUID = obj.GroupID; | ||
3846 | colliding.Add(detobj); | ||
3847 | } | ||
3848 | } | ||
3849 | |||
3850 | if (colliding.Count > 0) | ||
3851 | { | ||
3852 | EndCollidingMessage.Colliders = colliding; | ||
3853 | |||
3854 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3855 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3856 | } | ||
3857 | } | ||
3858 | |||
3859 | if (thisHitColliders.Count > 0) | ||
3860 | { | ||
3861 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3862 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3863 | foreach (uint localId in thisHitColliders) | ||
3864 | { | ||
3865 | if (localId == 0) | ||
3866 | continue; | ||
3867 | |||
3868 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3869 | string data = ""; | ||
3870 | if (obj != null) | ||
3871 | { | ||
3872 | DetectedObject detobj = new DetectedObject(); | ||
3873 | detobj.keyUUID = obj.UUID; | ||
3874 | detobj.nameStr = obj.Name; | ||
3875 | detobj.ownerUUID = obj.OwnerID; | ||
3876 | detobj.posVector = obj.AbsolutePosition; | ||
3877 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3878 | detobj.velVector = obj.Velocity; | ||
3879 | detobj.colliderType = 0; | ||
3880 | detobj.groupUUID = obj.GroupID; | ||
3881 | colliding.Add(detobj); | ||
3882 | } | ||
3883 | } | ||
3884 | |||
3885 | if (colliding.Count > 0) | ||
3886 | { | ||
3887 | CollidingMessage.Colliders = colliding; | ||
3888 | |||
3889 | lock (m_attachments) | ||
3890 | { | ||
3891 | foreach (SceneObjectGroup att in m_attachments) | ||
3892 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3893 | } | ||
3894 | } | ||
3895 | } | ||
3896 | |||
3897 | if (Invulnerable) | ||
3391 | return; | 3898 | return; |
3392 | 3899 | ||
3393 | float starthealth = Health; | 3900 | float starthealth = Health; |
@@ -3412,13 +3919,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3412 | //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); | 3919 | //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); |
3413 | } | 3920 | } |
3414 | //Health = 100; | 3921 | //Health = 100; |
3415 | if (!m_invulnerable) | 3922 | if (!Invulnerable) |
3416 | { | 3923 | { |
3417 | if (starthealth != Health) | 3924 | if (starthealth != Health) |
3418 | { | 3925 | { |
3419 | ControllingClient.SendHealth(Health); | 3926 | ControllingClient.SendHealth(Health); |
3420 | } | 3927 | } |
3421 | if (m_health <= 0) | 3928 | if (Health <= 0) |
3422 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | 3929 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); |
3423 | } | 3930 | } |
3424 | } | 3931 | } |
@@ -3449,17 +3956,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3449 | // unsetting the elapsed callback should be enough to allow for cleanup however. | 3956 | // unsetting the elapsed callback should be enough to allow for cleanup however. |
3450 | // m_reprioritizationTimer.Dispose(); | 3957 | // m_reprioritizationTimer.Dispose(); |
3451 | 3958 | ||
3452 | m_sceneViewer.Close(); | 3959 | SceneViewer.Close(); |
3453 | 3960 | ||
3454 | RemoveFromPhysicalScene(); | 3961 | RemoveFromPhysicalScene(); |
3455 | m_animator.Close(); | 3962 | Animator.Close(); |
3456 | m_animator = null; | 3963 | Animator = null; |
3457 | } | 3964 | } |
3458 | 3965 | ||
3459 | public void AddAttachment(SceneObjectGroup gobj) | 3966 | public void AddAttachment(SceneObjectGroup gobj) |
3460 | { | 3967 | { |
3461 | lock (m_attachments) | 3968 | lock (m_attachments) |
3462 | { | 3969 | { |
3970 | // This may be true when the attachment comes back | ||
3971 | // from serialization after login. Clear it. | ||
3972 | gobj.IsDeleted = false; | ||
3973 | |||
3463 | m_attachments.Add(gobj); | 3974 | m_attachments.Add(gobj); |
3464 | } | 3975 | } |
3465 | } | 3976 | } |
@@ -3815,7 +4326,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3815 | 4326 | ||
3816 | private void Reprioritize(object sender, ElapsedEventArgs e) | 4327 | private void Reprioritize(object sender, ElapsedEventArgs e) |
3817 | { | 4328 | { |
3818 | m_controllingClient.ReprioritizeUpdates(); | 4329 | ControllingClient.ReprioritizeUpdates(); |
3819 | 4330 | ||
3820 | lock (m_reprioritization_timer) | 4331 | lock (m_reprioritization_timer) |
3821 | { | 4332 | { |
@@ -3823,5 +4334,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3823 | m_reprioritization_called = false; | 4334 | m_reprioritization_called = false; |
3824 | } | 4335 | } |
3825 | } | 4336 | } |
4337 | |||
4338 | private Vector3 Quat2Euler(Quaternion rot){ | ||
4339 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , | ||
4340 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); | ||
4341 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); | ||
4342 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | ||
4343 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); | ||
4344 | return(new Vector3(x,y,z)); | ||
4345 | } | ||
4346 | |||
4347 | private void CheckLandingPoint(ref Vector3 pos) | ||
4348 | { | ||
4349 | // Never constrain lures | ||
4350 | if ((TeleportFlags & TeleportFlags.ViaLure) != 0) | ||
4351 | return; | ||
4352 | |||
4353 | if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) | ||
4354 | return; | ||
4355 | |||
4356 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
4357 | |||
4358 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
4359 | land.LandData.UserLocation != Vector3.Zero && | ||
4360 | land.LandData.OwnerID != m_uuid && | ||
4361 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
4362 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | ||
4363 | { | ||
4364 | float curr = Vector3.Distance(AbsolutePosition, pos); | ||
4365 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | ||
4366 | pos = land.LandData.UserLocation; | ||
4367 | else | ||
4368 | ControllingClient.SendAlertMessage("Can't teleport closer to destination"); | ||
4369 | } | ||
4370 | } | ||
3826 | } | 4371 | } |
3827 | } | 4372 | } |