aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs216
1 files changed, 88 insertions, 128 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 03aa8cf..1fc3ed6 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -75,7 +75,6 @@ namespace OpenSim.Region.Framework.Scenes
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);
77 77
78 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
79// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); 78// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
80 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); 79 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
81 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); 80 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@@ -137,8 +136,6 @@ namespace OpenSim.Region.Framework.Scenes
137 136
138 private SendCourseLocationsMethod m_sendCourseLocationsMethod; 137 private SendCourseLocationsMethod m_sendCourseLocationsMethod;
139 138
140 private bool m_startAnimationSet;
141
142 //private Vector3 m_requestedSitOffset = new Vector3(); 139 //private Vector3 m_requestedSitOffset = new Vector3();
143 140
144 private Vector3 m_LastFinitePos; 141 private Vector3 m_LastFinitePos;
@@ -707,19 +704,14 @@ namespace OpenSim.Region.Framework.Scenes
707 // we created a new ScenePresence (a new child agent) in a fresh region. 704 // we created a new ScenePresence (a new child agent) in a fresh region.
708 // Request info about all the (root) agents in this region 705 // Request info about all the (root) agents in this region
709 // Note: This won't send data *to* other clients in that region (children don't send) 706 // Note: This won't send data *to* other clients in that region (children don't send)
707
708// MIC: This gets called again in CompleteMovement
710 SendInitialFullUpdateToAllClients(); 709 SendInitialFullUpdateToAllClients();
711 710
712 RegisterToEvents(); 711 RegisterToEvents();
713 SetDirectionVectors(); 712 SetDirectionVectors();
714 } 713 }
715 714
716 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
717 AvatarWearable[] wearables)
718 : this(client, world, reginfo)
719 {
720 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
721 }
722
723 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 715 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
724 : this(client, world, reginfo) 716 : this(client, world, reginfo)
725 { 717 {
@@ -733,8 +725,6 @@ namespace OpenSim.Region.Framework.Scenes
733 725
734 public void RegisterToEvents() 726 public void RegisterToEvents()
735 { 727 {
736 m_controllingClient.OnRequestWearables += SendWearables;
737 m_controllingClient.OnSetAppearance += SetAppearance;
738 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; 728 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
739 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; 729 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData;
740 m_controllingClient.OnAgentUpdate += HandleAgentUpdate; 730 m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
@@ -1068,7 +1058,7 @@ namespace OpenSim.Region.Framework.Scenes
1068 /// <summary> 1058 /// <summary>
1069 /// Sets avatar height in the phyiscs plugin 1059 /// Sets avatar height in the phyiscs plugin
1070 /// </summary> 1060 /// </summary>
1071 internal void SetHeight(float height) 1061 public void SetHeight(float height)
1072 { 1062 {
1073 m_avHeight = height; 1063 m_avHeight = height;
1074 if (PhysicsActor != null && !IsChildAgent) 1064 if (PhysicsActor != null && !IsChildAgent)
@@ -2393,15 +2383,26 @@ namespace OpenSim.Region.Framework.Scenes
2393 // 2 stage check is needed. 2383 // 2 stage check is needed.
2394 if (remoteAvatar == null) 2384 if (remoteAvatar == null)
2395 return; 2385 return;
2386
2396 IClientAPI cl=remoteAvatar.ControllingClient; 2387 IClientAPI cl=remoteAvatar.ControllingClient;
2397 if (cl == null) 2388 if (cl == null)
2398 return; 2389 return;
2390
2399 if (m_appearance.Texture == null) 2391 if (m_appearance.Texture == null)
2400 return; 2392 return;
2401 2393
2402 Vector3 pos = m_pos; 2394 if (LocalId == remoteAvatar.LocalId)
2403 pos.Z += m_appearance.HipOffset; 2395 {
2396 m_log.WarnFormat("[SP] An agent is attempting to send data to itself; {0}",UUID);
2397 return;
2398 }
2404 2399
2400 if (IsChildAgent)
2401 {
2402 m_log.WarnFormat("[SCENEPRESENCE] A child agent is attempting to send out avatar data");
2403 return;
2404 }
2405
2405 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); 2406 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this);
2406 m_scene.StatsReporter.AddAgentUpdates(1); 2407 m_scene.StatsReporter.AddAgentUpdates(1);
2407 } 2408 }
@@ -2416,20 +2417,23 @@ namespace OpenSim.Region.Framework.Scenes
2416 m_scene.ForEachScenePresence(delegate(ScenePresence avatar) 2417 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2417 { 2418 {
2418 ++avUpdates; 2419 ++avUpdates;
2419 // only send if this is the root (children are only "listening posts" in a foreign region) 2420
2421 // Don't update ourselves
2422 if (avatar.LocalId == LocalId)
2423 return;
2424
2425 // If this is a root agent, then get info about the avatar
2420 if (!IsChildAgent) 2426 if (!IsChildAgent)
2421 { 2427 {
2422 SendFullUpdateToOtherClient(avatar); 2428 SendFullUpdateToOtherClient(avatar);
2423 } 2429 }
2424 2430
2425 if (avatar.LocalId != LocalId) 2431 // If the other avatar is a root
2432 if (!avatar.IsChildAgent)
2426 { 2433 {
2427 if (!avatar.IsChildAgent) 2434 avatar.SendFullUpdateToOtherClient(this);
2428 { 2435 avatar.SendAppearanceToOtherAgent(this);
2429 avatar.SendFullUpdateToOtherClient(this); 2436 avatar.Animator.SendAnimPackToClient(ControllingClient);
2430 avatar.SendAppearanceToOtherAgent(this);
2431 avatar.Animator.SendAnimPackToClient(ControllingClient);
2432 }
2433 } 2437 }
2434 }); 2438 });
2435 2439
@@ -2444,6 +2448,12 @@ namespace OpenSim.Region.Framework.Scenes
2444 m_perfMonMS = Util.EnvironmentTickCount(); 2448 m_perfMonMS = Util.EnvironmentTickCount();
2445 2449
2446 // only send update from root agents to other clients; children are only "listening posts" 2450 // only send update from root agents to other clients; children are only "listening posts"
2451 if (IsChildAgent)
2452 {
2453 m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent");
2454 return;
2455 }
2456
2447 int count = 0; 2457 int count = 0;
2448 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 2458 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2449 { 2459 {
@@ -2467,29 +2477,32 @@ namespace OpenSim.Region.Framework.Scenes
2467 // the inventory arrives 2477 // the inventory arrives
2468 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2478 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2469 2479
2470 Vector3 pos = m_pos;
2471 pos.Z += m_appearance.HipOffset;
2472
2473 m_controllingClient.SendAvatarDataImmediate(this); 2480 m_controllingClient.SendAvatarDataImmediate(this);
2481 if (m_scene.AvatarFactory != null)
2482 {
2483 if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient))
2484 {
2485 m_log.WarnFormat("[SP] baked textures are in the ache for {0}",Name);
2486 m_controllingClient.SendAppearance(
2487 m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes());
2488 }
2489 }
2490 else
2491 {
2492 m_log.WarnFormat("[SP] AvatarFactory not set");
2493 }
2474 2494
2475 SendInitialFullUpdateToAllClients(); 2495 SendInitialFullUpdateToAllClients();
2476 } 2496 }
2477 2497
2478 /// <summary> 2498 /// <summary>
2479 /// Tell the client for this scene presence what items it should be wearing now
2480 /// </summary>
2481 public void SendWearables()
2482 {
2483 m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name);
2484
2485 ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2486 }
2487
2488 /// <summary>
2489 /// 2499 ///
2490 /// </summary> 2500 /// </summary>
2491 public void SendAppearanceToAllOtherAgents() 2501 public void SendAppearanceToAllOtherAgents()
2492 { 2502 {
2503// DEBUG ON
2504 m_log.WarnFormat("[SP] Send appearance from {0} to all other agents",m_uuid);
2505// DEBUG OFF
2493 m_perfMonMS = Util.EnvironmentTickCount(); 2506 m_perfMonMS = Util.EnvironmentTickCount();
2494 2507
2495 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2508 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
@@ -2509,85 +2522,18 @@ namespace OpenSim.Region.Framework.Scenes
2509 /// <param name="avatar"></param> 2522 /// <param name="avatar"></param>
2510 public void SendAppearanceToOtherAgent(ScenePresence avatar) 2523 public void SendAppearanceToOtherAgent(ScenePresence avatar)
2511 { 2524 {
2512 avatar.ControllingClient.SendAppearance( 2525 if (LocalId == avatar.LocalId)
2513 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
2514 }
2515
2516 /// <summary>
2517 /// Set appearance data (textureentry and slider settings) received from the client
2518 /// </summary>
2519 /// <param name="texture"></param>
2520 /// <param name="visualParam"></param>
2521 public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
2522 {
2523 if (m_physicsActor != null)
2524 {
2525 if (!IsChildAgent)
2526 {
2527 // This may seem like it's redundant, remove the avatar from the physics scene
2528 // just to add it back again, but it saves us from having to update
2529 // 3 variables 10 times a second.
2530 bool flyingTemp = m_physicsActor.Flying;
2531 RemoveFromPhysicalScene();
2532 //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor);
2533
2534 //PhysicsActor = null;
2535
2536 AddToPhysicalScene(flyingTemp);
2537 }
2538 }
2539
2540 #region Bake Cache Check
2541
2542 if (textureEntry != null)
2543 {
2544 for (int i = 0; i < BAKE_INDICES.Length; i++)
2545 {
2546 int j = BAKE_INDICES[i];
2547 Primitive.TextureEntryFace face = textureEntry.FaceTextures[j];
2548
2549 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
2550 {
2551 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
2552 {
2553 m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name);
2554 this.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
2555 }
2556 }
2557 }
2558
2559 }
2560
2561
2562 #endregion Bake Cache Check
2563
2564 m_appearance.SetAppearance(textureEntry, visualParams);
2565 if (m_appearance.AvatarHeight > 0)
2566 SetHeight(m_appearance.AvatarHeight);
2567
2568 // This is not needed, because only the transient data changed
2569 //AvatarData adata = new AvatarData(m_appearance);
2570 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2571
2572 SendAppearanceToAllOtherAgents();
2573 if (!m_startAnimationSet)
2574 { 2526 {
2575 Animator.UpdateMovementAnimations(); 2527 m_log.WarnFormat("[SP] An agent is attempting to send data to itself; {0}",UUID);
2576 m_startAnimationSet = true; 2528 return;
2577 } 2529 }
2578 2530
2579 Vector3 pos = m_pos; 2531// DEBUG ON
2580 pos.Z += m_appearance.HipOffset; 2532// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2581 2533// DEBUG OFF
2582 m_controllingClient.SendAvatarDataImmediate(this);
2583 }
2584 2534
2585 public void SetWearable(int wearableId, AvatarWearable wearable) 2535 avatar.ControllingClient.SendAppearance(
2586 { 2536 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
2587 m_appearance.SetWearable(wearableId, wearable);
2588 AvatarData adata = new AvatarData(m_appearance);
2589 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2590 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2591 } 2537 }
2592 2538
2593 // Because appearance setting is in a module, we actually need 2539 // Because appearance setting is in a module, we actually need
@@ -2983,6 +2929,8 @@ namespace OpenSim.Region.Framework.Scenes
2983 2929
2984 public void CopyTo(AgentData cAgent) 2930 public void CopyTo(AgentData cAgent)
2985 { 2931 {
2932 cAgent.CallbackURI = m_callbackURI;
2933
2986 cAgent.AgentID = UUID; 2934 cAgent.AgentID = UUID;
2987 cAgent.RegionID = Scene.RegionInfo.RegionID; 2935 cAgent.RegionID = Scene.RegionInfo.RegionID;
2988 2936
@@ -3022,6 +2970,9 @@ namespace OpenSim.Region.Framework.Scenes
3022 2970
3023 cAgent.AlwaysRun = m_setAlwaysRun; 2971 cAgent.AlwaysRun = m_setAlwaysRun;
3024 2972
2973 cAgent.Appearance = new AvatarAppearance(m_appearance);
2974
2975/*
3025 try 2976 try
3026 { 2977 {
3027 // We might not pass the Wearables in all cases... 2978 // We might not pass the Wearables in all cases...
@@ -3061,14 +3012,14 @@ namespace OpenSim.Region.Framework.Scenes
3061 { 3012 {
3062 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); 3013 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
3063 int i = 0; 3014 int i = 0;
3064 AttachmentData[] attachs = new AttachmentData[attPoints.Count]; 3015 AvatarAttachment[] attachs = new AvatarAttachment[attPoints.Count];
3065 foreach (int point in attPoints) 3016 foreach (int point in attPoints)
3066 { 3017 {
3067 attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); 3018 attachs[i++] = new AvatarAttachment(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
3068 } 3019 }
3069 cAgent.Attachments = attachs; 3020 cAgent.Attachments = attachs;
3070 } 3021 }
3071 3022*/
3072 lock (scriptedcontrols) 3023 lock (scriptedcontrols)
3073 { 3024 {
3074 ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; 3025 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
@@ -3095,6 +3046,9 @@ namespace OpenSim.Region.Framework.Scenes
3095 3046
3096 public void CopyFrom(AgentData cAgent) 3047 public void CopyFrom(AgentData cAgent)
3097 { 3048 {
3049// DEBUG ON
3050 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
3051// DEBUG OFF
3098 m_originRegionID = cAgent.RegionID; 3052 m_originRegionID = cAgent.RegionID;
3099 3053
3100 m_callbackURI = cAgent.CallbackURI; 3054 m_callbackURI = cAgent.CallbackURI;
@@ -3120,6 +3074,9 @@ namespace OpenSim.Region.Framework.Scenes
3120 m_godLevel = cAgent.GodLevel; 3074 m_godLevel = cAgent.GodLevel;
3121 m_setAlwaysRun = cAgent.AlwaysRun; 3075 m_setAlwaysRun = cAgent.AlwaysRun;
3122 3076
3077 m_appearance = new AvatarAppearance(cAgent.Appearance);
3078
3079/*
3123 uint i = 0; 3080 uint i = 0;
3124 try 3081 try
3125 { 3082 {
@@ -3132,15 +3089,17 @@ namespace OpenSim.Region.Framework.Scenes
3132 UUID assetId = cAgent.Wearables[n + 1]; 3089 UUID assetId = cAgent.Wearables[n + 1];
3133 wears[i++] = new AvatarWearable(itemId, assetId); 3090 wears[i++] = new AvatarWearable(itemId, assetId);
3134 } 3091 }
3135 m_appearance.Wearables = wears; 3092 // m_appearance.Wearables = wears;
3136 Primitive.TextureEntry te; 3093 Primitive.TextureEntry textures = null;
3137 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) 3094 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1)
3138 te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); 3095 textures = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length);
3139 else 3096
3140 te = AvatarAppearance.GetDefaultTexture(); 3097 byte[] visuals = null;
3141 if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) 3098
3142 cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); 3099 if ((cAgent.VisualParams != null) && (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT))
3143 m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); 3100 visuals = (byte[])cAgent.VisualParams.Clone();
3101
3102 m_appearance = new AvatarAppearance(cAgent.AgentID,wears,textures,visuals);
3144 } 3103 }
3145 catch (Exception e) 3104 catch (Exception e)
3146 { 3105 {
@@ -3153,14 +3112,14 @@ namespace OpenSim.Region.Framework.Scenes
3153 if (cAgent.Attachments != null) 3112 if (cAgent.Attachments != null)
3154 { 3113 {
3155 m_appearance.ClearAttachments(); 3114 m_appearance.ClearAttachments();
3156 foreach (AttachmentData att in cAgent.Attachments) 3115 foreach (AvatarAttachment att in cAgent.Attachments)
3157 { 3116 {
3158 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); 3117 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
3159 } 3118 }
3160 } 3119 }
3161 } 3120 }
3162 catch { } 3121 catch { }
3163 3122*/
3164 try 3123 try
3165 { 3124 {
3166 lock (scriptedcontrols) 3125 lock (scriptedcontrols)
@@ -3729,15 +3688,16 @@ namespace OpenSim.Region.Framework.Scenes
3729 return; 3688 return;
3730 } 3689 }
3731 3690
3732 List<int> attPoints = m_appearance.GetAttachedPoints(); 3691 List<AvatarAttachment> attachments = m_appearance.GetAttachments();
3733 foreach (int p in attPoints) 3692 foreach (AvatarAttachment attach in attachments)
3734 { 3693 {
3735 if (m_isDeleted) 3694 if (m_isDeleted)
3736 return; 3695 return;
3737 3696
3738 UUID itemID = m_appearance.GetAttachedItem(p); 3697 int p = attach.AttachPoint;
3698 UUID itemID = attach.ItemID;
3739 3699
3740 //UUID assetID = m_appearance.GetAttachedAsset(p); 3700 //UUID assetID = attach.AssetID;
3741 // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down 3701 // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
3742 // But they're not used anyway, the item is being looked up for now, so let's proceed. 3702 // But they're not used anyway, the item is being looked up for now, so let's proceed.
3743 //if (UUID.Zero == assetID) 3703 //if (UUID.Zero == assetID)