diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
3 files changed, 169 insertions, 95 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2a0c0b1..ad6b1de 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -124,13 +124,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
124 | 124 | ||
125 | // Save avatar attachment information | 125 | // Save avatar attachment information |
126 | ScenePresence presence; | 126 | ScenePresence presence; |
127 | if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 127 | if (m_scene.AvatarService != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) |
128 | { | 128 | { |
129 | m_log.Info( | 129 | m_log.Info( |
130 | "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | 130 | "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId |
131 | + ", AttachmentPoint: " + AttachmentPt); | 131 | + ", AttachmentPoint: " + AttachmentPt); |
132 | 132 | ||
133 | m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | 133 | m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | } | 136 | } |
@@ -382,8 +382,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
382 | item = m_scene.InventoryService.GetItem(item); | 382 | item = m_scene.InventoryService.GetItem(item); |
383 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); | 383 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); |
384 | 384 | ||
385 | if (m_scene.AvatarFactory != null) | 385 | if (m_scene.AvatarService != null) |
386 | m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | 386 | m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | 389 | ||
@@ -405,10 +405,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
405 | presence.Appearance.DetachAttachment(itemID); | 405 | presence.Appearance.DetachAttachment(itemID); |
406 | 406 | ||
407 | // Save avatar attachment information | 407 | // Save avatar attachment information |
408 | if (m_scene.AvatarFactory != null) | 408 | if (m_scene.AvatarService != null) |
409 | { | 409 | { |
410 | m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID); | 410 | m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID); |
411 | m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | 411 | m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance); |
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
@@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
435 | 435 | ||
436 | presence.Appearance.DetachAttachment(itemID); | 436 | presence.Appearance.DetachAttachment(itemID); |
437 | 437 | ||
438 | if (m_scene.AvatarFactory != null) | 438 | if (m_scene.AvatarService != null) |
439 | { | 439 | { |
440 | m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | 440 | m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance); |
441 | } | 441 | } |
442 | part.ParentGroup.DetachToGround(); | 442 | part.ParentGroup.DetachToGround(); |
443 | 443 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 22c8937..9f7ff7f 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -38,48 +38,20 @@ using OpenSim.Services.Interfaces; | |||
38 | 38 | ||
39 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | 39 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory |
40 | { | 40 | { |
41 | public class AvatarFactoryModule : IAvatarFactory, IRegionModule | 41 | public class AvatarFactoryModule : IRegionModule |
42 | { | 42 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | 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 }; | ||
44 | private Scene m_scene = null; | 45 | private Scene m_scene = null; |
45 | private static readonly AvatarAppearance def = new AvatarAppearance(); | ||
46 | 46 | ||
47 | public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance) | 47 | private bool m_startAnimationSet = false; |
48 | { | ||
49 | AvatarData avatar = m_scene.AvatarService.GetAvatar(avatarId); | ||
50 | //if ((profile != null) && (profile.RootFolder != null)) | ||
51 | if (avatar != null) | ||
52 | { | ||
53 | appearance = avatar.ToAvatarAppearance(avatarId); | ||
54 | return true; | ||
55 | } | ||
56 | |||
57 | m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId); | ||
58 | appearance = CreateDefault(avatarId); | ||
59 | return false; | ||
60 | } | ||
61 | |||
62 | private AvatarAppearance CreateDefault(UUID avatarId) | ||
63 | { | ||
64 | AvatarAppearance appearance = null; | ||
65 | AvatarWearable[] wearables; | ||
66 | byte[] visualParams; | ||
67 | GetDefaultAvatarAppearance(out wearables, out visualParams); | ||
68 | appearance = new AvatarAppearance(avatarId, wearables, visualParams); | ||
69 | |||
70 | return appearance; | ||
71 | } | ||
72 | 48 | ||
73 | public void Initialise(Scene scene, IConfigSource source) | 49 | public void Initialise(Scene scene, IConfigSource source) |
74 | { | 50 | { |
75 | scene.RegisterModuleInterface<IAvatarFactory>(this); | ||
76 | scene.EventManager.OnNewClient += NewClient; | 51 | scene.EventManager.OnNewClient += NewClient; |
77 | 52 | ||
78 | if (m_scene == null) | 53 | if (m_scene == null) |
79 | { | ||
80 | m_scene = scene; | 54 | m_scene = scene; |
81 | } | ||
82 | |||
83 | } | 55 | } |
84 | 56 | ||
85 | public void PostInitialise() | 57 | public void PostInitialise() |
@@ -102,6 +74,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
102 | 74 | ||
103 | public void NewClient(IClientAPI client) | 75 | public void NewClient(IClientAPI client) |
104 | { | 76 | { |
77 | client.OnRequestWearables += SendWearables; | ||
78 | client.OnSetAppearance += SetAppearance; | ||
105 | client.OnAvatarNowWearing += AvatarIsWearing; | 79 | client.OnAvatarNowWearing += AvatarIsWearing; |
106 | } | 80 | } |
107 | 81 | ||
@@ -110,42 +84,115 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
110 | // client.OnAvatarNowWearing -= AvatarIsWearing; | 84 | // client.OnAvatarNowWearing -= AvatarIsWearing; |
111 | } | 85 | } |
112 | 86 | ||
113 | public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) | 87 | /// <summary> |
88 | /// Set appearance data (textureentry and slider settings) received from the client | ||
89 | /// </summary> | ||
90 | /// <param name="texture"></param> | ||
91 | /// <param name="visualParam"></param> | ||
92 | public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) | ||
114 | { | 93 | { |
115 | IInventoryService invService = m_scene.InventoryService; | 94 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
95 | if (sp == null) | ||
96 | { | ||
97 | m_log.WarnFormat("[AVFACTORY] SetAppearance unable to find presence for {0}",client.AgentId); | ||
98 | return; | ||
99 | } | ||
100 | |||
101 | // DEBUG ON | ||
102 | m_log.WarnFormat("[AVFACTORY] SetAppearance for {0}",client.AgentId); | ||
103 | // DEBUG OFF | ||
116 | 104 | ||
117 | if (invService.GetRootFolder(userID) != null) | 105 | /* |
106 | if (m_physicsActor != null) | ||
118 | { | 107 | { |
119 | for (int i = 0; i < 13; i++) | 108 | if (!IsChildAgent) |
120 | { | 109 | { |
121 | if (appearance.Wearables[i].ItemID == UUID.Zero) | 110 | // This may seem like it's redundant, remove the avatar from the physics scene |
122 | { | 111 | // just to add it back again, but it saves us from having to update |
123 | appearance.Wearables[i].AssetID = UUID.Zero; | 112 | // 3 variables 10 times a second. |
124 | } | 113 | bool flyingTemp = m_physicsActor.Flying; |
125 | else | 114 | RemoveFromPhysicalScene(); |
126 | { | 115 | //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); |
127 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID); | ||
128 | baseItem = invService.GetItem(baseItem); | ||
129 | 116 | ||
130 | if (baseItem != null) | 117 | //PhysicsActor = null; |
131 | { | 118 | |
132 | appearance.Wearables[i].AssetID = baseItem.AssetID; | 119 | AddToPhysicalScene(flyingTemp); |
133 | } | 120 | } |
134 | else | 121 | } |
122 | */ | ||
123 | #region Bake Cache Check | ||
124 | |||
125 | bool changed = false; | ||
126 | |||
127 | // Process the texture entry | ||
128 | if (textureEntry != null) | ||
129 | { | ||
130 | for (int i = 0; i < BAKE_INDICES.Length; i++) | ||
131 | { | ||
132 | int j = BAKE_INDICES[i]; | ||
133 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; | ||
134 | |||
135 | if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) | ||
136 | { | ||
137 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | ||
135 | { | 138 | { |
136 | m_log.ErrorFormat( | 139 | m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",face.TextureID,j,this.Name); |
137 | "[APPEARANCE]: Can't find inventory item {0} for {1}, setting to default", | 140 | client.SendRebakeAvatarTextures(face.TextureID); |
138 | appearance.Wearables[i].ItemID, (WearableType)i); | ||
139 | |||
140 | appearance.Wearables[i].AssetID = def.Wearables[i].AssetID; | ||
141 | } | 141 | } |
142 | } | 142 | } |
143 | } | 143 | } |
144 | changed = sp.Appearance.SetTextureEntries(textureEntry); | ||
145 | |||
146 | } | ||
147 | |||
148 | #endregion Bake Cache Check | ||
149 | |||
150 | changed = sp.Appearance.SetVisualParams(visualParams) || changed; | ||
151 | |||
152 | // If nothing changed (this happens frequently) just return | ||
153 | if (changed) | ||
154 | { | ||
155 | // DEBUG ON | ||
156 | m_log.Warn("[AVFACTORY] Appearance changed"); | ||
157 | // DEBUG OFF | ||
158 | sp.Appearance.SetAppearance(textureEntry, visualParams); | ||
159 | if (sp.Appearance.AvatarHeight > 0) | ||
160 | sp.SetHeight(sp.Appearance.AvatarHeight); | ||
161 | |||
162 | m_scene.AvatarService.SetAppearance(client.AgentId, sp.Appearance); | ||
144 | } | 163 | } |
164 | // DEBUG ON | ||
145 | else | 165 | else |
166 | m_log.Warn("[AVFACTORY] Appearance did not change"); | ||
167 | // DEBUG OFF | ||
168 | |||
169 | sp.SendAppearanceToAllOtherAgents(); | ||
170 | if (!m_startAnimationSet) | ||
171 | { | ||
172 | sp.Animator.UpdateMovementAnimations(); | ||
173 | m_startAnimationSet = true; | ||
174 | } | ||
175 | |||
176 | client.SendAvatarDataImmediate(sp); | ||
177 | client.SendAppearance(sp.Appearance.Owner,sp.Appearance.VisualParams,sp.Appearance.Texture.GetBytes()); | ||
178 | } | ||
179 | |||
180 | /// <summary> | ||
181 | /// Tell the client for this scene presence what items it should be wearing now | ||
182 | /// </summary> | ||
183 | public void SendWearables(IClientAPI client) | ||
184 | { | ||
185 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | ||
186 | if (sp == null) | ||
146 | { | 187 | { |
147 | m_log.WarnFormat("[APPEARANCE]: user {0} has no inventory, appearance isn't going to work", userID); | 188 | m_log.WarnFormat("[AVFACTORY] SendWearables unable to find presence for {0}",client.AgentId); |
189 | return; | ||
148 | } | 190 | } |
191 | |||
192 | // DEBUG ON | ||
193 | m_log.WarnFormat("[AVFACTORY]: Received request for wearables of {0}", client.AgentId); | ||
194 | // DEBUG OFF | ||
195 | client.SendWearables(sp.Appearance.Wearables,sp.Appearance.Serial++); | ||
149 | } | 196 | } |
150 | 197 | ||
151 | /// <summary> | 198 | /// <summary> |
@@ -153,65 +200,81 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
153 | /// </summary> | 200 | /// </summary> |
154 | /// <param name="sender"></param> | 201 | /// <param name="sender"></param> |
155 | /// <param name="e"></param> | 202 | /// <param name="e"></param> |
156 | public void AvatarIsWearing(Object sender, AvatarWearingArgs e) | 203 | public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e) |
157 | { | 204 | { |
158 | m_log.DebugFormat("[APPEARANCE]: AvatarIsWearing"); | 205 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
159 | 206 | if (sp == null) | |
160 | IClientAPI clientView = (IClientAPI)sender; | ||
161 | ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId); | ||
162 | |||
163 | if (sp == null) | ||
164 | { | 207 | { |
165 | m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event"); | 208 | m_log.WarnFormat("[AVFACTORY] AvatarIsWearing unable to find presence for {0}",client.AgentId); |
166 | return; | 209 | return; |
167 | } | 210 | } |
211 | |||
212 | // DEBUG ON | ||
213 | m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}",client.AgentId); | ||
214 | // DEBUG OFF | ||
215 | |||
216 | AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance); | ||
168 | 217 | ||
169 | AvatarAppearance avatAppearance = sp.Appearance; | 218 | //if (!TryGetAvatarAppearance(client.AgentId, out avatAppearance)) |
170 | //if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) | ||
171 | //{ | 219 | //{ |
172 | // m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); | 220 | // m_log.Warn("[AVFACTORY]: We didn't seem to find the appearance, falling back to ScenePresence"); |
173 | // avatAppearance = sp.Appearance; | 221 | // avatAppearance = sp.Appearance; |
174 | //} | 222 | //} |
175 | 223 | ||
176 | //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); | 224 | //m_log.DebugFormat("[AVFACTORY]: Received wearables for {0}", client.Name); |
177 | 225 | ||
178 | foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) | 226 | foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) |
179 | { | 227 | { |
180 | if (wear.Type < 13) | 228 | if (wear.Type < AvatarWearable.MAX_WEARABLES) |
181 | { | 229 | { |
182 | avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; | 230 | AvatarWearable newWearable = new AvatarWearable(wear.ItemID,UUID.Zero); |
231 | avatAppearance.SetWearable(wear.Type, newWearable); | ||
183 | } | 232 | } |
184 | } | 233 | } |
185 | 234 | ||
186 | SetAppearanceAssets(sp.UUID, ref avatAppearance); | 235 | SetAppearanceAssets(sp.UUID, ref avatAppearance); |
187 | AvatarData adata = new AvatarData(avatAppearance); | ||
188 | m_scene.AvatarService.SetAvatar(clientView.AgentId, adata); | ||
189 | 236 | ||
237 | m_scene.AvatarService.SetAppearance(client.AgentId, avatAppearance); | ||
190 | sp.Appearance = avatAppearance; | 238 | sp.Appearance = avatAppearance; |
191 | } | 239 | } |
192 | 240 | ||
193 | public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) | 241 | private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) |
194 | { | 242 | { |
195 | visualParams = GetDefaultVisualParams(); | 243 | IInventoryService invService = m_scene.InventoryService; |
196 | wearables = AvatarWearable.DefaultWearables; | ||
197 | } | ||
198 | 244 | ||
199 | public void UpdateDatabase(UUID user, AvatarAppearance appearance) | 245 | if (invService.GetRootFolder(userID) != null) |
200 | { | 246 | { |
201 | //m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); | 247 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) |
202 | AvatarData adata = new AvatarData(appearance); | 248 | { |
203 | m_scene.AvatarService.SetAvatar(user, adata); | 249 | if (appearance.Wearables[i].ItemID == UUID.Zero) |
204 | } | 250 | { |
251 | appearance.Wearables[i].AssetID = UUID.Zero; | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID); | ||
256 | baseItem = invService.GetItem(baseItem); | ||
205 | 257 | ||
206 | private static byte[] GetDefaultVisualParams() | 258 | if (baseItem != null) |
207 | { | 259 | { |
208 | byte[] visualParams; | 260 | appearance.Wearables[i].AssetID = baseItem.AssetID; |
209 | visualParams = new byte[218]; | 261 | } |
210 | for (int i = 0; i < 218; i++) | 262 | else |
263 | { | ||
264 | m_log.ErrorFormat( | ||
265 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", | ||
266 | appearance.Wearables[i].ItemID, (WearableType)i); | ||
267 | |||
268 | appearance.Wearables[i].ItemID = UUID.Zero; | ||
269 | appearance.Wearables[i].AssetID = UUID.Zero; | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | } | ||
274 | else | ||
211 | { | 275 | { |
212 | visualParams[i] = 100; | 276 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); |
213 | } | 277 | } |
214 | return visualParams; | ||
215 | } | 278 | } |
216 | } | 279 | } |
217 | } | 280 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs index 47f19a3..9ee19f8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
@@ -137,6 +138,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar | |||
137 | 138 | ||
138 | #region IAvatarService | 139 | #region IAvatarService |
139 | 140 | ||
141 | public AvatarAppearance GetAppearance(UUID userID) | ||
142 | { | ||
143 | return m_AvatarService.GetAppearance(userID); | ||
144 | } | ||
145 | |||
146 | public bool SetAppearance(UUID userID, AvatarAppearance appearance) | ||
147 | { | ||
148 | return m_AvatarService.SetAppearance(userID,appearance); | ||
149 | } | ||
150 | |||
140 | public AvatarData GetAvatar(UUID userID) | 151 | public AvatarData GetAvatar(UUID userID) |
141 | { | 152 | { |
142 | return m_AvatarService.GetAvatar(userID); | 153 | return m_AvatarService.GetAvatar(userID); |