aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs186
1 files changed, 127 insertions, 59 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6a2ab02..453523a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -33,12 +33,12 @@ using OpenMetaverse;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Client; 35using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation; 37using OpenSim.Region.Framework.Scenes.Animation;
39using OpenSim.Region.Framework.Scenes.Types; 38using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Interfaces;
42 42
43namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
44{ 44{
@@ -167,6 +167,8 @@ namespace OpenSim.Region.Framework.Scenes
167 167
168 private Quaternion m_bodyRot= Quaternion.Identity; 168 private Quaternion m_bodyRot= Quaternion.Identity;
169 169
170 private Quaternion m_bodyRotPrevious = Quaternion.Identity;
171
170 private const int LAND_VELOCITYMAG_MAX = 12; 172 private const int LAND_VELOCITYMAG_MAX = 12;
171 173
172 public bool IsRestrictedToRegion; 174 public bool IsRestrictedToRegion;
@@ -233,7 +235,7 @@ namespace OpenSim.Region.Framework.Scenes
233 // Agent's Draw distance. 235 // Agent's Draw distance.
234 protected float m_DrawDistance; 236 protected float m_DrawDistance;
235 237
236 protected AvatarAppearance m_appearance; 238 protected AvatarAppearance m_appearance;
237 239
238 // neighbouring regions we have enabled a child agent in 240 // neighbouring regions we have enabled a child agent in
239 // holds the seed cap for the child agent in that region 241 // holds the seed cap for the child agent in that region
@@ -264,6 +266,8 @@ namespace OpenSim.Region.Framework.Scenes
264 266
265 // For teleports and crossings callbacks 267 // For teleports and crossings callbacks
266 string m_callbackURI; 268 string m_callbackURI;
269 UUID m_originRegionID;
270
267 ulong m_rootRegionHandle; 271 ulong m_rootRegionHandle;
268 272
269 /// <value> 273 /// <value>
@@ -518,6 +522,12 @@ namespace OpenSim.Region.Framework.Scenes
518 set { m_bodyRot = value; } 522 set { m_bodyRot = value; }
519 } 523 }
520 524
525 public Quaternion PreviousRotation
526 {
527 get { return m_bodyRotPrevious; }
528 set { m_bodyRotPrevious = value; }
529 }
530
521 /// <summary> 531 /// <summary>
522 /// If this is true, agent doesn't have a representation in this scene. 532 /// If this is true, agent doesn't have a representation in this scene.
523 /// this is an agent 'looking into' this scene from a nearby scene(region) 533 /// this is an agent 'looking into' this scene from a nearby scene(region)
@@ -650,7 +660,7 @@ namespace OpenSim.Region.Framework.Scenes
650 #region Constructor(s) 660 #region Constructor(s)
651 661
652 public ScenePresence() 662 public ScenePresence()
653 { 663 {
654 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 664 m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
655 CreateSceneViewer(); 665 CreateSceneViewer();
656 m_animator = new ScenePresenceAnimator(this); 666 m_animator = new ScenePresenceAnimator(this);
@@ -868,6 +878,31 @@ namespace OpenSim.Region.Framework.Scenes
868 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) 878 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0)
869 { 879 {
870 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); 880 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
881
882 if (pos.X < 0)
883 {
884 emergencyPos.X = (int)Constants.RegionSize + pos.X;
885 if (!(pos.Y < 0))
886 emergencyPos.Y = pos.Y;
887 if (!(pos.Z < 0))
888 emergencyPos.X = pos.X;
889 }
890 if (pos.Y < 0)
891 {
892 emergencyPos.Y = (int)Constants.RegionSize + pos.Y;
893 if (!(pos.X < 0))
894 emergencyPos.X = pos.X;
895 if (!(pos.Z < 0))
896 emergencyPos.Z = pos.Z;
897 }
898 if (pos.Z < 0)
899 {
900 if (!(pos.X < 0))
901 emergencyPos.X = pos.X;
902 if (!(pos.Y < 0))
903 emergencyPos.Y = pos.Y;
904 //Leave as 128
905 }
871 906
872 m_log.WarnFormat( 907 m_log.WarnFormat(
873 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 908 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
@@ -1127,8 +1162,10 @@ namespace OpenSim.Region.Framework.Scenes
1127 /// This is called upon a very important packet sent from the client, 1162 /// This is called upon a very important packet sent from the client,
1128 /// so it's client-controlled. Never call this method directly. 1163 /// so it's client-controlled. Never call this method directly.
1129 /// </summary> 1164 /// </summary>
1130 public void CompleteMovement() 1165 public void CompleteMovement(IClientAPI client)
1131 { 1166 {
1167 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1168
1132 Vector3 look = Velocity; 1169 Vector3 look = Velocity;
1133 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1170 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1134 { 1171 {
@@ -1153,7 +1190,7 @@ namespace OpenSim.Region.Framework.Scenes
1153 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1190 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1154 { 1191 {
1155 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1192 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1156 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1193 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1157 m_callbackURI = null; 1194 m_callbackURI = null;
1158 } 1195 }
1159 1196
@@ -1161,6 +1198,21 @@ namespace OpenSim.Region.Framework.Scenes
1161 1198
1162 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1199 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1163 SendInitialData(); 1200 SendInitialData();
1201
1202 // Create child agents in neighbouring regions
1203 if (!m_isChildAgent)
1204 {
1205 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1206 if (m_agentTransfer != null)
1207 m_agentTransfer.EnableChildAgents(this);
1208 else
1209 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1210
1211 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1212 if (friendsModule != null)
1213 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1214 }
1215
1164 } 1216 }
1165 1217
1166 /// <summary> 1218 /// <summary>
@@ -2364,6 +2416,7 @@ namespace OpenSim.Region.Framework.Scenes
2364 { 2416 {
2365 if (m_isChildAgent) 2417 if (m_isChildAgent)
2366 { 2418 {
2419 // WHAT???
2367 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2420 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2368 2421
2369 // we have to reset the user's child agent connections. 2422 // we have to reset the user's child agent connections.
@@ -2387,7 +2440,9 @@ namespace OpenSim.Region.Framework.Scenes
2387 2440
2388 if (m_scene.SceneGridService != null) 2441 if (m_scene.SceneGridService != null)
2389 { 2442 {
2390 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2443 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2444 if (m_agentTransfer != null)
2445 m_agentTransfer.EnableChildAgents(this);
2391 } 2446 }
2392 2447
2393 return; 2448 return;
@@ -2687,14 +2742,9 @@ namespace OpenSim.Region.Framework.Scenes
2687 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2742 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2688 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); 2743 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2689 2744
2690 if (!m_isChildAgent)
2691 {
2692 m_scene.InformClientOfNeighbours(this);
2693 }
2694
2695 SendInitialFullUpdateToAllClients(); 2745 SendInitialFullUpdateToAllClients();
2696 SendAppearanceToAllOtherAgents(); 2746 SendAppearanceToAllOtherAgents();
2697 } 2747 }
2698 2748
2699 /// <summary> 2749 /// <summary>
2700 /// Tell the client for this scene presence what items it should be wearing now 2750 /// Tell the client for this scene presence what items it should be wearing now
@@ -2776,14 +2826,19 @@ namespace OpenSim.Region.Framework.Scenes
2776 } 2826 }
2777 } 2827 }
2778 } 2828 }
2829
2779 } 2830 }
2780 2831
2832
2781 #endregion Bake Cache Check 2833 #endregion Bake Cache Check
2782 2834
2783 m_appearance.SetAppearance(textureEntry, visualParams); 2835 m_appearance.SetAppearance(textureEntry, visualParams);
2784 if (m_appearance.AvatarHeight > 0) 2836 if (m_appearance.AvatarHeight > 0)
2785 SetHeight(m_appearance.AvatarHeight); 2837 SetHeight(m_appearance.AvatarHeight);
2786 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2838
2839 // This is not needed, because only the transient data changed
2840 //AvatarData adata = new AvatarData(m_appearance);
2841 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2787 2842
2788 SendAppearanceToAllOtherAgents(); 2843 SendAppearanceToAllOtherAgents();
2789 if (!m_startAnimationSet) 2844 if (!m_startAnimationSet)
@@ -2803,7 +2858,8 @@ namespace OpenSim.Region.Framework.Scenes
2803 public void SetWearable(int wearableId, AvatarWearable wearable) 2858 public void SetWearable(int wearableId, AvatarWearable wearable)
2804 { 2859 {
2805 m_appearance.SetWearable(wearableId, wearable); 2860 m_appearance.SetWearable(wearableId, wearable);
2806 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2861 AvatarData adata = new AvatarData(m_appearance);
2862 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2807 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2863 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2808 } 2864 }
2809 2865
@@ -2900,36 +2956,75 @@ namespace OpenSim.Region.Framework.Scenes
2900 { 2956 {
2901 // Checks if where it's headed exists a region 2957 // Checks if where it's headed exists a region
2902 2958
2959 bool needsTransit = false;
2903 if (m_scene.TestBorderCross(pos2, Cardinals.W)) 2960 if (m_scene.TestBorderCross(pos2, Cardinals.W))
2904 { 2961 {
2905 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2962 if (m_scene.TestBorderCross(pos2, Cardinals.S))
2963 {
2964 needsTransit = true;
2906 neighbor = HaveNeighbor(Cardinals.SW, ref fix); 2965 neighbor = HaveNeighbor(Cardinals.SW, ref fix);
2966 }
2907 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2967 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2968 {
2969 needsTransit = true;
2908 neighbor = HaveNeighbor(Cardinals.NW, ref fix); 2970 neighbor = HaveNeighbor(Cardinals.NW, ref fix);
2971 }
2909 else 2972 else
2973 {
2974 needsTransit = true;
2910 neighbor = HaveNeighbor(Cardinals.W, ref fix); 2975 neighbor = HaveNeighbor(Cardinals.W, ref fix);
2976 }
2911 } 2977 }
2912 else if (m_scene.TestBorderCross(pos2, Cardinals.E)) 2978 else if (m_scene.TestBorderCross(pos2, Cardinals.E))
2913 { 2979 {
2914 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2980 if (m_scene.TestBorderCross(pos2, Cardinals.S))
2981 {
2982 needsTransit = true;
2915 neighbor = HaveNeighbor(Cardinals.SE, ref fix); 2983 neighbor = HaveNeighbor(Cardinals.SE, ref fix);
2984 }
2916 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2985 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2986 {
2987 needsTransit = true;
2917 neighbor = HaveNeighbor(Cardinals.NE, ref fix); 2988 neighbor = HaveNeighbor(Cardinals.NE, ref fix);
2989 }
2918 else 2990 else
2991 {
2992 needsTransit = true;
2919 neighbor = HaveNeighbor(Cardinals.E, ref fix); 2993 neighbor = HaveNeighbor(Cardinals.E, ref fix);
2994 }
2920 } 2995 }
2921 else if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2996 else if (m_scene.TestBorderCross(pos2, Cardinals.S))
2997 {
2998 needsTransit = true;
2922 neighbor = HaveNeighbor(Cardinals.S, ref fix); 2999 neighbor = HaveNeighbor(Cardinals.S, ref fix);
3000 }
2923 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 3001 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
3002 {
3003 needsTransit = true;
2924 neighbor = HaveNeighbor(Cardinals.N, ref fix); 3004 neighbor = HaveNeighbor(Cardinals.N, ref fix);
3005 }
3006
2925 3007
2926
2927 // Makes sure avatar does not end up outside region 3008 // Makes sure avatar does not end up outside region
2928 if (neighbor < 0) 3009 if (neighbor <= 0)
2929 AbsolutePosition = new Vector3( 3010 {
2930 AbsolutePosition.X + 3*fix[0], 3011 if (!needsTransit)
2931 AbsolutePosition.Y + 3*fix[1], 3012 {
2932 AbsolutePosition.Z); 3013 if (m_requestedSitTargetUUID == UUID.Zero)
3014 {
3015 Vector3 pos = AbsolutePosition;
3016 if (AbsolutePosition.X < 0)
3017 pos.X += Velocity.X;
3018 else if (AbsolutePosition.X > Constants.RegionSize)
3019 pos.X -= Velocity.X;
3020 if (AbsolutePosition.Y < 0)
3021 pos.Y += Velocity.Y;
3022 else if (AbsolutePosition.Y > Constants.RegionSize)
3023 pos.Y -= Velocity.Y;
3024 AbsolutePosition = pos;
3025 }
3026 }
3027 }
2933 else if (neighbor > 0) 3028 else if (neighbor > 0)
2934 CrossToNewRegion(); 3029 CrossToNewRegion();
2935 } 3030 }
@@ -3087,11 +3182,14 @@ namespace OpenSim.Region.Framework.Scenes
3087 // For now, assign god level 200 to anyone 3182 // For now, assign god level 200 to anyone
3088 // who is granted god powers, but has no god level set. 3183 // who is granted god powers, but has no god level set.
3089 // 3184 //
3090 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 3185 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
3091 if (profile.UserProfile.GodLevel > 0) 3186 if (account != null)
3092 m_godlevel = profile.UserProfile.GodLevel; 3187 {
3093 else 3188 if (account.UserLevel > 0)
3094 m_godlevel = 200; 3189 m_godlevel = account.UserLevel;
3190 else
3191 m_godlevel = 200;
3192 }
3095 } 3193 }
3096 else 3194 else
3097 { 3195 {
@@ -3157,7 +3255,7 @@ namespace OpenSim.Region.Framework.Scenes
3157 public void CopyTo(AgentData cAgent) 3255 public void CopyTo(AgentData cAgent)
3158 { 3256 {
3159 cAgent.AgentID = UUID; 3257 cAgent.AgentID = UUID;
3160 cAgent.RegionHandle = m_rootRegionHandle; 3258 cAgent.RegionID = Scene.RegionInfo.RegionID;
3161 3259
3162 cAgent.Position = AbsolutePosition; 3260 cAgent.Position = AbsolutePosition;
3163 cAgent.Velocity = m_velocity; 3261 cAgent.Velocity = m_velocity;
@@ -3256,7 +3354,7 @@ namespace OpenSim.Region.Framework.Scenes
3256 3354
3257 public void CopyFrom(AgentData cAgent) 3355 public void CopyFrom(AgentData cAgent)
3258 { 3356 {
3259 m_rootRegionHandle = cAgent.RegionHandle; 3357 m_originRegionID = cAgent.RegionID;
3260 3358
3261 m_callbackURI = cAgent.CallbackURI; 3359 m_callbackURI = cAgent.CallbackURI;
3262 3360
@@ -3400,7 +3498,7 @@ namespace OpenSim.Region.Framework.Scenes
3400 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 3498 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
3401 m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong 3499 m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
3402 m_physicsActor.SubscribeEvents(500); 3500 m_physicsActor.SubscribeEvents(500);
3403 m_physicsActor.LocalID = LocalId; 3501 m_physicsActor.LocalID = LocalId;
3404 } 3502 }
3405 3503
3406 private void OutOfBoundsCall(Vector3 pos) 3504 private void OutOfBoundsCall(Vector3 pos)
@@ -3503,7 +3601,7 @@ namespace OpenSim.Region.Framework.Scenes
3503 } 3601 }
3504 if (m_health <= 0) 3602 if (m_health <= 0)
3505 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3603 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3506 } 3604 }
3507 } 3605 }
3508 3606
3509 public void setHealthWithUpdate(float health) 3607 public void setHealthWithUpdate(float health)
@@ -3636,36 +3734,6 @@ namespace OpenSim.Region.Framework.Scenes
3636 } 3734 }
3637 } 3735 }
3638 3736
3639 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3640 {
3641 lock (m_attachments)
3642 {
3643 // Validate
3644 foreach (SceneObjectGroup gobj in m_attachments)
3645 {
3646 if (gobj == null || gobj.IsDeleted)
3647 return false;
3648 }
3649
3650 foreach (SceneObjectGroup gobj in m_attachments)
3651 {
3652 // If the prim group is null then something must have happened to it!
3653 if (gobj != null && gobj.RootPart != null)
3654 {
3655 // Set the parent localID to 0 so it transfers over properly.
3656 gobj.RootPart.SetParentLocalId(0);
3657 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3658 gobj.RootPart.IsAttachment = false;
3659 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3660 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3661 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3662 }
3663 }
3664 m_attachments.Clear();
3665
3666 return true;
3667 }
3668 }
3669 3737
3670 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3738 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3671 { 3739 {