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 | 27 | ||||
-rw-r--r-- | OpenSim/Framework/ILandObject.cs | 1 | ||||
-rw-r--r-- | OpenSim/Framework/MapBlockData.cs | 18 | ||||
-rw-r--r-- | OpenSim/Framework/MapItemReplyStruct.cs | 33 | ||||
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 191 | ||||
-rw-r--r-- | OpenSim/Framework/SLUtil.cs | 40 | ||||
-rw-r--r-- | OpenSim/Framework/Serialization/ArchiveConstants.cs | 3 | ||||
-rw-r--r-- | OpenSim/Framework/TerrainData.cs | 423 | ||||
-rw-r--r-- | OpenSim/Framework/UserProfileData.cs | 14 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 45 | ||||
-rw-r--r-- | OpenSim/Framework/WearableCacheItem.cs | 157 |
15 files changed, 1146 insertions, 224 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..a853e90 100644 --- a/OpenSim/Framework/IImprovedAssetCache.cs +++ b/OpenSim/Framework/IImprovedAssetCache.cs | |||
@@ -31,9 +31,34 @@ namespace OpenSim.Framework | |||
31 | { | 31 | { |
32 | public interface IImprovedAssetCache | 32 | public interface IImprovedAssetCache |
33 | { | 33 | { |
34 | /// <summary> | ||
35 | /// Cache the specified asset. | ||
36 | /// </summary> | ||
37 | /// <param name='asset'></param> | ||
34 | void Cache(AssetBase asset); | 38 | void Cache(AssetBase asset); |
39 | |||
40 | /// <summary> | ||
41 | /// Get an asset by its id. | ||
42 | /// </summary> | ||
43 | /// <param name='id'></param> | ||
44 | /// <returns>null if the asset does not exist.</returns> | ||
35 | AssetBase Get(string id); | 45 | AssetBase Get(string id); |
46 | |||
47 | /// <summary> | ||
48 | /// Check whether an asset with the specified id exists in the cache. | ||
49 | /// </summary> | ||
50 | /// <param name='id'></param> | ||
51 | bool Check(string id); | ||
52 | |||
53 | /// <summary> | ||
54 | /// Expire an asset from the cache. | ||
55 | /// </summary> | ||
56 | /// <param name='id'></param> | ||
36 | void Expire(string id); | 57 | void Expire(string id); |
58 | |||
59 | /// <summary> | ||
60 | /// Clear the cache. | ||
61 | /// </summary> | ||
37 | void Clear(); | 62 | void Clear(); |
38 | } | 63 | } |
39 | } | 64 | } \ No newline at end of file |
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/MapBlockData.cs b/OpenSim/Framework/MapBlockData.cs index 2298ac5..4bee499 100644 --- a/OpenSim/Framework/MapBlockData.cs +++ b/OpenSim/Framework/MapBlockData.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | using OpenMetaverse.StructuredData; | ||
30 | 31 | ||
31 | namespace OpenSim.Framework | 32 | namespace OpenSim.Framework |
32 | { | 33 | { |
@@ -40,9 +41,26 @@ namespace OpenSim.Framework | |||
40 | public byte WaterHeight; | 41 | public byte WaterHeight; |
41 | public ushort X; | 42 | public ushort X; |
42 | public ushort Y; | 43 | public ushort Y; |
44 | public ushort SizeX; | ||
45 | public ushort SizeY; | ||
43 | 46 | ||
44 | public MapBlockData() | 47 | public MapBlockData() |
45 | { | 48 | { |
46 | } | 49 | } |
50 | |||
51 | public OSDMap ToOSD() | ||
52 | { | ||
53 | OSDMap map = new OSDMap(); | ||
54 | map["X"] = X; | ||
55 | map["Y"] = Y; | ||
56 | map["SizeX"] = SizeX; | ||
57 | map["SizeY"] = SizeY; | ||
58 | map["Name"] = Name; | ||
59 | map["Access"] = Access; | ||
60 | map["RegionFlags"] = RegionFlags; | ||
61 | map["WaterHeight"] = WaterHeight; | ||
62 | map["MapImageID"] = MapImageId; | ||
63 | return map; | ||
64 | } | ||
47 | } | 65 | } |
48 | } | 66 | } |
diff --git a/OpenSim/Framework/MapItemReplyStruct.cs b/OpenSim/Framework/MapItemReplyStruct.cs index 58011bd..c8693ae 100644 --- a/OpenSim/Framework/MapItemReplyStruct.cs +++ b/OpenSim/Framework/MapItemReplyStruct.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | using OpenMetaverse.StructuredData; | ||
29 | 30 | ||
30 | namespace OpenSim.Framework | 31 | namespace OpenSim.Framework |
31 | { | 32 | { |
@@ -37,5 +38,37 @@ namespace OpenSim.Framework | |||
37 | public int Extra; | 38 | public int Extra; |
38 | public int Extra2; | 39 | public int Extra2; |
39 | public string name; | 40 | public string name; |
41 | |||
42 | public mapItemReply(uint pX, uint pY, UUID pId, string pName, int pExt1, int pExt2) | ||
43 | { | ||
44 | x = pX; | ||
45 | y = pY; | ||
46 | id = pId; | ||
47 | name = pName; | ||
48 | Extra = pExt1; | ||
49 | Extra2 = pExt2; | ||
50 | } | ||
51 | |||
52 | public OSDMap ToOSD() | ||
53 | { | ||
54 | OSDMap map = new OSDMap(); | ||
55 | map["X"] = OSD.FromInteger((int)x); | ||
56 | map["Y"] = OSD.FromInteger((int)y); | ||
57 | map["ID"] = OSD.FromUUID(id); | ||
58 | map["Name"] = OSD.FromString(name); | ||
59 | map["Extra"] = OSD.FromInteger(Extra); | ||
60 | map["Extra2"] = OSD.FromInteger(Extra2); | ||
61 | return map; | ||
62 | } | ||
63 | |||
64 | public void FromOSD(OSDMap map) | ||
65 | { | ||
66 | x = (uint) map["X"].AsInteger(); | ||
67 | y = (uint) map["Y"].AsInteger(); | ||
68 | id = map["ID"].AsUUID(); | ||
69 | Extra = map["Extra"].AsInteger(); | ||
70 | Extra2 = map["Extra2"].AsInteger(); | ||
71 | name = map["Name"].AsString(); | ||
72 | } | ||
40 | } | 73 | } |
41 | } | 74 | } |
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/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index cb73e8f..9249105 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs | |||
@@ -39,8 +39,32 @@ namespace OpenSim.Framework | |||
39 | { | 39 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | /// <summary> | ||
43 | /// Asset types used only in OpenSim. | ||
44 | /// To avoid clashing with the code numbers used in Second Life, use only negative numbers here. | ||
45 | /// </summary> | ||
46 | public enum OpenSimAssetType : sbyte | ||
47 | { | ||
48 | Material = -2 | ||
49 | } | ||
50 | |||
51 | |||
42 | #region SL / file extension / content-type conversions | 52 | #region SL / file extension / content-type conversions |
43 | 53 | ||
54 | /// <summary> | ||
55 | /// Returns the Enum entry corresponding to the given code, regardless of whether it belongs | ||
56 | /// to the AssetType or OpenSimAssetType enums. | ||
57 | /// </summary> | ||
58 | public static object AssetTypeFromCode(sbyte assetType) | ||
59 | { | ||
60 | if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) | ||
61 | return (OpenMetaverse.AssetType)assetType; | ||
62 | else if (Enum.IsDefined(typeof(OpenSimAssetType), assetType)) | ||
63 | return (OpenSimAssetType)assetType; | ||
64 | else | ||
65 | return OpenMetaverse.AssetType.Unknown; | ||
66 | } | ||
67 | |||
44 | private class TypeMapping | 68 | private class TypeMapping |
45 | { | 69 | { |
46 | private sbyte assetType; | 70 | private sbyte assetType; |
@@ -56,12 +80,7 @@ namespace OpenSim.Framework | |||
56 | 80 | ||
57 | public object AssetType | 81 | public object AssetType |
58 | { | 82 | { |
59 | get { | 83 | get { return AssetTypeFromCode(assetType); } |
60 | if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) | ||
61 | return (OpenMetaverse.AssetType)assetType; | ||
62 | else | ||
63 | return OpenMetaverse.AssetType.Unknown; | ||
64 | } | ||
65 | } | 84 | } |
66 | 85 | ||
67 | public InventoryType InventoryType | 86 | public InventoryType InventoryType |
@@ -102,6 +121,11 @@ namespace OpenSim.Framework | |||
102 | : this((sbyte)assetType, inventoryType, contentType, null, extension) | 121 | : this((sbyte)assetType, inventoryType, contentType, null, extension) |
103 | { | 122 | { |
104 | } | 123 | } |
124 | |||
125 | public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, string contentType, string extension) | ||
126 | : this((sbyte)assetType, inventoryType, contentType, null, extension) | ||
127 | { | ||
128 | } | ||
105 | } | 129 | } |
106 | 130 | ||
107 | /// <summary> | 131 | /// <summary> |
@@ -142,7 +166,9 @@ namespace OpenSim.Framework | |||
142 | new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), | 166 | new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), |
143 | new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), | 167 | new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), |
144 | new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), | 168 | new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), |
145 | new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm") | 169 | new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm"), |
170 | |||
171 | new TypeMapping(OpenSimAssetType.Material, InventoryType.Unknown, "application/llsd+xml", "material") | ||
146 | }; | 172 | }; |
147 | 173 | ||
148 | private static Dictionary<sbyte, string> asset2Content; | 174 | private static Dictionary<sbyte, string> asset2Content; |
diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index 0c12787..73ebfae 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; | ||
32 | 33 | ||
33 | namespace OpenSim.Framework.Serialization | 34 | namespace OpenSim.Framework.Serialization |
34 | { | 35 | { |
@@ -128,6 +129,7 @@ namespace OpenSim.Framework.Serialization | |||
128 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2"; | 129 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2"; |
129 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga"; | 130 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga"; |
130 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"; // Not sure if we'll ever see this | 131 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"; // Not sure if we'll ever see this |
132 | ASSET_TYPE_TO_EXTENSION[(sbyte)OpenSimAssetType.Material] = ASSET_EXTENSION_SEPARATOR + "material.xml"; // Not sure if we'll ever see this | ||
131 | 133 | ||
132 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation; | 134 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation; |
133 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bodypart.txt"] = (sbyte)AssetType.Bodypart; | 135 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bodypart.txt"] = (sbyte)AssetType.Bodypart; |
@@ -152,6 +154,7 @@ namespace OpenSim.Framework.Serialization | |||
152 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture; | 154 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture; |
153 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA; | 155 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA; |
154 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder; | 156 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder; |
157 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)OpenSimAssetType.Material; | ||
155 | } | 158 | } |
156 | 159 | ||
157 | public static string CreateOarLandDataPath(LandData ld) | 160 | public static string CreateOarLandDataPath(LandData ld) |
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs new file mode 100644 index 0000000..9325df2 --- /dev/null +++ b/OpenSim/Framework/TerrainData.cs | |||
@@ -0,0 +1,423 @@ | |||
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 System.IO; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | |||
35 | using log4net; | ||
36 | |||
37 | namespace OpenSim.Framework | ||
38 | { | ||
39 | public abstract class TerrainData | ||
40 | { | ||
41 | // Terrain always is a square | ||
42 | public int SizeX { get; protected set; } | ||
43 | public int SizeY { get; protected set; } | ||
44 | public int SizeZ { get; protected set; } | ||
45 | |||
46 | // A height used when the user doesn't specify anything | ||
47 | public const float DefaultTerrainHeight = 21f; | ||
48 | |||
49 | public abstract float this[int x, int y] { get; set; } | ||
50 | // Someday terrain will have caves | ||
51 | public abstract float this[int x, int y, int z] { get; set; } | ||
52 | |||
53 | public bool IsTainted { get; protected set; } | ||
54 | public abstract bool IsTaintedAt(int xx, int yy); | ||
55 | public abstract void ClearTaint(); | ||
56 | |||
57 | public abstract void ClearLand(); | ||
58 | public abstract void ClearLand(float height); | ||
59 | |||
60 | // Return a representation of this terrain for storing as a blob in the database. | ||
61 | // Returns 'true' to say blob was stored in the 'out' locations. | ||
62 | public abstract bool GetDatabaseBlob(out int DBFormatRevisionCode, out Array blob); | ||
63 | |||
64 | // Given a revision code and a blob from the database, create and return the right type of TerrainData. | ||
65 | // The sizes passed are the expected size of the region. The database info will be used to | ||
66 | // initialize the heightmap of that sized region with as much data is in the blob. | ||
67 | // Return created TerrainData or 'null' if unsuccessful. | ||
68 | public static TerrainData CreateFromDatabaseBlobFactory(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) | ||
69 | { | ||
70 | // For the moment, there is only one implementation class | ||
71 | return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob); | ||
72 | } | ||
73 | |||
74 | // return a special compressed representation of the heightmap in shorts | ||
75 | public abstract short[] GetCompressedMap(); | ||
76 | public abstract float CompressionFactor { get; } | ||
77 | |||
78 | public abstract double[,] GetDoubles(); | ||
79 | public abstract TerrainData Clone(); | ||
80 | } | ||
81 | |||
82 | // The terrain is stored in the database as a blob with a 'revision' field. | ||
83 | // Some implementations of terrain storage would fill the revision field with | ||
84 | // the time the terrain was stored. When real revisions were added and this | ||
85 | // feature removed, that left some old entries with the time in the revision | ||
86 | // field. | ||
87 | // Thus, if revision is greater than 'RevisionHigh' then terrain db entry is | ||
88 | // left over and it is presumed to be 'Legacy256'. | ||
89 | // Numbers are arbitrary and are chosen to to reduce possible mis-interpretation. | ||
90 | // If a revision does not match any of these, it is assumed to be Legacy256. | ||
91 | public enum DBTerrainRevision | ||
92 | { | ||
93 | // Terrain is 'double[256,256]' | ||
94 | Legacy256 = 11, | ||
95 | // Terrain is 'int32, int32, float[,]' where the ints are X and Y dimensions | ||
96 | // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. | ||
97 | Variable2D = 22, | ||
98 | // Terrain is 'int32, int32, int32, int16[]' where the ints are X and Y dimensions | ||
99 | // and third int is the 'compression factor'. The heights are compressed as | ||
100 | // "short compressedHeight = (short)(height * compressionFactor);" | ||
101 | // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. | ||
102 | Compressed2D = 27, | ||
103 | // A revision that is not listed above or any revision greater than this value is 'Legacy256'. | ||
104 | RevisionHigh = 1234 | ||
105 | } | ||
106 | |||
107 | // Version of terrain that is a heightmap. | ||
108 | // This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge | ||
109 | // of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer. | ||
110 | // The heighmap is kept as an array of short integers. The integer values are converted to | ||
111 | // and from floats by TerrainCompressionFactor. Shorts are used to limit storage used. | ||
112 | public class HeightmapTerrainData : TerrainData | ||
113 | { | ||
114 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
115 | private static string LogHeader = "[HEIGHTMAP TERRAIN DATA]"; | ||
116 | |||
117 | // TerrainData.this[x, y] | ||
118 | public override float this[int x, int y] | ||
119 | { | ||
120 | get { return FromCompressedHeight(m_heightmap[x, y]); } | ||
121 | set { | ||
122 | short newVal = ToCompressedHeight(value); | ||
123 | if (m_heightmap[x, y] != newVal) | ||
124 | { | ||
125 | m_heightmap[x, y] = newVal; | ||
126 | m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = true; | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | |||
131 | // TerrainData.this[x, y, z] | ||
132 | public override float this[int x, int y, int z] | ||
133 | { | ||
134 | get { return this[x, y]; } | ||
135 | set { this[x, y] = value; } | ||
136 | } | ||
137 | |||
138 | // TerrainData.ClearTaint | ||
139 | public override void ClearTaint() | ||
140 | { | ||
141 | IsTainted = false; | ||
142 | for (int ii = 0; ii < m_taint.GetLength(0); ii++) | ||
143 | for (int jj = 0; jj < m_taint.GetLength(1); jj++) | ||
144 | m_taint[ii, jj] = false; | ||
145 | } | ||
146 | |||
147 | // TerrainData.ClearLand | ||
148 | public override void ClearLand() | ||
149 | { | ||
150 | ClearLand(DefaultTerrainHeight); | ||
151 | } | ||
152 | // TerrainData.ClearLand(float) | ||
153 | public override void ClearLand(float pHeight) | ||
154 | { | ||
155 | short flatHeight = ToCompressedHeight(pHeight); | ||
156 | for (int xx = 0; xx < SizeX; xx++) | ||
157 | for (int yy = 0; yy < SizeY; yy++) | ||
158 | m_heightmap[xx, yy] = flatHeight; | ||
159 | } | ||
160 | |||
161 | public override bool IsTaintedAt(int xx, int yy) | ||
162 | { | ||
163 | int tx = xx / Constants.TerrainPatchSize; | ||
164 | int ty = yy / Constants.TerrainPatchSize; | ||
165 | bool ret = m_taint[tx, ty]; | ||
166 | m_taint[tx, ty] = false; | ||
167 | return ret; | ||
168 | } | ||
169 | |||
170 | // TerrainData.GetDatabaseBlob | ||
171 | // The user wants something to store in the database. | ||
172 | public override bool GetDatabaseBlob(out int DBRevisionCode, out Array blob) | ||
173 | { | ||
174 | bool ret = false; | ||
175 | if (SizeX == Constants.RegionSize && SizeY == Constants.RegionSize) | ||
176 | { | ||
177 | DBRevisionCode = (int)DBTerrainRevision.Legacy256; | ||
178 | blob = ToLegacyTerrainSerialization(); | ||
179 | ret = true; | ||
180 | } | ||
181 | else | ||
182 | { | ||
183 | DBRevisionCode = (int)DBTerrainRevision.Compressed2D; | ||
184 | blob = ToCompressedTerrainSerialization(); | ||
185 | ret = true; | ||
186 | } | ||
187 | return ret; | ||
188 | } | ||
189 | |||
190 | // TerrainData.CompressionFactor | ||
191 | private float m_compressionFactor = 100.0f; | ||
192 | public override float CompressionFactor { get { return m_compressionFactor; } } | ||
193 | |||
194 | // TerrainData.GetCompressedMap | ||
195 | public override short[] GetCompressedMap() | ||
196 | { | ||
197 | short[] newMap = new short[SizeX * SizeY]; | ||
198 | |||
199 | int ind = 0; | ||
200 | for (int xx = 0; xx < SizeX; xx++) | ||
201 | for (int yy = 0; yy < SizeY; yy++) | ||
202 | newMap[ind++] = m_heightmap[xx, yy]; | ||
203 | |||
204 | return newMap; | ||
205 | |||
206 | } | ||
207 | // TerrainData.Clone | ||
208 | public override TerrainData Clone() | ||
209 | { | ||
210 | HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ); | ||
211 | ret.m_heightmap = (short[,])this.m_heightmap.Clone(); | ||
212 | return ret; | ||
213 | } | ||
214 | |||
215 | // TerrainData.GetDoubles | ||
216 | public override double[,] GetDoubles() | ||
217 | { | ||
218 | double[,] ret = new double[SizeX, SizeY]; | ||
219 | for (int xx = 0; xx < SizeX; xx++) | ||
220 | for (int yy = 0; yy < SizeY; yy++) | ||
221 | ret[xx, yy] = FromCompressedHeight(m_heightmap[xx, yy]); | ||
222 | |||
223 | return ret; | ||
224 | } | ||
225 | |||
226 | |||
227 | // ============================================================= | ||
228 | |||
229 | private short[,] m_heightmap; | ||
230 | // Remember subregions of the heightmap that has changed. | ||
231 | private bool[,] m_taint; | ||
232 | |||
233 | // To save space (especially for large regions), keep the height as a short integer | ||
234 | // that is coded as the float height times the compression factor (usually '100' | ||
235 | // to make for two decimal points). | ||
236 | public short ToCompressedHeight(double pHeight) | ||
237 | { | ||
238 | return (short)(pHeight * CompressionFactor); | ||
239 | } | ||
240 | |||
241 | public float FromCompressedHeight(short pHeight) | ||
242 | { | ||
243 | return ((float)pHeight) / CompressionFactor; | ||
244 | } | ||
245 | |||
246 | // To keep with the legacy theme, create an instance of this class based on the | ||
247 | // way terrain used to be passed around. | ||
248 | public HeightmapTerrainData(double[,] pTerrain) | ||
249 | { | ||
250 | SizeX = pTerrain.GetLength(0); | ||
251 | SizeY = pTerrain.GetLength(1); | ||
252 | SizeZ = (int)Constants.RegionHeight; | ||
253 | m_compressionFactor = 100.0f; | ||
254 | |||
255 | m_heightmap = new short[SizeX, SizeY]; | ||
256 | for (int ii = 0; ii < SizeX; ii++) | ||
257 | { | ||
258 | for (int jj = 0; jj < SizeY; jj++) | ||
259 | { | ||
260 | m_heightmap[ii, jj] = ToCompressedHeight(pTerrain[ii, jj]); | ||
261 | |||
262 | } | ||
263 | } | ||
264 | // m_log.DebugFormat("{0} new by doubles. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); | ||
265 | |||
266 | m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; | ||
267 | ClearTaint(); | ||
268 | } | ||
269 | |||
270 | // Create underlying structures but don't initialize the heightmap assuming the caller will immediately do that | ||
271 | public HeightmapTerrainData(int pX, int pY, int pZ) | ||
272 | { | ||
273 | SizeX = pX; | ||
274 | SizeY = pY; | ||
275 | SizeZ = pZ; | ||
276 | m_compressionFactor = 100.0f; | ||
277 | m_heightmap = new short[SizeX, SizeY]; | ||
278 | m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; | ||
279 | // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); | ||
280 | ClearTaint(); | ||
281 | ClearLand(0f); | ||
282 | } | ||
283 | |||
284 | public HeightmapTerrainData(short[] cmap, float pCompressionFactor, int pX, int pY, int pZ) : this(pX, pY, pZ) | ||
285 | { | ||
286 | m_compressionFactor = pCompressionFactor; | ||
287 | int ind = 0; | ||
288 | for (int xx = 0; xx < SizeX; xx++) | ||
289 | for (int yy = 0; yy < SizeY; yy++) | ||
290 | m_heightmap[xx, yy] = cmap[ind++]; | ||
291 | // m_log.DebugFormat("{0} new by compressed map. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); | ||
292 | } | ||
293 | |||
294 | // Create a heighmap from a database blob | ||
295 | public HeightmapTerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) : this(pSizeX, pSizeY, pSizeZ) | ||
296 | { | ||
297 | switch ((DBTerrainRevision)pFormatCode) | ||
298 | { | ||
299 | case DBTerrainRevision.Compressed2D: | ||
300 | FromCompressedTerrainSerialization(pBlob); | ||
301 | m_log.DebugFormat("{0} HeightmapTerrainData create from Compressed2D serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY); | ||
302 | break; | ||
303 | default: | ||
304 | FromLegacyTerrainSerialization(pBlob); | ||
305 | m_log.DebugFormat("{0} HeightmapTerrainData create from legacy serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY); | ||
306 | break; | ||
307 | } | ||
308 | } | ||
309 | |||
310 | // Just create an array of doubles. Presumes the caller implicitly knows the size. | ||
311 | public Array ToLegacyTerrainSerialization() | ||
312 | { | ||
313 | Array ret = null; | ||
314 | |||
315 | using (MemoryStream str = new MemoryStream((int)Constants.RegionSize * (int)Constants.RegionSize * sizeof(double))) | ||
316 | { | ||
317 | using (BinaryWriter bw = new BinaryWriter(str)) | ||
318 | { | ||
319 | for (int xx = 0; xx < Constants.RegionSize; xx++) | ||
320 | { | ||
321 | for (int yy = 0; yy < Constants.RegionSize; yy++) | ||
322 | { | ||
323 | double height = this[xx, yy]; | ||
324 | if (height == 0.0) | ||
325 | height = double.Epsilon; | ||
326 | bw.Write(height); | ||
327 | } | ||
328 | } | ||
329 | } | ||
330 | ret = str.ToArray(); | ||
331 | } | ||
332 | return ret; | ||
333 | } | ||
334 | |||
335 | // Just create an array of doubles. Presumes the caller implicitly knows the size. | ||
336 | public void FromLegacyTerrainSerialization(byte[] pBlob) | ||
337 | { | ||
338 | // In case database info doesn't match real terrain size, initialize the whole terrain. | ||
339 | ClearLand(); | ||
340 | |||
341 | using (MemoryStream mstr = new MemoryStream(pBlob)) | ||
342 | { | ||
343 | using (BinaryReader br = new BinaryReader(mstr)) | ||
344 | { | ||
345 | for (int xx = 0; xx < (int)Constants.RegionSize; xx++) | ||
346 | { | ||
347 | for (int yy = 0; yy < (int)Constants.RegionSize; yy++) | ||
348 | { | ||
349 | float val = (float)br.ReadDouble(); | ||
350 | if (xx < SizeX && yy < SizeY) | ||
351 | m_heightmap[xx, yy] = ToCompressedHeight(val); | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | ClearTaint(); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | // See the reader below. | ||
360 | public Array ToCompressedTerrainSerialization() | ||
361 | { | ||
362 | Array ret = null; | ||
363 | using (MemoryStream str = new MemoryStream((3 * sizeof(Int32)) + (SizeX * SizeY * sizeof(Int16)))) | ||
364 | { | ||
365 | using (BinaryWriter bw = new BinaryWriter(str)) | ||
366 | { | ||
367 | bw.Write((Int32)DBTerrainRevision.Compressed2D); | ||
368 | bw.Write((Int32)SizeX); | ||
369 | bw.Write((Int32)SizeY); | ||
370 | bw.Write((Int32)CompressionFactor); | ||
371 | for (int yy = 0; yy < SizeY; yy++) | ||
372 | for (int xx = 0; xx < SizeX; xx++) | ||
373 | { | ||
374 | bw.Write((Int16)m_heightmap[xx, yy]); | ||
375 | } | ||
376 | } | ||
377 | ret = str.ToArray(); | ||
378 | } | ||
379 | return ret; | ||
380 | } | ||
381 | |||
382 | // Initialize heightmap from blob consisting of: | ||
383 | // int32, int32, int32, int32, int16[] | ||
384 | // where the first int32 is format code, next two int32s are the X and y of heightmap data and | ||
385 | // the forth int is the compression factor for the following int16s | ||
386 | // This is just sets heightmap info. The actual size of the region was set on this instance's | ||
387 | // creation and any heights not initialized by theis blob are set to the default height. | ||
388 | public void FromCompressedTerrainSerialization(byte[] pBlob) | ||
389 | { | ||
390 | Int32 hmFormatCode, hmSizeX, hmSizeY, hmCompressionFactor; | ||
391 | |||
392 | using (MemoryStream mstr = new MemoryStream(pBlob)) | ||
393 | { | ||
394 | using (BinaryReader br = new BinaryReader(mstr)) | ||
395 | { | ||
396 | hmFormatCode = br.ReadInt32(); | ||
397 | hmSizeX = br.ReadInt32(); | ||
398 | hmSizeY = br.ReadInt32(); | ||
399 | hmCompressionFactor = br.ReadInt32(); | ||
400 | |||
401 | m_compressionFactor = hmCompressionFactor; | ||
402 | |||
403 | // In case database info doesn't match real terrain size, initialize the whole terrain. | ||
404 | ClearLand(); | ||
405 | |||
406 | for (int yy = 0; yy < hmSizeY; yy++) | ||
407 | { | ||
408 | for (int xx = 0; xx < hmSizeX; xx++) | ||
409 | { | ||
410 | Int16 val = br.ReadInt16(); | ||
411 | if (xx < SizeX && yy < SizeY) | ||
412 | m_heightmap[xx, yy] = val; | ||
413 | } | ||
414 | } | ||
415 | } | ||
416 | ClearTaint(); | ||
417 | |||
418 | m_log.InfoFormat("{0} Read compressed 2d heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}", | ||
419 | LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor); | ||
420 | } | ||
421 | } | ||
422 | } | ||
423 | } | ||
diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs index 9bac739..266ccf0 100644 --- a/OpenSim/Framework/UserProfileData.cs +++ b/OpenSim/Framework/UserProfileData.cs | |||
@@ -160,15 +160,19 @@ namespace OpenSim.Framework | |||
160 | public virtual ulong HomeRegion | 160 | public virtual ulong HomeRegion |
161 | { | 161 | { |
162 | get | 162 | get |
163 | { | 163 | { |
164 | return Utils.UIntsToLong( | 164 | return Util.RegionWorldLocToHandle(Util.RegionToWorldLoc(m_homeRegionX), Util.RegionToWorldLoc(m_homeRegionY)); |
165 | m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize); | 165 | // return Utils.UIntsToLong( m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize); |
166 | } | 166 | } |
167 | 167 | ||
168 | set | 168 | set |
169 | { | 169 | { |
170 | m_homeRegionX = (uint) (value >> 40); | 170 | uint regionWorldLocX, regionWorldLocY; |
171 | m_homeRegionY = (((uint) (value)) >> 8); | 171 | Util.RegionHandleToWorldLoc(value, out regionWorldLocX, out regionWorldLocY); |
172 | m_homeRegionX = Util.WorldToRegionLoc(regionWorldLocX); | ||
173 | m_homeRegionY = Util.WorldToRegionLoc(regionWorldLocY); | ||
174 | // m_homeRegionX = (uint) (value >> 40); | ||
175 | // m_homeRegionY = (((uint) (value)) >> 8); | ||
172 | } | 176 | } |
173 | } | 177 | } |
174 | 178 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 52635b2..7bc8176 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 | { |
@@ -988,7 +1031,7 @@ namespace OpenSim.Framework | |||
988 | else if (typeof(T) == typeof(Int32)) | 1031 | else if (typeof(T) == typeof(Int32)) |
989 | val = cnf.GetInt(varname, (int)val); | 1032 | val = cnf.GetInt(varname, (int)val); |
990 | else if (typeof(T) == typeof(float)) | 1033 | else if (typeof(T) == typeof(float)) |
991 | val = cnf.GetFloat(varname, (int)val); | 1034 | val = cnf.GetFloat(varname, (float)val); |
992 | else | 1035 | else |
993 | m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); | 1036 | m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); |
994 | } | 1037 | } |
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 | } | ||