diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 201 |
1 files changed, 124 insertions, 77 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f231a39..5b02c3b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -70,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
70 | { | 70 | { |
71 | // ~ScenePresence() | 71 | // ~ScenePresence() |
72 | // { | 72 | // { |
73 | // m_log.Debug("[ScenePresence] Destructor called"); | 73 | // m_log.Debug("[SCENE PRESENCE] Destructor called"); |
74 | // } | 74 | // } |
75 | 75 | ||
76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -120,6 +120,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | /// </remarks> | 120 | /// </remarks> |
121 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | 121 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); |
122 | 122 | ||
123 | public Object AttachmentsSyncLock { get; private set; } | ||
124 | |||
123 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); | 125 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); |
124 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; | 126 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; |
125 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; | 127 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; |
@@ -176,8 +178,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
176 | 178 | ||
177 | private Quaternion m_bodyRot = Quaternion.Identity; | 179 | private Quaternion m_bodyRot = Quaternion.Identity; |
178 | 180 | ||
179 | private Quaternion m_bodyRotPrevious = Quaternion.Identity; | ||
180 | |||
181 | private const int LAND_VELOCITYMAG_MAX = 12; | 181 | private const int LAND_VELOCITYMAG_MAX = 12; |
182 | 182 | ||
183 | public bool IsRestrictedToRegion; | 183 | public bool IsRestrictedToRegion; |
@@ -186,7 +186,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
186 | 186 | ||
187 | private float m_health = 100f; | 187 | private float m_health = 100f; |
188 | 188 | ||
189 | protected RegionInfo m_regionInfo; | ||
190 | protected ulong crossingFromRegion; | 189 | protected ulong crossingFromRegion; |
191 | 190 | ||
192 | private readonly Vector3[] Dir_Vectors = new Vector3[9]; | 191 | private readonly Vector3[] Dir_Vectors = new Vector3[9]; |
@@ -221,6 +220,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
221 | public bool MovingToTarget { get; private set; } | 220 | public bool MovingToTarget { get; private set; } |
222 | public Vector3 MoveToPositionTarget { get; private set; } | 221 | public Vector3 MoveToPositionTarget { get; private set; } |
223 | 222 | ||
223 | /// <summary> | ||
224 | /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying). | ||
225 | /// </summary> | ||
226 | public bool LandAtTarget { get; private set; } | ||
227 | |||
224 | private bool m_followCamAuto; | 228 | private bool m_followCamAuto; |
225 | 229 | ||
226 | private int m_movementUpdateCount; | 230 | private int m_movementUpdateCount; |
@@ -466,7 +470,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
466 | { | 470 | { |
467 | PhysicsActor actor = m_physicsActor; | 471 | PhysicsActor actor = m_physicsActor; |
468 | if (actor != null) | 472 | if (actor != null) |
473 | { | ||
469 | m_pos = actor.Position; | 474 | m_pos = actor.Position; |
475 | |||
476 | // m_log.DebugFormat( | ||
477 | // "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!", | ||
478 | // m_pos, Name, Scene.RegionInfo.RegionName); | ||
479 | } | ||
470 | else | 480 | else |
471 | { | 481 | { |
472 | // Obtain the correct position of a seated avatar. | 482 | // Obtain the correct position of a seated avatar. |
@@ -510,19 +520,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
510 | } | 520 | } |
511 | catch (Exception e) | 521 | catch (Exception e) |
512 | { | 522 | { |
513 | m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); | 523 | m_log.Error("[SCENE PRESENCE]: ABSOLUTE POSITION " + e.Message); |
514 | } | 524 | } |
515 | } | 525 | } |
516 | 526 | ||
517 | m_pos = value; | 527 | m_pos = value; |
518 | m_parentPosition = Vector3.Zero; | 528 | m_parentPosition = Vector3.Zero; |
529 | |||
530 | // m_log.DebugFormat( | ||
531 | // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", | ||
532 | // Scene.RegionInfo.RegionName, Name, m_pos); | ||
519 | } | 533 | } |
520 | } | 534 | } |
521 | 535 | ||
536 | /// <summary> | ||
537 | /// If sitting, returns the offset position from the prim the avatar is sitting on. | ||
538 | /// Otherwise, returns absolute position in the scene. | ||
539 | /// </summary> | ||
522 | public Vector3 OffsetPosition | 540 | public Vector3 OffsetPosition |
523 | { | 541 | { |
524 | get { return m_pos; } | 542 | get { return m_pos; } |
525 | set { m_pos = value; } | ||
526 | } | 543 | } |
527 | 544 | ||
528 | /// <summary> | 545 | /// <summary> |
@@ -534,8 +551,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
534 | { | 551 | { |
535 | PhysicsActor actor = m_physicsActor; | 552 | PhysicsActor actor = m_physicsActor; |
536 | if (actor != null) | 553 | if (actor != null) |
554 | { | ||
537 | m_velocity = actor.Velocity; | 555 | m_velocity = actor.Velocity; |
538 | 556 | ||
557 | // m_log.DebugFormat( | ||
558 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
559 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
560 | } | ||
561 | |||
539 | return m_velocity; | 562 | return m_velocity; |
540 | } | 563 | } |
541 | set | 564 | set |
@@ -550,24 +573,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
550 | } | 573 | } |
551 | catch (Exception e) | 574 | catch (Exception e) |
552 | { | 575 | { |
553 | m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); | 576 | m_log.Error("[SCENE PRESENCE]: VELOCITY " + e.Message); |
554 | } | 577 | } |
555 | } | 578 | } |
556 | 579 | ||
557 | m_velocity = value; | 580 | m_velocity = value; |
581 | |||
582 | // m_log.DebugFormat( | ||
583 | // "[SCENE PRESENCE]: In {0} set velocity of {1} to {2}", | ||
584 | // Scene.RegionInfo.RegionName, Name, m_velocity); | ||
558 | } | 585 | } |
559 | } | 586 | } |
560 | 587 | ||
561 | public Quaternion Rotation | 588 | public Quaternion Rotation |
562 | { | 589 | { |
563 | get { return m_bodyRot; } | 590 | get { return m_bodyRot; } |
564 | set { m_bodyRot = value; } | 591 | set |
565 | } | 592 | { |
566 | 593 | m_bodyRot = value; | |
567 | public Quaternion PreviousRotation | 594 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
568 | { | 595 | } |
569 | get { return m_bodyRotPrevious; } | ||
570 | set { m_bodyRotPrevious = value; } | ||
571 | } | 596 | } |
572 | 597 | ||
573 | /// <summary> | 598 | /// <summary> |
@@ -705,23 +730,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
705 | #endregion | 730 | #endregion |
706 | 731 | ||
707 | #region Constructor(s) | 732 | #region Constructor(s) |
708 | 733 | ||
709 | public ScenePresence( | 734 | public ScenePresence( |
710 | IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance, PresenceType type) | 735 | IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) |
711 | { | 736 | { |
737 | AttachmentsSyncLock = new Object(); | ||
738 | |||
712 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 739 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
713 | m_sceneViewer = new SceneViewer(this); | 740 | m_sceneViewer = new SceneViewer(this); |
714 | m_animator = new ScenePresenceAnimator(this); | 741 | m_animator = new ScenePresenceAnimator(this); |
715 | PresenceType = type; | 742 | PresenceType = type; |
716 | m_DrawDistance = world.DefaultDrawDistance; | 743 | m_DrawDistance = world.DefaultDrawDistance; |
717 | m_rootRegionHandle = reginfo.RegionHandle; | 744 | m_rootRegionHandle = world.RegionInfo.RegionHandle; |
718 | m_controllingClient = client; | 745 | m_controllingClient = client; |
719 | m_firstname = m_controllingClient.FirstName; | 746 | m_firstname = m_controllingClient.FirstName; |
720 | m_lastname = m_controllingClient.LastName; | 747 | m_lastname = m_controllingClient.LastName; |
721 | m_name = String.Format("{0} {1}", m_firstname, m_lastname); | 748 | m_name = String.Format("{0} {1}", m_firstname, m_lastname); |
722 | m_scene = world; | 749 | m_scene = world; |
723 | m_uuid = client.AgentId; | 750 | m_uuid = client.AgentId; |
724 | m_regionInfo = reginfo; | ||
725 | m_localId = m_scene.AllocateLocalId(); | 751 | m_localId = m_scene.AllocateLocalId(); |
726 | 752 | ||
727 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | 753 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); |
@@ -983,7 +1009,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
983 | Animator.ResetAnimations(); | 1009 | Animator.ResetAnimations(); |
984 | 1010 | ||
985 | // m_log.DebugFormat( | 1011 | // m_log.DebugFormat( |
986 | // "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1012 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
987 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1013 | // Name, UUID, m_scene.RegionInfo.RegionName); |
988 | 1014 | ||
989 | // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, | 1015 | // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, |
@@ -1150,9 +1176,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1150 | m_callbackURI = null; | 1176 | m_callbackURI = null; |
1151 | } | 1177 | } |
1152 | 1178 | ||
1153 | //m_log.DebugFormat("Completed movement"); | 1179 | //m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); |
1154 | 1180 | ||
1155 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); | 1181 | m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |
1156 | SendInitialData(); | 1182 | SendInitialData(); |
1157 | 1183 | ||
1158 | // Create child agents in neighbouring regions | 1184 | // Create child agents in neighbouring regions |
@@ -1217,7 +1243,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1217 | /// </summary> | 1243 | /// </summary> |
1218 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 1244 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
1219 | { | 1245 | { |
1220 | // m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); | 1246 | // m_log.DebugFormat( |
1247 | // "[SCENE PRESENCE]: In {0} received agent update from {1}", | ||
1248 | // Scene.RegionInfo.RegionName, remoteClient.Name); | ||
1221 | 1249 | ||
1222 | //if (m_isChildAgent) | 1250 | //if (m_isChildAgent) |
1223 | //{ | 1251 | //{ |
@@ -1658,7 +1686,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1658 | /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path | 1686 | /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path |
1659 | /// from start to finish. | 1687 | /// from start to finish. |
1660 | /// </param> | 1688 | /// </param> |
1661 | public void MoveToTarget(Vector3 pos, bool noFly) | 1689 | /// <param name="landAtTarget"> |
1690 | /// If true and the avatar starts flying during the move then land at the target. | ||
1691 | /// </param> | ||
1692 | public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget) | ||
1662 | { | 1693 | { |
1663 | m_log.DebugFormat( | 1694 | m_log.DebugFormat( |
1664 | "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", | 1695 | "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", |
@@ -1684,7 +1715,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1684 | 1715 | ||
1685 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is | 1716 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is |
1686 | // always slightly higher than the actual terrain height. | 1717 | // always slightly higher than the actual terrain height. |
1687 | // FIXME: This constrains NOC movements as well, so should be somewhere else. | 1718 | // FIXME: This constrains NPC movements as well, so should be somewhere else. |
1688 | if (pos.Z - terrainHeight < 0.2) | 1719 | if (pos.Z - terrainHeight < 0.2) |
1689 | pos.Z = terrainHeight; | 1720 | pos.Z = terrainHeight; |
1690 | 1721 | ||
@@ -1697,9 +1728,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
1697 | else if (pos.Z > terrainHeight) | 1728 | else if (pos.Z > terrainHeight) |
1698 | PhysicsActor.Flying = true; | 1729 | PhysicsActor.Flying = true; |
1699 | 1730 | ||
1731 | LandAtTarget = landAtTarget; | ||
1700 | MovingToTarget = true; | 1732 | MovingToTarget = true; |
1701 | MoveToPositionTarget = pos; | 1733 | MoveToPositionTarget = pos; |
1702 | 1734 | ||
1735 | // Rotate presence around the z-axis to point in same direction as movement. | ||
1736 | // Ignore z component of vector | ||
1737 | Vector3 localVectorToTarget3D = pos - AbsolutePosition; | ||
1738 | Vector3 localVectorToTarget2D = new Vector3((float)(localVectorToTarget3D.X), (float)(localVectorToTarget3D.Y), 0f); | ||
1739 | |||
1740 | // m_log.DebugFormat("[SCENE PRESENCE]: Local vector to target is {0}", localVectorToTarget2D); | ||
1741 | |||
1742 | // Calculate the yaw. | ||
1743 | Vector3 angle = new Vector3(0, 0, (float)(Math.Atan2(localVectorToTarget2D.Y, localVectorToTarget2D.X))); | ||
1744 | |||
1745 | // m_log.DebugFormat("[SCENE PRESENCE]: Angle is {0}", angle); | ||
1746 | |||
1747 | Rotation = Quaternion.CreateFromEulers(angle); | ||
1748 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, Rotation); | ||
1749 | |||
1703 | Vector3 agent_control_v3 = new Vector3(); | 1750 | Vector3 agent_control_v3 = new Vector3(); |
1704 | HandleMoveToTargetUpdate(ref agent_control_v3); | 1751 | HandleMoveToTargetUpdate(ref agent_control_v3); |
1705 | AddNewMovement(agent_control_v3); | 1752 | AddNewMovement(agent_control_v3); |
@@ -2389,7 +2436,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2389 | Vector3 pos = m_pos; | 2436 | Vector3 pos = m_pos; |
2390 | pos.Z += m_appearance.HipOffset; | 2437 | pos.Z += m_appearance.HipOffset; |
2391 | 2438 | ||
2392 | //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); | 2439 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); |
2393 | 2440 | ||
2394 | remoteClient.SendPrimUpdate( | 2441 | remoteClient.SendPrimUpdate( |
2395 | this, | 2442 | this, |
@@ -2476,6 +2523,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2476 | /// </summary> | 2523 | /// </summary> |
2477 | private void SendInitialData() | 2524 | private void SendInitialData() |
2478 | { | 2525 | { |
2526 | //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); | ||
2479 | // Moved this into CompleteMovement to ensure that m_appearance is initialized before | 2527 | // Moved this into CompleteMovement to ensure that m_appearance is initialized before |
2480 | // the inventory arrives | 2528 | // the inventory arrives |
2481 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); | 2529 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); |
@@ -2520,10 +2568,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2520 | /// </summary> | 2568 | /// </summary> |
2521 | public void SendAvatarDataToAllAgents() | 2569 | public void SendAvatarDataToAllAgents() |
2522 | { | 2570 | { |
2571 | //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAllAgents: {0} ({1})", Name, UUID); | ||
2523 | // only send update from root agents to other clients; children are only "listening posts" | 2572 | // only send update from root agents to other clients; children are only "listening posts" |
2524 | if (IsChildAgent) | 2573 | if (IsChildAgent) |
2525 | { | 2574 | { |
2526 | m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); | 2575 | m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent"); |
2527 | return; | 2576 | return; |
2528 | } | 2577 | } |
2529 | 2578 | ||
@@ -2573,7 +2622,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2573 | /// <param name="avatar"></param> | 2622 | /// <param name="avatar"></param> |
2574 | public void SendAvatarDataToAgent(ScenePresence avatar) | 2623 | public void SendAvatarDataToAgent(ScenePresence avatar) |
2575 | { | 2624 | { |
2576 | // m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); | 2625 | //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); |
2577 | 2626 | ||
2578 | avatar.ControllingClient.SendAvatarDataImmediate(this); | 2627 | avatar.ControllingClient.SendAvatarDataImmediate(this); |
2579 | if (Animator != null) | 2628 | if (Animator != null) |
@@ -2586,10 +2635,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2586 | /// </summary> | 2635 | /// </summary> |
2587 | public void SendAppearanceToAllOtherAgents() | 2636 | public void SendAppearanceToAllOtherAgents() |
2588 | { | 2637 | { |
2638 | m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} ({1})", Name, UUID); | ||
2589 | // only send update from root agents to other clients; children are only "listening posts" | 2639 | // only send update from root agents to other clients; children are only "listening posts" |
2590 | if (IsChildAgent) | 2640 | if (IsChildAgent) |
2591 | { | 2641 | { |
2592 | m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); | 2642 | m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent"); |
2593 | return; | 2643 | return; |
2594 | } | 2644 | } |
2595 | 2645 | ||
@@ -2615,6 +2665,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2615 | /// </summary> | 2665 | /// </summary> |
2616 | public void SendOtherAgentsAppearanceToMe() | 2666 | public void SendOtherAgentsAppearanceToMe() |
2617 | { | 2667 | { |
2668 | //m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID); | ||
2618 | m_perfMonMS = Util.EnvironmentTickCount(); | 2669 | m_perfMonMS = Util.EnvironmentTickCount(); |
2619 | 2670 | ||
2620 | int count = 0; | 2671 | int count = 0; |
@@ -2873,8 +2924,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2873 | /// </returns> | 2924 | /// </returns> |
2874 | protected int HaveNeighbor(Cardinals car, ref int[] fix) | 2925 | protected int HaveNeighbor(Cardinals car, ref int[] fix) |
2875 | { | 2926 | { |
2876 | uint neighbourx = m_regionInfo.RegionLocX; | 2927 | uint neighbourx = m_scene.RegionInfo.RegionLocX; |
2877 | uint neighboury = m_regionInfo.RegionLocY; | 2928 | uint neighboury = m_scene.RegionInfo.RegionLocY; |
2878 | 2929 | ||
2879 | int dir = (int)car; | 2930 | int dir = (int)car; |
2880 | 2931 | ||
@@ -2894,8 +2945,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2894 | 2945 | ||
2895 | if (neighbourRegion == null) | 2946 | if (neighbourRegion == null) |
2896 | { | 2947 | { |
2897 | fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); | 2948 | fix[0] = (int)(m_scene.RegionInfo.RegionLocX - neighbourx); |
2898 | fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); | 2949 | fix[1] = (int)(m_scene.RegionInfo.RegionLocY - neighboury); |
2899 | return dir * (-1); | 2950 | return dir * (-1); |
2900 | } | 2951 | } |
2901 | else | 2952 | else |
@@ -3141,26 +3192,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3141 | catch { } | 3192 | catch { } |
3142 | 3193 | ||
3143 | // Attachment objects | 3194 | // Attachment objects |
3144 | if (m_attachments != null && m_attachments.Count > 0) | 3195 | lock (m_attachments) |
3145 | { | 3196 | { |
3146 | cAgent.AttachmentObjects = new List<ISceneObject>(); | 3197 | if (m_attachments.Count > 0) |
3147 | cAgent.AttachmentObjectStates = new List<string>(); | ||
3148 | // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); | ||
3149 | m_InTransitScriptStates.Clear(); | ||
3150 | foreach (SceneObjectGroup sog in m_attachments) | ||
3151 | { | 3198 | { |
3152 | // We need to make a copy and pass that copy | 3199 | cAgent.AttachmentObjects = new List<ISceneObject>(); |
3153 | // because of transfers withn the same sim | 3200 | cAgent.AttachmentObjectStates = new List<string>(); |
3154 | ISceneObject clone = sog.CloneForNewScene(); | 3201 | // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); |
3155 | // Attachment module assumes that GroupPosition holds the offsets...! | 3202 | m_InTransitScriptStates.Clear(); |
3156 | ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; | 3203 | |
3157 | ((SceneObjectGroup)clone).IsAttachment = false; | 3204 | foreach (SceneObjectGroup sog in m_attachments) |
3158 | cAgent.AttachmentObjects.Add(clone); | 3205 | { |
3159 | string state = sog.GetStateSnapshot(); | 3206 | // We need to make a copy and pass that copy |
3160 | cAgent.AttachmentObjectStates.Add(state); | 3207 | // because of transfers withn the same sim |
3161 | m_InTransitScriptStates.Add(state); | 3208 | ISceneObject clone = sog.CloneForNewScene(); |
3162 | // Let's remove the scripts of the original object here | 3209 | // Attachment module assumes that GroupPosition holds the offsets...! |
3163 | sog.RemoveScriptInstances(true); | 3210 | ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; |
3211 | ((SceneObjectGroup)clone).IsAttachment = false; | ||
3212 | cAgent.AttachmentObjects.Add(clone); | ||
3213 | string state = sog.GetStateSnapshot(); | ||
3214 | cAgent.AttachmentObjectStates.Add(state); | ||
3215 | m_InTransitScriptStates.Add(state); | ||
3216 | // Let's remove the scripts of the original object here | ||
3217 | sog.RemoveScriptInstances(true); | ||
3218 | } | ||
3164 | } | 3219 | } |
3165 | } | 3220 | } |
3166 | } | 3221 | } |
@@ -3277,6 +3332,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3277 | /// </summary> | 3332 | /// </summary> |
3278 | public void AddToPhysicalScene(bool isFlying) | 3333 | public void AddToPhysicalScene(bool isFlying) |
3279 | { | 3334 | { |
3335 | // m_log.DebugFormat( | ||
3336 | // "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}", | ||
3337 | // Name, isFlying, Scene.RegionInfo.RegionName); | ||
3338 | |||
3280 | if (m_appearance.AvatarHeight == 0) | 3339 | if (m_appearance.AvatarHeight == 0) |
3281 | m_appearance.SetHeight(); | 3340 | m_appearance.SetHeight(); |
3282 | 3341 | ||
@@ -3317,7 +3376,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3317 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3376 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
3318 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | 3377 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( |
3319 | // as of this comment the interval is set in AddToPhysicalScene | 3378 | // as of this comment the interval is set in AddToPhysicalScene |
3320 | if (Animator!=null) | 3379 | if (Animator != null) |
3321 | Animator.UpdateMovementAnimations(); | 3380 | Animator.UpdateMovementAnimations(); |
3322 | 3381 | ||
3323 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3382 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
@@ -3398,7 +3457,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3398 | 3457 | ||
3399 | public void Close() | 3458 | public void Close() |
3400 | { | 3459 | { |
3401 | m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); | 3460 | if (!IsChildAgent) |
3461 | m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); | ||
3402 | 3462 | ||
3403 | lock (m_knownChildRegions) | 3463 | lock (m_knownChildRegions) |
3404 | { | 3464 | { |
@@ -3501,8 +3561,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3501 | /// <summary> | 3561 | /// <summary> |
3502 | /// This is currently just being done for information. | 3562 | /// This is currently just being done for information. |
3503 | /// </summary> | 3563 | /// </summary> |
3504 | public void ValidateAttachments() | 3564 | public bool ValidateAttachments() |
3505 | { | 3565 | { |
3566 | bool validated = true; | ||
3567 | |||
3506 | lock (m_attachments) | 3568 | lock (m_attachments) |
3507 | { | 3569 | { |
3508 | // Validate | 3570 | // Validate |
@@ -3512,15 +3574,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3512 | { | 3574 | { |
3513 | m_log.WarnFormat( | 3575 | m_log.WarnFormat( |
3514 | "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null. Continuing", Name); | 3576 | "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null. Continuing", Name); |
3577 | |||
3578 | validated = false; | ||
3515 | } | 3579 | } |
3516 | else if (gobj.IsDeleted) | 3580 | else if (gobj.IsDeleted) |
3517 | { | 3581 | { |
3518 | m_log.WarnFormat( | 3582 | m_log.WarnFormat( |
3519 | "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted. Continuing", | 3583 | "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted. Continuing", |
3520 | gobj.Name, gobj.UUID, Name); | 3584 | gobj.Name, gobj.UUID, Name); |
3585 | |||
3586 | validated = false; | ||
3521 | } | 3587 | } |
3522 | } | 3588 | } |
3523 | } | 3589 | } |
3590 | |||
3591 | return validated; | ||
3524 | } | 3592 | } |
3525 | 3593 | ||
3526 | /// <summary> | 3594 | /// <summary> |
@@ -3552,29 +3620,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3552 | } | 3620 | } |
3553 | } | 3621 | } |
3554 | 3622 | ||
3555 | |||
3556 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) | ||
3557 | { | ||
3558 | m_controllingClient = client; | ||
3559 | m_regionInfo = region; | ||
3560 | m_scene = scene; | ||
3561 | |||
3562 | RegisterToEvents(); | ||
3563 | |||
3564 | /* | ||
3565 | AbsolutePosition = client.StartPos; | ||
3566 | |||
3567 | Animations = new AvatarAnimations(); | ||
3568 | Animations.LoadAnims(); | ||
3569 | |||
3570 | m_animations = new List<UUID>(); | ||
3571 | m_animations.Add(Animations.AnimsUUID["STAND"]); | ||
3572 | m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); | ||
3573 | |||
3574 | SetDirectionVectors(); | ||
3575 | */ | ||
3576 | } | ||
3577 | |||
3578 | internal void PushForce(Vector3 impulse) | 3623 | internal void PushForce(Vector3 impulse) |
3579 | { | 3624 | { |
3580 | if (PhysicsActor != null) | 3625 | if (PhysicsActor != null) |
@@ -3602,6 +3647,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3602 | obj.ignoreControls = (ScriptControlled)controls; | 3647 | obj.ignoreControls = (ScriptControlled)controls; |
3603 | obj.eventControls = (ScriptControlled)controls; | 3648 | obj.eventControls = (ScriptControlled)controls; |
3604 | } | 3649 | } |
3650 | |||
3605 | if (pass_on == 1 && accept == 1) | 3651 | if (pass_on == 1 && accept == 1) |
3606 | { | 3652 | { |
3607 | IgnoredControls = ScriptControlled.CONTROL_ZERO; | 3653 | IgnoredControls = ScriptControlled.CONTROL_ZERO; |
@@ -3622,6 +3668,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3622 | scriptedcontrols[Script_item_UUID] = obj; | 3668 | scriptedcontrols[Script_item_UUID] = obj; |
3623 | } | 3669 | } |
3624 | } | 3670 | } |
3671 | |||
3625 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); | 3672 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); |
3626 | } | 3673 | } |
3627 | 3674 | ||
@@ -3803,4 +3850,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
3803 | } | 3850 | } |
3804 | } | 3851 | } |
3805 | } | 3852 | } |
3806 | } \ No newline at end of file | 3853 | } |