diff options
author | Melanie | 2010-10-29 21:22:35 +0100 |
---|---|---|
committer | Melanie | 2010-10-29 21:22:35 +0100 |
commit | 69c1e0b2f7cfaa195a8496aff1fb23c24a645c6e (patch) | |
tree | 2a046b787abced2a1e68b1e62831e0b4f3778323 /OpenSim/Region | |
parent | Add my work on top of cmickeyb's (diff) | |
parent | Rename the new default texture to be consistent with the others (diff) | |
download | opensim-SC-69c1e0b2f7cfaa195a8496aff1fb23c24a645c6e.zip opensim-SC-69c1e0b2f7cfaa195a8496aff1fb23c24a645c6e.tar.gz opensim-SC-69c1e0b2f7cfaa195a8496aff1fb23c24a645c6e.tar.bz2 opensim-SC-69c1e0b2f7cfaa195a8496aff1fb23c24a645c6e.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region')
6 files changed, 327 insertions, 116 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index facf146..e453618 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -124,15 +124,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
124 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | 124 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); |
125 | 125 | ||
126 | // Save avatar attachment information | 126 | // Save avatar attachment information |
127 | ScenePresence presence; | 127 | m_log.Info( |
128 | if (m_scene.AvatarService != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 128 | "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId |
129 | { | 129 | + ", AttachmentPoint: " + AttachmentPt); |
130 | m_log.Info( | ||
131 | "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
132 | + ", AttachmentPoint: " + AttachmentPt); | ||
133 | 130 | ||
134 | m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance); | 131 | if (m_scene.AvatarFactory != null) |
135 | } | 132 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
136 | } | 133 | } |
137 | } | 134 | } |
138 | catch (Exception e) | 135 | catch (Exception e) |
@@ -399,8 +396,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
399 | item = m_scene.InventoryService.GetItem(item); | 396 | item = m_scene.InventoryService.GetItem(item); |
400 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); | 397 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); |
401 | 398 | ||
402 | if (m_scene.AvatarService != null) | 399 | if (m_scene.AvatarFactory != null) |
403 | m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance); | 400 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
404 | } | 401 | } |
405 | } | 402 | } |
406 | 403 | ||
@@ -422,11 +419,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
422 | presence.Appearance.DetachAttachment(itemID); | 419 | presence.Appearance.DetachAttachment(itemID); |
423 | 420 | ||
424 | // Save avatar attachment information | 421 | // Save avatar attachment information |
425 | if (m_scene.AvatarService != null) | 422 | m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID); |
426 | { | 423 | if (m_scene.AvatarFactory != null) |
427 | m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID); | 424 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
428 | m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance); | ||
429 | } | ||
430 | } | 425 | } |
431 | 426 | ||
432 | DetachSingleAttachmentToInv(itemID, remoteClient); | 427 | DetachSingleAttachmentToInv(itemID, remoteClient); |
@@ -452,10 +447,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
452 | 447 | ||
453 | presence.Appearance.DetachAttachment(itemID); | 448 | presence.Appearance.DetachAttachment(itemID); |
454 | 449 | ||
455 | if (m_scene.AvatarService != null) | 450 | if (m_scene.AvatarFactory != null) |
456 | { | 451 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
457 | m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance); | 452 | |
458 | } | ||
459 | part.ParentGroup.DetachToGround(); | 453 | part.ParentGroup.DetachToGround(); |
460 | 454 | ||
461 | List<UUID> uuids = new List<UUID>(); | 455 | List<UUID> uuids = new List<UUID>(); |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 9f7ff7f..bfbbcf8 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -32,23 +32,45 @@ using Nini.Config; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | 34 | ||
35 | using System.Threading; | ||
36 | using System.Timers; | ||
37 | using System.Collections.Generic; | ||
38 | |||
35 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
38 | 42 | ||
39 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | 43 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory |
40 | { | 44 | { |
41 | public class AvatarFactoryModule : IRegionModule | 45 | public class AvatarFactoryModule : IAvatarFactory, IRegionModule |
42 | { | 46 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | ||
45 | private Scene m_scene = null; | 48 | private Scene m_scene = null; |
46 | 49 | ||
47 | private bool m_startAnimationSet = false; | 50 | private int m_savetime = 5; // seconds to wait before saving changed appearance |
51 | private int m_sendtime = 2; // seconds to wait before sending changed appearance | ||
52 | |||
53 | private int m_checkTime = 500; // milliseconds to wait between checks for appearance updates | ||
54 | private System.Timers.Timer m_updateTimer = new System.Timers.Timer(); | ||
55 | private Dictionary<UUID,long> m_savequeue = new Dictionary<UUID,long>(); | ||
56 | private Dictionary<UUID,long> m_sendqueue = new Dictionary<UUID,long>(); | ||
48 | 57 | ||
49 | public void Initialise(Scene scene, IConfigSource source) | 58 | #region RegionModule Members |
59 | |||
60 | public void Initialise(Scene scene, IConfigSource config) | ||
50 | { | 61 | { |
62 | scene.RegisterModuleInterface<IAvatarFactory>(this); | ||
51 | scene.EventManager.OnNewClient += NewClient; | 63 | scene.EventManager.OnNewClient += NewClient; |
64 | |||
65 | if (config != null) | ||
66 | { | ||
67 | IConfig sconfig = config.Configs["Startup"]; | ||
68 | if (sconfig != null) | ||
69 | { | ||
70 | m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime))); | ||
71 | m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime))); | ||
72 | } | ||
73 | } | ||
52 | 74 | ||
53 | if (m_scene == null) | 75 | if (m_scene == null) |
54 | m_scene = scene; | 76 | m_scene = scene; |
@@ -56,6 +78,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
56 | 78 | ||
57 | public void PostInitialise() | 79 | public void PostInitialise() |
58 | { | 80 | { |
81 | m_updateTimer.Enabled = false; | ||
82 | m_updateTimer.AutoReset = true; | ||
83 | m_updateTimer.Interval = m_checkTime; // 500 milliseconds wait to start async ops | ||
84 | m_updateTimer.Elapsed += new ElapsedEventHandler(HandleAppearanceUpdateTimer); | ||
59 | } | 85 | } |
60 | 86 | ||
61 | public void Close() | 87 | public void Close() |
@@ -84,6 +110,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
84 | // client.OnAvatarNowWearing -= AvatarIsWearing; | 110 | // client.OnAvatarNowWearing -= AvatarIsWearing; |
85 | } | 111 | } |
86 | 112 | ||
113 | #endregion | ||
114 | |||
115 | public bool ValidateBakedTextureCache(IClientAPI client) | ||
116 | { | ||
117 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | ||
118 | if (sp == null) | ||
119 | { | ||
120 | m_log.WarnFormat("[AVFACTORY] SetAppearance unable to find presence for {0}",client.AgentId); | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | bool cached = true; | ||
125 | |||
126 | // Process the texture entry | ||
127 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | ||
128 | { | ||
129 | int idx = AvatarAppearance.BAKE_INDICES[i]; | ||
130 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; | ||
131 | if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) | ||
132 | if (! CheckBakedTextureAsset(client,face.TextureID,idx)) | ||
133 | { | ||
134 | sp.Appearance.Texture.FaceTextures[idx] = null; | ||
135 | cached = false; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | return cached; | ||
140 | } | ||
141 | |||
142 | |||
87 | /// <summary> | 143 | /// <summary> |
88 | /// Set appearance data (textureentry and slider settings) received from the client | 144 | /// Set appearance data (textureentry and slider settings) received from the client |
89 | /// </summary> | 145 | /// </summary> |
@@ -91,6 +147,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
91 | /// <param name="visualParam"></param> | 147 | /// <param name="visualParam"></param> |
92 | public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) | 148 | public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) |
93 | { | 149 | { |
150 | // DEBUG ON | ||
151 | m_log.WarnFormat("[AVFACTORY] SetAppearance for {0}",client.AgentId); | ||
152 | // DEBUG OFF | ||
153 | |||
94 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 154 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
95 | if (sp == null) | 155 | if (sp == null) |
96 | { | 156 | { |
@@ -98,85 +158,179 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
98 | return; | 158 | return; |
99 | } | 159 | } |
100 | 160 | ||
101 | // DEBUG ON | ||
102 | m_log.WarnFormat("[AVFACTORY] SetAppearance for {0}",client.AgentId); | ||
103 | // DEBUG OFF | ||
104 | |||
105 | /* | ||
106 | if (m_physicsActor != null) | ||
107 | { | ||
108 | if (!IsChildAgent) | ||
109 | { | ||
110 | // This may seem like it's redundant, remove the avatar from the physics scene | ||
111 | // just to add it back again, but it saves us from having to update | ||
112 | // 3 variables 10 times a second. | ||
113 | bool flyingTemp = m_physicsActor.Flying; | ||
114 | RemoveFromPhysicalScene(); | ||
115 | //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); | ||
116 | |||
117 | //PhysicsActor = null; | ||
118 | |||
119 | AddToPhysicalScene(flyingTemp); | ||
120 | } | ||
121 | } | ||
122 | */ | ||
123 | #region Bake Cache Check | ||
124 | |||
125 | bool changed = false; | 161 | bool changed = false; |
126 | 162 | ||
127 | // Process the texture entry | 163 | // Process the texture entry |
128 | if (textureEntry != null) | 164 | if (textureEntry != null) |
129 | { | 165 | { |
130 | for (int i = 0; i < BAKE_INDICES.Length; i++) | 166 | changed = sp.Appearance.SetTextureEntries(textureEntry); |
131 | { | ||
132 | int j = BAKE_INDICES[i]; | ||
133 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; | ||
134 | 167 | ||
168 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | ||
169 | { | ||
170 | int idx = AvatarAppearance.BAKE_INDICES[i]; | ||
171 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; | ||
135 | if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) | 172 | if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) |
136 | { | 173 | Util.FireAndForget(delegate(object o) { |
137 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | 174 | if (! CheckBakedTextureAsset(client,face.TextureID,idx)) |
138 | { | 175 | client.SendRebakeAvatarTextures(face.TextureID); |
139 | m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",face.TextureID,j,this.Name); | 176 | }); |
140 | client.SendRebakeAvatarTextures(face.TextureID); | ||
141 | } | ||
142 | } | ||
143 | } | 177 | } |
144 | changed = sp.Appearance.SetTextureEntries(textureEntry); | ||
145 | |||
146 | } | 178 | } |
147 | 179 | ||
148 | #endregion Bake Cache Check | 180 | // Process the visual params, this may change height as well |
149 | 181 | if (visualParams != null) | |
150 | changed = sp.Appearance.SetVisualParams(visualParams) || changed; | 182 | { |
151 | 183 | if (sp.Appearance.SetVisualParams(visualParams)) | |
152 | // If nothing changed (this happens frequently) just return | 184 | { |
185 | changed = true; | ||
186 | if (sp.Appearance.AvatarHeight > 0) | ||
187 | sp.SetHeight(sp.Appearance.AvatarHeight); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | // If something changed in the appearance then queue an appearance save | ||
153 | if (changed) | 192 | if (changed) |
193 | QueueAppearanceSave(client.AgentId); | ||
194 | |||
195 | // And always queue up an appearance update to send out | ||
196 | QueueAppearanceSend(client.AgentId); | ||
197 | |||
198 | // Send the appearance back to the avatar | ||
199 | // AvatarAppearance avp = sp.Appearance; | ||
200 | // sp.ControllingClient.SendAvatarDataImmediate(sp); | ||
201 | // sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes()); | ||
202 | } | ||
203 | |||
204 | /// <summary> | ||
205 | /// Checks for the existance of a baked texture asset and | ||
206 | /// requests the viewer rebake if the asset is not found | ||
207 | /// </summary> | ||
208 | /// <param name="client"></param> | ||
209 | /// <param name="textureID"></param> | ||
210 | /// <param name="idx"></param> | ||
211 | private bool CheckBakedTextureAsset(IClientAPI client, UUID textureID, int idx) | ||
212 | { | ||
213 | if (m_scene.AssetService.Get(textureID.ToString()) == null) | ||
154 | { | 214 | { |
215 | m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}", | ||
216 | textureID,idx,client.Name); | ||
217 | return false; | ||
218 | } | ||
219 | return true; | ||
220 | } | ||
221 | |||
222 | #region UpdateAppearanceTimer | ||
223 | |||
224 | public void QueueAppearanceSend(UUID agentid) | ||
225 | { | ||
155 | // DEBUG ON | 226 | // DEBUG ON |
156 | m_log.Warn("[AVFACTORY] Appearance changed"); | 227 | m_log.WarnFormat("[AVFACTORY] Queue appearance send for {0}",agentid); |
157 | // DEBUG OFF | 228 | // DEBUG OFF |
158 | sp.Appearance.SetAppearance(textureEntry, visualParams); | ||
159 | if (sp.Appearance.AvatarHeight > 0) | ||
160 | sp.SetHeight(sp.Appearance.AvatarHeight); | ||
161 | 229 | ||
162 | m_scene.AvatarService.SetAppearance(client.AgentId, sp.Appearance); | 230 | // 100 nanoseconds (ticks) we should wait |
231 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 10000000); | ||
232 | lock (m_sendqueue) | ||
233 | { | ||
234 | m_sendqueue[agentid] = timestamp; | ||
235 | m_updateTimer.Start(); | ||
163 | } | 236 | } |
237 | } | ||
238 | |||
239 | public void QueueAppearanceSave(UUID agentid) | ||
240 | { | ||
164 | // DEBUG ON | 241 | // DEBUG ON |
165 | else | 242 | m_log.WarnFormat("[AVFACTORY] Queue appearance save for {0}",agentid); |
166 | m_log.Warn("[AVFACTORY] Appearance did not change"); | 243 | // DEBUG OFF |
167 | // DEBUG OFF | ||
168 | 244 | ||
245 | // 100 nanoseconds (ticks) we should wait | ||
246 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 10000000); | ||
247 | lock (m_savequeue) | ||
248 | { | ||
249 | m_savequeue[agentid] = timestamp; | ||
250 | m_updateTimer.Start(); | ||
251 | } | ||
252 | } | ||
253 | |||
254 | private void HandleAppearanceSend(UUID agentid) | ||
255 | { | ||
256 | ScenePresence sp = m_scene.GetScenePresence(agentid); | ||
257 | if (sp == null) | ||
258 | { | ||
259 | m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid); | ||
260 | return; | ||
261 | } | ||
262 | |||
263 | // DEBUG ON | ||
264 | m_log.WarnFormat("[AVFACTORY] Handle appearance send for {0}",agentid); | ||
265 | // DEBUG OFF | ||
266 | |||
267 | // Send the appearance to everyone in the scene | ||
169 | sp.SendAppearanceToAllOtherAgents(); | 268 | sp.SendAppearanceToAllOtherAgents(); |
269 | sp.ControllingClient.SendAvatarDataImmediate(sp); | ||
270 | |||
271 | // Send the appearance back to the avatar | ||
272 | // AvatarAppearance avp = sp.Appearance; | ||
273 | // sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes()); | ||
274 | |||
275 | /* | ||
276 | // this needs to be fixed, the flag should be on scene presence not the region module | ||
277 | // Start the animations if necessary | ||
170 | if (!m_startAnimationSet) | 278 | if (!m_startAnimationSet) |
171 | { | 279 | { |
172 | sp.Animator.UpdateMovementAnimations(); | 280 | sp.Animator.UpdateMovementAnimations(); |
173 | m_startAnimationSet = true; | 281 | m_startAnimationSet = true; |
174 | } | 282 | } |
283 | */ | ||
284 | } | ||
175 | 285 | ||
176 | client.SendAvatarDataImmediate(sp); | 286 | private void HandleAppearanceSave(UUID agentid) |
177 | client.SendAppearance(sp.Appearance.Owner,sp.Appearance.VisualParams,sp.Appearance.Texture.GetBytes()); | 287 | { |
288 | ScenePresence sp = m_scene.GetScenePresence(agentid); | ||
289 | if (sp == null) | ||
290 | { | ||
291 | m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid); | ||
292 | return; | ||
293 | } | ||
294 | |||
295 | m_scene.AvatarService.SetAppearance(agentid, sp.Appearance); | ||
178 | } | 296 | } |
179 | 297 | ||
298 | private void HandleAppearanceUpdateTimer(object sender, EventArgs ea) | ||
299 | { | ||
300 | long now = DateTime.Now.Ticks; | ||
301 | |||
302 | lock (m_sendqueue) | ||
303 | { | ||
304 | Dictionary<UUID,long> sends = new Dictionary<UUID,long>(m_sendqueue); | ||
305 | foreach (KeyValuePair<UUID,long> kvp in sends) | ||
306 | { | ||
307 | if (kvp.Value < now) | ||
308 | { | ||
309 | Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); }); | ||
310 | m_sendqueue.Remove(kvp.Key); | ||
311 | } | ||
312 | } | ||
313 | } | ||
314 | |||
315 | lock (m_savequeue) | ||
316 | { | ||
317 | Dictionary<UUID,long> saves = new Dictionary<UUID,long>(m_savequeue); | ||
318 | foreach (KeyValuePair<UUID,long> kvp in saves) | ||
319 | { | ||
320 | if (kvp.Value < now) | ||
321 | { | ||
322 | Util.FireAndForget(delegate(object o) { HandleAppearanceSave(kvp.Key); }); | ||
323 | m_savequeue.Remove(kvp.Key); | ||
324 | } | ||
325 | } | ||
326 | } | ||
327 | |||
328 | if (m_savequeue.Count == 0 && m_sendqueue.Count == 0) | ||
329 | m_updateTimer.Stop(); | ||
330 | } | ||
331 | |||
332 | #endregion | ||
333 | |||
180 | /// <summary> | 334 | /// <summary> |
181 | /// Tell the client for this scene presence what items it should be wearing now | 335 | /// Tell the client for this scene presence what items it should be wearing now |
182 | /// </summary> | 336 | /// </summary> |
@@ -215,14 +369,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
215 | 369 | ||
216 | AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance); | 370 | AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance); |
217 | 371 | ||
218 | //if (!TryGetAvatarAppearance(client.AgentId, out avatAppearance)) | ||
219 | //{ | ||
220 | // m_log.Warn("[AVFACTORY]: We didn't seem to find the appearance, falling back to ScenePresence"); | ||
221 | // avatAppearance = sp.Appearance; | ||
222 | //} | ||
223 | |||
224 | //m_log.DebugFormat("[AVFACTORY]: Received wearables for {0}", client.Name); | ||
225 | |||
226 | foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) | 372 | foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) |
227 | { | 373 | { |
228 | if (wear.Type < AvatarWearable.MAX_WEARABLES) | 374 | if (wear.Type < AvatarWearable.MAX_WEARABLES) |
@@ -232,10 +378,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
232 | } | 378 | } |
233 | } | 379 | } |
234 | 380 | ||
381 | // This could take awhile since it needs to pull inventory | ||
235 | SetAppearanceAssets(sp.UUID, ref avatAppearance); | 382 | SetAppearanceAssets(sp.UUID, ref avatAppearance); |
236 | 383 | ||
237 | m_scene.AvatarService.SetAppearance(client.AgentId, avatAppearance); | ||
238 | sp.Appearance = avatAppearance; | 384 | sp.Appearance = avatAppearance; |
385 | m_scene.AvatarService.SetAppearance(client.AgentId, sp.Appearance); | ||
239 | } | 386 | } |
240 | 387 | ||
241 | private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) | 388 | private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) |
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs new file mode 100644 index 0000000..22795fc --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | |||
31 | namespace OpenSim.Region.Framework.Interfaces | ||
32 | { | ||
33 | public interface IAvatarFactory | ||
34 | { | ||
35 | bool ValidateBakedTextureCache(IClientAPI client); | ||
36 | void QueueAppearanceSend(UUID agentid); | ||
37 | void QueueAppearanceSave(UUID agentid); | ||
38 | } | ||
39 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f0f8d55..ae48c02 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -120,6 +120,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | 120 | ||
121 | protected IXMLRPC m_xmlrpcModule; | 121 | protected IXMLRPC m_xmlrpcModule; |
122 | protected IWorldComm m_worldCommModule; | 122 | protected IWorldComm m_worldCommModule; |
123 | protected IAvatarFactory m_AvatarFactory; | ||
123 | protected IConfigSource m_config; | 124 | protected IConfigSource m_config; |
124 | protected IRegionSerialiserModule m_serialiser; | 125 | protected IRegionSerialiserModule m_serialiser; |
125 | protected IDialogModule m_dialogModule; | 126 | protected IDialogModule m_dialogModule; |
@@ -414,6 +415,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
414 | 415 | ||
415 | public IAttachmentsModule AttachmentsModule { get; set; } | 416 | public IAttachmentsModule AttachmentsModule { get; set; } |
416 | 417 | ||
418 | public IAvatarFactory AvatarFactory | ||
419 | { | ||
420 | get { return m_AvatarFactory; } | ||
421 | } | ||
422 | |||
417 | public ICapabilitiesModule CapsModule | 423 | public ICapabilitiesModule CapsModule |
418 | { | 424 | { |
419 | get { return m_capsModule; } | 425 | get { return m_capsModule; } |
@@ -1187,6 +1193,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1187 | m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); | 1193 | m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); |
1188 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); | 1194 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); |
1189 | XferManager = RequestModuleInterface<IXfer>(); | 1195 | XferManager = RequestModuleInterface<IXfer>(); |
1196 | m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); | ||
1190 | AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); | 1197 | AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); |
1191 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); | 1198 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); |
1192 | m_dialogModule = RequestModuleInterface<IDialogModule>(); | 1199 | m_dialogModule = RequestModuleInterface<IDialogModule>(); |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8cbf4dc..dafc1af 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -766,6 +766,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
766 | // we created a new ScenePresence (a new child agent) in a fresh region. | 766 | // we created a new ScenePresence (a new child agent) in a fresh region. |
767 | // Request info about all the (root) agents in this region | 767 | // Request info about all the (root) agents in this region |
768 | // Note: This won't send data *to* other clients in that region (children don't send) | 768 | // Note: This won't send data *to* other clients in that region (children don't send) |
769 | |||
770 | // MIC: This gets called again in CompleteMovement | ||
769 | SendInitialFullUpdateToAllClients(); | 771 | SendInitialFullUpdateToAllClients(); |
770 | RegisterToEvents(); | 772 | RegisterToEvents(); |
771 | if (m_controllingClient != null) | 773 | if (m_controllingClient != null) |
@@ -775,14 +777,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
775 | SetDirectionVectors(); | 777 | SetDirectionVectors(); |
776 | } | 778 | } |
777 | 779 | ||
778 | /* | ||
779 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, | ||
780 | AvatarWearable[] wearables) | ||
781 | : this(client, world, reginfo) | ||
782 | { | ||
783 | m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); | ||
784 | } | ||
785 | */ | ||
786 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) | 780 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) |
787 | : this(client, world, reginfo) | 781 | : this(client, world, reginfo) |
788 | { | 782 | { |
@@ -1221,7 +1215,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1221 | /// </summary> | 1215 | /// </summary> |
1222 | public void CompleteMovement(IClientAPI client) | 1216 | public void CompleteMovement(IClientAPI client) |
1223 | { | 1217 | { |
1224 | //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); | 1218 | // DEBUG ON |
1219 | m_log.WarnFormat("[SCENE PRESENCE]: CompleteMovement for {0}",UUID); | ||
1220 | // DEBUG OFF | ||
1225 | 1221 | ||
1226 | Vector3 look = Velocity; | 1222 | Vector3 look = Velocity; |
1227 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1223 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
@@ -2731,12 +2727,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
2731 | // 2 stage check is needed. | 2727 | // 2 stage check is needed. |
2732 | if (remoteAvatar == null) | 2728 | if (remoteAvatar == null) |
2733 | return; | 2729 | return; |
2730 | |||
2734 | IClientAPI cl=remoteAvatar.ControllingClient; | 2731 | IClientAPI cl=remoteAvatar.ControllingClient; |
2735 | if (cl == null) | 2732 | if (cl == null) |
2736 | return; | 2733 | return; |
2734 | |||
2737 | if (m_appearance.Texture == null) | 2735 | if (m_appearance.Texture == null) |
2738 | return; | 2736 | return; |
2739 | 2737 | ||
2738 | if (LocalId == remoteAvatar.LocalId) | ||
2739 | { | ||
2740 | m_log.WarnFormat("[SP] An agent is attempting to send data to itself; {0}",UUID); | ||
2741 | return; | ||
2742 | } | ||
2743 | |||
2740 | if (IsChildAgent) | 2744 | if (IsChildAgent) |
2741 | { | 2745 | { |
2742 | m_log.WarnFormat("[SCENEPRESENCE] A child agent is attempting to send out avatar data"); | 2746 | m_log.WarnFormat("[SCENEPRESENCE] A child agent is attempting to send out avatar data"); |
@@ -2757,20 +2761,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2757 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) | 2761 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2758 | { | 2762 | { |
2759 | ++avUpdates; | 2763 | ++avUpdates; |
2760 | // only send if this is the root (children are only "listening posts" in a foreign region) | 2764 | |
2765 | // Don't update ourselves | ||
2766 | if (avatar.LocalId == LocalId) | ||
2767 | return; | ||
2768 | |||
2769 | // If this is a root agent, then get info about the avatar | ||
2761 | if (!IsChildAgent) | 2770 | if (!IsChildAgent) |
2762 | { | 2771 | { |
2763 | SendFullUpdateToOtherClient(avatar); | 2772 | SendFullUpdateToOtherClient(avatar); |
2764 | } | 2773 | } |
2765 | 2774 | ||
2766 | if (avatar.LocalId != LocalId) | 2775 | // If the other avatar is a root |
2776 | if (!avatar.IsChildAgent) | ||
2767 | { | 2777 | { |
2768 | if (!avatar.IsChildAgent) | 2778 | avatar.SendFullUpdateToOtherClient(this); |
2769 | { | 2779 | avatar.SendAppearanceToOtherAgent(this); |
2770 | avatar.SendFullUpdateToOtherClient(this); | 2780 | avatar.Animator.SendAnimPackToClient(ControllingClient); |
2771 | avatar.SendAppearanceToOtherAgent(this); | ||
2772 | avatar.Animator.SendAnimPackToClient(ControllingClient); | ||
2773 | } | ||
2774 | } | 2781 | } |
2775 | }); | 2782 | }); |
2776 | 2783 | ||
@@ -2815,7 +2822,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2815 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); | 2822 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); |
2816 | 2823 | ||
2817 | m_controllingClient.SendAvatarDataImmediate(this); | 2824 | m_controllingClient.SendAvatarDataImmediate(this); |
2818 | m_controllingClient.SendAppearance(m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes()); | 2825 | if (m_scene.AvatarFactory != null) |
2826 | { | ||
2827 | if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient)) | ||
2828 | { | ||
2829 | m_log.WarnFormat("[SP] baked textures are in the ache for {0}",Name); | ||
2830 | m_controllingClient.SendAppearance( | ||
2831 | m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes()); | ||
2832 | } | ||
2833 | } | ||
2834 | else | ||
2835 | { | ||
2836 | m_log.WarnFormat("[SP] AvatarFactory not set"); | ||
2837 | } | ||
2819 | 2838 | ||
2820 | SendInitialFullUpdateToAllClients(); | 2839 | SendInitialFullUpdateToAllClients(); |
2821 | } | 2840 | } |
@@ -2847,9 +2866,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2847 | /// <param name="avatar"></param> | 2866 | /// <param name="avatar"></param> |
2848 | public void SendAppearanceToOtherAgent(ScenePresence avatar) | 2867 | public void SendAppearanceToOtherAgent(ScenePresence avatar) |
2849 | { | 2868 | { |
2869 | if (LocalId == avatar.LocalId) | ||
2870 | { | ||
2871 | m_log.WarnFormat("[SP] An agent is attempting to send data to itself; {0}",UUID); | ||
2872 | return; | ||
2873 | } | ||
2874 | |||
2850 | // DEBUG ON | 2875 | // DEBUG ON |
2851 | m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); | 2876 | // m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); |
2852 | // DEBUG OFF | 2877 | // DEBUG OFF |
2878 | |||
2853 | avatar.ControllingClient.SendAppearance( | 2879 | avatar.ControllingClient.SendAppearance( |
2854 | m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); | 2880 | m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); |
2855 | } | 2881 | } |
@@ -4225,15 +4251,16 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4225 | } | 4251 | } |
4226 | } | 4252 | } |
4227 | 4253 | ||
4228 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4254 | List<AvatarAttachment> attachments = m_appearance.GetAttachments(); |
4229 | foreach (int p in attPoints) | 4255 | foreach (AvatarAttachment attach in attachments) |
4230 | { | 4256 | { |
4231 | if (m_isDeleted) | 4257 | if (m_isDeleted) |
4232 | return; | 4258 | return; |
4233 | 4259 | ||
4234 | UUID itemID = m_appearance.GetAttachedItem(p); | 4260 | int p = attach.AttachPoint; |
4261 | UUID itemID = attach.ItemID; | ||
4235 | 4262 | ||
4236 | //UUID assetID = m_appearance.GetAttachedAsset(p); | 4263 | //UUID assetID = attach.AssetID; |
4237 | // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down | 4264 | // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down |
4238 | // But they're not used anyway, the item is being looked up for now, so let's proceed. | 4265 | // But they're not used anyway, the item is being looked up for now, so let's proceed. |
4239 | //if (UUID.Zero == assetID) | 4266 | //if (UUID.Zero == assetID) |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 0786bd9..922eaaf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | |||
@@ -29,6 +29,7 @@ using System.Collections; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Security; | 30 | using System.Security; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | 35 | ||
@@ -81,16 +82,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
81 | get { | 82 | get { |
82 | List<IAvatarAttachment> attachments = new List<IAvatarAttachment>(); | 83 | List<IAvatarAttachment> attachments = new List<IAvatarAttachment>(); |
83 | 84 | ||
84 | Hashtable internalAttachments = GetSP().Appearance.GetAttachments(); | 85 | List<AvatarAttachment> internalAttachments = GetSP().Appearance.GetAttachments(); |
85 | if (internalAttachments != null) | 86 | foreach (AvatarAttachment attach in internalAttachments) |
86 | { | 87 | { |
87 | foreach (DictionaryEntry element in internalAttachments) | 88 | attachments.Add(new SPAvatarAttachment(m_rootScene, this, attach.AttachPoint, |
88 | { | 89 | new UUID(attach.ItemID), |
89 | Hashtable attachInfo = (Hashtable)element.Value; | 90 | new UUID(attach.AssetID), m_security)); |
90 | attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int) element.Key, | ||
91 | new UUID((string) attachInfo["item"]), | ||
92 | new UUID((string) attachInfo["asset"]), m_security)); | ||
93 | } | ||
94 | } | 91 | } |
95 | 92 | ||
96 | return attachments.ToArray(); | 93 | return attachments.ToArray(); |