diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 387 | ||||
-rw-r--r-- | OpenSim/Framework/ChildAgentDataUpdate.cs | 18 | ||||
-rw-r--r-- | OpenSim/Framework/Constants.cs | 11 | ||||
-rw-r--r-- | OpenSim/Framework/IClientAPI.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/IImprovedAssetCache.cs | 1 | ||||
-rw-r--r-- | OpenSim/Framework/ILandObject.cs | 1 | ||||
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 191 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 43 | ||||
-rw-r--r-- | OpenSim/Framework/WearableCacheItem.cs | 157 |
9 files changed, 601 insertions, 210 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 024eeeb..b7a0adf 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -40,8 +40,17 @@ namespace OpenSim.Framework | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class AvatarAppearance | 41 | public class AvatarAppearance |
42 | { | 42 | { |
43 | // SL box diferent to size | ||
44 | const float AVBOXAJUST = 0.2f; | ||
45 | // constrains for ubitode physics | ||
46 | const float AVBOXMINX = 0.2f; | ||
47 | const float AVBOXMINY = 0.3f; | ||
48 | const float AVBOXMINZ = 1.2f; | ||
49 | |||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 51 | ||
52 | // this is viewer capabilities and weared things dependent | ||
53 | // should be only used as initial default value ( V1 viewers ) | ||
45 | public readonly static int VISUALPARAM_COUNT = 218; | 54 | public readonly static int VISUALPARAM_COUNT = 218; |
46 | 55 | ||
47 | public readonly static int TEXTURE_COUNT = 21; | 56 | public readonly static int TEXTURE_COUNT = 21; |
@@ -53,7 +62,12 @@ namespace OpenSim.Framework | |||
53 | protected AvatarWearable[] m_wearables; | 62 | protected AvatarWearable[] m_wearables; |
54 | protected Dictionary<int, List<AvatarAttachment>> m_attachments; | 63 | protected Dictionary<int, List<AvatarAttachment>> m_attachments; |
55 | protected float m_avatarHeight = 0; | 64 | protected float m_avatarHeight = 0; |
56 | protected UUID[] m_texturehashes; | 65 | protected Vector3 m_avatarSize = new Vector3(0.45f, 0.6f, 1.9f); // sl Z cloud value |
66 | protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); | ||
67 | protected float m_avatarFeetOffset = 0; | ||
68 | protected float m_avatarAnimOffset = 0; | ||
69 | protected WearableCacheItem[] m_cacheitems; | ||
70 | protected bool m_cacheItemsDirty = true; | ||
57 | 71 | ||
58 | public virtual int Serial | 72 | public virtual int Serial |
59 | { | 73 | { |
@@ -67,6 +81,21 @@ namespace OpenSim.Framework | |||
67 | set { m_visualparams = value; } | 81 | set { m_visualparams = value; } |
68 | } | 82 | } |
69 | 83 | ||
84 | public virtual Vector3 AvatarSize | ||
85 | { | ||
86 | get { return m_avatarSize; } | ||
87 | } | ||
88 | |||
89 | public virtual Vector3 AvatarBoxSize | ||
90 | { | ||
91 | get { return m_avatarBoxSize; } | ||
92 | } | ||
93 | |||
94 | public virtual float AvatarFeetOffset | ||
95 | { | ||
96 | get { return m_avatarFeetOffset + m_avatarAnimOffset; } | ||
97 | } | ||
98 | |||
70 | public virtual Primitive.TextureEntry Texture | 99 | public virtual Primitive.TextureEntry Texture |
71 | { | 100 | { |
72 | get { return m_texture; } | 101 | get { return m_texture; } |
@@ -88,6 +117,18 @@ namespace OpenSim.Framework | |||
88 | get { return m_avatarHeight; } | 117 | get { return m_avatarHeight; } |
89 | set { m_avatarHeight = value; } | 118 | set { m_avatarHeight = value; } |
90 | } | 119 | } |
120 | |||
121 | public virtual WearableCacheItem[] WearableCacheItems | ||
122 | { | ||
123 | get { return m_cacheitems; } | ||
124 | set { m_cacheitems = value; } | ||
125 | } | ||
126 | |||
127 | public virtual bool WearableCacheItemsDirty | ||
128 | { | ||
129 | get { return m_cacheItemsDirty; } | ||
130 | set { m_cacheItemsDirty = value; } | ||
131 | } | ||
91 | 132 | ||
92 | public AvatarAppearance() | 133 | public AvatarAppearance() |
93 | { | 134 | { |
@@ -97,10 +138,9 @@ namespace OpenSim.Framework | |||
97 | SetDefaultWearables(); | 138 | SetDefaultWearables(); |
98 | SetDefaultTexture(); | 139 | SetDefaultTexture(); |
99 | SetDefaultParams(); | 140 | SetDefaultParams(); |
100 | SetHeight(); | 141 | // SetHeight(); |
142 | SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
101 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 143 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
102 | |||
103 | ResetTextureHashes(); | ||
104 | } | 144 | } |
105 | 145 | ||
106 | public AvatarAppearance(OSDMap map) | 146 | public AvatarAppearance(OSDMap map) |
@@ -108,7 +148,35 @@ namespace OpenSim.Framework | |||
108 | // m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap"); | 148 | // m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap"); |
109 | 149 | ||
110 | Unpack(map); | 150 | Unpack(map); |
111 | SetHeight(); | 151 | // SetHeight(); done in Unpack |
152 | } | ||
153 | |||
154 | public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) | ||
155 | { | ||
156 | // m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance"); | ||
157 | |||
158 | m_serial = 0; | ||
159 | |||
160 | if (wearables != null) | ||
161 | m_wearables = wearables; | ||
162 | else | ||
163 | SetDefaultWearables(); | ||
164 | |||
165 | if (textureEntry != null) | ||
166 | m_texture = textureEntry; | ||
167 | else | ||
168 | SetDefaultTexture(); | ||
169 | |||
170 | if (visualParams != null) | ||
171 | m_visualparams = visualParams; | ||
172 | else | ||
173 | SetDefaultParams(); | ||
174 | |||
175 | // SetHeight(); | ||
176 | if(m_avatarHeight == 0) | ||
177 | SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
178 | |||
179 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | ||
112 | } | 180 | } |
113 | 181 | ||
114 | public AvatarAppearance(AvatarAppearance appearance) : this(appearance, true) | 182 | public AvatarAppearance(AvatarAppearance appearance) : this(appearance, true) |
@@ -125,11 +193,10 @@ namespace OpenSim.Framework | |||
125 | SetDefaultWearables(); | 193 | SetDefaultWearables(); |
126 | SetDefaultTexture(); | 194 | SetDefaultTexture(); |
127 | SetDefaultParams(); | 195 | SetDefaultParams(); |
128 | SetHeight(); | 196 | // SetHeight(); |
197 | SetSize(new Vector3(0.45f, 0.6f, 1.9f)); | ||
129 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 198 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
130 | 199 | ||
131 | ResetTextureHashes(); | ||
132 | |||
133 | return; | 200 | return; |
134 | } | 201 | } |
135 | 202 | ||
@@ -145,10 +212,6 @@ namespace OpenSim.Framework | |||
145 | SetWearable(i,appearance.Wearables[i]); | 212 | SetWearable(i,appearance.Wearables[i]); |
146 | } | 213 | } |
147 | 214 | ||
148 | m_texturehashes = new UUID[AvatarAppearance.TEXTURE_COUNT]; | ||
149 | for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) | ||
150 | m_texturehashes[i] = new UUID(appearance.m_texturehashes[i]); | ||
151 | |||
152 | m_texture = null; | 215 | m_texture = null; |
153 | if (appearance.Texture != null) | 216 | if (appearance.Texture != null) |
154 | { | 217 | { |
@@ -160,7 +223,8 @@ namespace OpenSim.Framework | |||
160 | if (appearance.VisualParams != null) | 223 | if (appearance.VisualParams != null) |
161 | m_visualparams = (byte[])appearance.VisualParams.Clone(); | 224 | m_visualparams = (byte[])appearance.VisualParams.Clone(); |
162 | 225 | ||
163 | m_avatarHeight = appearance.m_avatarHeight; | 226 | // m_avatarHeight = appearance.m_avatarHeight; |
227 | SetSize(appearance.AvatarSize); | ||
164 | 228 | ||
165 | // Copy the attachment, force append mode since that ensures consistency | 229 | // Copy the attachment, force append mode since that ensures consistency |
166 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 230 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
@@ -183,37 +247,6 @@ namespace OpenSim.Framework | |||
183 | } | 247 | } |
184 | } | 248 | } |
185 | 249 | ||
186 | public void ResetTextureHashes() | ||
187 | { | ||
188 | m_texturehashes = new UUID[AvatarAppearance.TEXTURE_COUNT]; | ||
189 | for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) | ||
190 | m_texturehashes[i] = UUID.Zero; | ||
191 | } | ||
192 | |||
193 | public UUID GetTextureHash(int textureIndex) | ||
194 | { | ||
195 | return m_texturehashes[NormalizeBakedTextureIndex(textureIndex)]; | ||
196 | } | ||
197 | |||
198 | public void SetTextureHash(int textureIndex, UUID textureHash) | ||
199 | { | ||
200 | m_texturehashes[NormalizeBakedTextureIndex(textureIndex)] = new UUID(textureHash); | ||
201 | } | ||
202 | |||
203 | /// <summary> | ||
204 | /// Normalizes the texture index to the actual bake index, this is done to | ||
205 | /// accommodate older viewers that send the BAKE_INDICES index rather than | ||
206 | /// the actual texture index | ||
207 | /// </summary> | ||
208 | private int NormalizeBakedTextureIndex(int textureIndex) | ||
209 | { | ||
210 | // Earlier viewer send the index into the baked index array, just trying to be careful here | ||
211 | if (textureIndex < BAKE_INDICES.Length) | ||
212 | return BAKE_INDICES[textureIndex]; | ||
213 | |||
214 | return textureIndex; | ||
215 | } | ||
216 | |||
217 | public void ClearWearables() | 250 | public void ClearWearables() |
218 | { | 251 | { |
219 | m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; | 252 | m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; |
@@ -237,7 +270,12 @@ namespace OpenSim.Framework | |||
237 | m_serial = 0; | 270 | m_serial = 0; |
238 | 271 | ||
239 | SetDefaultTexture(); | 272 | SetDefaultTexture(); |
240 | ResetTextureHashes(); | 273 | |
274 | //for (int i = 0; i < BAKE_INDICES.Length; i++) | ||
275 | // { | ||
276 | // int idx = BAKE_INDICES[i]; | ||
277 | // m_texture.FaceTextures[idx].TextureID = UUID.Zero; | ||
278 | // } | ||
241 | } | 279 | } |
242 | 280 | ||
243 | protected virtual void SetDefaultParams() | 281 | protected virtual void SetDefaultParams() |
@@ -249,6 +287,21 @@ namespace OpenSim.Framework | |||
249 | // } | 287 | // } |
250 | } | 288 | } |
251 | 289 | ||
290 | /// <summary> | ||
291 | /// Invalidate all of the baked textures in the appearance, useful | ||
292 | /// if you know that none are valid | ||
293 | /// </summary> | ||
294 | public virtual void ResetBakedTextures() | ||
295 | { | ||
296 | SetDefaultTexture(); | ||
297 | |||
298 | //for (int i = 0; i < BAKE_INDICES.Length; i++) | ||
299 | // { | ||
300 | // int idx = BAKE_INDICES[i]; | ||
301 | // m_texture.FaceTextures[idx].TextureID = UUID.Zero; | ||
302 | // } | ||
303 | } | ||
304 | |||
252 | protected virtual void SetDefaultTexture() | 305 | protected virtual void SetDefaultTexture() |
253 | { | 306 | { |
254 | m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); | 307 | m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); |
@@ -313,22 +366,33 @@ namespace OpenSim.Framework | |||
313 | // made. We determine if any of the visual parameters actually | 366 | // made. We determine if any of the visual parameters actually |
314 | // changed to know if the appearance should be saved later | 367 | // changed to know if the appearance should be saved later |
315 | bool changed = false; | 368 | bool changed = false; |
316 | for (int i = 0; i < AvatarAppearance.VISUALPARAM_COUNT; i++) | 369 | |
370 | int newsize = visualParams.Length; | ||
371 | |||
372 | if (newsize != m_visualparams.Length) | ||
373 | { | ||
374 | changed = true; | ||
375 | m_visualparams = (byte[])visualParams.Clone(); | ||
376 | } | ||
377 | else | ||
317 | { | 378 | { |
318 | if (visualParams[i] != m_visualparams[i]) | 379 | |
380 | for (int i = 0; i < newsize; i++) | ||
319 | { | 381 | { |
320 | // DEBUG ON | 382 | if (visualParams[i] != m_visualparams[i]) |
321 | // m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}", | 383 | { |
322 | // i,m_visualparams[i],visualParams[i]); | 384 | // DEBUG ON |
323 | // DEBUG OFF | 385 | // m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}", |
324 | m_visualparams[i] = visualParams[i]; | 386 | // i,m_visualparams[i],visualParams[i]); |
325 | changed = true; | 387 | // DEBUG OFF |
388 | m_visualparams[i] = visualParams[i]; | ||
389 | changed = true; | ||
390 | } | ||
326 | } | 391 | } |
327 | } | 392 | } |
328 | |||
329 | // Reset the height if the visual parameters actually changed | 393 | // Reset the height if the visual parameters actually changed |
330 | if (changed) | 394 | // if (changed) |
331 | SetHeight(); | 395 | // SetHeight(); |
332 | 396 | ||
333 | return changed; | 397 | return changed; |
334 | } | 398 | } |
@@ -344,6 +408,7 @@ namespace OpenSim.Framework | |||
344 | /// </summary> | 408 | /// </summary> |
345 | public virtual void SetHeight() | 409 | public virtual void SetHeight() |
346 | { | 410 | { |
411 | /* | ||
347 | // Start with shortest possible female avatar height | 412 | // Start with shortest possible female avatar height |
348 | m_avatarHeight = 1.14597f; | 413 | m_avatarHeight = 1.14597f; |
349 | // Add offset for male avatars | 414 | // Add offset for male avatars |
@@ -356,6 +421,35 @@ namespace OpenSim.Framework | |||
356 | + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f | 421 | + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f |
357 | + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f | 422 | + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f |
358 | + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; | 423 | + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; |
424 | */ | ||
425 | } | ||
426 | |||
427 | public void SetSize(Vector3 avSize) | ||
428 | { | ||
429 | if (avSize.X > 32f) | ||
430 | avSize.X = 32f; | ||
431 | else if (avSize.X < 0.1f) | ||
432 | avSize.X = 0.1f; | ||
433 | |||
434 | if (avSize.Y > 32f) | ||
435 | avSize.Y = 32f; | ||
436 | else if (avSize.Y < 0.1f) | ||
437 | avSize.Y = 0.1f; | ||
438 | if (avSize.Z > 32f) | ||
439 | avSize.Z = 32f; | ||
440 | else if (avSize.Z < 0.1f) | ||
441 | avSize.Z = 0.1f; | ||
442 | |||
443 | m_avatarSize = avSize; | ||
444 | m_avatarBoxSize = avSize; | ||
445 | m_avatarBoxSize.Z += AVBOXAJUST; | ||
446 | if (m_avatarBoxSize.X < AVBOXMINX) | ||
447 | m_avatarBoxSize.X = AVBOXMINX; | ||
448 | if (m_avatarBoxSize.Y < AVBOXMINY) | ||
449 | m_avatarBoxSize.Y = AVBOXMINY; | ||
450 | if (m_avatarBoxSize.Z < AVBOXMINZ) | ||
451 | m_avatarBoxSize.Z = AVBOXMINZ; | ||
452 | m_avatarHeight = m_avatarSize.Z; | ||
359 | } | 453 | } |
360 | 454 | ||
361 | public virtual void SetWearable(int wearableId, AvatarWearable wearable) | 455 | public virtual void SetWearable(int wearableId, AvatarWearable wearable) |
@@ -386,7 +480,8 @@ namespace OpenSim.Framework | |||
386 | } | 480 | } |
387 | 481 | ||
388 | s += "Visual Params: "; | 482 | s += "Visual Params: "; |
389 | for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) | 483 | // for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) |
484 | for (uint j = 0; j < m_visualparams.Length; j++) | ||
390 | s += String.Format("{0},",m_visualparams[j]); | 485 | s += String.Format("{0},",m_visualparams[j]); |
391 | s += "\n"; | 486 | s += "\n"; |
392 | 487 | ||
@@ -402,18 +497,16 @@ namespace OpenSim.Framework | |||
402 | /// </remarks> | 497 | /// </remarks> |
403 | public List<AvatarAttachment> GetAttachments() | 498 | public List<AvatarAttachment> GetAttachments() |
404 | { | 499 | { |
405 | List<AvatarAttachment> alist = new List<AvatarAttachment>(); | ||
406 | |||
407 | lock (m_attachments) | 500 | lock (m_attachments) |
408 | { | 501 | { |
502 | List<AvatarAttachment> alist = new List<AvatarAttachment>(); | ||
409 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) | 503 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) |
410 | { | 504 | { |
411 | foreach (AvatarAttachment attach in kvp.Value) | 505 | foreach (AvatarAttachment attach in kvp.Value) |
412 | alist.Add(new AvatarAttachment(attach)); | 506 | alist.Add(new AvatarAttachment(attach)); |
413 | } | 507 | } |
414 | } | 508 | return alist; |
415 | 509 | } | |
416 | return alist; | ||
417 | } | 510 | } |
418 | 511 | ||
419 | internal void AppendAttachment(AvatarAttachment attach) | 512 | internal void AppendAttachment(AvatarAttachment attach) |
@@ -557,7 +650,6 @@ namespace OpenSim.Framework | |||
557 | return kvp.Key; | 650 | return kvp.Key; |
558 | } | 651 | } |
559 | } | 652 | } |
560 | |||
561 | return 0; | 653 | return 0; |
562 | } | 654 | } |
563 | 655 | ||
@@ -607,12 +699,6 @@ namespace OpenSim.Framework | |||
607 | data["serial"] = OSD.FromInteger(m_serial); | 699 | data["serial"] = OSD.FromInteger(m_serial); |
608 | data["height"] = OSD.FromReal(m_avatarHeight); | 700 | data["height"] = OSD.FromReal(m_avatarHeight); |
609 | 701 | ||
610 | // Hashes | ||
611 | OSDArray hashes = new OSDArray(AvatarAppearance.TEXTURE_COUNT); | ||
612 | for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) | ||
613 | hashes.Add(OSD.FromUUID(m_texturehashes[i])); | ||
614 | data["hashes"] = hashes; | ||
615 | |||
616 | // Wearables | 702 | // Wearables |
617 | OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES); | 703 | OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES); |
618 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | 704 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) |
@@ -634,12 +720,14 @@ namespace OpenSim.Framework | |||
634 | OSDBinary visualparams = new OSDBinary(m_visualparams); | 720 | OSDBinary visualparams = new OSDBinary(m_visualparams); |
635 | data["visualparams"] = visualparams; | 721 | data["visualparams"] = visualparams; |
636 | 722 | ||
637 | // Attachments | 723 | lock (m_attachments) |
638 | List<AvatarAttachment> attachments = GetAttachments(); | 724 | { |
639 | OSDArray attachs = new OSDArray(attachments.Count); | 725 | // Attachments |
640 | foreach (AvatarAttachment attach in GetAttachments()) | 726 | OSDArray attachs = new OSDArray(m_attachments.Count); |
641 | attachs.Add(attach.Pack()); | 727 | foreach (AvatarAttachment attach in GetAttachments()) |
642 | data["attachments"] = attachs; | 728 | attachs.Add(attach.Pack()); |
729 | data["attachments"] = attachs; | ||
730 | } | ||
643 | 731 | ||
644 | return data; | 732 | return data; |
645 | } | 733 | } |
@@ -653,29 +741,11 @@ namespace OpenSim.Framework | |||
653 | if ((data != null) && (data["serial"] != null)) | 741 | if ((data != null) && (data["serial"] != null)) |
654 | m_serial = data["serial"].AsInteger(); | 742 | m_serial = data["serial"].AsInteger(); |
655 | if ((data != null) && (data["height"] != null)) | 743 | if ((data != null) && (data["height"] != null)) |
656 | m_avatarHeight = (float)data["height"].AsReal(); | 744 | // m_avatarHeight = (float)data["height"].AsReal(); |
745 | SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal())); | ||
657 | 746 | ||
658 | try | 747 | try |
659 | { | 748 | { |
660 | // Hashes | ||
661 | m_texturehashes = new UUID[AvatarAppearance.TEXTURE_COUNT]; | ||
662 | if ((data != null) && (data["hashes"] != null) && (data["hashes"]).Type == OSDType.Array) | ||
663 | { | ||
664 | OSDArray hashes = (OSDArray)(data["hashes"]); | ||
665 | for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) | ||
666 | { | ||
667 | UUID hashID = UUID.Zero; | ||
668 | if (i < hashes.Count && hashes[i] != null) | ||
669 | hashID = hashes[i].AsUUID(); | ||
670 | m_texturehashes[i] = hashID; | ||
671 | } | ||
672 | } | ||
673 | else | ||
674 | { | ||
675 | for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) | ||
676 | m_texturehashes[i] = UUID.Zero; | ||
677 | } | ||
678 | |||
679 | // Wearables | 749 | // Wearables |
680 | SetDefaultWearables(); | 750 | SetDefaultWearables(); |
681 | if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array) | 751 | if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array) |
@@ -1505,81 +1575,58 @@ namespace OpenSim.Framework | |||
1505 | SHAPE_EYELID_INNER_CORNER_UP = 214, | 1575 | SHAPE_EYELID_INNER_CORNER_UP = 214, |
1506 | SKIRT_SKIRT_RED = 215, | 1576 | SKIRT_SKIRT_RED = 215, |
1507 | SKIRT_SKIRT_GREEN = 216, | 1577 | SKIRT_SKIRT_GREEN = 216, |
1508 | SKIRT_SKIRT_BLUE = 217, | 1578 | SKIRT_SKIRT_BLUE = 217, |
1509 | /// Breast_Physics_UpDown_Controller - -1-+1 | 1579 | |
1510 | PHYSICS_BREAST_UPDOWN_CONTROLLER = 218, | 1580 | /// <summary> |
1511 | /// Breast_Physics_InOut_Controller -1-+1 | 1581 | /// Avatar Physics section. These are 0 type visual params which get transmitted. |
1512 | PHYSICS_BREAST_PHYSICS_INOUT_CONTROLLER = 219, | 1582 | /// </summary> |
1513 | /// Belly_Physics_UpDown_Controller - -1-+1 | 1583 | |
1514 | PHYSICS_BELLY_PHYSICS_UPDOWN_CONTROLLER = 220, | 1584 | /// <summary> |
1515 | /// Butt_Physics_UpDown_Controller - -1-+1 | 1585 | /// Breast Part 1 |
1516 | PHYSICS_BUTT_PHYSICS_UPDOWN_CONTROLLER = 221, | 1586 | /// </summary> |
1517 | /// Breast_Physics_LeftRight_Controller -1-+1 | 1587 | BREAST_PHYSICS_MASS = 218, |
1518 | PHYSICS_BREAST_PHYSICS_LEFTRIGHT_CONTROLLER = 222, | 1588 | BREAST_PHYSICS_GRAVITY = 219, |
1519 | /// Breast_Physics_Mass - +0.1-+1 | 1589 | BREAST_PHYSICS_DRAG = 220, |
1520 | PHYSICS_BREAST_PHYSICS_MASS = 223, | 1590 | BREAST_PHYSICS_UPDOWN_MAX_EFFECT = 221, |
1521 | /// Breast_Physics_Gravity - 0-+30 | 1591 | BREAST_PHYSICS_UPDOWN_SPRING = 222, |
1522 | PHYSICS_BREAST_PHYSICS_GRAVITY = 224, | 1592 | BREAST_PHYSICS_UPDOWN_GAIN = 223, |
1523 | /// Breast_Physics_Drag - 0-+10 | 1593 | BREAST_PHYSICS_UPDOWN_DAMPING = 224, |
1524 | PHYSICS_BREAST_PHYSICS_DRAG = 225, | 1594 | BREAST_PHYSICS_INOUT_MAX_EFFECT = 225, |
1525 | /// Breast_Physics_UpDown_Max_Effect - 0-+3 | 1595 | BREAST_PHYSICS_INOUT_SPRING = 226, |
1526 | PHYSICS_BREAST_UPDOWN_MAX_EFFECT = 226, | 1596 | BREAST_PHYSICS_INOUT_GAIN = 227, |
1527 | /// Breast_Physics_UpDown_Spring - 0-+100 | 1597 | BREAST_PHYSICS_INOUT_DAMPING = 228, |
1528 | PHYSICS_BREAST_UPDOWN_SPRING = 227, | 1598 | /// <summary> |
1529 | /// Breast_Physics_UpDown_Gain - +1-+100 | 1599 | /// Belly |
1530 | PHYSICS_BREAST_UPDOWN_GAIN = 228, | 1600 | /// </summary> |
1531 | /// Breast_Physics_UpDown_Damping - 0-+1 | 1601 | BELLY_PHYISCS_MASS = 229, |
1532 | PHYSICS_BREAST_UPDOWN_DAMPING = 229, | 1602 | BELLY_PHYSICS_GRAVITY = 230, |
1533 | /// Breast_Physics_InOut_Max_Effect - 0-+3 | 1603 | BELLY_PHYSICS_DRAG = 231, |
1534 | PHYSICS_BREAST_INOUT_MAX_EFFECT = 230, | 1604 | BELLY_PHYISCS_UPDOWN_MAX_EFFECT = 232, |
1535 | /// Breast_Physics_InOut_Gain = +1-+100 | 1605 | BELLY_PHYSICS_UPDOWN_SPRING = 233, |
1536 | PHYSICS_BREAST_INOUT_GAIN = 231, | 1606 | BELLY_PHYSICS_UPDOWN_GAIN = 234, |
1537 | /// Breast_Physics_InOut_Damping - 0-+1 | 1607 | BELLY_PHYSICS_UPDOWN_DAMPING = 235, |
1538 | PHYSICS_BREAST_INOUT_DAMPING = 232, | 1608 | |
1539 | /// Belly_Physics_Mass - +0.1-+1 | 1609 | /// <summary> |
1540 | PHYSICS_BELLY_PHYSICS_MASS = 233, | 1610 | /// Butt |
1541 | /// Belly_Physics_Gravity - 0-+30 | 1611 | /// </summary> |
1542 | PHYSICS_BELLY_PHYSICS_GRAVITY = 234, | 1612 | BUTT_PHYSICS_MASS = 236, |
1543 | /// Belly_Physics_Drag - 0-+10 | 1613 | BUTT_PHYSICS_GRAVITY = 237, |
1544 | PHYSICS_BELLY_PHYSICS_DRAG = 235, | 1614 | BUTT_PHYSICS_DRAG = 238, |
1545 | /// Belly_Physics_UpDown_Max_Effect - 0-+3 | 1615 | BUTT_PHYSICS_UPDOWN_MAX_EFFECT = 239, |
1546 | PHYSICS_BELLY_PHYSICS_UPDOWN_MAX_EFFECT = 236, | 1616 | BUTT_PHYSICS_UPDOWN_SPRING = 240, |
1547 | /// Belly_Physics_UpDown_Spring - 0-+100 | 1617 | BUTT_PHYSICS_UPDOWN_GAIN = 241, |
1548 | PHYSICS_BELLY_PHYSICS_UPDOWN_SPRING = 237, | 1618 | BUTT_PHYSICS_UPDOWN_DAMPING = 242, |
1549 | /// Belly_Physics_UpDown_Gain - +1-+100 | 1619 | BUTT_PHYSICS_LEFTRIGHT_MAX_EFFECT = 243, |
1550 | PHYSICS_BELLY_PHYSICS_UPDOWN_GAIN = 238, | 1620 | BUTT_PHYSICS_LEFTRIGHT_SPRING = 244, |
1551 | /// Belly_Physics_UpDown_Damping - 0-+1 | 1621 | BUTT_PHYSICS_LEFTRIGHT_GAIN = 245, |
1552 | PHYSICS_BELLY_PHYSICS_UPDOWN_DAMPING = 239, | 1622 | BUTT_PHYSICS_LEFTRIGHT_DAMPING = 246, |
1553 | /// Butt_Physics_Mass - +0.1-+1 | 1623 | /// <summary> |
1554 | PHYSICS_BUTT_PHYSICS_MASS = 240, | 1624 | /// Breast Part 2 |
1555 | /// Butt_Physics_Gravity - 0-+30 | 1625 | /// </summary> |
1556 | PHYSICS_BUTT_PHYSICS_GRAVITY = 241, | 1626 | BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247, |
1557 | /// Butt_Physics_Drag - 0-+10 | 1627 | BREAST_PHYSICS_LEFTRIGHT_SPRING= 248, |
1558 | PHYSICS_BUTT_PHYSICS_DRAG = 242, | 1628 | BREAST_PHYSICS_LEFTRIGHT_GAIN = 249, |
1559 | /// Butt_Physics_UpDown_Max_Effect - 0-+30 | 1629 | BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250 |
1560 | PHYSICS_BUTT_PHYSICS_UPDOWN_MAX_EFFECT = 243, | ||
1561 | /// Butt_Physics_UpDown_Spring - 0-+100 | ||
1562 | PHYSICS_BUTT_PHYSICS_UPDOWN_SPRING = 244, | ||
1563 | /// Butt_Physics_UpDown_Gain - +1-+100 | ||
1564 | PHYSICS_BUTT_PHYSICS_UPDOWN_GAIN = 245, | ||
1565 | /// Butt_Physics_UpDown_Damping - 0-+1 | ||
1566 | PHYSICS_BUTT_PHYSICS_UPDOWN_DAMPING = 246, | ||
1567 | /// Butt_Physics_LeftRight_Max_Effect - 0-+3 | ||
1568 | PHYSICS_BUTT_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247, | ||
1569 | /// Butt_Physics_LeftRight_Spring - 0-+100 | ||
1570 | PHYSICS_BUTT_PHYSICS_LEFTRIGHT_SPRING = 248, | ||
1571 | /// Butt_Physics_LeftRight_Gain - +1-+100 | ||
1572 | PHYSICS_BUTT_PHYSICS_LEFTRIGHT_GAIN = 249, | ||
1573 | /// Butt_Physics_LeftRight_Damping - 0-+1 | ||
1574 | PHYSICS_BUTT_PHYSICS_LEFTRIGHT_DAMPING = 250, | ||
1575 | /// Breast_Physics_LeftRight_Max_Effect = 0-+3 | ||
1576 | PHYSICS_BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 251, | ||
1577 | /// Breast_Physics_LeftRight_Spring - 0-+100 | ||
1578 | PHYSICS_BREAST_PHYSICS_LEFTRIGHT_SPRING = 252, | ||
1579 | /// Breast_Physics_LeftRight_Gain - +1-+100 | ||
1580 | PHYSICS_BREAST_PHYSICS_LEFT_RIGHT_GAIN = 253, | ||
1581 | /// Breast_Physics_LeftRight_Damping - 0-+1 | ||
1582 | PHYSICS_BREAST_LEFTRIGHT_DAMPING = 254 | ||
1583 | } | 1630 | } |
1584 | #endregion | 1631 | #endregion |
1585 | } | 1632 | } |
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 18d008c..2a8e67d 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs | |||
@@ -230,12 +230,14 @@ namespace OpenSim.Framework | |||
230 | 230 | ||
231 | public class ControllerData | 231 | public class ControllerData |
232 | { | 232 | { |
233 | public UUID ObjectID; | ||
233 | public UUID ItemID; | 234 | public UUID ItemID; |
234 | public uint IgnoreControls; | 235 | public uint IgnoreControls; |
235 | public uint EventControls; | 236 | public uint EventControls; |
236 | 237 | ||
237 | public ControllerData(UUID item, uint ignore, uint ev) | 238 | public ControllerData(UUID obj, UUID item, uint ignore, uint ev) |
238 | { | 239 | { |
240 | ObjectID = obj; | ||
239 | ItemID = item; | 241 | ItemID = item; |
240 | IgnoreControls = ignore; | 242 | IgnoreControls = ignore; |
241 | EventControls = ev; | 243 | EventControls = ev; |
@@ -249,6 +251,7 @@ namespace OpenSim.Framework | |||
249 | public OSDMap PackUpdateMessage() | 251 | public OSDMap PackUpdateMessage() |
250 | { | 252 | { |
251 | OSDMap controldata = new OSDMap(); | 253 | OSDMap controldata = new OSDMap(); |
254 | controldata["object"] = OSD.FromUUID(ObjectID); | ||
252 | controldata["item"] = OSD.FromUUID(ItemID); | 255 | controldata["item"] = OSD.FromUUID(ItemID); |
253 | controldata["ignore"] = OSD.FromInteger(IgnoreControls); | 256 | controldata["ignore"] = OSD.FromInteger(IgnoreControls); |
254 | controldata["event"] = OSD.FromInteger(EventControls); | 257 | controldata["event"] = OSD.FromInteger(EventControls); |
@@ -259,6 +262,8 @@ namespace OpenSim.Framework | |||
259 | 262 | ||
260 | public void UnpackUpdateMessage(OSDMap args) | 263 | public void UnpackUpdateMessage(OSDMap args) |
261 | { | 264 | { |
265 | if (args["object"] != null) | ||
266 | ObjectID = args["object"].AsUUID(); | ||
262 | if (args["item"] != null) | 267 | if (args["item"] != null) |
263 | ItemID = args["item"].AsUUID(); | 268 | ItemID = args["item"].AsUUID(); |
264 | if (args["ignore"] != null) | 269 | if (args["ignore"] != null) |
@@ -317,6 +322,8 @@ namespace OpenSim.Framework | |||
317 | public Animation AnimState = null; | 322 | public Animation AnimState = null; |
318 | 323 | ||
319 | public UUID GranterID; | 324 | public UUID GranterID; |
325 | public UUID ParentPart; | ||
326 | public Vector3 SitOffset; | ||
320 | 327 | ||
321 | // Appearance | 328 | // Appearance |
322 | public AvatarAppearance Appearance; | 329 | public AvatarAppearance Appearance; |
@@ -488,6 +495,10 @@ namespace OpenSim.Framework | |||
488 | } | 495 | } |
489 | args["attach_objects"] = attObjs; | 496 | args["attach_objects"] = attObjs; |
490 | } | 497 | } |
498 | |||
499 | args["parent_part"] = OSD.FromUUID(ParentPart); | ||
500 | args["sit_offset"] = OSD.FromString(SitOffset.ToString()); | ||
501 | |||
491 | return args; | 502 | return args; |
492 | } | 503 | } |
493 | 504 | ||
@@ -719,6 +730,11 @@ namespace OpenSim.Framework | |||
719 | } | 730 | } |
720 | } | 731 | } |
721 | } | 732 | } |
733 | |||
734 | if (args["parent_part"] != null) | ||
735 | ParentPart = args["parent_part"].AsUUID(); | ||
736 | if (args["sit_offset"] != null) | ||
737 | Vector3.TryParse(args["sit_offset"].AsString(), out SitOffset); | ||
722 | } | 738 | } |
723 | 739 | ||
724 | public AgentData() | 740 | public AgentData() |
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index a2eb5ee..3ba264c 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs | |||
@@ -30,9 +30,18 @@ namespace OpenSim.Framework | |||
30 | { | 30 | { |
31 | public class Constants | 31 | public class Constants |
32 | { | 32 | { |
33 | // 'RegionSize' is the legacy region size. | ||
34 | // DO NOT USE THIS FOR ANY NEW CODE. Use Scene.RegionInfo.RegionSize[XYZ] as a region might not | ||
35 | // be the legacy region size. | ||
33 | public const uint RegionSize = 256; | 36 | public const uint RegionSize = 256; |
34 | public const uint RegionHeight = 4096; | 37 | public const uint RegionHeight = 4096; |
35 | public const byte TerrainPatchSize = 16; | 38 | // This could be a parameters but, really, a region of greater than this is pretty unmanageable |
39 | public const uint MaximumRegionSize = 8192; | ||
40 | |||
41 | // Since terrain is stored in 16x16 heights, regions must be a multiple of this number and that is the minimum | ||
42 | public const int MinRegionSize = 16; | ||
43 | public const int TerrainPatchSize = 16; | ||
44 | |||
36 | public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; | 45 | public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; |
37 | 46 | ||
38 | public enum EstateAccessCodex : uint | 47 | public enum EstateAccessCodex : uint |
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 98358e5..e36edb2 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -66,7 +66,7 @@ namespace OpenSim.Framework | |||
66 | 66 | ||
67 | public delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List<CachedTextureRequestArg> cachedTextureRequest); | 67 | public delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List<CachedTextureRequestArg> cachedTextureRequest); |
68 | 68 | ||
69 | public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, List<CachedTextureRequestArg> cachedTextureData); | 69 | public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems); |
70 | 70 | ||
71 | public delegate void StartAnim(IClientAPI remoteClient, UUID animID); | 71 | public delegate void StartAnim(IClientAPI remoteClient, UUID animID); |
72 | 72 | ||
diff --git a/OpenSim/Framework/IImprovedAssetCache.cs b/OpenSim/Framework/IImprovedAssetCache.cs index 251215a..a0b8b55 100644 --- a/OpenSim/Framework/IImprovedAssetCache.cs +++ b/OpenSim/Framework/IImprovedAssetCache.cs | |||
@@ -33,6 +33,7 @@ namespace OpenSim.Framework | |||
33 | { | 33 | { |
34 | void Cache(AssetBase asset); | 34 | void Cache(AssetBase asset); |
35 | AssetBase Get(string id); | 35 | AssetBase Get(string id); |
36 | bool Check(string id); | ||
36 | void Expire(string id); | 37 | void Expire(string id); |
37 | void Clear(); | 38 | void Clear(); |
38 | } | 39 | } |
diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index 4f98d7b..7a24d1e 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs | |||
@@ -70,6 +70,7 @@ namespace OpenSim.Framework | |||
70 | void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client); | 70 | void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client); |
71 | bool IsEitherBannedOrRestricted(UUID avatar); | 71 | bool IsEitherBannedOrRestricted(UUID avatar); |
72 | bool IsBannedFromLand(UUID avatar); | 72 | bool IsBannedFromLand(UUID avatar); |
73 | bool CanBeOnThisLand(UUID avatar, float posHeight); | ||
73 | bool IsRestrictedFromLand(UUID avatar); | 74 | bool IsRestrictedFromLand(UUID avatar); |
74 | bool IsInLandAccessList(UUID avatar); | 75 | bool IsInLandAccessList(UUID avatar); |
75 | void SendLandUpdateToClient(IClientAPI remote_client); | 76 | void SendLandUpdateToClient(IClientAPI remote_client); |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 24b9c89..1de30af 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -99,6 +99,7 @@ namespace OpenSim.Framework | |||
99 | public class RegionInfo | 99 | public class RegionInfo |
100 | { | 100 | { |
101 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 101 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
102 | private static readonly string LogHeader = "[REGION INFO]"; | ||
102 | 103 | ||
103 | public bool commFailTF = false; | 104 | public bool commFailTF = false; |
104 | public ConfigurationMember configMember; | 105 | public ConfigurationMember configMember; |
@@ -137,16 +138,20 @@ namespace OpenSim.Framework | |||
137 | public bool m_allow_alternate_ports; | 138 | public bool m_allow_alternate_ports; |
138 | protected string m_externalHostName; | 139 | protected string m_externalHostName; |
139 | protected IPEndPoint m_internalEndPoint; | 140 | protected IPEndPoint m_internalEndPoint; |
140 | protected uint? m_regionLocX; | ||
141 | protected uint? m_regionLocY; | ||
142 | protected uint m_remotingPort; | 141 | protected uint m_remotingPort; |
143 | public UUID RegionID = UUID.Zero; | 142 | public UUID RegionID = UUID.Zero; |
144 | public string RemotingAddress; | 143 | public string RemotingAddress; |
145 | public UUID ScopeID = UUID.Zero; | 144 | public UUID ScopeID = UUID.Zero; |
146 | private UUID m_maptileStaticUUID = UUID.Zero; | 145 | private UUID m_maptileStaticUUID = UUID.Zero; |
147 | 146 | ||
148 | private Dictionary<String, String> m_otherSettings = new Dictionary<string, string>(); | 147 | public uint WorldLocX = 0; |
148 | public uint WorldLocY = 0; | ||
149 | public uint WorldLocZ = 0; | ||
150 | public uint RegionSizeX = Constants.RegionSize; | ||
151 | public uint RegionSizeY = Constants.RegionSize; | ||
152 | public uint RegionSizeZ = Constants.RegionHeight; | ||
149 | 153 | ||
154 | private Dictionary<String, String> m_otherSettings = new Dictionary<string, string>(); | ||
150 | 155 | ||
151 | // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. | 156 | // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. |
152 | 157 | ||
@@ -229,11 +234,12 @@ namespace OpenSim.Framework | |||
229 | m_serverURI = string.Empty; | 234 | m_serverURI = string.Empty; |
230 | } | 235 | } |
231 | 236 | ||
232 | public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) | 237 | public RegionInfo(uint legacyRegionLocX, uint legacyRegionLocY, IPEndPoint internalEndPoint, string externalUri) |
233 | { | 238 | { |
234 | m_regionLocX = regionLocX; | 239 | RegionLocX = legacyRegionLocX; |
235 | m_regionLocY = regionLocY; | 240 | RegionLocY = legacyRegionLocY; |
236 | 241 | RegionSizeX = Constants.RegionSize; | |
242 | RegionSizeY = Constants.RegionSize; | ||
237 | m_internalEndPoint = internalEndPoint; | 243 | m_internalEndPoint = internalEndPoint; |
238 | m_externalHostName = externalUri; | 244 | m_externalHostName = externalUri; |
239 | m_serverURI = string.Empty; | 245 | m_serverURI = string.Empty; |
@@ -447,25 +453,42 @@ namespace OpenSim.Framework | |||
447 | 453 | ||
448 | /// <summary> | 454 | /// <summary> |
449 | /// The x co-ordinate of this region in map tiles (e.g. 1000). | 455 | /// The x co-ordinate of this region in map tiles (e.g. 1000). |
456 | /// Coordinate is scaled as world coordinates divided by the legacy region size | ||
457 | /// and is thus is the number of legacy regions. | ||
450 | /// </summary> | 458 | /// </summary> |
451 | public uint RegionLocX | 459 | public uint RegionLocX |
452 | { | 460 | { |
453 | get { return m_regionLocX.Value; } | 461 | get { return WorldLocX / Constants.RegionSize; } |
454 | set { m_regionLocX = value; } | 462 | set { WorldLocX = value * Constants.RegionSize; } |
455 | } | 463 | } |
456 | 464 | ||
457 | /// <summary> | 465 | /// <summary> |
458 | /// The y co-ordinate of this region in map tiles (e.g. 1000). | 466 | /// The y co-ordinate of this region in map tiles (e.g. 1000). |
467 | /// Coordinate is scaled as world coordinates divided by the legacy region size | ||
468 | /// and is thus is the number of legacy regions. | ||
459 | /// </summary> | 469 | /// </summary> |
460 | public uint RegionLocY | 470 | public uint RegionLocY |
461 | { | 471 | { |
462 | get { return m_regionLocY.Value; } | 472 | get { return WorldLocY / Constants.RegionSize; } |
463 | set { m_regionLocY = value; } | 473 | set { WorldLocY = value * Constants.RegionSize; } |
474 | } | ||
475 | |||
476 | public void SetDefaultRegionSize() | ||
477 | { | ||
478 | WorldLocX = 0; | ||
479 | WorldLocY = 0; | ||
480 | WorldLocZ = 0; | ||
481 | RegionSizeX = Constants.RegionSize; | ||
482 | RegionSizeY = Constants.RegionSize; | ||
483 | RegionSizeZ = Constants.RegionHeight; | ||
464 | } | 484 | } |
465 | 485 | ||
486 | // A unique region handle is created from the region's world coordinates. | ||
487 | // This cannot be changed because some code expects to receive the region handle and then | ||
488 | // compute the region coordinates from it. | ||
466 | public ulong RegionHandle | 489 | public ulong RegionHandle |
467 | { | 490 | { |
468 | get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } | 491 | get { return Util.UIntsToLong(WorldLocX, WorldLocY); } |
469 | } | 492 | } |
470 | 493 | ||
471 | public void SetEndPoint(string ipaddr, int port) | 494 | public void SetEndPoint(string ipaddr, int port) |
@@ -572,8 +595,25 @@ namespace OpenSim.Framework | |||
572 | 595 | ||
573 | string[] locationElements = location.Split(new char[] {','}); | 596 | string[] locationElements = location.Split(new char[] {','}); |
574 | 597 | ||
575 | m_regionLocX = Convert.ToUInt32(locationElements[0]); | 598 | RegionLocX = Convert.ToUInt32(locationElements[0]); |
576 | m_regionLocY = Convert.ToUInt32(locationElements[1]); | 599 | RegionLocY = Convert.ToUInt32(locationElements[1]); |
600 | |||
601 | // Region size | ||
602 | // Default to legacy region size if not specified. | ||
603 | allKeys.Remove("SizeX"); | ||
604 | string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString()); | ||
605 | config.Set("SizeX", configSizeX); | ||
606 | RegionSizeX = Convert.ToUInt32(configSizeX); | ||
607 | allKeys.Remove("SizeY"); | ||
608 | string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString()); | ||
609 | config.Set("SizeY", configSizeX); | ||
610 | RegionSizeY = Convert.ToUInt32(configSizeY); | ||
611 | allKeys.Remove("SizeZ"); | ||
612 | string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString()); | ||
613 | config.Set("SizeZ", configSizeX); | ||
614 | RegionSizeZ = Convert.ToUInt32(configSizeZ); | ||
615 | |||
616 | DoRegionSizeSanityChecks(); | ||
577 | 617 | ||
578 | // InternalAddress | 618 | // InternalAddress |
579 | // | 619 | // |
@@ -693,6 +733,57 @@ namespace OpenSim.Framework | |||
693 | } | 733 | } |
694 | } | 734 | } |
695 | 735 | ||
736 | // Make sure user specified region sizes are sane. | ||
737 | // Must be multiples of legacy region size (256). | ||
738 | private void DoRegionSizeSanityChecks() | ||
739 | { | ||
740 | if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize) | ||
741 | { | ||
742 | // Doing non-legacy region sizes. | ||
743 | // Enforce region size to be multiples of the legacy region size (256) | ||
744 | uint partial = RegionSizeX % Constants.RegionSize; | ||
745 | if (partial != 0) | ||
746 | { | ||
747 | RegionSizeX -= partial; | ||
748 | if (RegionSizeX == 0) | ||
749 | RegionSizeX = Constants.RegionSize; | ||
750 | m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeX={3} instead of specified {4}", | ||
751 | LogHeader, Constants.RegionSize, m_regionName, RegionSizeX, RegionSizeX + partial); | ||
752 | } | ||
753 | partial = RegionSizeY % Constants.RegionSize; | ||
754 | if (partial != 0) | ||
755 | { | ||
756 | RegionSizeY -= partial; | ||
757 | if (RegionSizeY == 0) | ||
758 | RegionSizeY = Constants.RegionSize; | ||
759 | m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeY={3} instead of specified {4}", | ||
760 | LogHeader, Constants.RegionSize, m_regionName, RegionSizeY, RegionSizeY + partial); | ||
761 | } | ||
762 | |||
763 | // Because of things in the viewer, regions MUST be square. | ||
764 | // Remove this check when viewers have been updated. | ||
765 | if (RegionSizeX != RegionSizeY) | ||
766 | { | ||
767 | uint minSize = Math.Min(RegionSizeX, RegionSizeY); | ||
768 | RegionSizeX = minSize; | ||
769 | RegionSizeY = minSize; | ||
770 | m_log.ErrorFormat("{0} Regions must be square until viewers are updated. Forcing region {1} size to <{2},{3}>", | ||
771 | LogHeader, m_regionName, RegionSizeX, RegionSizeY); | ||
772 | } | ||
773 | |||
774 | // There is a practical limit to region size. | ||
775 | if (RegionSizeX > Constants.MaximumRegionSize || RegionSizeY > Constants.MaximumRegionSize) | ||
776 | { | ||
777 | RegionSizeX = Util.Clamp<uint>(RegionSizeX, Constants.RegionSize, Constants.MaximumRegionSize); | ||
778 | RegionSizeY = Util.Clamp<uint>(RegionSizeY, Constants.RegionSize, Constants.MaximumRegionSize); | ||
779 | m_log.ErrorFormat("{0} Region dimensions must be less than {1}. Clamping {2}'s size to <{3},{4}>", | ||
780 | LogHeader, Constants.MaximumRegionSize, m_regionName, RegionSizeX, RegionSizeY); | ||
781 | } | ||
782 | |||
783 | m_log.InfoFormat("{0} Region {1} size set to <{2},{3}>", LogHeader, m_regionName, RegionSizeX, RegionSizeY); | ||
784 | } | ||
785 | } | ||
786 | |||
696 | private void WriteNiniConfig(IConfigSource source) | 787 | private void WriteNiniConfig(IConfigSource source) |
697 | { | 788 | { |
698 | IConfig config = source.Configs[RegionName]; | 789 | IConfig config = source.Configs[RegionName]; |
@@ -704,9 +795,16 @@ namespace OpenSim.Framework | |||
704 | 795 | ||
705 | config.Set("RegionUUID", RegionID.ToString()); | 796 | config.Set("RegionUUID", RegionID.ToString()); |
706 | 797 | ||
707 | string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY); | 798 | string location = String.Format("{0},{1}", RegionLocX, RegionLocY); |
708 | config.Set("Location", location); | 799 | config.Set("Location", location); |
709 | 800 | ||
801 | if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize) | ||
802 | { | ||
803 | config.Set("SizeX", RegionSizeX); | ||
804 | config.Set("SizeY", RegionSizeY); | ||
805 | config.Set("SizeZ", RegionSizeZ); | ||
806 | } | ||
807 | |||
710 | config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); | 808 | config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); |
711 | config.Set("InternalPort", m_internalEndPoint.Port); | 809 | config.Set("InternalPort", m_internalEndPoint.Port); |
712 | 810 | ||
@@ -789,10 +887,18 @@ namespace OpenSim.Framework | |||
789 | RegionID.ToString(), true); | 887 | RegionID.ToString(), true); |
790 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 888 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
791 | "Region Name", RegionName, true); | 889 | "Region Name", RegionName, true); |
890 | |||
792 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 891 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
793 | "Grid Location (X Axis)", m_regionLocX.ToString(), true); | 892 | "Grid Location (X Axis)", RegionLocX.ToString(), true); |
794 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 893 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
795 | "Grid Location (Y Axis)", m_regionLocY.ToString(), true); | 894 | "Grid Location (Y Axis)", RegionLocY.ToString(), true); |
895 | configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
896 | "Size of region in X dimension", RegionSizeX.ToString(), true); | ||
897 | configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
898 | "Size of region in Y dimension", RegionSizeY.ToString(), true); | ||
899 | configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
900 | "Size of region in Z dimension", RegionSizeZ.ToString(), true); | ||
901 | |||
796 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); | 902 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); |
797 | configMember.addConfigurationOption("internal_ip_address", | 903 | configMember.addConfigurationOption("internal_ip_address", |
798 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, | 904 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, |
@@ -855,10 +961,18 @@ namespace OpenSim.Framework | |||
855 | UUID.Random().ToString(), true); | 961 | UUID.Random().ToString(), true); |
856 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 962 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
857 | "Region Name", "OpenSim Test", false); | 963 | "Region Name", "OpenSim Test", false); |
964 | |||
858 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 965 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
859 | "Grid Location (X Axis)", "1000", false); | 966 | "Grid Location (X Axis)", "1000", false); |
860 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 967 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
861 | "Grid Location (Y Axis)", "1000", false); | 968 | "Grid Location (Y Axis)", "1000", false); |
969 | configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
970 | "Size of region in X dimension", Constants.RegionSize.ToString(), false); | ||
971 | configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
972 | "Size of region in Y dimension", Constants.RegionSize.ToString(), false); | ||
973 | configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
974 | "Size of region in Z dimension", Constants.RegionHeight.ToString(), false); | ||
975 | |||
862 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); | 976 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); |
863 | configMember.addConfigurationOption("internal_ip_address", | 977 | configMember.addConfigurationOption("internal_ip_address", |
864 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, | 978 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, |
@@ -916,10 +1030,19 @@ namespace OpenSim.Framework | |||
916 | RegionName = (string) configuration_result; | 1030 | RegionName = (string) configuration_result; |
917 | break; | 1031 | break; |
918 | case "sim_location_x": | 1032 | case "sim_location_x": |
919 | m_regionLocX = (uint) configuration_result; | 1033 | RegionLocX = (uint) configuration_result; |
920 | break; | 1034 | break; |
921 | case "sim_location_y": | 1035 | case "sim_location_y": |
922 | m_regionLocY = (uint) configuration_result; | 1036 | RegionLocY = (uint) configuration_result; |
1037 | break; | ||
1038 | case "sim_size_x": | ||
1039 | RegionSizeX = (uint) configuration_result; | ||
1040 | break; | ||
1041 | case "sim_size_y": | ||
1042 | RegionSizeY = (uint) configuration_result; | ||
1043 | break; | ||
1044 | case "sim_size_z": | ||
1045 | RegionSizeZ = (uint) configuration_result; | ||
923 | break; | 1046 | break; |
924 | case "internal_ip_address": | 1047 | case "internal_ip_address": |
925 | IPAddress address = (IPAddress) configuration_result; | 1048 | IPAddress address = (IPAddress) configuration_result; |
@@ -1000,8 +1123,13 @@ namespace OpenSim.Framework | |||
1000 | args["external_host_name"] = OSD.FromString(ExternalHostName); | 1123 | args["external_host_name"] = OSD.FromString(ExternalHostName); |
1001 | args["http_port"] = OSD.FromString(HttpPort.ToString()); | 1124 | args["http_port"] = OSD.FromString(HttpPort.ToString()); |
1002 | args["server_uri"] = OSD.FromString(ServerURI); | 1125 | args["server_uri"] = OSD.FromString(ServerURI); |
1126 | |||
1003 | args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); | 1127 | args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); |
1004 | args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); | 1128 | args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); |
1129 | args["region_size_x"] = OSD.FromString(RegionSizeX.ToString()); | ||
1130 | args["region_size_y"] = OSD.FromString(RegionSizeY.ToString()); | ||
1131 | args["region_size_z"] = OSD.FromString(RegionSizeZ.ToString()); | ||
1132 | |||
1005 | args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); | 1133 | args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); |
1006 | args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); | 1134 | args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); |
1007 | if ((RemotingAddress != null) && !RemotingAddress.Equals("")) | 1135 | if ((RemotingAddress != null) && !RemotingAddress.Equals("")) |
@@ -1040,6 +1168,13 @@ namespace OpenSim.Framework | |||
1040 | UInt32.TryParse(args["region_yloc"].AsString(), out locy); | 1168 | UInt32.TryParse(args["region_yloc"].AsString(), out locy); |
1041 | RegionLocY = locy; | 1169 | RegionLocY = locy; |
1042 | } | 1170 | } |
1171 | if (args.ContainsKey("region_size_x")) | ||
1172 | RegionSizeX = (uint)args["region_size_x"].AsInteger(); | ||
1173 | if (args.ContainsKey("region_size_y")) | ||
1174 | RegionSizeY = (uint)args["region_size_y"].AsInteger(); | ||
1175 | if (args.ContainsKey("region_size_z")) | ||
1176 | RegionSizeZ = (uint)args["region_size_z"].AsInteger(); | ||
1177 | |||
1043 | IPAddress ip_addr = null; | 1178 | IPAddress ip_addr = null; |
1044 | if (args["internal_ep_address"] != null) | 1179 | if (args["internal_ep_address"] != null) |
1045 | { | 1180 | { |
@@ -1076,23 +1211,5 @@ namespace OpenSim.Framework | |||
1076 | regionInfo.ServerURI = serverURI; | 1211 | regionInfo.ServerURI = serverURI; |
1077 | return regionInfo; | 1212 | return regionInfo; |
1078 | } | 1213 | } |
1079 | |||
1080 | public Dictionary<string, object> ToKeyValuePairs() | ||
1081 | { | ||
1082 | Dictionary<string, object> kvp = new Dictionary<string, object>(); | ||
1083 | kvp["uuid"] = RegionID.ToString(); | ||
1084 | kvp["locX"] = RegionLocX.ToString(); | ||
1085 | kvp["locY"] = RegionLocY.ToString(); | ||
1086 | kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); | ||
1087 | kvp["external_port"] = ExternalEndPoint.Port.ToString(); | ||
1088 | kvp["external_host_name"] = ExternalHostName; | ||
1089 | kvp["http_port"] = HttpPort.ToString(); | ||
1090 | kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); | ||
1091 | kvp["internal_port"] = InternalEndPoint.Port.ToString(); | ||
1092 | kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); | ||
1093 | kvp["server_uri"] = ServerURI; | ||
1094 | |||
1095 | return kvp; | ||
1096 | } | ||
1097 | } | 1214 | } |
1098 | } | 1215 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index e8dfec1..b84673b 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -333,6 +333,49 @@ namespace OpenSim.Framework | |||
333 | return Utils.UIntsToLong(X, Y); | 333 | return Utils.UIntsToLong(X, Y); |
334 | } | 334 | } |
335 | 335 | ||
336 | // Regions are identified with a 'handle' made up of its region coordinates packed into a ulong. | ||
337 | // Several places rely on the ability to extract a region's location from its handle. | ||
338 | // Note the location is in 'world coordinates' (see below). | ||
339 | // Region handles are based on the lowest coordinate of the region so trim the passed x,y to be the regions 0,0. | ||
340 | public static ulong RegionWorldLocToHandle(uint X, uint Y) | ||
341 | { | ||
342 | return Utils.UIntsToLong(X, Y); | ||
343 | } | ||
344 | |||
345 | public static ulong RegionLocToHandle(uint X, uint Y) | ||
346 | { | ||
347 | return Utils.UIntsToLong(Util.RegionToWorldLoc(X), Util.RegionToWorldLoc(Y)); | ||
348 | } | ||
349 | |||
350 | public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y) | ||
351 | { | ||
352 | X = (uint)(handle >> 32); | ||
353 | Y = (uint)(handle & (ulong)uint.MaxValue); | ||
354 | } | ||
355 | |||
356 | public static void RegionHandleToRegionLoc(ulong handle, out uint X, out uint Y) | ||
357 | { | ||
358 | uint worldX, worldY; | ||
359 | RegionHandleToWorldLoc(handle, out worldX, out worldY); | ||
360 | X = WorldToRegionLoc(worldX); | ||
361 | Y = WorldToRegionLoc(worldY); | ||
362 | } | ||
363 | |||
364 | // A region location can be 'world coordinates' (meters from zero) or 'region coordinates' | ||
365 | // (number of regions from zero). This measurement of regions relies on the legacy 256 region size. | ||
366 | // These routines exist to make what is being converted explicit so the next person knows what was meant. | ||
367 | // Convert a region's 'world coordinate' to its 'region coordinate'. | ||
368 | public static uint WorldToRegionLoc(uint worldCoord) | ||
369 | { | ||
370 | return worldCoord / Constants.RegionSize; | ||
371 | } | ||
372 | |||
373 | // Convert a region's 'region coordinate' to its 'world coordinate'. | ||
374 | public static uint RegionToWorldLoc(uint regionCoord) | ||
375 | { | ||
376 | return regionCoord * Constants.RegionSize; | ||
377 | } | ||
378 | |||
336 | public static T Clamp<T>(T x, T min, T max) | 379 | public static T Clamp<T>(T x, T min, T max) |
337 | where T : IComparable<T> | 380 | where T : IComparable<T> |
338 | { | 381 | { |
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs new file mode 100644 index 0000000..1aecf79 --- /dev/null +++ b/OpenSim/Framework/WearableCacheItem.cs | |||
@@ -0,0 +1,157 @@ | |||
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 System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenMetaverse.StructuredData; | ||
32 | |||
33 | namespace OpenSim.Framework | ||
34 | { | ||
35 | [Serializable] | ||
36 | public class WearableCacheItem | ||
37 | { | ||
38 | public uint TextureIndex { get; set; } | ||
39 | public UUID CacheId { get; set; } | ||
40 | public UUID TextureID { get; set; } | ||
41 | public AssetBase TextureAsset { get; set; } | ||
42 | |||
43 | |||
44 | public static WearableCacheItem[] GetDefaultCacheItem() | ||
45 | { | ||
46 | int itemmax = 21; | ||
47 | WearableCacheItem[] retitems = new WearableCacheItem[itemmax]; | ||
48 | for (uint i=0;i<itemmax;i++) | ||
49 | retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1}; | ||
50 | return retitems; | ||
51 | } | ||
52 | public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache) | ||
53 | { | ||
54 | List<WearableCacheItem> ret = new List<WearableCacheItem>(); | ||
55 | if (pInput.Type == OSDType.Array) | ||
56 | { | ||
57 | OSDArray itemarray = (OSDArray) pInput; | ||
58 | foreach (OSDMap item in itemarray) | ||
59 | { | ||
60 | ret.Add(new WearableCacheItem() | ||
61 | { | ||
62 | TextureIndex = item["textureindex"].AsUInteger(), | ||
63 | CacheId = item["cacheid"].AsUUID(), | ||
64 | TextureID = item["textureid"].AsUUID() | ||
65 | }); | ||
66 | |||
67 | if (dataCache != null && item.ContainsKey("assetdata")) | ||
68 | { | ||
69 | AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString()); | ||
70 | asset.Temporary = true; | ||
71 | asset.Data = item["assetdata"].AsBinary(); | ||
72 | dataCache.Cache(asset); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | else if (pInput.Type == OSDType.Map) | ||
77 | { | ||
78 | OSDMap item = (OSDMap) pInput; | ||
79 | ret.Add(new WearableCacheItem(){ | ||
80 | TextureIndex = item["textureindex"].AsUInteger(), | ||
81 | CacheId = item["cacheid"].AsUUID(), | ||
82 | TextureID = item["textureid"].AsUUID() | ||
83 | }); | ||
84 | if (dataCache != null && item.ContainsKey("assetdata")) | ||
85 | { | ||
86 | string assetCreator = item["assetcreator"].AsString(); | ||
87 | string assetName = item["assetname"].AsString(); | ||
88 | AssetBase asset = new AssetBase(item["textureid"].AsUUID(), assetName, (sbyte)AssetType.Texture, assetCreator); | ||
89 | asset.Temporary = true; | ||
90 | asset.Data = item["assetdata"].AsBinary(); | ||
91 | dataCache.Cache(asset); | ||
92 | } | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | return new WearableCacheItem[0]; | ||
97 | } | ||
98 | return ret.ToArray(); | ||
99 | |||
100 | } | ||
101 | public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache) | ||
102 | { | ||
103 | OSDArray arr = new OSDArray(); | ||
104 | foreach (WearableCacheItem item in pcacheItems) | ||
105 | { | ||
106 | OSDMap itemmap = new OSDMap(); | ||
107 | itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex)); | ||
108 | itemmap.Add("cacheid", OSD.FromUUID(item.CacheId)); | ||
109 | itemmap.Add("textureid", OSD.FromUUID(item.TextureID)); | ||
110 | if (dataCache != null) | ||
111 | { | ||
112 | if (dataCache.Check(item.TextureID.ToString())) | ||
113 | { | ||
114 | AssetBase assetItem = dataCache.Get(item.TextureID.ToString()); | ||
115 | if (assetItem != null) | ||
116 | { | ||
117 | itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data)); | ||
118 | itemmap.Add("assetcreator", OSD.FromString(assetItem.CreatorID)); | ||
119 | itemmap.Add("assetname", OSD.FromString(assetItem.Name)); | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | arr.Add(itemmap); | ||
124 | } | ||
125 | return arr; | ||
126 | } | ||
127 | public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems) | ||
128 | { | ||
129 | for (int i = 0; i < pcacheItems.Length; i++) | ||
130 | { | ||
131 | if (pcacheItems[i].TextureIndex == pTextureIndex) | ||
132 | return pcacheItems[i]; | ||
133 | } | ||
134 | return null; | ||
135 | } | ||
136 | public static WearableCacheItem SearchTextureCacheId(UUID pCacheId, WearableCacheItem[] pcacheItems) | ||
137 | { | ||
138 | for (int i = 0; i < pcacheItems.Length; i++) | ||
139 | { | ||
140 | if (pcacheItems[i].CacheId == pCacheId) | ||
141 | return pcacheItems[i]; | ||
142 | } | ||
143 | return null; | ||
144 | } | ||
145 | public static WearableCacheItem SearchTextureTextureId(UUID pTextureId, WearableCacheItem[] pcacheItems) | ||
146 | { | ||
147 | for (int i = 0; i < pcacheItems.Length; i++) | ||
148 | { | ||
149 | if (pcacheItems[i].TextureID == pTextureId) | ||
150 | return pcacheItems[i]; | ||
151 | } | ||
152 | return null; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | |||
157 | } | ||