diff options
65 files changed, 3768 insertions, 1828 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 63492c2..6ed3b06 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -546,6 +546,10 @@ namespace OpenSim.Data.MySQL | |||
546 | reader.Read(); | 546 | reader.Read(); |
547 | notes.Notes = OSD.FromString((string)reader["notes"]); | 547 | notes.Notes = OSD.FromString((string)reader["notes"]); |
548 | } | 548 | } |
549 | else | ||
550 | { | ||
551 | notes.Notes = OSD.FromString(""); | ||
552 | } | ||
549 | } | 553 | } |
550 | } | 554 | } |
551 | } | 555 | } |
@@ -925,15 +929,19 @@ namespace OpenSim.Data.MySQL | |||
925 | } | 929 | } |
926 | else | 930 | else |
927 | { | 931 | { |
932 | dbcon.Close(); | ||
933 | dbcon.Open(); | ||
934 | |||
935 | query = "INSERT INTO usersettings VALUES "; | ||
936 | query += "(?uuid,'false','false', ?Email)"; | ||
937 | |||
928 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | 938 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) |
929 | { | 939 | { |
930 | query = "INSERT INTO usersettings VALUES "; | ||
931 | query += "(?Id,'false','false', '')"; | ||
932 | 940 | ||
933 | lock(Lock) | 941 | put.Parameters.AddWithValue("?Email", pref.EMail); |
934 | { | 942 | put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); |
935 | put.ExecuteNonQuery(); | 943 | |
936 | } | 944 | put.ExecuteNonQuery(); |
937 | } | 945 | } |
938 | } | 946 | } |
939 | } | 947 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs index 916a226..90d45e9 100644 --- a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | |||
@@ -808,11 +808,12 @@ namespace OpenSim.Data.SQLite | |||
808 | else | 808 | else |
809 | { | 809 | { |
810 | query = "INSERT INTO usersettings VALUES "; | 810 | query = "INSERT INTO usersettings VALUES "; |
811 | query += "(:Id,'false','false', '')"; | 811 | query += "(:Id,'false','false', :Email)"; |
812 | 812 | ||
813 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) | 813 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) |
814 | { | 814 | { |
815 | put.Parameters.AddWithValue(":Id", pref.UserId.ToString()); | 815 | put.Parameters.AddWithValue(":Id", pref.UserId.ToString()); |
816 | put.Parameters.AddWithValue(":Email", pref.EMail); | ||
816 | put.ExecuteNonQuery(); | 817 | put.ExecuteNonQuery(); |
817 | 818 | ||
818 | } | 819 | } |
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/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/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 | } | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 0dbdbaf..a05e88c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -711,34 +711,46 @@ namespace OpenSim.Region.ClientStack.Linden | |||
711 | Enqueue(item, avatarID); | 711 | Enqueue(item, avatarID); |
712 | } | 712 | } |
713 | 713 | ||
714 | public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID) | 714 | public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) |
715 | { | 715 | { |
716 | OSD item = EventQueueHelper.EnableSimulator(handle, endPoint); | 716 | m_log.DebugFormat("{0} EnableSimulator. handle={1}, avatarID={2}, regionSize={3},{4}>", |
717 | "[EVENT QUEUE GET MODULE]", handle, avatarID, regionSizeX, regionSizeY); | ||
718 | |||
719 | OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); | ||
717 | Enqueue(item, avatarID); | 720 | Enqueue(item, avatarID); |
718 | } | 721 | } |
719 | 722 | ||
720 | public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath) | 723 | public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, |
724 | ulong regionHandle, int regionSizeX, int regionSizeY) | ||
721 | { | 725 | { |
722 | OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath); | 726 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, avatarID={2}, regionSize={3},{4}>", |
727 | "[EVENT QUEUE GET MODULE]", regionHandle, avatarID, regionSizeX, regionSizeY); | ||
728 | OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); | ||
723 | Enqueue(item, avatarID); | 729 | Enqueue(item, avatarID); |
724 | } | 730 | } |
725 | 731 | ||
726 | public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, | 732 | public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, |
727 | IPEndPoint regionExternalEndPoint, | 733 | IPEndPoint regionExternalEndPoint, |
728 | uint locationID, uint flags, string capsURL, | 734 | uint locationID, uint flags, string capsURL, |
729 | UUID avatarID) | 735 | UUID avatarID, int regionSizeX, int regionSizeY) |
730 | { | 736 | { |
737 | m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize={3},{4}>", | ||
738 | "[EVENT QUEUE GET MODULE]", regionHandle, avatarID, regionSizeX, regionSizeY); | ||
739 | |||
731 | OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, | 740 | OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, |
732 | locationID, flags, capsURL, avatarID); | 741 | locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); |
733 | Enqueue(item, avatarID); | 742 | Enqueue(item, avatarID); |
734 | } | 743 | } |
735 | 744 | ||
736 | public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | 745 | public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, |
737 | IPEndPoint newRegionExternalEndPoint, | 746 | IPEndPoint newRegionExternalEndPoint, |
738 | string capsURL, UUID avatarID, UUID sessionID) | 747 | string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) |
739 | { | 748 | { |
749 | m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", | ||
750 | "[EVENT QUEUE GET MODULE]", handle, avatarID, regionSizeX, regionSizeY); | ||
751 | |||
740 | OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, | 752 | OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, |
741 | capsURL, avatarID, sessionID); | 753 | capsURL, avatarID, sessionID, regionSizeX, regionSizeY); |
742 | Enqueue(item, avatarID); | 754 | Enqueue(item, avatarID); |
743 | } | 755 | } |
744 | 756 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index dab727f..ded228d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | |||
@@ -70,13 +70,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
70 | return llsdEvent; | 70 | return llsdEvent; |
71 | } | 71 | } |
72 | 72 | ||
73 | public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint) | 73 | public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint, int regionSizeX, int regionSizeY) |
74 | { | 74 | { |
75 | OSDMap llsdSimInfo = new OSDMap(3); | 75 | OSDMap llsdSimInfo = new OSDMap(5); |
76 | 76 | ||
77 | llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); | 77 | llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); |
78 | llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); | 78 | llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); |
79 | llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); | 79 | llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); |
80 | llsdSimInfo.Add("RegionSizeX", new OSDInteger(regionSizeX)); | ||
81 | llsdSimInfo.Add("RegionSizeY", new OSDInteger(regionSizeY)); | ||
80 | 82 | ||
81 | OSDArray arr = new OSDArray(1); | 83 | OSDArray arr = new OSDArray(1); |
82 | arr.Add(llsdSimInfo); | 84 | arr.Add(llsdSimInfo); |
@@ -104,7 +106,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
104 | 106 | ||
105 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | 107 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, |
106 | IPEndPoint newRegionExternalEndPoint, | 108 | IPEndPoint newRegionExternalEndPoint, |
107 | string capsURL, UUID agentID, UUID sessionID) | 109 | string capsURL, UUID agentID, UUID sessionID, |
110 | int regionSizeX, int regionSizeY) | ||
108 | { | 111 | { |
109 | OSDArray lookAtArr = new OSDArray(3); | 112 | OSDArray lookAtArr = new OSDArray(3); |
110 | lookAtArr.Add(OSD.FromReal(lookAt.X)); | 113 | lookAtArr.Add(OSD.FromReal(lookAt.X)); |
@@ -130,11 +133,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
130 | OSDArray agentDataArr = new OSDArray(1); | 133 | OSDArray agentDataArr = new OSDArray(1); |
131 | agentDataArr.Add(agentDataMap); | 134 | agentDataArr.Add(agentDataMap); |
132 | 135 | ||
133 | OSDMap regionDataMap = new OSDMap(4); | 136 | OSDMap regionDataMap = new OSDMap(6); |
134 | regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle))); | 137 | regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle))); |
135 | regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); | 138 | regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); |
136 | regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); | 139 | regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); |
137 | regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); | 140 | regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); |
141 | regionDataMap.Add("RegionSizeX", new OSDInteger(regionSizeX)); | ||
142 | regionDataMap.Add("RegionSizeY", new OSDInteger(regionSizeY)); | ||
138 | 143 | ||
139 | OSDArray regionDataArr = new OSDArray(1); | 144 | OSDArray regionDataArr = new OSDArray(1); |
140 | regionDataArr.Add(regionDataMap); | 145 | regionDataArr.Add(regionDataMap); |
@@ -148,8 +153,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
148 | } | 153 | } |
149 | 154 | ||
150 | public static OSD TeleportFinishEvent( | 155 | public static OSD TeleportFinishEvent( |
151 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 156 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
152 | uint locationID, uint flags, string capsURL, UUID agentID) | 157 | uint locationID, uint flags, string capsURL, UUID agentID, |
158 | int regionSizeX, int regionSizeY) | ||
153 | { | 159 | { |
154 | OSDMap info = new OSDMap(); | 160 | OSDMap info = new OSDMap(); |
155 | info.Add("AgentID", OSD.FromUUID(agentID)); | 161 | info.Add("AgentID", OSD.FromUUID(agentID)); |
@@ -160,6 +166,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
160 | info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); | 166 | info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); |
161 | info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); | 167 | info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); |
162 | info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation | 168 | info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation |
169 | info.Add("RegionSizeX", new OSDInteger(regionSizeX)); | ||
170 | info.Add("RegionSizeY", new OSDInteger(regionSizeY)); | ||
163 | 171 | ||
164 | OSDArray infoArr = new OSDArray(); | 172 | OSDArray infoArr = new OSDArray(); |
165 | infoArr.Add(info); | 173 | infoArr.Add(info); |
@@ -187,12 +195,18 @@ namespace OpenSim.Region.ClientStack.Linden | |||
187 | return BuildEvent("ScriptRunningReply", body); | 195 | return BuildEvent("ScriptRunningReply", body); |
188 | } | 196 | } |
189 | 197 | ||
190 | public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap) | 198 | public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap, |
199 | ulong regionHandle, int regionSizeX, int regionSizeY) | ||
191 | { | 200 | { |
192 | OSDMap body = new OSDMap(3); | 201 | OSDMap body = new OSDMap(6) |
193 | body.Add("agent-id", new OSDUUID(agentID)); | 202 | { |
194 | body.Add("sim-ip-and-port", new OSDString(simIpAndPort)); | 203 | {"agent-id", new OSDUUID(agentID)}, |
195 | body.Add("seed-capability", new OSDString(seedcap)); | 204 | {"sim-ip-and-port", new OSDString(simIpAndPort)}, |
205 | {"seed-capability", new OSDString(seedcap)}, | ||
206 | {"region-handle", OSD.FromULong(regionHandle)}, | ||
207 | {"region-size-x", OSD.FromInteger(regionSizeX)}, | ||
208 | {"region-size-y", OSD.FromInteger(regionSizeY)} | ||
209 | }; | ||
196 | 210 | ||
197 | return BuildEvent("EstablishAgentCommunication", body); | 211 | return BuildEvent("EstablishAgentCommunication", body); |
198 | } | 212 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 0ebccbe..3a0ddae 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -6446,26 +6446,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6446 | // Temporarily protect ourselves from the mantis #951 failure. | 6446 | // Temporarily protect ourselves from the mantis #951 failure. |
6447 | // However, we could do this for several other handlers where a failure isn't terminal | 6447 | // However, we could do this for several other handlers where a failure isn't terminal |
6448 | // for the client session anyway, in order to protect ourselves against bad code in plugins | 6448 | // for the client session anyway, in order to protect ourselves against bad code in plugins |
6449 | Vector3 avSize = appear.AgentData.Size; | ||
6449 | try | 6450 | try |
6450 | { | 6451 | { |
6451 | byte[] visualparams = new byte[appear.VisualParam.Length]; | 6452 | byte[] visualparams = new byte[appear.VisualParam.Length]; |
6452 | for (int i = 0; i < appear.VisualParam.Length; i++) | 6453 | for (int i = 0; i < appear.VisualParam.Length; i++) |
6453 | visualparams[i] = appear.VisualParam[i].ParamValue; | 6454 | visualparams[i] = appear.VisualParam[i].ParamValue; |
6455 | //var b = appear.WearableData[0]; | ||
6454 | 6456 | ||
6455 | Primitive.TextureEntry te = null; | 6457 | Primitive.TextureEntry te = null; |
6456 | if (appear.ObjectData.TextureEntry.Length > 1) | 6458 | if (appear.ObjectData.TextureEntry.Length > 1) |
6457 | te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); | 6459 | te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); |
6458 | 6460 | ||
6459 | List<CachedTextureRequestArg> hashes = new List<CachedTextureRequestArg>(); | 6461 | WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length]; |
6460 | for (int i = 0; i < appear.WearableData.Length; i++) | 6462 | for (int i=0; i<appear.WearableData.Length;i++) |
6461 | { | 6463 | cacheitems[i] = new WearableCacheItem(){CacheId = appear.WearableData[i].CacheID,TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)}; |
6462 | CachedTextureRequestArg arg = new CachedTextureRequestArg(); | 6464 | |
6463 | arg.BakedTextureIndex = appear.WearableData[i].TextureIndex; | 6465 | |
6464 | arg.WearableHashID = appear.WearableData[i].CacheID; | ||
6465 | hashes.Add(arg); | ||
6466 | } | ||
6467 | 6466 | ||
6468 | handlerSetAppearance(sender, te, visualparams, hashes); | 6467 | handlerSetAppearance(sender, te, visualparams,avSize, cacheitems); |
6469 | } | 6468 | } |
6470 | catch (Exception e) | 6469 | catch (Exception e) |
6471 | { | 6470 | { |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 202cc62..51433cb 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
@@ -162,6 +162,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
162 | private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC | 162 | private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC |
163 | private int m_maxRTO = 60000; | 163 | private int m_maxRTO = 60000; |
164 | 164 | ||
165 | /// <summary> | ||
166 | /// This is the percentage of the udp texture queue to add to the task queue since | ||
167 | /// textures are now generally handled through http. | ||
168 | /// </summary> | ||
169 | private double m_cannibalrate = 0.0; | ||
170 | |||
165 | private ClientInfo m_info = new ClientInfo(); | 171 | private ClientInfo m_info = new ClientInfo(); |
166 | 172 | ||
167 | /// <summary> | 173 | /// <summary> |
@@ -201,6 +207,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
201 | // Create an array of token buckets for this clients different throttle categories | 207 | // Create an array of token buckets for this clients different throttle categories |
202 | m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; | 208 | m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; |
203 | 209 | ||
210 | m_cannibalrate = rates.CannibalizeTextureRate; | ||
211 | |||
204 | for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) | 212 | for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) |
205 | { | 213 | { |
206 | ThrottleOutPacketType type = (ThrottleOutPacketType)i; | 214 | ThrottleOutPacketType type = (ThrottleOutPacketType)i; |
@@ -349,6 +357,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
349 | texture = Math.Max(texture, LLUDPServer.MTU); | 357 | texture = Math.Max(texture, LLUDPServer.MTU); |
350 | asset = Math.Max(asset, LLUDPServer.MTU); | 358 | asset = Math.Max(asset, LLUDPServer.MTU); |
351 | 359 | ||
360 | // Since most textures are now delivered through http, make it possible | ||
361 | // to cannibalize some of the bw from the texture throttle to use for | ||
362 | // the task queue (e.g. object updates) | ||
363 | task = task + (int)(m_cannibalrate * texture); | ||
364 | texture = (int)((1 - m_cannibalrate) * texture); | ||
365 | |||
352 | //int total = resend + land + wind + cloud + task + texture + asset; | 366 | //int total = resend + land + wind + cloud + task + texture + asset; |
353 | //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, Total={8}", | 367 | //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, Total={8}", |
354 | // AgentID, resend, land, wind, cloud, task, texture, asset, total); | 368 | // AgentID, resend, land, wind, cloud, task, texture, asset, total); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs index c9aac0b..e5bae6e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs | |||
@@ -59,6 +59,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
59 | /// <summary>Flag used to enable adaptive throttles</summary> | 59 | /// <summary>Flag used to enable adaptive throttles</summary> |
60 | public bool AdaptiveThrottlesEnabled; | 60 | public bool AdaptiveThrottlesEnabled; |
61 | 61 | ||
62 | /// <summary>Amount of the texture throttle to steal for the task throttle</summary> | ||
63 | public double CannibalizeTextureRate; | ||
64 | |||
62 | /// <summary> | 65 | /// <summary> |
63 | /// Default constructor | 66 | /// Default constructor |
64 | /// </summary> | 67 | /// </summary> |
@@ -80,6 +83,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
80 | Total = throttleConfig.GetInt("client_throttle_max_bps", 0); | 83 | Total = throttleConfig.GetInt("client_throttle_max_bps", 0); |
81 | 84 | ||
82 | AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false); | 85 | AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false); |
86 | |||
87 | CannibalizeTextureRate = (double)throttleConfig.GetFloat("CannibalizeTextureRate", 0.0f); | ||
88 | CannibalizeTextureRate = Util.Clamp<double>(CannibalizeTextureRate,0.0, 0.9); | ||
83 | } | 89 | } |
84 | catch (Exception) { } | 90 | catch (Exception) { } |
85 | } | 91 | } |
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index e40caec..9b0e1f4 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -194,6 +194,14 @@ namespace OpenSim.Region.CoreModules.Asset | |||
194 | 194 | ||
195 | #region IImprovedAssetCache Members | 195 | #region IImprovedAssetCache Members |
196 | 196 | ||
197 | public bool Check(string id) | ||
198 | { | ||
199 | AssetBase asset; | ||
200 | |||
201 | // XXX:This is probably not an efficient implementation. | ||
202 | return m_cache.TryGetValue(id, out asset); | ||
203 | } | ||
204 | |||
197 | /// <summary> | 205 | /// <summary> |
198 | /// Cache asset. | 206 | /// Cache asset. |
199 | /// </summary> | 207 | /// </summary> |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 9742a5c..f720748 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -112,6 +112,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
112 | //////////////////////////////////////////////////////////// | 112 | //////////////////////////////////////////////////////////// |
113 | // IImprovedAssetCache | 113 | // IImprovedAssetCache |
114 | // | 114 | // |
115 | public bool Check(string id) | ||
116 | { | ||
117 | // XXX This is probably not an efficient implementation. | ||
118 | return Get(id) != null; | ||
119 | } | ||
115 | 120 | ||
116 | public void Cache(AssetBase asset) | 121 | public void Cache(AssetBase asset) |
117 | { | 122 | { |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 08d4fc0..b270de9 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -248,23 +248,32 @@ namespace OpenSim.Region.CoreModules.Asset | |||
248 | 248 | ||
249 | private void UpdateFileCache(string key, AssetBase asset) | 249 | private void UpdateFileCache(string key, AssetBase asset) |
250 | { | 250 | { |
251 | string filename = GetFileName(asset.ID); | 251 | string filename = GetFileName(key); |
252 | 252 | ||
253 | try | 253 | try |
254 | { | 254 | { |
255 | // If the file is already cached just update access time. | 255 | // If the file is already cached, don't cache it, just touch it so access time is updated |
256 | if (File.Exists(filename)) | 256 | if (File.Exists(filename)) |
257 | { | 257 | { |
258 | lock (m_CurrentlyWriting) | 258 | // We don't really want to know about sharing |
259 | // violations here. If the file is locked, then | ||
260 | // the other thread has updated the time for us. | ||
261 | try | ||
259 | { | 262 | { |
260 | if (!m_CurrentlyWriting.Contains(filename)) | 263 | lock (m_CurrentlyWriting) |
261 | File.SetLastAccessTime(filename, DateTime.Now); | 264 | { |
265 | if (!m_CurrentlyWriting.Contains(filename)) | ||
266 | File.SetLastAccessTime(filename, DateTime.Now); | ||
267 | } | ||
262 | } | 268 | } |
263 | } | 269 | catch |
264 | else | 270 | { |
271 | } | ||
272 | } | ||
273 | else | ||
265 | { | 274 | { |
266 | // Once we start writing, make sure we flag that we're writing | 275 | // Once we start writing, make sure we flag that we're writing |
267 | // that object to the cache so that we don't try to write the | 276 | // that object to the cache so that we don't try to write the |
268 | // same file multiple times. | 277 | // same file multiple times. |
269 | lock (m_CurrentlyWriting) | 278 | lock (m_CurrentlyWriting) |
270 | { | 279 | { |
@@ -276,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
276 | else | 285 | else |
277 | { | 286 | { |
278 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); | 287 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); |
279 | } | 288 | } |
280 | 289 | ||
281 | #else | 290 | #else |
282 | if (m_CurrentlyWriting.Contains(filename)) | 291 | if (m_CurrentlyWriting.Contains(filename)) |
@@ -288,6 +297,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
288 | m_CurrentlyWriting.Add(filename); | 297 | m_CurrentlyWriting.Add(filename); |
289 | } | 298 | } |
290 | #endif | 299 | #endif |
300 | |||
291 | } | 301 | } |
292 | 302 | ||
293 | Util.FireAndForget( | 303 | Util.FireAndForget( |
@@ -296,7 +306,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
296 | } | 306 | } |
297 | catch (Exception e) | 307 | catch (Exception e) |
298 | { | 308 | { |
299 | m_log.WarnFormat( | 309 | m_log.ErrorFormat( |
300 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | 310 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", |
301 | asset.ID, e.Message, e.StackTrace); | 311 | asset.ID, e.Message, e.StackTrace); |
302 | } | 312 | } |
@@ -332,6 +342,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
332 | return asset; | 342 | return asset; |
333 | } | 343 | } |
334 | 344 | ||
345 | private bool CheckFromMemoryCache(string id) | ||
346 | { | ||
347 | return m_MemoryCache.Contains(id); | ||
348 | } | ||
349 | |||
335 | /// <summary> | 350 | /// <summary> |
336 | /// Try to get an asset from the file cache. | 351 | /// Try to get an asset from the file cache. |
337 | /// </summary> | 352 | /// </summary> |
@@ -369,15 +384,16 @@ namespace OpenSim.Region.CoreModules.Asset | |||
369 | 384 | ||
370 | if (File.Exists(filename)) | 385 | if (File.Exists(filename)) |
371 | { | 386 | { |
372 | FileStream stream = null; | ||
373 | try | 387 | try |
374 | { | 388 | { |
375 | stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); | 389 | using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) |
376 | BinaryFormatter bformatter = new BinaryFormatter(); | 390 | { |
391 | BinaryFormatter bformatter = new BinaryFormatter(); | ||
377 | 392 | ||
378 | asset = (AssetBase)bformatter.Deserialize(stream); | 393 | asset = (AssetBase)bformatter.Deserialize(stream); |
379 | 394 | ||
380 | m_DiskHits++; | 395 | m_DiskHits++; |
396 | } | ||
381 | } | 397 | } |
382 | catch (System.Runtime.Serialization.SerializationException e) | 398 | catch (System.Runtime.Serialization.SerializationException e) |
383 | { | 399 | { |
@@ -397,14 +413,36 @@ namespace OpenSim.Region.CoreModules.Asset | |||
397 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", | 413 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", |
398 | filename, id, e.Message, e.StackTrace); | 414 | filename, id, e.Message, e.StackTrace); |
399 | } | 415 | } |
400 | finally | 416 | } |
417 | |||
418 | return asset; | ||
419 | } | ||
420 | |||
421 | private bool CheckFromFileCache(string id) | ||
422 | { | ||
423 | bool found = false; | ||
424 | |||
425 | string filename = GetFileName(id); | ||
426 | |||
427 | if (File.Exists(filename)) | ||
428 | { | ||
429 | try | ||
401 | { | 430 | { |
402 | if (stream != null) | 431 | using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) |
403 | stream.Close(); | 432 | { |
433 | if (stream != null) | ||
434 | found = true; | ||
435 | } | ||
436 | } | ||
437 | catch (Exception e) | ||
438 | { | ||
439 | m_log.ErrorFormat( | ||
440 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | ||
441 | filename, id, e.Message, e.StackTrace); | ||
404 | } | 442 | } |
405 | } | 443 | } |
406 | 444 | ||
407 | return asset; | 445 | return found; |
408 | } | 446 | } |
409 | 447 | ||
410 | public AssetBase Get(string id) | 448 | public AssetBase Get(string id) |
@@ -434,6 +472,16 @@ namespace OpenSim.Region.CoreModules.Asset | |||
434 | return asset; | 472 | return asset; |
435 | } | 473 | } |
436 | 474 | ||
475 | public bool Check(string id) | ||
476 | { | ||
477 | if (m_MemoryCacheEnabled && CheckFromMemoryCache(id)) | ||
478 | return true; | ||
479 | |||
480 | if (m_FileCacheEnabled && CheckFromFileCache(id)) | ||
481 | return true; | ||
482 | return false; | ||
483 | } | ||
484 | |||
437 | public AssetBase GetCached(string id) | 485 | public AssetBase GetCached(string id) |
438 | { | 486 | { |
439 | return Get(id); | 487 | return Get(id); |
@@ -723,7 +771,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
723 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); | 771 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); |
724 | 772 | ||
725 | HashSet<UUID> uniqueUuids = new HashSet<UUID>(); | 773 | HashSet<UUID> uniqueUuids = new HashSet<UUID>(); |
726 | Dictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>(); | 774 | Dictionary<UUID, sbyte> assets = new Dictionary<UUID, sbyte>(); |
727 | 775 | ||
728 | foreach (Scene s in m_Scenes) | 776 | foreach (Scene s in m_Scenes) |
729 | { | 777 | { |
@@ -746,7 +794,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
746 | else if (storeUncached) | 794 | else if (storeUncached) |
747 | { | 795 | { |
748 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); | 796 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); |
749 | if (cachedAsset == null && assets[assetID] != AssetType.Unknown) | 797 | if (cachedAsset == null && assets[assetID] != (sbyte)AssetType.Unknown) |
750 | m_log.DebugFormat( | 798 | m_log.DebugFormat( |
751 | "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", | 799 | "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", |
752 | assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); | 800 | assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 9592ca0..5f76ac2 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
115 | // IImprovedAssetCache | 115 | // IImprovedAssetCache |
116 | // | 116 | // |
117 | 117 | ||
118 | public bool Check(string id) | ||
119 | { | ||
120 | return m_Cache.Contains(id); | ||
121 | } | ||
122 | |||
118 | public void Cache(AssetBase asset) | 123 | public void Cache(AssetBase asset) |
119 | { | 124 | { |
120 | if (asset != null) | 125 | if (asset != null) |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index aea768e..09cc998 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -145,33 +145,37 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
145 | /// <param name="sp"></param> | 145 | /// <param name="sp"></param> |
146 | /// <param name="texture"></param> | 146 | /// <param name="texture"></param> |
147 | /// <param name="visualParam"></param> | 147 | /// <param name="visualParam"></param> |
148 | public void SetAppearance(IScenePresence sp, AvatarAppearance appearance) | 148 | public void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems) |
149 | { | 149 | { |
150 | DoSetAppearance(sp, appearance.Texture, appearance.VisualParams, new List<CachedTextureRequestArg>()); | 150 | SetAppearance(sp, appearance.Texture, appearance.VisualParams, cacheItems); |
151 | } | 151 | } |
152 | 152 | ||
153 | /// <summary> | 153 | |
154 | /// Set appearance data (texture asset IDs and slider settings) | 154 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) |
155 | /// </summary> | ||
156 | /// <param name="sp"></param> | ||
157 | /// <param name="texture"></param> | ||
158 | /// <param name="visualParam"></param> | ||
159 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) | ||
160 | { | 155 | { |
161 | DoSetAppearance(sp, textureEntry, visualParams, new List<CachedTextureRequestArg>()); | 156 | float oldoff = sp.Appearance.AvatarFeetOffset; |
157 | Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
158 | |||
159 | SetAppearance(sp, textureEntry, visualParams, cacheItems); | ||
160 | sp.Appearance.SetSize(avSize); | ||
161 | |||
162 | float off = sp.Appearance.AvatarFeetOffset; | ||
163 | Vector3 box = sp.Appearance.AvatarBoxSize; | ||
164 | if (oldoff != off || oldbox != box) | ||
165 | ((ScenePresence)sp).SetSize(box, off); | ||
162 | } | 166 | } |
163 | 167 | ||
164 | /// <summary> | 168 | /// <summary> |
165 | /// Set appearance data (texture asset IDs and slider settings) | 169 | /// Set appearance data (texture asset IDs and slider settings) |
166 | /// </summary> | 170 | /// </summary> |
167 | /// <param name="sp"></param> | 171 | /// <param name="sp"></param> |
168 | /// <param name="texture"></param> | 172 | /// <param name="texture"></param> |
169 | /// <param name="visualParam"></param> | 173 | /// <param name="visualParam"></param> |
170 | protected void DoSetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, List<CachedTextureRequestArg> hashes) | 174 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems) |
171 | { | 175 | { |
172 | // m_log.DebugFormat( | 176 | // m_log.DebugFormat( |
173 | // "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", | 177 | // "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", |
174 | // sp.Name, textureEntry, visualParams); | 178 | // sp.Name, textureEntry, visualParams); |
175 | 179 | ||
176 | // TODO: This is probably not necessary any longer, just assume the | 180 | // TODO: This is probably not necessary any longer, just assume the |
177 | // textureEntry set implies that the appearance transaction is complete | 181 | // textureEntry set implies that the appearance transaction is complete |
@@ -190,36 +194,38 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
190 | // m_log.DebugFormat( | 194 | // m_log.DebugFormat( |
191 | // "[AVFACTORY]: Setting visual params for {0} to {1}", | 195 | // "[AVFACTORY]: Setting visual params for {0} to {1}", |
192 | // client.Name, string.Join(", ", visualParamsStrings)); | 196 | // client.Name, string.Join(", ", visualParamsStrings)); |
193 | 197 | /* | |
194 | float oldHeight = sp.Appearance.AvatarHeight; | 198 | float oldHeight = sp.Appearance.AvatarHeight; |
195 | changed = sp.Appearance.SetVisualParams(visualParams); | 199 | changed = sp.Appearance.SetVisualParams(visualParams); |
196 | 200 | ||
197 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) | 201 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) |
198 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); | 202 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); |
199 | } | 203 | */ |
204 | // float oldoff = sp.Appearance.AvatarFeetOffset; | ||
205 | // Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
206 | changed = sp.Appearance.SetVisualParams(visualParams); | ||
207 | // float off = sp.Appearance.AvatarFeetOffset; | ||
208 | // Vector3 box = sp.Appearance.AvatarBoxSize; | ||
209 | // if(oldoff != off || oldbox != box) | ||
210 | // ((ScenePresence)sp).SetSize(box,off); | ||
200 | 211 | ||
212 | } | ||
213 | |||
201 | // Process the baked texture array | 214 | // Process the baked texture array |
202 | if (textureEntry != null) | 215 | if (textureEntry != null) |
203 | { | 216 | { |
204 | // m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); | 217 | m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); |
205 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | 218 | |
219 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | ||
206 | 220 | ||
207 | changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; | 221 | changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; |
208 | 222 | ||
209 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | 223 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); |
210 | 224 | ||
211 | // If bake textures are missing and this is not an NPC, request a rebake from client | 225 | // If bake textures are missing and this is not an NPC, request a rebake from client |
212 | if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc)) | 226 | if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc)) |
213 | RequestRebake(sp, true); | 227 | RequestRebake(sp, true); |
214 | 228 | ||
215 | // Save the wearble hashes in the appearance | ||
216 | sp.Appearance.ResetTextureHashes(); | ||
217 | if (m_reusetextures) | ||
218 | { | ||
219 | foreach (CachedTextureRequestArg arg in hashes) | ||
220 | sp.Appearance.SetTextureHash(arg.BakedTextureIndex,arg.WearableHashID); | ||
221 | } | ||
222 | |||
223 | // This appears to be set only in the final stage of the appearance | 229 | // This appears to be set only in the final stage of the appearance |
224 | // update transaction. In theory, we should be able to do an immediate | 230 | // update transaction. In theory, we should be able to do an immediate |
225 | // appearance send and save here. | 231 | // appearance send and save here. |
@@ -253,13 +259,13 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
253 | 259 | ||
254 | public bool SendAppearance(UUID agentId) | 260 | public bool SendAppearance(UUID agentId) |
255 | { | 261 | { |
256 | // m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId); | 262 | // m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId); |
257 | 263 | ||
258 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 264 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
259 | if (sp == null) | 265 | if (sp == null) |
260 | { | 266 | { |
261 | // This is expected if the user has gone away. | 267 | // This is expected if the user has gone away. |
262 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); | 268 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); |
263 | return false; | 269 | return false; |
264 | } | 270 | } |
265 | 271 | ||
@@ -277,6 +283,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
277 | return GetBakedTextureFaces(sp); | 283 | return GetBakedTextureFaces(sp); |
278 | } | 284 | } |
279 | 285 | ||
286 | public WearableCacheItem[] GetCachedItems(UUID agentId) | ||
287 | { | ||
288 | ScenePresence sp = m_scene.GetScenePresence(agentId); | ||
289 | WearableCacheItem[] items = sp.Appearance.WearableCacheItems; | ||
290 | //foreach (WearableCacheItem item in items) | ||
291 | //{ | ||
292 | |||
293 | //} | ||
294 | return items; | ||
295 | } | ||
296 | |||
280 | public bool SaveBakedTextures(UUID agentId) | 297 | public bool SaveBakedTextures(UUID agentId) |
281 | { | 298 | { |
282 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 299 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
@@ -336,7 +353,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
336 | /// <param name="agentId"></param> | 353 | /// <param name="agentId"></param> |
337 | public void QueueAppearanceSend(UUID agentid) | 354 | public void QueueAppearanceSend(UUID agentid) |
338 | { | 355 | { |
339 | // m_log.DebugFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); | 356 | // m_log.DebugFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); |
340 | 357 | ||
341 | // 10000 ticks per millisecond, 1000 milliseconds per second | 358 | // 10000 ticks per millisecond, 1000 milliseconds per second |
342 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000); | 359 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000); |
@@ -349,7 +366,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
349 | 366 | ||
350 | public void QueueAppearanceSave(UUID agentid) | 367 | public void QueueAppearanceSave(UUID agentid) |
351 | { | 368 | { |
352 | // m_log.DebugFormat("[AVFACTORY]: Queueing appearance save for {0}", agentid); | 369 | // m_log.DebugFormat("[AVFACTORY]: Queueing appearance save for {0}", agentid); |
353 | 370 | ||
354 | // 10000 ticks per millisecond, 1000 milliseconds per second | 371 | // 10000 ticks per millisecond, 1000 milliseconds per second |
355 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000); | 372 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000); |
@@ -363,6 +380,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
363 | public bool ValidateBakedTextureCache(IScenePresence sp) | 380 | public bool ValidateBakedTextureCache(IScenePresence sp) |
364 | { | 381 | { |
365 | bool defonly = true; // are we only using default textures | 382 | bool defonly = true; // are we only using default textures |
383 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
384 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
385 | WearableCacheItem[] wearableCache = null; | ||
386 | |||
387 | // Cache wearable data for teleport. | ||
388 | // Only makes sense if there's a bake module and a cache module | ||
389 | if (bakedModule != null && cache != null) | ||
390 | { | ||
391 | try | ||
392 | { | ||
393 | wearableCache = bakedModule.Get(sp.UUID); | ||
394 | } | ||
395 | catch (Exception) | ||
396 | { | ||
397 | |||
398 | } | ||
399 | if (wearableCache != null) | ||
400 | { | ||
401 | for (int i = 0; i < wearableCache.Length; i++) | ||
402 | { | ||
403 | cache.Cache(wearableCache[i].TextureAsset); | ||
404 | } | ||
405 | } | ||
406 | } | ||
407 | /* | ||
408 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
409 | if (invService.GetRootFolder(userID) != null) | ||
410 | { | ||
411 | WearableCacheItem[] wearableCache = null; | ||
412 | if (bakedModule != null) | ||
413 | { | ||
414 | try | ||
415 | { | ||
416 | wearableCache = bakedModule.Get(userID); | ||
417 | appearance.WearableCacheItems = wearableCache; | ||
418 | appearance.WearableCacheItemsDirty = false; | ||
419 | foreach (WearableCacheItem item in wearableCache) | ||
420 | { | ||
421 | appearance.Texture.FaceTextures[item.TextureIndex].TextureID = item.TextureID; | ||
422 | } | ||
423 | } | ||
424 | catch (Exception) | ||
425 | { | ||
426 | |||
427 | } | ||
428 | } | ||
429 | */ | ||
366 | 430 | ||
367 | // Process the texture entry | 431 | // Process the texture entry |
368 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 432 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
@@ -370,13 +434,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
370 | int idx = AvatarAppearance.BAKE_INDICES[i]; | 434 | int idx = AvatarAppearance.BAKE_INDICES[i]; |
371 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; | 435 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; |
372 | 436 | ||
373 | // if there is no texture entry, skip it | 437 | // No face, so lets check our baked service cache, teleport or login. |
374 | if (face == null) | 438 | if (face == null) |
375 | continue; | 439 | { |
440 | if (wearableCache != null) | ||
441 | { | ||
442 | // If we find the an appearance item, set it as the textureentry and the face | ||
443 | WearableCacheItem searchitem = WearableCacheItem.SearchTextureIndex((uint) idx, wearableCache); | ||
444 | if (searchitem != null) | ||
445 | { | ||
446 | sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx); | ||
447 | sp.Appearance.Texture.FaceTextures[idx].TextureID = searchitem.TextureID; | ||
448 | face = sp.Appearance.Texture.FaceTextures[idx]; | ||
449 | } | ||
450 | else | ||
451 | { | ||
452 | // if there is no texture entry and no baked cache, skip it | ||
453 | continue; | ||
454 | } | ||
455 | } | ||
456 | else | ||
457 | { | ||
458 | //No texture entry face and no cache. Skip this face. | ||
459 | continue; | ||
460 | } | ||
461 | } | ||
462 | |||
376 | 463 | ||
377 | // m_log.DebugFormat( | 464 | // m_log.DebugFormat( |
378 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", | 465 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", |
379 | // face.TextureID, idx, client.Name, client.AgentId); | 466 | // face.TextureID, idx, client.Name, client.AgentId); |
380 | 467 | ||
381 | // if the texture is one of the "defaults" then skip it | 468 | // if the texture is one of the "defaults" then skip it |
382 | // this should probably be more intelligent (skirt texture doesnt matter | 469 | // this should probably be more intelligent (skirt texture doesnt matter |
@@ -387,11 +474,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
387 | 474 | ||
388 | defonly = false; // found a non-default texture reference | 475 | defonly = false; // found a non-default texture reference |
389 | 476 | ||
390 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | 477 | if (cache != null) |
391 | return false; | 478 | { |
479 | if (!cache.Check(face.TextureID.ToString())) | ||
480 | return false; | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | ||
485 | return false; | ||
486 | } | ||
392 | } | 487 | } |
393 | 488 | ||
394 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); | 489 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); |
395 | 490 | ||
396 | // If we only found default textures, then the appearance is not cached | 491 | // If we only found default textures, then the appearance is not cached |
397 | return (defonly ? false : true); | 492 | return (defonly ? false : true); |
@@ -400,6 +495,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
400 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) | 495 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) |
401 | { | 496 | { |
402 | int texturesRebaked = 0; | 497 | int texturesRebaked = 0; |
498 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
403 | 499 | ||
404 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 500 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
405 | { | 501 | { |
@@ -410,9 +506,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
410 | if (face == null) | 506 | if (face == null) |
411 | continue; | 507 | continue; |
412 | 508 | ||
413 | // m_log.DebugFormat( | 509 | // m_log.DebugFormat( |
414 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", | 510 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", |
415 | // face.TextureID, idx, client.Name, client.AgentId); | 511 | // face.TextureID, idx, client.Name, client.AgentId); |
416 | 512 | ||
417 | // if the texture is one of the "defaults" then skip it | 513 | // if the texture is one of the "defaults" then skip it |
418 | // this should probably be more intelligent (skirt texture doesnt matter | 514 | // this should probably be more intelligent (skirt texture doesnt matter |
@@ -423,21 +519,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
423 | 519 | ||
424 | if (missingTexturesOnly) | 520 | if (missingTexturesOnly) |
425 | { | 521 | { |
426 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) | 522 | if (cache != null) |
427 | { | 523 | { |
428 | continue; | 524 | if (cache.Check(face.TextureID.ToString())) |
525 | continue; | ||
526 | else | ||
527 | { | ||
528 | m_log.DebugFormat( | ||
529 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
530 | face.TextureID, idx, sp.Name); | ||
531 | } | ||
429 | } | 532 | } |
430 | else | 533 | else |
431 | { | 534 | { |
432 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the | 535 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) |
433 | // grid asset service (which means that they are not available to the new region and so have | 536 | { |
434 | // to be re-requested from the client). | 537 | continue; |
435 | // | 538 | } |
436 | // The only available core OpenSimulator behaviour right now | 539 | |
437 | // is not to store these textures, temporarily or otherwise. | 540 | else |
438 | m_log.DebugFormat( | 541 | { |
439 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | 542 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the |
440 | face.TextureID, idx, sp.Name); | 543 | // grid asset service (which means that they are not available to the new region and so have |
544 | // to be re-requested from the client). | ||
545 | // | ||
546 | // The only available core OpenSimulator behaviour right now | ||
547 | // is not to store these textures, temporarily or otherwise. | ||
548 | m_log.DebugFormat( | ||
549 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
550 | face.TextureID, idx, sp.Name); | ||
551 | } | ||
441 | } | 552 | } |
442 | } | 553 | } |
443 | else | 554 | else |
@@ -476,9 +587,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
476 | if (bakeType == BakeType.Unknown) | 587 | if (bakeType == BakeType.Unknown) |
477 | continue; | 588 | continue; |
478 | 589 | ||
479 | // m_log.DebugFormat( | 590 | // m_log.DebugFormat( |
480 | // "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", | 591 | // "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", |
481 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | 592 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); |
482 | 593 | ||
483 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); | 594 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); |
484 | Primitive.TextureEntryFace texture = faceTextures[ftIndex]; // this will be null if there's no such baked texture | 595 | Primitive.TextureEntryFace texture = faceTextures[ftIndex]; // this will be null if there's no such baked texture |
@@ -502,7 +613,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
502 | UUID avatarID = kvp.Key; | 613 | UUID avatarID = kvp.Key; |
503 | long sendTime = kvp.Value; | 614 | long sendTime = kvp.Value; |
504 | 615 | ||
505 | // m_log.DebugFormat("[AVFACTORY]: Handling queued appearance updates for {0}, update delta to now is {1}", avatarID, sendTime - now); | 616 | // m_log.DebugFormat("[AVFACTORY]: Handling queued appearance updates for {0}, update delta to now is {1}", avatarID, sendTime - now); |
506 | 617 | ||
507 | if (sendTime < now) | 618 | if (sendTime < now) |
508 | { | 619 | { |
@@ -548,11 +659,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
548 | if (sp == null) | 659 | if (sp == null) |
549 | { | 660 | { |
550 | // This is expected if the user has gone away. | 661 | // This is expected if the user has gone away. |
551 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); | 662 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); |
552 | return; | 663 | return; |
553 | } | 664 | } |
554 | 665 | ||
555 | // m_log.DebugFormat("[AVFACTORY]: Saving appearance for avatar {0}", agentid); | 666 | // m_log.DebugFormat("[AVFACTORY]: Saving appearance for avatar {0}", agentid); |
556 | 667 | ||
557 | // This could take awhile since it needs to pull inventory | 668 | // This could take awhile since it needs to pull inventory |
558 | // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape | 669 | // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape |
@@ -579,26 +690,70 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
579 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) | 690 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) |
580 | { | 691 | { |
581 | IInventoryService invService = m_scene.InventoryService; | 692 | IInventoryService invService = m_scene.InventoryService; |
582 | 693 | bool resetwearable = false; | |
583 | if (invService.GetRootFolder(userID) != null) | 694 | if (invService.GetRootFolder(userID) != null) |
584 | { | 695 | { |
585 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | 696 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) |
586 | { | 697 | { |
587 | for (int j = 0; j < appearance.Wearables[i].Count; j++) | 698 | for (int j = 0; j < appearance.Wearables[i].Count; j++) |
588 | { | 699 | { |
700 | // Check if the default wearables are not set | ||
589 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) | 701 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) |
702 | { | ||
703 | switch ((WearableType) i) | ||
704 | { | ||
705 | case WearableType.Eyes: | ||
706 | case WearableType.Hair: | ||
707 | case WearableType.Shape: | ||
708 | case WearableType.Skin: | ||
709 | //case WearableType.Underpants: | ||
710 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); | ||
711 | resetwearable = true; | ||
712 | m_log.Warn("[AVFACTORY]: UUID.Zero Wearables, passing fake values."); | ||
713 | resetwearable = true; | ||
714 | break; | ||
715 | |||
716 | } | ||
590 | continue; | 717 | continue; |
718 | } | ||
591 | 719 | ||
592 | // Ignore ruth's assets | 720 | // Ignore ruth's assets except for the body parts! missing body parts fail avatar appearance on V1 |
593 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) | 721 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) |
722 | { | ||
723 | switch ((WearableType)i) | ||
724 | { | ||
725 | case WearableType.Eyes: | ||
726 | case WearableType.Hair: | ||
727 | case WearableType.Shape: | ||
728 | case WearableType.Skin: | ||
729 | //case WearableType.Underpants: | ||
730 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); | ||
731 | |||
732 | m_log.WarnFormat("[AVFACTORY]: {0} Default Wearables, passing existing values.", (WearableType)i); | ||
733 | resetwearable = true; | ||
734 | break; | ||
735 | |||
736 | } | ||
594 | continue; | 737 | continue; |
595 | 738 | } | |
739 | |||
596 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); | 740 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); |
597 | baseItem = invService.GetItem(baseItem); | 741 | baseItem = invService.GetItem(baseItem); |
598 | 742 | ||
599 | if (baseItem != null) | 743 | if (baseItem != null) |
600 | { | 744 | { |
601 | appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); | 745 | appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); |
746 | int unmodifiedWearableIndexForClosure = i; | ||
747 | m_scene.AssetService.Get(baseItem.AssetID.ToString(), this, | ||
748 | delegate(string x, object y, AssetBase z) | ||
749 | { | ||
750 | if (z == null) | ||
751 | { | ||
752 | TryAndRepairBrokenWearable( | ||
753 | (WearableType)unmodifiedWearableIndexForClosure, invService, | ||
754 | userID, appearance); | ||
755 | } | ||
756 | }); | ||
602 | } | 757 | } |
603 | else | 758 | else |
604 | { | 759 | { |
@@ -606,17 +761,236 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
606 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", | 761 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", |
607 | appearance.Wearables[i][j].ItemID, (WearableType)i); | 762 | appearance.Wearables[i][j].ItemID, (WearableType)i); |
608 | 763 | ||
609 | appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID); | 764 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); |
765 | resetwearable = true; | ||
766 | |||
610 | } | 767 | } |
611 | } | 768 | } |
612 | } | 769 | } |
770 | |||
771 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
772 | if (appearance.Wearables[(int) WearableType.Eyes] == null) | ||
773 | { | ||
774 | m_log.WarnFormat("[AVFACTORY]: {0} Eyes are Null, passing existing values.", (WearableType.Eyes)); | ||
775 | |||
776 | TryAndRepairBrokenWearable(WearableType.Eyes, invService, userID, appearance); | ||
777 | resetwearable = true; | ||
778 | } | ||
779 | else | ||
780 | { | ||
781 | if (appearance.Wearables[(int) WearableType.Eyes][0].ItemID == UUID.Zero) | ||
782 | { | ||
783 | m_log.WarnFormat("[AVFACTORY]: Eyes are UUID.Zero are broken, {0} {1}", | ||
784 | appearance.Wearables[(int) WearableType.Eyes][0].ItemID, | ||
785 | appearance.Wearables[(int) WearableType.Eyes][0].AssetID); | ||
786 | TryAndRepairBrokenWearable(WearableType.Eyes, invService, userID, appearance); | ||
787 | resetwearable = true; | ||
788 | |||
789 | } | ||
790 | |||
791 | } | ||
792 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
793 | if (appearance.Wearables[(int)WearableType.Shape] == null) | ||
794 | { | ||
795 | m_log.WarnFormat("[AVFACTORY]: {0} shape is Null, passing existing values.", (WearableType.Shape)); | ||
796 | |||
797 | TryAndRepairBrokenWearable(WearableType.Shape, invService, userID, appearance); | ||
798 | resetwearable = true; | ||
799 | } | ||
800 | else | ||
801 | { | ||
802 | if (appearance.Wearables[(int)WearableType.Shape][0].ItemID == UUID.Zero) | ||
803 | { | ||
804 | m_log.WarnFormat("[AVFACTORY]: Shape is UUID.Zero and broken, {0} {1}", | ||
805 | appearance.Wearables[(int)WearableType.Shape][0].ItemID, | ||
806 | appearance.Wearables[(int)WearableType.Shape][0].AssetID); | ||
807 | TryAndRepairBrokenWearable(WearableType.Shape, invService, userID, appearance); | ||
808 | resetwearable = true; | ||
809 | |||
810 | } | ||
811 | |||
812 | } | ||
813 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
814 | if (appearance.Wearables[(int)WearableType.Hair] == null) | ||
815 | { | ||
816 | m_log.WarnFormat("[AVFACTORY]: {0} Hair is Null, passing existing values.", (WearableType.Hair)); | ||
817 | |||
818 | TryAndRepairBrokenWearable(WearableType.Hair, invService, userID, appearance); | ||
819 | resetwearable = true; | ||
820 | } | ||
821 | else | ||
822 | { | ||
823 | if (appearance.Wearables[(int)WearableType.Hair][0].ItemID == UUID.Zero) | ||
824 | { | ||
825 | m_log.WarnFormat("[AVFACTORY]: Hair is UUID.Zero and broken, {0} {1}", | ||
826 | appearance.Wearables[(int)WearableType.Hair][0].ItemID, | ||
827 | appearance.Wearables[(int)WearableType.Hair][0].AssetID); | ||
828 | TryAndRepairBrokenWearable(WearableType.Hair, invService, userID, appearance); | ||
829 | resetwearable = true; | ||
830 | |||
831 | } | ||
832 | |||
833 | } | ||
834 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
835 | if (appearance.Wearables[(int)WearableType.Skin] == null) | ||
836 | { | ||
837 | m_log.WarnFormat("[AVFACTORY]: {0} Skin is Null, passing existing values.", (WearableType.Skin)); | ||
838 | |||
839 | TryAndRepairBrokenWearable(WearableType.Skin, invService, userID, appearance); | ||
840 | resetwearable = true; | ||
841 | } | ||
842 | else | ||
843 | { | ||
844 | if (appearance.Wearables[(int)WearableType.Skin][0].ItemID == UUID.Zero) | ||
845 | { | ||
846 | m_log.WarnFormat("[AVFACTORY]: Skin is UUID.Zero and broken, {0} {1}", | ||
847 | appearance.Wearables[(int)WearableType.Skin][0].ItemID, | ||
848 | appearance.Wearables[(int)WearableType.Skin][0].AssetID); | ||
849 | TryAndRepairBrokenWearable(WearableType.Skin, invService, userID, appearance); | ||
850 | resetwearable = true; | ||
851 | |||
852 | } | ||
853 | |||
854 | } | ||
855 | if (resetwearable) | ||
856 | { | ||
857 | ScenePresence presence = null; | ||
858 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
859 | { | ||
860 | presence.ControllingClient.SendWearables(presence.Appearance.Wearables, | ||
861 | presence.Appearance.Serial++); | ||
862 | } | ||
863 | } | ||
864 | |||
613 | } | 865 | } |
614 | else | 866 | else |
615 | { | 867 | { |
616 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); | 868 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); |
617 | } | 869 | } |
618 | } | 870 | } |
871 | private void TryAndRepairBrokenWearable(WearableType type, IInventoryService invService, UUID userID,AvatarAppearance appearance) | ||
872 | { | ||
873 | UUID defaultwearable = GetDefaultItem(type); | ||
874 | if (defaultwearable != UUID.Zero) | ||
875 | { | ||
876 | UUID newInvItem = UUID.Random(); | ||
877 | InventoryItemBase itembase = new InventoryItemBase(newInvItem, userID) | ||
878 | { | ||
879 | AssetID = | ||
880 | defaultwearable, | ||
881 | AssetType | ||
882 | = | ||
883 | (int) | ||
884 | AssetType | ||
885 | .Bodypart, | ||
886 | CreatorId | ||
887 | = | ||
888 | userID | ||
889 | .ToString | ||
890 | (), | ||
891 | //InvType = (int)InventoryType.Wearable, | ||
892 | |||
893 | Description | ||
894 | = | ||
895 | "Failed Wearable Replacement", | ||
896 | Folder = | ||
897 | invService | ||
898 | .GetFolderForType | ||
899 | (userID, | ||
900 | AssetType | ||
901 | .Bodypart) | ||
902 | .ID, | ||
903 | Flags = (uint) type, | ||
904 | Name = Enum.GetName(typeof (WearableType), type), | ||
905 | BasePermissions = (uint) PermissionMask.Copy, | ||
906 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
907 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
908 | GroupPermissions = (uint) PermissionMask.Copy, | ||
909 | NextPermissions = (uint) PermissionMask.Copy | ||
910 | }; | ||
911 | invService.AddItem(itembase); | ||
912 | UUID LinkInvItem = UUID.Random(); | ||
913 | itembase = new InventoryItemBase(LinkInvItem, userID) | ||
914 | { | ||
915 | AssetID = | ||
916 | newInvItem, | ||
917 | AssetType | ||
918 | = | ||
919 | (int) | ||
920 | AssetType | ||
921 | .Link, | ||
922 | CreatorId | ||
923 | = | ||
924 | userID | ||
925 | .ToString | ||
926 | (), | ||
927 | InvType = (int) InventoryType.Wearable, | ||
928 | |||
929 | Description | ||
930 | = | ||
931 | "Failed Wearable Replacement", | ||
932 | Folder = | ||
933 | invService | ||
934 | .GetFolderForType | ||
935 | (userID, | ||
936 | AssetType | ||
937 | .CurrentOutfitFolder) | ||
938 | .ID, | ||
939 | Flags = (uint) type, | ||
940 | Name = Enum.GetName(typeof (WearableType), type), | ||
941 | BasePermissions = (uint) PermissionMask.Copy, | ||
942 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
943 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
944 | GroupPermissions = (uint) PermissionMask.Copy, | ||
945 | NextPermissions = (uint) PermissionMask.Copy | ||
946 | }; | ||
947 | invService.AddItem(itembase); | ||
948 | appearance.Wearables[(int)type] = new AvatarWearable(newInvItem, GetDefaultItem(type)); | ||
949 | ScenePresence presence = null; | ||
950 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
951 | { | ||
952 | m_scene.SendInventoryUpdate(presence.ControllingClient, | ||
953 | invService.GetFolderForType(userID, | ||
954 | AssetType | ||
955 | .CurrentOutfitFolder), | ||
956 | false, true); | ||
957 | } | ||
958 | } | ||
959 | } | ||
960 | private UUID GetDefaultItem(WearableType wearable) | ||
961 | { | ||
962 | // These are ruth | ||
963 | UUID ret = UUID.Zero; | ||
964 | switch (wearable) | ||
965 | { | ||
966 | case WearableType.Eyes: | ||
967 | ret = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); | ||
968 | break; | ||
969 | case WearableType.Hair: | ||
970 | ret = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66"); | ||
971 | break; | ||
972 | case WearableType.Pants: | ||
973 | ret = new UUID("00000000-38f9-1111-024e-222222111120"); | ||
974 | break; | ||
975 | case WearableType.Shape: | ||
976 | ret = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
977 | break; | ||
978 | case WearableType.Shirt: | ||
979 | ret = new UUID("00000000-38f9-1111-024e-222222111110"); | ||
980 | break; | ||
981 | case WearableType.Skin: | ||
982 | ret = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb"); | ||
983 | break; | ||
984 | case WearableType.Undershirt: | ||
985 | ret = new UUID("16499ebb-3208-ec27-2def-481881728f47"); | ||
986 | break; | ||
987 | case WearableType.Underpants: | ||
988 | ret = new UUID("4ac2e9c7-3671-d229-316a-67717730841d"); | ||
989 | break; | ||
990 | } | ||
619 | 991 | ||
992 | return ret; | ||
993 | } | ||
620 | #endregion | 994 | #endregion |
621 | 995 | ||
622 | #region Client Event Handlers | 996 | #region Client Event Handlers |
@@ -626,12 +1000,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
626 | /// <param name="client"></param> | 1000 | /// <param name="client"></param> |
627 | private void Client_OnRequestWearables(IClientAPI client) | 1001 | private void Client_OnRequestWearables(IClientAPI client) |
628 | { | 1002 | { |
629 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); | 1003 | Util.FireAndForget(delegate(object x) |
630 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1004 | { |
631 | if (sp != null) | 1005 | Thread.Sleep(4000); |
632 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | 1006 | |
633 | else | 1007 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); |
634 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | 1008 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
1009 | if (sp != null) | ||
1010 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | ||
1011 | else | ||
1012 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | ||
1013 | }); | ||
635 | } | 1014 | } |
636 | 1015 | ||
637 | /// <summary> | 1016 | /// <summary> |
@@ -640,12 +1019,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
640 | /// <param name="client"></param> | 1019 | /// <param name="client"></param> |
641 | /// <param name="texture"></param> | 1020 | /// <param name="texture"></param> |
642 | /// <param name="visualParam"></param> | 1021 | /// <param name="visualParam"></param> |
643 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, List<CachedTextureRequestArg> hashes) | 1022 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) |
644 | { | 1023 | { |
645 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); | 1024 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); |
646 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1025 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
647 | if (sp != null) | 1026 | if (sp != null) |
648 | DoSetAppearance(sp, textureEntry, visualParams, hashes); | 1027 | SetAppearance(sp, textureEntry, visualParams,avSize, cacheItems); |
649 | else | 1028 | else |
650 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); | 1029 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); |
651 | } | 1030 | } |
@@ -702,7 +1081,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
702 | /// <param name="cachedTextureRequest"></param> | 1081 | /// <param name="cachedTextureRequest"></param> |
703 | private void Client_OnCachedTextureRequest(IClientAPI client, int serial, List<CachedTextureRequestArg> cachedTextureRequest) | 1082 | private void Client_OnCachedTextureRequest(IClientAPI client, int serial, List<CachedTextureRequestArg> cachedTextureRequest) |
704 | { | 1083 | { |
705 | // m_log.DebugFormat("[AVFACTORY]: Client_OnCachedTextureRequest called for {0} ({1})", client.Name, client.AgentId); | 1084 | // m_log.WarnFormat("[AVFACTORY]: Client_OnCachedTextureRequest called for {0} ({1})", client.Name, client.AgentId); |
706 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1085 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
707 | 1086 | ||
708 | List<CachedTextureResponseArg> cachedTextureResponse = new List<CachedTextureResponseArg>(); | 1087 | List<CachedTextureResponseArg> cachedTextureResponse = new List<CachedTextureResponseArg>(); |
@@ -713,20 +1092,23 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
713 | 1092 | ||
714 | if (m_reusetextures) | 1093 | if (m_reusetextures) |
715 | { | 1094 | { |
716 | if (sp.Appearance.GetTextureHash(index) == request.WearableHashID) | 1095 | // this is the most insanely dumb way to do this... however it seems to |
717 | { | 1096 | // actually work. if the appearance has been reset because wearables have |
718 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[index]; | 1097 | // changed then the texture entries are zero'd out until the bakes are |
719 | if (face != null) | 1098 | // uploaded. on login, if the textures exist in the cache (eg if you logged |
720 | texture = face.TextureID; | 1099 | // into the simulator recently, then the appearance will pull those and send |
721 | } | 1100 | // them back in the packet and you won't have to rebake. if the textures aren't |
722 | else | 1101 | // in the cache then the intial makeroot() call in scenepresence will zero |
723 | { | 1102 | // them out. |
724 | // We know that that hash is wrong, null it out | 1103 | // |
725 | // and wait for the setappearance call | 1104 | // a better solution (though how much better is an open question) is to |
726 | sp.Appearance.SetTextureHash(index,UUID.Zero); | 1105 | // store the hashes in the appearance and compare them. Thats's coming. |
727 | } | 1106 | |
728 | 1107 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[index]; | |
729 | // m_log.WarnFormat("[AVFACTORY]: use texture {0} for index {1}; hash={2}",texture,index,request.WearableHashID); | 1108 | if (face != null) |
1109 | texture = face.TextureID; | ||
1110 | |||
1111 | // m_log.WarnFormat("[AVFACTORY]: reuse texture {0} for index {1}",texture,index); | ||
730 | } | 1112 | } |
731 | 1113 | ||
732 | CachedTextureResponseArg response = new CachedTextureResponseArg(); | 1114 | CachedTextureResponseArg response = new CachedTextureResponseArg(); |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 1830d41..ff4c6c9 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | |||
@@ -61,10 +61,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
61 | for (byte i = 0; i < visualParams.Length; i++) | 61 | for (byte i = 0; i < visualParams.Length; i++) |
62 | visualParams[i] = i; | 62 | visualParams[i] = i; |
63 | 63 | ||
64 | afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); | 64 | // afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); |
65 | 65 | ||
66 | // TODO: Check baked texture | 66 | // TODO: Check baked texture |
67 | Assert.AreEqual(visualParams, sp.Appearance.VisualParams); | 67 | // Assert.AreEqual(visualParams, sp.Appearance.VisualParams); |
68 | } | 68 | } |
69 | 69 | ||
70 | [Test] | 70 | [Test] |
@@ -102,6 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
102 | Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); | 102 | Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); |
103 | eyesFace.TextureID = eyesTextureId; | 103 | eyesFace.TextureID = eyesTextureId; |
104 | 104 | ||
105 | /* | ||
105 | afm.SetAppearance(sp, bakedTextureEntry, visualParams); | 106 | afm.SetAppearance(sp, bakedTextureEntry, visualParams); |
106 | afm.SaveBakedTextures(userId); | 107 | afm.SaveBakedTextures(userId); |
107 | // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); | 108 | // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); |
@@ -113,6 +114,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
113 | Assert.That(eyesBake, Is.Not.Null); | 114 | Assert.That(eyesBake, Is.Not.Null); |
114 | Assert.That(eyesBake.Temporary, Is.False); | 115 | Assert.That(eyesBake.Temporary, Is.False); |
115 | Assert.That(eyesBake.Local, Is.False); | 116 | Assert.That(eyesBake.Local, Is.False); |
117 | */ | ||
116 | } | 118 | } |
117 | } | 119 | } |
118 | } \ No newline at end of file | 120 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 4ec8ae7..4292719 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -78,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
78 | /// <value> | 78 | /// <value> |
79 | /// Used to collect the uuids of the assets that we need to save into the archive | 79 | /// Used to collect the uuids of the assets that we need to save into the archive |
80 | /// </value> | 80 | /// </value> |
81 | protected Dictionary<UUID, AssetType> m_assetUuids = new Dictionary<UUID, AssetType>(); | 81 | protected Dictionary<UUID, sbyte> m_assetUuids = new Dictionary<UUID, sbyte>(); |
82 | 82 | ||
83 | /// <value> | 83 | /// <value> |
84 | /// Used to collect the uuids of the users that we need to save into the archive | 84 | /// Used to collect the uuids of the users that we need to save into the archive |
@@ -187,7 +187,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
187 | 187 | ||
188 | // Don't chase down link asset items as they actually point to their target item IDs rather than an asset | 188 | // Don't chase down link asset items as they actually point to their target item IDs rather than an asset |
189 | if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) | 189 | if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) |
190 | m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids); | 190 | m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (sbyte)inventoryItem.AssetType, m_assetUuids); |
191 | } | 191 | } |
192 | 192 | ||
193 | /// <summary> | 193 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index b21082f..bfa30e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |||
@@ -758,8 +758,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles | |||
758 | IClientAPI remoteClient = (IClientAPI)sender; | 758 | IClientAPI remoteClient = (IClientAPI)sender; |
759 | string serverURI = string.Empty; | 759 | string serverURI = string.Empty; |
760 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); | 760 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); |
761 | note.TargetId = remoteClient.AgentId; | 761 | note.UserId = remoteClient.AgentId; |
762 | UUID.TryParse(args[0], out note.UserId); | 762 | UUID.TryParse(args[0], out note.TargetId); |
763 | 763 | ||
764 | object Note = (object)note; | 764 | object Note = (object)note; |
765 | if(!JsonRpcRequest(ref Note, "avatarnotesrequest", serverURI, UUID.Random().ToString())) | 765 | if(!JsonRpcRequest(ref Note, "avatarnotesrequest", serverURI, UUID.Random().ToString())) |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index aa8a4db..5fea0cf 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -51,7 +51,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EntityTransferModule")] | 51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EntityTransferModule")] |
52 | public class EntityTransferModule : INonSharedRegionModule, IEntityTransferModule | 52 | public class EntityTransferModule : INonSharedRegionModule, IEntityTransferModule |
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | private static readonly string LogHeader = "[ENTITY TRANSFER MODULE]"; | ||
55 | 56 | ||
56 | public const int DefaultMaxTransferDistance = 4095; | 57 | public const int DefaultMaxTransferDistance = 4095; |
57 | public const bool WaitForAgentArrivedAtDestinationDefault = true; | 58 | public const bool WaitForAgentArrivedAtDestinationDefault = true; |
@@ -409,7 +410,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
409 | /// <param name="sp"></param> | 410 | /// <param name="sp"></param> |
410 | /// <param name="position"></param> | 411 | /// <param name="position"></param> |
411 | /// <param name="lookAt"></param> | 412 | /// <param name="lookAt"></param> |
412 | /// <param name="teleportFlags"></param | 413 | /// <param name="teleportFlags"></param> |
413 | private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags) | 414 | private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags) |
414 | { | 415 | { |
415 | m_log.DebugFormat( | 416 | m_log.DebugFormat( |
@@ -444,11 +445,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
444 | position.Z = newPosZ; | 445 | position.Z = newPosZ; |
445 | } | 446 | } |
446 | 447 | ||
448 | if (sp.Flying) | ||
449 | teleportFlags |= (uint)TeleportFlags.IsFlying; | ||
450 | |||
447 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); | 451 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); |
448 | 452 | ||
449 | sp.ControllingClient.SendTeleportStart(teleportFlags); | 453 | sp.ControllingClient.SendTeleportStart(teleportFlags); |
450 | 454 | ||
451 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | 455 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); |
456 | sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags; | ||
452 | sp.Velocity = Vector3.Zero; | 457 | sp.Velocity = Vector3.Zero; |
453 | sp.Teleport(position); | 458 | sp.Teleport(position); |
454 | 459 | ||
@@ -652,8 +657,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
652 | // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, | 657 | // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, |
653 | // it's actually doing a lot of work. | 658 | // it's actually doing a lot of work. |
654 | IPEndPoint endPoint = finalDestination.ExternalEndPoint; | 659 | IPEndPoint endPoint = finalDestination.ExternalEndPoint; |
655 | 660 | if (endPoint == null || endPoint.Address == null) | |
656 | if (endPoint.Address == null) | ||
657 | { | 661 | { |
658 | sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); | 662 | sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); |
659 | 663 | ||
@@ -692,6 +696,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
692 | // both regions | 696 | // both regions |
693 | if (sp.ParentID != (uint)0) | 697 | if (sp.ParentID != (uint)0) |
694 | sp.StandUp(); | 698 | sp.StandUp(); |
699 | else if (sp.Flying) | ||
700 | teleportFlags |= (uint)TeleportFlags.IsFlying; | ||
695 | 701 | ||
696 | if (DisableInterRegionTeleportCancellation) | 702 | if (DisableInterRegionTeleportCancellation) |
697 | teleportFlags |= (uint)TeleportFlags.DisableCancel; | 703 | teleportFlags |= (uint)TeleportFlags.DisableCancel; |
@@ -820,7 +826,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
820 | // The EnableSimulator message makes the client establish a connection with the destination | 826 | // The EnableSimulator message makes the client establish a connection with the destination |
821 | // simulator by sending the initial UseCircuitCode UDP packet to the destination containing the | 827 | // simulator by sending the initial UseCircuitCode UDP packet to the destination containing the |
822 | // correct circuit code. | 828 | // correct circuit code. |
823 | m_eqModule.EnableSimulator(destinationHandle, endPoint, sp.UUID); | 829 | m_eqModule.EnableSimulator(destinationHandle, endPoint, sp.UUID, |
830 | finalDestination.RegionSizeX, finalDestination.RegionSizeY); | ||
831 | m_log.DebugFormat("{0} Sent EnableSimulator. regName={1}, size=<{2},{3}>", LogHeader, | ||
832 | finalDestination.RegionName, finalDestination.RegionSizeX, finalDestination.RegionSizeY); | ||
824 | 833 | ||
825 | // XXX: Is this wait necessary? We will always end up waiting on UpdateAgent for the destination | 834 | // XXX: Is this wait necessary? We will always end up waiting on UpdateAgent for the destination |
826 | // simulator to confirm that it has established communication with the viewer. | 835 | // simulator to confirm that it has established communication with the viewer. |
@@ -830,7 +839,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
830 | // unnecessary - teleport will succeed and SEED caps will be requested without it (though possibly | 839 | // unnecessary - teleport will succeed and SEED caps will be requested without it (though possibly |
831 | // only on TeleportFinish). This is untested for region teleport between different simulators | 840 | // only on TeleportFinish). This is untested for region teleport between different simulators |
832 | // though this probably also works. | 841 | // though this probably also works. |
833 | m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); | 842 | m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, finalDestination.RegionHandle, |
843 | finalDestination.RegionSizeX, finalDestination.RegionSizeY); | ||
834 | } | 844 | } |
835 | else | 845 | else |
836 | { | 846 | { |
@@ -916,7 +926,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
916 | // OK, send TPFinish to the client, so that it starts the process of contacting the destination region | 926 | // OK, send TPFinish to the client, so that it starts the process of contacting the destination region |
917 | if (m_eqModule != null) | 927 | if (m_eqModule != null) |
918 | { | 928 | { |
919 | m_eqModule.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID); | 929 | m_eqModule.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID, |
930 | finalDestination.RegionSizeX, finalDestination.RegionSizeY); | ||
920 | } | 931 | } |
921 | else | 932 | else |
922 | { | 933 | { |
@@ -1069,7 +1080,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1069 | 1080 | ||
1070 | // New protocol: send TP Finish directly, without prior ES or EAC. That's what happens in the Linden grid | 1081 | // New protocol: send TP Finish directly, without prior ES or EAC. That's what happens in the Linden grid |
1071 | if (m_eqModule != null) | 1082 | if (m_eqModule != null) |
1072 | m_eqModule.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID); | 1083 | m_eqModule.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID, |
1084 | finalDestination.RegionSizeX, finalDestination.RegionSizeY); | ||
1073 | else | 1085 | else |
1074 | sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, | 1086 | sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, |
1075 | teleportFlags, capsPath); | 1087 | teleportFlags, capsPath); |
@@ -1319,11 +1331,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1319 | 1331 | ||
1320 | #region Teleport Home | 1332 | #region Teleport Home |
1321 | 1333 | ||
1322 | public virtual void TriggerTeleportHome(UUID id, IClientAPI client) | 1334 | public virtual void TriggerTeleportHome(UUID id, IClientAPI client) |
1323 | { | 1335 | { |
1324 | TeleportHome(id, client); | 1336 | TeleportHome(id, client); |
1325 | } | 1337 | } |
1326 | 1338 | ||
1327 | public virtual bool TeleportHome(UUID id, IClientAPI client) | 1339 | public virtual bool TeleportHome(UUID id, IClientAPI client) |
1328 | { | 1340 | { |
1329 | m_log.DebugFormat( | 1341 | m_log.DebugFormat( |
@@ -1334,6 +1346,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1334 | 1346 | ||
1335 | if (uinfo != null) | 1347 | if (uinfo != null) |
1336 | { | 1348 | { |
1349 | if (uinfo.HomeRegionID == UUID.Zero) | ||
1350 | { | ||
1351 | // can't find the Home region: Tell viewer and abort | ||
1352 | client.SendTeleportFailed("You don't have a home position set."); | ||
1353 | return false; | ||
1354 | } | ||
1337 | GridRegion regionInfo = Scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); | 1355 | GridRegion regionInfo = Scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); |
1338 | if (regionInfo == null) | 1356 | if (regionInfo == null) |
1339 | { | 1357 | { |
@@ -1353,9 +1371,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1353 | } | 1371 | } |
1354 | else | 1372 | else |
1355 | { | 1373 | { |
1356 | m_log.ErrorFormat( | 1374 | // can't find the Home region: Tell viewer and abort |
1357 | "[ENTITY TRANSFER MODULE]: No grid user information found for {0} {1}. Cannot send home.", | 1375 | client.SendTeleportFailed("Your home region could not be found."); |
1358 | client.Name, client.AgentId); | ||
1359 | } | 1376 | } |
1360 | return false; | 1377 | return false; |
1361 | } | 1378 | } |
@@ -1365,15 +1382,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1365 | 1382 | ||
1366 | #region Agent Crossings | 1383 | #region Agent Crossings |
1367 | 1384 | ||
1368 | public bool Cross(ScenePresence agent, bool isFlying) | 1385 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos) |
1369 | { | 1386 | { |
1370 | Scene scene = agent.Scene; | 1387 | version = String.Empty; |
1371 | Vector3 pos = agent.AbsolutePosition; | 1388 | newpos = pos; |
1372 | 1389 | ||
1373 | // m_log.DebugFormat( | 1390 | // m_log.DebugFormat( |
1374 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); | 1391 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); |
1375 | 1392 | ||
1376 | Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); | ||
1377 | uint neighbourx = scene.RegionInfo.RegionLocX; | 1393 | uint neighbourx = scene.RegionInfo.RegionLocX; |
1378 | uint neighboury = scene.RegionInfo.RegionLocY; | 1394 | uint neighboury = scene.RegionInfo.RegionLocY; |
1379 | const float boundaryDistance = 1.7f; | 1395 | const float boundaryDistance = 1.7f; |
@@ -1394,52 +1410,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1394 | } | 1410 | } |
1395 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | 1411 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) |
1396 | { | 1412 | { |
1397 | Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | 1413 | neighboury--; |
1398 | if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) | 1414 | newpos.Y = Constants.RegionSize - enterDistance; |
1399 | { | ||
1400 | neighboury--; | ||
1401 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1402 | } | ||
1403 | else | ||
1404 | { | ||
1405 | agent.IsInTransit = true; | ||
1406 | |||
1407 | neighboury = b.TriggerRegionY; | ||
1408 | neighbourx = b.TriggerRegionX; | ||
1409 | |||
1410 | Vector3 newposition = pos; | ||
1411 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
1412 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
1413 | agent.ControllingClient.SendAgentAlertMessage( | ||
1414 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
1415 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
1416 | return true; | ||
1417 | } | ||
1418 | } | ||
1419 | |||
1420 | Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W); | ||
1421 | if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) | ||
1422 | { | ||
1423 | neighbourx--; | ||
1424 | newpos.X = Constants.RegionSize - enterDistance; | ||
1425 | } | ||
1426 | else | ||
1427 | { | ||
1428 | agent.IsInTransit = true; | ||
1429 | |||
1430 | neighboury = ba.TriggerRegionY; | ||
1431 | neighbourx = ba.TriggerRegionX; | ||
1432 | |||
1433 | Vector3 newposition = pos; | ||
1434 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
1435 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
1436 | agent.ControllingClient.SendAgentAlertMessage( | ||
1437 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
1438 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
1439 | |||
1440 | return true; | ||
1441 | } | 1415 | } |
1442 | 1416 | ||
1417 | neighbourx--; | ||
1418 | newpos.X = Constants.RegionSize - enterDistance; | ||
1443 | } | 1419 | } |
1444 | else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) | 1420 | else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) |
1445 | { | 1421 | { |
@@ -1449,26 +1425,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1449 | 1425 | ||
1450 | if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | 1426 | if (scene.TestBorderCross(pos + southCross, Cardinals.S)) |
1451 | { | 1427 | { |
1452 | Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | 1428 | neighboury--; |
1453 | if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) | 1429 | newpos.Y = Constants.RegionSize - enterDistance; |
1454 | { | ||
1455 | neighboury--; | ||
1456 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1457 | } | ||
1458 | else | ||
1459 | { | ||
1460 | agent.IsInTransit = true; | ||
1461 | |||
1462 | neighboury = ba.TriggerRegionY; | ||
1463 | neighbourx = ba.TriggerRegionX; | ||
1464 | Vector3 newposition = pos; | ||
1465 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
1466 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
1467 | agent.ControllingClient.SendAgentAlertMessage( | ||
1468 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
1469 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
1470 | return true; | ||
1471 | } | ||
1472 | } | 1430 | } |
1473 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | 1431 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) |
1474 | { | 1432 | { |
@@ -1480,25 +1438,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1480 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | 1438 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) |
1481 | { | 1439 | { |
1482 | Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | 1440 | Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); |
1483 | if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) | 1441 | neighboury--; |
1484 | { | 1442 | newpos.Y = Constants.RegionSize - enterDistance; |
1485 | neighboury--; | ||
1486 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1487 | } | ||
1488 | else | ||
1489 | { | ||
1490 | agent.IsInTransit = true; | ||
1491 | |||
1492 | neighboury = b.TriggerRegionY; | ||
1493 | neighbourx = b.TriggerRegionX; | ||
1494 | Vector3 newposition = pos; | ||
1495 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
1496 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
1497 | agent.ControllingClient.SendAgentAlertMessage( | ||
1498 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
1499 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
1500 | return true; | ||
1501 | } | ||
1502 | } | 1443 | } |
1503 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | 1444 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) |
1504 | { | 1445 | { |
@@ -1532,19 +1473,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1532 | } | 1473 | } |
1533 | */ | 1474 | */ |
1534 | 1475 | ||
1535 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | 1476 | xDest = neighbourx; |
1477 | yDest = neighboury; | ||
1536 | 1478 | ||
1537 | int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); | 1479 | int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); |
1538 | 1480 | ||
1481 | ulong neighbourHandle = Utils.UIntsToLong((uint)x, (uint)y); | ||
1482 | |||
1539 | ExpiringCache<ulong, DateTime> r; | 1483 | ExpiringCache<ulong, DateTime> r; |
1540 | DateTime banUntil; | 1484 | DateTime banUntil; |
1541 | 1485 | ||
1542 | if (m_bannedRegions.TryGetValue(agent.ControllingClient.AgentId, out r)) | 1486 | if (m_bannedRegions.TryGetValue(agentID, out r)) |
1543 | { | 1487 | { |
1544 | if (r.TryGetValue(neighbourHandle, out banUntil)) | 1488 | if (r.TryGetValue(neighbourHandle, out banUntil)) |
1545 | { | 1489 | { |
1546 | if (DateTime.Now < banUntil) | 1490 | if (DateTime.Now < banUntil) |
1547 | return false; | 1491 | return null; |
1548 | r.Remove(neighbourHandle); | 1492 | r.Remove(neighbourHandle); |
1549 | } | 1493 | } |
1550 | } | 1494 | } |
@@ -1556,28 +1500,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1556 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); | 1500 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); |
1557 | 1501 | ||
1558 | string reason; | 1502 | string reason; |
1559 | string version; | 1503 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agentID, newpos, out version, out reason)) |
1560 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out version, out reason)) | ||
1561 | { | 1504 | { |
1562 | agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); | ||
1563 | if (r == null) | 1505 | if (r == null) |
1564 | { | 1506 | { |
1565 | r = new ExpiringCache<ulong, DateTime>(); | 1507 | r = new ExpiringCache<ulong, DateTime>(); |
1566 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); | 1508 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); |
1567 | 1509 | ||
1568 | m_bannedRegions.Add(agent.ControllingClient.AgentId, r, TimeSpan.FromSeconds(45)); | 1510 | m_bannedRegions.Add(agentID, r, TimeSpan.FromSeconds(45)); |
1569 | } | 1511 | } |
1570 | else | 1512 | else |
1571 | { | 1513 | { |
1572 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); | 1514 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); |
1573 | } | 1515 | } |
1516 | return null; | ||
1517 | } | ||
1518 | |||
1519 | return neighbourRegion; | ||
1520 | } | ||
1521 | |||
1522 | public bool Cross(ScenePresence agent, bool isFlying) | ||
1523 | { | ||
1524 | uint x; | ||
1525 | uint y; | ||
1526 | Vector3 newpos; | ||
1527 | string version; | ||
1528 | |||
1529 | GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition, out x, out y, out version, out newpos); | ||
1530 | if (neighbourRegion == null) | ||
1531 | { | ||
1532 | agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); | ||
1574 | return false; | 1533 | return false; |
1575 | } | 1534 | } |
1576 | 1535 | ||
1577 | agent.IsInTransit = true; | 1536 | agent.IsInTransit = true; |
1578 | 1537 | ||
1579 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; | 1538 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; |
1580 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d); | 1539 | d.BeginInvoke(agent, newpos, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d); |
1581 | 1540 | ||
1582 | return true; | 1541 | return true; |
1583 | } | 1542 | } |
@@ -1659,52 +1618,49 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1659 | icon.EndInvoke(iar); | 1618 | icon.EndInvoke(iar); |
1660 | } | 1619 | } |
1661 | 1620 | ||
1662 | public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying, string version); | 1621 | public bool CrossAgentToNewRegionPrep(ScenePresence agent, GridRegion neighbourRegion) |
1622 | { | ||
1623 | if (neighbourRegion == null) | ||
1624 | return false; | ||
1625 | |||
1626 | m_entityTransferStateMachine.SetInTransit(agent.UUID); | ||
1627 | |||
1628 | agent.RemoveFromPhysicalScene(); | ||
1629 | |||
1630 | return true; | ||
1631 | } | ||
1663 | 1632 | ||
1664 | /// <summary> | 1633 | /// <summary> |
1665 | /// This Closes child agents on neighbouring regions | 1634 | /// This Closes child agents on neighbouring regions |
1666 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | 1635 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. |
1667 | /// </summary> | 1636 | /// </summary> |
1668 | protected ScenePresence CrossAgentToNewRegionAsync( | 1637 | public ScenePresence CrossAgentToNewRegionAsync( |
1669 | ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, | 1638 | ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, |
1670 | bool isFlying, string version) | 1639 | bool isFlying, string version) |
1671 | { | 1640 | { |
1672 | if (neighbourRegion == null) | 1641 | if (!CrossAgentToNewRegionPrep(agent, neighbourRegion)) |
1642 | { | ||
1643 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); | ||
1673 | return agent; | 1644 | return agent; |
1645 | } | ||
1674 | 1646 | ||
1675 | if (!m_entityTransferStateMachine.SetInTransit(agent.UUID)) | 1647 | if (!CrossAgentIntoNewRegionMain(agent, pos, neighbourRegion, isFlying)) |
1676 | { | 1648 | { |
1677 | m_log.ErrorFormat( | 1649 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); |
1678 | "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2} - agent is already in transit", | ||
1679 | agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName); | ||
1680 | return agent; | 1650 | return agent; |
1681 | } | 1651 | } |
1682 | 1652 | ||
1683 | bool transitWasReset = false; | 1653 | CrossAgentToNewRegionPost(agent, pos, neighbourRegion, isFlying, version); |
1654 | return agent; | ||
1655 | } | ||
1684 | 1656 | ||
1657 | public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying) | ||
1658 | { | ||
1685 | try | 1659 | try |
1686 | { | 1660 | { |
1687 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | 1661 | AgentData cAgent = new AgentData(); |
1688 | |||
1689 | m_log.DebugFormat( | ||
1690 | "[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", | ||
1691 | agent.Firstname, agent.Lastname, neighbourx, neighboury, version); | ||
1692 | |||
1693 | Scene m_scene = agent.Scene; | ||
1694 | |||
1695 | if (!agent.ValidateAttachments()) | ||
1696 | m_log.DebugFormat( | ||
1697 | "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.", | ||
1698 | agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName); | ||
1699 | |||
1700 | pos = pos + agent.Velocity; | ||
1701 | Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); | ||
1702 | |||
1703 | agent.RemoveFromPhysicalScene(); | ||
1704 | |||
1705 | AgentData cAgent = new AgentData(); | ||
1706 | agent.CopyTo(cAgent); | 1662 | agent.CopyTo(cAgent); |
1707 | cAgent.Position = pos; | 1663 | cAgent.Position = pos + agent.Velocity; |
1708 | if (isFlying) | 1664 | if (isFlying) |
1709 | cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 1665 | cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
1710 | 1666 | ||
@@ -1714,7 +1670,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1714 | // Beyond this point, extra cleanup is needed beyond removing transit state | 1670 | // Beyond this point, extra cleanup is needed beyond removing transit state |
1715 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); | 1671 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); |
1716 | 1672 | ||
1717 | if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) | 1673 | if (!agent.Scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) |
1718 | { | 1674 | { |
1719 | // region doesn't take it | 1675 | // region doesn't take it |
1720 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); | 1676 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); |
@@ -1726,88 +1682,111 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1726 | ReInstantiateScripts(agent); | 1682 | ReInstantiateScripts(agent); |
1727 | agent.AddToPhysicalScene(isFlying); | 1683 | agent.AddToPhysicalScene(isFlying); |
1728 | 1684 | ||
1729 | return agent; | 1685 | return false; |
1730 | } | 1686 | } |
1731 | 1687 | ||
1732 | //m_log.Debug("BEFORE CROSS"); | 1688 | } |
1733 | //Scene.DumpChildrenSeeds(UUID); | 1689 | catch (Exception e) |
1734 | //DumpKnownRegions(); | 1690 | { |
1735 | string agentcaps; | 1691 | m_log.ErrorFormat( |
1736 | if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) | 1692 | "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}", |
1737 | { | 1693 | agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace); |
1738 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", | ||
1739 | neighbourRegion.RegionHandle); | ||
1740 | return agent; | ||
1741 | } | ||
1742 | 1694 | ||
1743 | // No turning back | 1695 | // TODO: Might be worth attempting other restoration here such as reinstantiation of scripts, etc. |
1744 | agent.IsChildAgent = true; | 1696 | return false; |
1697 | } | ||
1745 | 1698 | ||
1746 | string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); | 1699 | return true; |
1700 | } | ||
1747 | 1701 | ||
1748 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); | 1702 | public void CrossAgentToNewRegionPost(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, |
1703 | bool isFlying, string version) | ||
1704 | { | ||
1705 | agent.ControllingClient.RequestClientInfo(); | ||
1749 | 1706 | ||
1750 | if (m_eqModule != null) | 1707 | string agentcaps; |
1751 | { | 1708 | if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) |
1752 | m_eqModule.CrossRegion( | 1709 | { |
1753 | neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint, | 1710 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", |
1754 | capsPath, agent.UUID, agent.ControllingClient.SessionId); | 1711 | neighbourRegion.RegionHandle); |
1755 | } | 1712 | return; |
1756 | else | 1713 | } |
1757 | { | ||
1758 | agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, | ||
1759 | capsPath); | ||
1760 | } | ||
1761 | 1714 | ||
1762 | // SUCCESS! | 1715 | // No turning back |
1763 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); | 1716 | agent.IsChildAgent = true; |
1764 | 1717 | ||
1765 | // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. | 1718 | string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); |
1766 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); | ||
1767 | 1719 | ||
1768 | agent.MakeChildAgent(); | 1720 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); |
1769 | 1721 | ||
1770 | // FIXME: Possibly this should occur lower down after other commands to close other agents, | 1722 | Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); |
1771 | // but not sure yet what the side effects would be. | 1723 | |
1772 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); | 1724 | if (m_eqModule != null) |
1773 | transitWasReset = true; | 1725 | { |
1726 | m_eqModule.CrossRegion( | ||
1727 | neighbourRegion.RegionHandle, pos + agent.Velocity, vel2 /* agent.Velocity */, | ||
1728 | neighbourRegion.ExternalEndPoint, | ||
1729 | capsPath, agent.UUID, agent.ControllingClient.SessionId, | ||
1730 | neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY); | ||
1731 | } | ||
1732 | else | ||
1733 | { | ||
1734 | m_log.ErrorFormat("{0} Using old CrossRegion packet. Varregion will not work!!", LogHeader); | ||
1735 | agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, pos + agent.Velocity, agent.Velocity, neighbourRegion.ExternalEndPoint, | ||
1736 | capsPath); | ||
1737 | } | ||
1774 | 1738 | ||
1775 | // now we have a child agent in this region. Request all interesting data about other (root) agents | 1739 | // SUCCESS! |
1776 | agent.SendOtherAgentsAvatarDataToMe(); | 1740 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); |
1777 | agent.SendOtherAgentsAppearanceToMe(); | ||
1778 | 1741 | ||
1779 | // Backwards compatibility. Best effort | 1742 | // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. |
1780 | if (version == "Unknown" || version == string.Empty) | 1743 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); |
1781 | { | ||
1782 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one..."); | ||
1783 | Thread.Sleep(3000); // wait a little now that we're not waiting for the callback | ||
1784 | CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); | ||
1785 | } | ||
1786 | 1744 | ||
1787 | // Next, let's close the child agent connections that are too far away. | 1745 | agent.MakeChildAgent(); |
1788 | agent.CloseChildAgents(neighbourx, neighboury); | ||
1789 | 1746 | ||
1790 | AgentHasMovedAway(agent, false); | 1747 | // FIXME: Possibly this should occur lower down after other commands to close other agents, |
1791 | 1748 | // but not sure yet what the side effects would be. | |
1792 | //m_log.Debug("AFTER CROSS"); | 1749 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); |
1793 | //Scene.DumpChildrenSeeds(UUID); | ||
1794 | //DumpKnownRegions(); | ||
1795 | } | ||
1796 | catch (Exception e) | ||
1797 | { | ||
1798 | m_log.ErrorFormat( | ||
1799 | "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}", | ||
1800 | agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace); | ||
1801 | 1750 | ||
1802 | // TODO: Might be worth attempting other restoration here such as reinstantiation of scripts, etc. | 1751 | // now we have a child agent in this region. Request all interesting data about other (root) agents |
1803 | } | 1752 | agent.SendOtherAgentsAvatarDataToMe(); |
1804 | finally | 1753 | agent.SendOtherAgentsAppearanceToMe(); |
1754 | |||
1755 | // Backwards compatibility. Best effort | ||
1756 | if (version == "Unknown" || version == string.Empty) | ||
1805 | { | 1757 | { |
1806 | if (!transitWasReset) | 1758 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one..."); |
1807 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); | 1759 | Thread.Sleep(3000); // wait a little now that we're not waiting for the callback |
1760 | CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); | ||
1808 | } | 1761 | } |
1809 | 1762 | ||
1810 | return agent; | 1763 | // Next, let's close the child agent connections that are too far away. |
1764 | uint neighbourx; | ||
1765 | uint neighboury; | ||
1766 | |||
1767 | Utils.LongToUInts(neighbourRegion.RegionHandle, out neighbourx, out neighboury); | ||
1768 | |||
1769 | neighbourx /= Constants.RegionSize; | ||
1770 | neighboury /= Constants.RegionSize; | ||
1771 | |||
1772 | agent.CloseChildAgents(neighbourx, neighboury); | ||
1773 | |||
1774 | AgentHasMovedAway(agent, false); | ||
1775 | |||
1776 | // the user may change their profile information in other region, | ||
1777 | // so the userinfo in UserProfileCache is not reliable any more, delete it | ||
1778 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | ||
1779 | // if (agent.Scene.NeedSceneCacheClear(agent.UUID)) | ||
1780 | // { | ||
1781 | // m_log.DebugFormat( | ||
1782 | // "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); | ||
1783 | // } | ||
1784 | |||
1785 | //m_log.Debug("AFTER CROSS"); | ||
1786 | //Scene.DumpChildrenSeeds(UUID); | ||
1787 | //DumpKnownRegions(); | ||
1788 | |||
1789 | return; | ||
1811 | } | 1790 | } |
1812 | 1791 | ||
1813 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | 1792 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) |
@@ -1878,10 +1857,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1878 | agent.Id0 = currentAgentCircuit.Id0; | 1857 | agent.Id0 = currentAgentCircuit.Id0; |
1879 | } | 1858 | } |
1880 | 1859 | ||
1881 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | 1860 | IPEndPoint external = region.ExternalEndPoint; |
1882 | d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, | 1861 | if (external != null) |
1862 | { | ||
1863 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | ||
1864 | d.BeginInvoke(sp, agent, region, external, true, | ||
1883 | InformClientOfNeighbourCompleted, | 1865 | InformClientOfNeighbourCompleted, |
1884 | d); | 1866 | d); |
1867 | } | ||
1885 | } | 1868 | } |
1886 | #endregion | 1869 | #endregion |
1887 | 1870 | ||
@@ -2114,12 +2097,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2114 | } | 2097 | } |
2115 | #endregion | 2098 | #endregion |
2116 | 2099 | ||
2117 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " + | 2100 | m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + |
2118 | "and EstablishAgentCommunication with seed cap {4}", | 2101 | "and EstablishAgentCommunication with seed cap {8}", LogHeader, |
2119 | scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); | 2102 | scene.RegionInfo.RegionName, sp.Name, |
2103 | reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY , capsPath); | ||
2120 | 2104 | ||
2121 | m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); | 2105 | m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY); |
2122 | m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); | 2106 | m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY); |
2123 | } | 2107 | } |
2124 | else | 2108 | else |
2125 | { | 2109 | { |
@@ -2478,30 +2462,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2478 | Utils.LongToUInts(newRegionHandle, out x, out y); | 2462 | Utils.LongToUInts(newRegionHandle, out x, out y); |
2479 | GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); | 2463 | GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); |
2480 | 2464 | ||
2481 | if (destination == null || !CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) | 2465 | if (destination != null) |
2482 | { | 2466 | { |
2483 | m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}",grp.UUID); | 2467 | if (CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) |
2468 | return; // we did it | ||
2469 | } | ||
2484 | 2470 | ||
2485 | // We are going to move the object back to the old position so long as the old position | 2471 | // no one or failed lets go back and tell physics to go on |
2486 | // is in the region | 2472 | oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 0.5f, (float)Constants.RegionSize - 0.5f); |
2487 | oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X,1.0f,(float)Constants.RegionSize-1); | 2473 | oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 0.5f, (float)Constants.RegionSize - 0.5f); |
2488 | oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y,1.0f,(float)Constants.RegionSize-1); | 2474 | oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 0.5f, 4096.0f); |
2489 | oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z,1.0f,4096.0f); | ||
2490 | 2475 | ||
2491 | grp.RootPart.GroupPosition = oldGroupPosition; | 2476 | grp.AbsolutePosition = oldGroupPosition; |
2477 | grp.Velocity = Vector3.Zero; | ||
2492 | 2478 | ||
2493 | // Need to turn off the physics flags, otherwise the object will continue to attempt to | 2479 | if (grp.RootPart.PhysActor != null) |
2494 | // move out of the region creating an infinite loop of failed attempts to cross | 2480 | grp.RootPart.PhysActor.CrossingFailure(); |
2495 | grp.UpdatePrimFlags(grp.RootPart.LocalId,false,grp.IsTemporary,grp.IsPhantom,false); | ||
2496 | 2481 | ||
2497 | if (grp.RootPart.KeyframeMotion != null) | 2482 | if (grp.RootPart.KeyframeMotion != null) |
2498 | grp.RootPart.KeyframeMotion.CrossingFailure(); | 2483 | grp.RootPart.KeyframeMotion.CrossingFailure(); |
2499 | 2484 | ||
2500 | grp.ScheduleGroupForFullUpdate(); | 2485 | grp.ScheduleGroupForFullUpdate(); |
2501 | } | ||
2502 | } | 2486 | } |
2503 | 2487 | ||
2504 | 2488 | ||
2489 | |||
2505 | /// <summary> | 2490 | /// <summary> |
2506 | /// Move the given scene object into a new region | 2491 | /// Move the given scene object into a new region |
2507 | /// </summary> | 2492 | /// </summary> |
@@ -2552,17 +2537,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2552 | grp, e); | 2537 | grp, e); |
2553 | } | 2538 | } |
2554 | } | 2539 | } |
2540 | /* | ||
2541 | * done on caller ( not in attachments crossing for now) | ||
2555 | else | 2542 | else |
2556 | { | 2543 | { |
2544 | |||
2557 | if (!grp.IsDeleted) | 2545 | if (!grp.IsDeleted) |
2558 | { | 2546 | { |
2559 | PhysicsActor pa = grp.RootPart.PhysActor; | 2547 | PhysicsActor pa = grp.RootPart.PhysActor; |
2560 | if (pa != null) | 2548 | if (pa != null) |
2549 | { | ||
2561 | pa.CrossingFailure(); | 2550 | pa.CrossingFailure(); |
2551 | if (grp.RootPart.KeyframeMotion != null) | ||
2552 | { | ||
2553 | // moved to KeyframeMotion.CrossingFailure | ||
2554 | // grp.RootPart.Velocity = Vector3.Zero; | ||
2555 | grp.RootPart.KeyframeMotion.CrossingFailure(); | ||
2556 | // grp.SendGroupRootTerseUpdate(); | ||
2557 | } | ||
2558 | } | ||
2562 | } | 2559 | } |
2563 | 2560 | ||
2564 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); | 2561 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); |
2565 | } | 2562 | } |
2563 | */ | ||
2566 | } | 2564 | } |
2567 | else | 2565 | else |
2568 | { | 2566 | { |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 04a0db6..09b1975 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -182,11 +182,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
182 | { | 182 | { |
183 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 183 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); |
184 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); | 184 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); |
185 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 185 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
186 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); | 186 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); |
187 | uuidGatherer.GatherAssetUuids(so, ids); | 187 | uuidGatherer.GatherAssetUuids(so, ids); |
188 | 188 | ||
189 | foreach (KeyValuePair<UUID, AssetType> kvp in ids) | 189 | foreach (KeyValuePair<UUID, sbyte> kvp in ids) |
190 | uuidGatherer.FetchAsset(kvp.Key); | 190 | uuidGatherer.FetchAsset(kvp.Key); |
191 | } | 191 | } |
192 | } | 192 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index b7a4d1a..d4fb1ba 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -260,9 +260,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
260 | 260 | ||
261 | // The act of gathering UUIDs downloads some assets from the remote server | 261 | // The act of gathering UUIDs downloads some assets from the remote server |
262 | // but not all... | 262 | // but not all... |
263 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 263 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
264 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); | 264 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); |
265 | uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids); | 265 | uuidGatherer.GatherAssetUuids(assetID, meta.Type, ids); |
266 | m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); | 266 | m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); |
267 | bool success = true; | 267 | bool success = true; |
268 | foreach (UUID uuid in ids.Keys) | 268 | foreach (UUID uuid in ids.Keys) |
@@ -286,9 +286,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); | 286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); |
287 | if (asset != null) | 287 | if (asset != null) |
288 | { | 288 | { |
289 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 289 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | 290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); |
291 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); | 291 | uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); |
292 | bool success = false; | 292 | bool success = false; |
293 | foreach (UUID uuid in ids.Keys) | 293 | foreach (UUID uuid in ids.Keys) |
294 | { | 294 | { |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index a990898..7a844f4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
178 | 178 | ||
179 | // Archive the regions | 179 | // Archive the regions |
180 | 180 | ||
181 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); | 181 | Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>(); |
182 | 182 | ||
183 | scenesGroup.ForEachScene(delegate(Scene scene) | 183 | scenesGroup.ForEachScene(delegate(Scene scene) |
184 | { | 184 | { |
@@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids) | 219 | private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, sbyte> assetUuids) |
220 | { | 220 | { |
221 | m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); | 221 | m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); |
222 | 222 | ||
@@ -276,16 +276,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
276 | RegionSettings regionSettings = scene.RegionInfo.RegionSettings; | 276 | RegionSettings regionSettings = scene.RegionInfo.RegionSettings; |
277 | 277 | ||
278 | if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) | 278 | if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) |
279 | assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture; | 279 | assetUuids[regionSettings.TerrainTexture1] = (sbyte)AssetType.Texture; |
280 | 280 | ||
281 | if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) | 281 | if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) |
282 | assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture; | 282 | assetUuids[regionSettings.TerrainTexture2] = (sbyte)AssetType.Texture; |
283 | 283 | ||
284 | if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) | 284 | if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) |
285 | assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture; | 285 | assetUuids[regionSettings.TerrainTexture3] = (sbyte)AssetType.Texture; |
286 | 286 | ||
287 | if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) | 287 | if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) |
288 | assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture; | 288 | assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture; |
289 | 289 | ||
290 | Save(scene, sceneObjects, regionDir); | 290 | Save(scene, sceneObjects, regionDir); |
291 | } | 291 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 9600023..2d0da61 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
81 | /// <value> | 81 | /// <value> |
82 | /// uuids to request | 82 | /// uuids to request |
83 | /// </value> | 83 | /// </value> |
84 | protected IDictionary<UUID, AssetType> m_uuids; | 84 | protected IDictionary<UUID, sbyte> m_uuids; |
85 | 85 | ||
86 | /// <value> | 86 | /// <value> |
87 | /// Callback used when all the assets requested have been received. | 87 | /// Callback used when all the assets requested have been received. |
@@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
115 | protected Dictionary<string, object> m_options; | 115 | protected Dictionary<string, object> m_options; |
116 | 116 | ||
117 | protected internal AssetsRequest( | 117 | protected internal AssetsRequest( |
118 | AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids, | 118 | AssetsArchiver assetsArchiver, IDictionary<UUID, sbyte> uuids, |
119 | IAssetService assetService, IUserAccountService userService, | 119 | IAssetService assetService, IUserAccountService userService, |
120 | UUID scope, Dictionary<string, object> options, | 120 | UUID scope, Dictionary<string, object> options, |
121 | AssetsRequestCallback assetsRequestCallback) | 121 | AssetsRequestCallback assetsRequestCallback) |
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
154 | 154 | ||
155 | m_requestCallbackTimer.Enabled = true; | 155 | m_requestCallbackTimer.Enabled = true; |
156 | 156 | ||
157 | foreach (KeyValuePair<UUID, AssetType> kvp in m_uuids) | 157 | foreach (KeyValuePair<UUID, sbyte> kvp in m_uuids) |
158 | { | 158 | { |
159 | // m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key); | 159 | // m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key); |
160 | 160 | ||
@@ -235,9 +235,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
235 | // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer | 235 | // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer |
236 | if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) | 236 | if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) |
237 | { | 237 | { |
238 | AssetType type = (AssetType)assetType; | 238 | m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, SLUtil.AssetTypeFromCode((sbyte)assetType)); |
239 | m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, type); | 239 | fetchedAsset.Type = (sbyte)assetType; |
240 | fetchedAsset.Type = (sbyte)type; | ||
241 | } | 240 | } |
242 | 241 | ||
243 | AssetRequestCallback(fetchedAssetID, this, fetchedAsset); | 242 | AssetRequestCallback(fetchedAssetID, this, fetchedAsset); |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index e55c9ed..e54c849 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -414,6 +414,19 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
414 | return false; | 414 | return false; |
415 | } | 415 | } |
416 | 416 | ||
417 | public bool CanBeOnThisLand(UUID avatar, float posHeight) | ||
418 | { | ||
419 | if (posHeight < LandChannel.BAN_LINE_SAFETY_HIEGHT && IsBannedFromLand(avatar)) | ||
420 | { | ||
421 | return false; | ||
422 | } | ||
423 | else if (IsRestrictedFromLand(avatar)) | ||
424 | { | ||
425 | return false; | ||
426 | } | ||
427 | return true; | ||
428 | } | ||
429 | |||
417 | public bool HasGroupAccess(UUID avatar) | 430 | public bool HasGroupAccess(UUID avatar) |
418 | { | 431 | { |
419 | if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) | 432 | if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) |
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs index 34aca33..d25c930 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs | |||
@@ -35,8 +35,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
35 | 35 | ||
36 | public interface IAvatarFactoryModule | 36 | public interface IAvatarFactoryModule |
37 | { | 37 | { |
38 | void SetAppearance(IScenePresence sp, AvatarAppearance appearance); | 38 | void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems); |
39 | void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams); | 39 | void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems); |
40 | 40 | ||
41 | /// <summary> | 41 | /// <summary> |
42 | /// Send the appearance of an avatar to others in the scene. | 42 | /// Send the appearance of an avatar to others in the scene. |
@@ -52,6 +52,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
52 | /// <returns>An empty list if this agent has no baked textures (e.g. because it's a child agent)</returns> | 52 | /// <returns>An empty list if this agent has no baked textures (e.g. because it's a child agent)</returns> |
53 | Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId); | 53 | Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId); |
54 | 54 | ||
55 | |||
56 | WearableCacheItem[] GetCachedItems(UUID agentId); | ||
55 | /// <summary> | 57 | /// <summary> |
56 | /// Save the baked textures for the given agent permanently in the asset database. | 58 | /// Save the baked textures for the given agent permanently in the asset database. |
57 | /// </summary> | 59 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs new file mode 100644 index 0000000..b536a49 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs | |||
@@ -0,0 +1,40 @@ | |||
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 Nini.Config; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenMetaverse; | ||
32 | |||
33 | namespace OpenSim.Services.Interfaces | ||
34 | { | ||
35 | public interface IBakedTextureModule | ||
36 | { | ||
37 | WearableCacheItem[] Get(UUID id); | ||
38 | void Store(UUID id, WearableCacheItem[] data); | ||
39 | } | ||
40 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 1c43a25..214b07a 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs | |||
@@ -35,6 +35,8 @@ using OpenSim.Region.Framework.Scenes; | |||
35 | 35 | ||
36 | namespace OpenSim.Region.Framework.Interfaces | 36 | namespace OpenSim.Region.Framework.Interfaces |
37 | { | 37 | { |
38 | public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); | ||
39 | |||
38 | public interface IEntityTransferModule | 40 | public interface IEntityTransferModule |
39 | { | 41 | { |
40 | /// <summary> | 42 | /// <summary> |
@@ -45,13 +47,22 @@ namespace OpenSim.Region.Framework.Interfaces | |||
45 | /// The handle of the destination region. If it's the same as the region currently | 47 | /// The handle of the destination region. If it's the same as the region currently |
46 | /// occupied by the agent then the teleport will be within that region. | 48 | /// occupied by the agent then the teleport will be within that region. |
47 | /// </param> | 49 | /// </param> |
50 | /// <param name='agent'></param> | ||
51 | /// <param name='regionHandle'></param> | ||
48 | /// <param name='position'></param> | 52 | /// <param name='position'></param> |
49 | /// <param name='lookAt'></param> | 53 | /// <param name='lookAt'></param> |
50 | /// <param name='teleportFlags'></param> | 54 | /// <param name='teleportFlags'></param> |
51 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags); | 55 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags); |
52 | 56 | ||
53 | /// <summary> | 57 | /// <summary> |
54 | /// Teleport an agent directly to a given region without checking whether the region should be subsituted. | 58 | /// Teleports the agent for the given client to their home destination. |
59 | /// </summary> | ||
60 | /// <param name='id'></param> | ||
61 | /// <param name='client'></param> | ||
62 | bool TeleportHome(UUID id, IClientAPI client); | ||
63 | |||
64 | /// <summary> | ||
65 | /// Teleport an agent directly to a given region without checking whether the region should be substituted. | ||
55 | /// </summary> | 66 | /// </summary> |
56 | /// <remarks> | 67 | /// <remarks> |
57 | /// Please use Teleport() instead unless you know exactly what you're doing. | 68 | /// Please use Teleport() instead unless you know exactly what you're doing. |
@@ -63,18 +74,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
63 | /// <param name='position'></param> | 74 | /// <param name='position'></param> |
64 | /// <param name='lookAt'></param> | 75 | /// <param name='lookAt'></param> |
65 | /// <param name='teleportFlags'></param> | 76 | /// <param name='teleportFlags'></param> |
66 | void DoTeleport( | 77 | void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, |
67 | ScenePresence sp, GridRegion reg, GridRegion finalDestination, | ||
68 | Vector3 position, Vector3 lookAt, uint teleportFlags); | 78 | Vector3 position, Vector3 lookAt, uint teleportFlags); |
69 | 79 | ||
70 | /// <summary> | 80 | /// <summary> |
71 | /// Teleports the agent for the given client to their home destination. | ||
72 | /// </summary> | ||
73 | /// <param name='id'></param> | ||
74 | /// <param name='client'></param> | ||
75 | bool TeleportHome(UUID id, IClientAPI client); | ||
76 | |||
77 | /// <summary> | ||
78 | /// Show whether the given agent is being teleported. | 81 | /// Show whether the given agent is being teleported. |
79 | /// </summary> | 82 | /// </summary> |
80 | /// <param name='id'>The agent ID</para></param> | 83 | /// <param name='id'>The agent ID</para></param> |
@@ -89,7 +92,12 @@ namespace OpenSim.Region.Framework.Interfaces | |||
89 | 92 | ||
90 | void EnableChildAgent(ScenePresence agent, GridRegion region); | 93 | void EnableChildAgent(ScenePresence agent, GridRegion region); |
91 | 94 | ||
95 | GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos); | ||
96 | |||
92 | void Cross(SceneObjectGroup sog, Vector3 position, bool silent); | 97 | void Cross(SceneObjectGroup sog, Vector3 position, bool silent); |
98 | |||
99 | ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); | ||
100 | |||
93 | } | 101 | } |
94 | 102 | ||
95 | public interface IUserAgentVerificationModule | 103 | public interface IUserAgentVerificationModule |
diff --git a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs index 3780ece..dfc269e 100644 --- a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs +++ b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs | |||
@@ -39,16 +39,17 @@ namespace OpenSim.Region.Framework.Interfaces | |||
39 | 39 | ||
40 | // These are required to decouple Scenes from EventQueueHelper | 40 | // These are required to decouple Scenes from EventQueueHelper |
41 | void DisableSimulator(ulong handle, UUID avatarID); | 41 | void DisableSimulator(ulong handle, UUID avatarID); |
42 | void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID); | 42 | void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY); |
43 | void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, | 43 | void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, |
44 | string capsPath); | 44 | string capsPath, ulong regionHandle, int regionSizeX, int regionSizeY); |
45 | void TeleportFinishEvent(ulong regionHandle, byte simAccess, | 45 | void TeleportFinishEvent(ulong regionHandle, byte simAccess, |
46 | IPEndPoint regionExternalEndPoint, | 46 | IPEndPoint regionExternalEndPoint, |
47 | uint locationID, uint flags, string capsURL, | 47 | uint locationID, uint flags, string capsURL, |
48 | UUID agentID); | 48 | UUID agentID, int regionSizeX, int regionSizeY); |
49 | void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | 49 | void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, |
50 | IPEndPoint newRegionExternalEndPoint, | 50 | IPEndPoint newRegionExternalEndPoint, |
51 | string capsURL, UUID avatarID, UUID sessionID); | 51 | string capsURL, UUID avatarID, UUID sessionID, |
52 | int regionSizeX, int regionSizeY); | ||
52 | void ChatterboxInvitation(UUID sessionID, string sessionName, | 53 | void ChatterboxInvitation(UUID sessionID, string sessionName, |
53 | UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, | 54 | UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, |
54 | uint timeStamp, bool offline, int parentEstateID, Vector3 position, | 55 | uint timeStamp, bool offline, int parentEstateID, Vector3 position, |
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs index b67312e..1a89721 100644 --- a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs | |||
@@ -51,10 +51,17 @@ namespace OpenSim.Region.Framework.Interfaces | |||
51 | UUID = 5 | 51 | UUID = 5 |
52 | } | 52 | } |
53 | 53 | ||
54 | public struct JsonStoreStats | ||
55 | { | ||
56 | public int StoreCount; | ||
57 | } | ||
58 | |||
54 | public delegate void TakeValueCallback(string s); | 59 | public delegate void TakeValueCallback(string s); |
55 | 60 | ||
56 | public interface IJsonStoreModule | 61 | public interface IJsonStoreModule |
57 | { | 62 | { |
63 | JsonStoreStats GetStoreStats(); | ||
64 | |||
58 | bool AttachObjectStore(UUID objectID); | 65 | bool AttachObjectStore(UUID objectID); |
59 | bool CreateStore(string value, ref UUID result); | 66 | bool CreateStore(string value, ref UUID result); |
60 | bool DestroyStore(UUID storeID); | 67 | bool DestroyStore(UUID storeID); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 59c5b09..c3110a2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1953,6 +1953,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1953 | 1953 | ||
1954 | GridRegion region = new GridRegion(RegionInfo); | 1954 | GridRegion region = new GridRegion(RegionInfo); |
1955 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); | 1955 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); |
1956 | m_log.DebugFormat("{0} RegisterRegionWithGrid. name={1},id={2},loc=<{3},{4}>,size=<{5},{6}>", | ||
1957 | LogHeader, m_regionName, | ||
1958 | RegionInfo.RegionID, | ||
1959 | RegionInfo.RegionLocX, RegionInfo.RegionLocY, | ||
1960 | RegionInfo.RegionSizeX, RegionInfo.RegionSizeY); | ||
1956 | if (error != String.Empty) | 1961 | if (error != String.Empty) |
1957 | throw new Exception(error); | 1962 | throw new Exception(error); |
1958 | } | 1963 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 4f04706..c86f412 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -42,7 +42,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
42 | { | 42 | { |
43 | public abstract class SceneBase : IScene | 43 | public abstract class SceneBase : IScene |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | protected static readonly string LogHeader = "[SCENE]"; | ||
46 | 47 | ||
47 | #region Events | 48 | #region Events |
48 | 49 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e31270c..9bd7632 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -121,6 +121,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
121 | private bool m_hasGroupChanged = false; | 121 | private bool m_hasGroupChanged = false; |
122 | private long timeFirstChanged; | 122 | private long timeFirstChanged; |
123 | private long timeLastChanged; | 123 | private long timeLastChanged; |
124 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
124 | 125 | ||
125 | /// <summary> | 126 | /// <summary> |
126 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage | 127 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage |
@@ -431,6 +432,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
431 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); | 432 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); |
432 | } | 433 | } |
433 | 434 | ||
435 | private struct avtocrossInfo | ||
436 | { | ||
437 | public ScenePresence av; | ||
438 | public uint ParentID; | ||
439 | } | ||
440 | |||
434 | /// <summary> | 441 | /// <summary> |
435 | /// The absolute position of this scene object in the scene | 442 | /// The absolute position of this scene object in the scene |
436 | /// </summary> | 443 | /// </summary> |
@@ -458,13 +465,124 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | || Scene.TestBorderCross(val, Cardinals.S)) | 465 | || Scene.TestBorderCross(val, Cardinals.S)) |
459 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | 466 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) |
460 | { | 467 | { |
468 | IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
469 | uint x = 0; | ||
470 | uint y = 0; | ||
471 | string version = String.Empty; | ||
472 | Vector3 newpos = Vector3.Zero; | ||
473 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
474 | |||
461 | if (m_rootPart.KeyframeMotion != null) | 475 | if (m_rootPart.KeyframeMotion != null) |
462 | m_rootPart.KeyframeMotion.StartCrossingCheck(); | 476 | m_rootPart.KeyframeMotion.StartCrossingCheck(); |
463 | 477 | ||
464 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 478 | bool canCross = true; |
479 | foreach (ScenePresence av in m_linkedAvatars) | ||
480 | { | ||
481 | // We need to cross these agents. First, let's find | ||
482 | // out if any of them can't cross for some reason. | ||
483 | // We have to deny the crossing entirely if any | ||
484 | // of them are banned. Alternatively, we could | ||
485 | // unsit banned agents.... | ||
486 | |||
487 | |||
488 | // We set the avatar position as being the object | ||
489 | // position to get the region to send to | ||
490 | if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) | ||
491 | { | ||
492 | canCross = false; | ||
493 | break; | ||
494 | } | ||
495 | |||
496 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); | ||
497 | } | ||
498 | |||
499 | if (canCross) | ||
500 | { | ||
501 | // We unparent the SP quietly so that it won't | ||
502 | // be made to stand up | ||
503 | |||
504 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); | ||
505 | |||
506 | foreach (ScenePresence av in m_linkedAvatars) | ||
507 | { | ||
508 | avtocrossInfo avinfo = new avtocrossInfo(); | ||
509 | SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); | ||
510 | if (parentPart != null) | ||
511 | av.ParentUUID = parentPart.UUID; | ||
512 | |||
513 | avinfo.av = av; | ||
514 | avinfo.ParentID = av.ParentID; | ||
515 | avsToCross.Add(avinfo); | ||
516 | |||
517 | av.PrevSitOffset = av.OffsetPosition; | ||
518 | av.ParentID = 0; | ||
519 | } | ||
520 | |||
521 | // m_linkedAvatars.Clear(); | ||
522 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | ||
523 | |||
524 | // Normalize | ||
525 | if (val.X >= Constants.RegionSize) | ||
526 | val.X -= Constants.RegionSize; | ||
527 | if (val.Y >= Constants.RegionSize) | ||
528 | val.Y -= Constants.RegionSize; | ||
529 | if (val.X < 0) | ||
530 | val.X += Constants.RegionSize; | ||
531 | if (val.Y < 0) | ||
532 | val.Y += Constants.RegionSize; | ||
533 | |||
534 | // If it's deleted, crossing was successful | ||
535 | if (IsDeleted) | ||
536 | { | ||
537 | // foreach (ScenePresence av in m_linkedAvatars) | ||
538 | foreach (avtocrossInfo avinfo in avsToCross) | ||
539 | { | ||
540 | ScenePresence av = avinfo.av; | ||
541 | if (!av.IsInTransit) // just in case... | ||
542 | { | ||
543 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); | ||
544 | |||
545 | av.IsInTransit = true; | ||
546 | |||
547 | CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; | ||
548 | d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); | ||
549 | } | ||
550 | else | ||
551 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); | ||
552 | } | ||
553 | avsToCross.Clear(); | ||
554 | return; | ||
555 | } | ||
556 | else // cross failed, put avas back ?? | ||
557 | { | ||
558 | foreach (avtocrossInfo avinfo in avsToCross) | ||
559 | { | ||
560 | ScenePresence av = avinfo.av; | ||
561 | av.ParentUUID = UUID.Zero; | ||
562 | av.ParentID = avinfo.ParentID; | ||
563 | // m_linkedAvatars.Add(av); | ||
564 | } | ||
565 | } | ||
566 | avsToCross.Clear(); | ||
567 | |||
568 | } | ||
569 | else | ||
570 | { | ||
571 | if (m_rootPart.KeyframeMotion != null) | ||
572 | m_rootPart.KeyframeMotion.CrossingFailure(); | ||
573 | |||
574 | if (RootPart.PhysActor != null) | ||
575 | { | ||
576 | RootPart.PhysActor.CrossingFailure(); | ||
577 | } | ||
578 | } | ||
579 | Vector3 oldp = AbsolutePosition; | ||
580 | val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
581 | val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
582 | val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); | ||
465 | } | 583 | } |
466 | } | 584 | } |
467 | 585 | ||
468 | if (RootPart.GetStatusSandbox()) | 586 | if (RootPart.GetStatusSandbox()) |
469 | { | 587 | { |
470 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 588 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -498,6 +616,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
498 | } | 616 | } |
499 | } | 617 | } |
500 | 618 | ||
619 | public override Vector3 Velocity | ||
620 | { | ||
621 | get { return RootPart.Velocity; } | ||
622 | set { RootPart.Velocity = value; } | ||
623 | } | ||
624 | |||
625 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | ||
626 | { | ||
627 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; | ||
628 | ScenePresence agent = icon.EndInvoke(iar); | ||
629 | |||
630 | //// If the cross was successful, this agent is a child agent | ||
631 | if (agent.IsChildAgent) | ||
632 | { | ||
633 | if (agent.ParentUUID != UUID.Zero) | ||
634 | { | ||
635 | agent.ParentPart = null; | ||
636 | // agent.ParentPosition = Vector3.Zero; | ||
637 | // agent.ParentUUID = UUID.Zero; | ||
638 | } | ||
639 | } | ||
640 | |||
641 | agent.ParentUUID = UUID.Zero; | ||
642 | // agent.Reset(); | ||
643 | // else // Not successful | ||
644 | // agent.RestoreInCurrentScene(); | ||
645 | |||
646 | // In any case | ||
647 | agent.IsInTransit = false; | ||
648 | |||
649 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | ||
650 | } | ||
651 | |||
501 | public override uint LocalId | 652 | public override uint LocalId |
502 | { | 653 | { |
503 | get { return m_rootPart.LocalId; } | 654 | get { return m_rootPart.LocalId; } |
@@ -1099,6 +1250,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1099 | } | 1250 | } |
1100 | } | 1251 | } |
1101 | 1252 | ||
1253 | |||
1102 | /// <summary> | 1254 | /// <summary> |
1103 | /// | 1255 | /// |
1104 | /// </summary> | 1256 | /// </summary> |
@@ -1108,6 +1260,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
1108 | part.ParentID = m_rootPart.LocalId; | 1260 | part.ParentID = m_rootPart.LocalId; |
1109 | part.ClearUndoState(); | 1261 | part.ClearUndoState(); |
1110 | } | 1262 | } |
1263 | /// <summary> | ||
1264 | /// Add the avatar to this linkset (avatar is sat). | ||
1265 | /// </summary> | ||
1266 | /// <param name="agentID"></param> | ||
1267 | public void AddAvatar(UUID agentID) | ||
1268 | { | ||
1269 | ScenePresence presence; | ||
1270 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1271 | { | ||
1272 | if (!m_linkedAvatars.Contains(presence)) | ||
1273 | { | ||
1274 | m_linkedAvatars.Add(presence); | ||
1275 | } | ||
1276 | } | ||
1277 | } | ||
1278 | |||
1279 | /// <summary> | ||
1280 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1281 | /// </summary> | ||
1282 | /// <param name="agentID"></param> | ||
1283 | public void DeleteAvatar(UUID agentID) | ||
1284 | { | ||
1285 | ScenePresence presence; | ||
1286 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1287 | { | ||
1288 | if (m_linkedAvatars.Contains(presence)) | ||
1289 | { | ||
1290 | m_linkedAvatars.Remove(presence); | ||
1291 | } | ||
1292 | } | ||
1293 | } | ||
1294 | |||
1295 | /// <summary> | ||
1296 | /// Returns the list of linked presences (avatars sat on this group) | ||
1297 | /// </summary> | ||
1298 | /// <param name="agentID"></param> | ||
1299 | public List<ScenePresence> GetLinkedAvatars() | ||
1300 | { | ||
1301 | return m_linkedAvatars; | ||
1302 | } | ||
1111 | 1303 | ||
1112 | public ushort GetTimeDilation() | 1304 | public ushort GetTimeDilation() |
1113 | { | 1305 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3290da1..85a20e9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -65,6 +65,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
65 | 65 | ||
66 | struct ScriptControllers | 66 | struct ScriptControllers |
67 | { | 67 | { |
68 | public UUID objectID; | ||
68 | public UUID itemID; | 69 | public UUID itemID; |
69 | public ScriptControlled ignoreControls; | 70 | public ScriptControlled ignoreControls; |
70 | public ScriptControlled eventControls; | 71 | public ScriptControlled eventControls; |
@@ -130,7 +131,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
130 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 131 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
131 | /// issue #1716 | 132 | /// issue #1716 |
132 | /// </summary> | 133 | /// </summary> |
133 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 134 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
134 | 135 | ||
135 | /// <summary> | 136 | /// <summary> |
136 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 137 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -152,8 +153,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
152 | /// <remarks> | 153 | /// <remarks> |
153 | /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is | 154 | /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is |
154 | /// necessary. | 155 | /// necessary. |
155 | /// NOTE: To avoid deadlocks, do not lock m_attachments and then perform other tasks under that lock. Take a copy | ||
156 | /// of the list and act on that instead. | ||
157 | /// </remarks> | 156 | /// </remarks> |
158 | private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | 157 | private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); |
159 | 158 | ||
@@ -172,6 +171,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
172 | private Vector3 m_lastPosition; | 171 | private Vector3 m_lastPosition; |
173 | private Quaternion m_lastRotation; | 172 | private Quaternion m_lastRotation; |
174 | private Vector3 m_lastVelocity; | 173 | private Vector3 m_lastVelocity; |
174 | private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); | ||
175 | |||
176 | private bool m_followCamAuto = false; | ||
177 | |||
175 | 178 | ||
176 | private Vector3? m_forceToApply; | 179 | private Vector3? m_forceToApply; |
177 | private int m_userFlags; | 180 | private int m_userFlags; |
@@ -204,6 +207,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 207 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
205 | // private int m_updateCount = 0; //KF: Update Anims for a while | 208 | // private int m_updateCount = 0; //KF: Update Anims for a while |
206 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 209 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
210 | private List<uint> m_lastColliders = new List<uint>(); | ||
207 | 211 | ||
208 | private TeleportFlags m_teleportFlags; | 212 | private TeleportFlags m_teleportFlags; |
209 | public TeleportFlags TeleportFlags | 213 | public TeleportFlags TeleportFlags |
@@ -259,8 +263,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | /// </summary> | 263 | /// </summary> |
260 | public bool LandAtTarget { get; private set; } | 264 | public bool LandAtTarget { get; private set; } |
261 | 265 | ||
262 | private bool m_followCamAuto; | ||
263 | |||
264 | private int m_movementUpdateCount; | 266 | private int m_movementUpdateCount; |
265 | private const int NumMovementsBetweenRayCast = 5; | 267 | private const int NumMovementsBetweenRayCast = 5; |
266 | 268 | ||
@@ -268,6 +270,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
268 | //private int m_moveToPositionStateStatus; | 270 | //private int m_moveToPositionStateStatus; |
269 | //***************************************************** | 271 | //***************************************************** |
270 | 272 | ||
273 | private bool m_collisionEventFlag = false; | ||
274 | private object m_collisionEventLock = new Object(); | ||
275 | |||
276 | private int m_movementAnimationUpdateCounter = 0; | ||
277 | |||
278 | public Vector3 PrevSitOffset { get; set; } | ||
279 | |||
271 | protected AvatarAppearance m_appearance; | 280 | protected AvatarAppearance m_appearance; |
272 | 281 | ||
273 | public AvatarAppearance Appearance | 282 | public AvatarAppearance Appearance |
@@ -407,6 +416,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
407 | /// </summary> | 416 | /// </summary> |
408 | protected Vector3 m_lastCameraPosition; | 417 | protected Vector3 m_lastCameraPosition; |
409 | 418 | ||
419 | private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1); | ||
420 | private bool m_doingCamRayCast = false; | ||
421 | |||
410 | public Vector3 CameraPosition { get; set; } | 422 | public Vector3 CameraPosition { get; set; } |
411 | 423 | ||
412 | public Quaternion CameraRotation | 424 | public Quaternion CameraRotation |
@@ -487,6 +499,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | get { return (IClientCore)ControllingClient; } | 499 | get { return (IClientCore)ControllingClient; } |
488 | } | 500 | } |
489 | 501 | ||
502 | public UUID COF { get; set; } | ||
503 | |||
504 | // public Vector3 ParentPosition { get; set; } | ||
505 | |||
490 | /// <summary> | 506 | /// <summary> |
491 | /// Position of this avatar relative to the region the avatar is in | 507 | /// Position of this avatar relative to the region the avatar is in |
492 | /// </summary> | 508 | /// </summary> |
@@ -613,7 +629,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
613 | // Scene.RegionInfo.RegionName, Name, m_velocity); | 629 | // Scene.RegionInfo.RegionName, Name, m_velocity); |
614 | } | 630 | } |
615 | } | 631 | } |
632 | /* | ||
633 | public override Vector3 AngularVelocity | ||
634 | { | ||
635 | get | ||
636 | { | ||
637 | if (PhysicsActor != null) | ||
638 | { | ||
639 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
640 | |||
641 | // m_log.DebugFormat( | ||
642 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
643 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
644 | } | ||
616 | 645 | ||
646 | return m_rotationalvelocity; | ||
647 | } | ||
648 | } | ||
649 | */ | ||
617 | private Quaternion m_bodyRot = Quaternion.Identity; | 650 | private Quaternion m_bodyRot = Quaternion.Identity; |
618 | 651 | ||
619 | /// <summary> | 652 | /// <summary> |
@@ -636,8 +669,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
636 | m_bodyRot = value; | 669 | m_bodyRot = value; |
637 | 670 | ||
638 | if (PhysicsActor != null) | 671 | if (PhysicsActor != null) |
639 | PhysicsActor.Orientation = m_bodyRot; | 672 | { |
640 | 673 | try | |
674 | { | ||
675 | PhysicsActor.Orientation = m_bodyRot; | ||
676 | } | ||
677 | catch (Exception e) | ||
678 | { | ||
679 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | ||
680 | } | ||
681 | } | ||
641 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 682 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
642 | } | 683 | } |
643 | } | 684 | } |
@@ -651,12 +692,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
651 | } | 692 | } |
652 | 693 | ||
653 | public bool IsChildAgent { get; set; } | 694 | public bool IsChildAgent { get; set; } |
695 | public bool IsLoggingIn { get; set; } | ||
654 | 696 | ||
655 | /// <summary> | 697 | /// <summary> |
656 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. | 698 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. |
657 | /// </summary> | 699 | /// </summary> |
658 | public uint ParentID { get; set; } | 700 | public uint ParentID { get; set; } |
659 | 701 | ||
702 | public UUID ParentUUID | ||
703 | { | ||
704 | get { return m_parentUUID; } | ||
705 | set { m_parentUUID = value; } | ||
706 | } | ||
707 | private UUID m_parentUUID = UUID.Zero; | ||
708 | |||
660 | /// <summary> | 709 | /// <summary> |
661 | /// Are we sitting on an object? | 710 | /// Are we sitting on an object? |
662 | /// </summary> | 711 | /// </summary> |
@@ -814,6 +863,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
814 | AttachmentsSyncLock = new Object(); | 863 | AttachmentsSyncLock = new Object(); |
815 | AllowMovement = true; | 864 | AllowMovement = true; |
816 | IsChildAgent = true; | 865 | IsChildAgent = true; |
866 | IsLoggingIn = false; | ||
817 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; | 867 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
818 | Animator = new ScenePresenceAnimator(this); | 868 | Animator = new ScenePresenceAnimator(this); |
819 | PresenceType = type; | 869 | PresenceType = type; |
@@ -859,6 +909,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
859 | m_stateMachine = new ScenePresenceStateMachine(this); | 909 | m_stateMachine = new ScenePresenceStateMachine(this); |
860 | } | 910 | } |
861 | 911 | ||
912 | private void RegionHeartbeatEnd(Scene scene) | ||
913 | { | ||
914 | if (IsChildAgent) | ||
915 | return; | ||
916 | |||
917 | m_movementAnimationUpdateCounter ++; | ||
918 | if (m_movementAnimationUpdateCounter >= 2) | ||
919 | { | ||
920 | m_movementAnimationUpdateCounter = 0; | ||
921 | if (Animator != null) | ||
922 | { | ||
923 | // If the parentID == 0 we are not sitting | ||
924 | // if !SitGournd then we are not sitting on the ground | ||
925 | // Fairly straightforward, now here comes the twist | ||
926 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
927 | // be sat on an object that isn't there yet. Should | ||
928 | // be treated as if sat. | ||
929 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
930 | Animator.UpdateMovementAnimations(); | ||
931 | } | ||
932 | else | ||
933 | { | ||
934 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
935 | } | ||
936 | } | ||
937 | } | ||
938 | |||
862 | public void RegisterToEvents() | 939 | public void RegisterToEvents() |
863 | { | 940 | { |
864 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 941 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -926,17 +1003,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
926 | /// </remarks> | 1003 | /// </remarks> |
927 | private bool MakeRootAgent(Vector3 pos, bool isFlying) | 1004 | private bool MakeRootAgent(Vector3 pos, bool isFlying) |
928 | { | 1005 | { |
929 | // m_log.InfoFormat( | ||
930 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", | ||
931 | // Name, m_scene.RegionInfo.RegionName); | ||
932 | |||
933 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
934 | |||
935 | lock (m_completeMovementLock) | 1006 | lock (m_completeMovementLock) |
936 | { | 1007 | { |
937 | if (!IsChildAgent) | 1008 | if (!IsChildAgent) |
938 | return false; | 1009 | return false; |
939 | 1010 | ||
1011 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
1012 | |||
1013 | // m_log.InfoFormat( | ||
1014 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", | ||
1015 | // Name, m_scene.RegionInfo.RegionName); | ||
1016 | |||
1017 | if (ParentUUID != UUID.Zero) | ||
1018 | { | ||
1019 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
1020 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
1021 | if (part == null) | ||
1022 | { | ||
1023 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
1024 | } | ||
1025 | else | ||
1026 | { | ||
1027 | part.ParentGroup.AddAvatar(UUID); | ||
1028 | if (part.SitTargetPosition != Vector3.Zero) | ||
1029 | part.SitTargetAvatar = UUID; | ||
1030 | // ParentPosition = part.GetWorldPosition(); | ||
1031 | ParentID = part.LocalId; | ||
1032 | ParentPart = part; | ||
1033 | m_pos = PrevSitOffset; | ||
1034 | // pos = ParentPosition; | ||
1035 | pos = part.GetWorldPosition(); | ||
1036 | } | ||
1037 | ParentUUID = UUID.Zero; | ||
1038 | |||
1039 | // Animator.TrySetMovementAnimation("SIT"); | ||
1040 | } | ||
1041 | else | ||
1042 | { | ||
1043 | IsLoggingIn = false; | ||
1044 | } | ||
1045 | |||
940 | IsChildAgent = false; | 1046 | IsChildAgent = false; |
941 | } | 1047 | } |
942 | 1048 | ||
@@ -953,70 +1059,106 @@ namespace OpenSim.Region.Framework.Scenes | |||
953 | 1059 | ||
954 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 1060 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
955 | 1061 | ||
956 | // Moved this from SendInitialData to ensure that Appearance is initialized | 1062 | UUID groupUUID = UUID.Zero; |
957 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 1063 | string GroupName = string.Empty; |
958 | // related to the handling of attachments | 1064 | ulong groupPowers = 0; |
959 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
960 | 1065 | ||
961 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 1066 | // ---------------------------------- |
1067 | // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status | ||
1068 | try | ||
962 | { | 1069 | { |
963 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 1070 | if (gm != null) |
964 | pos.X = crossedBorder.BorderLine.Z - 1; | 1071 | { |
1072 | groupUUID = ControllingClient.ActiveGroupId; | ||
1073 | GroupRecord record = gm.GetGroupRecord(groupUUID); | ||
1074 | if (record != null) | ||
1075 | GroupName = record.GroupName; | ||
1076 | GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); | ||
1077 | if (groupMembershipData != null) | ||
1078 | groupPowers = groupMembershipData.GroupPowers; | ||
1079 | } | ||
1080 | ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, | ||
1081 | Grouptitle); | ||
965 | } | 1082 | } |
966 | 1083 | catch (Exception e) | |
967 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | ||
968 | { | 1084 | { |
969 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 1085 | m_log.Debug("[AGENTUPDATE]: " + e.ToString()); |
970 | pos.Y = crossedBorder.BorderLine.Z - 1; | ||
971 | } | 1086 | } |
1087 | // ------------------------------------ | ||
972 | 1088 | ||
973 | CheckAndAdjustLandingPoint(ref pos); | 1089 | if (ParentID == 0) |
974 | |||
975 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | ||
976 | { | 1090 | { |
977 | m_log.WarnFormat( | 1091 | // Moved this from SendInitialData to ensure that Appearance is initialized |
978 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 1092 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
979 | pos, Name, UUID); | 1093 | // related to the handling of attachments |
1094 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
1095 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
1096 | { | ||
1097 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
1098 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
1099 | } | ||
980 | 1100 | ||
981 | if (pos.X < 0f) pos.X = 0f; | 1101 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
982 | if (pos.Y < 0f) pos.Y = 0f; | 1102 | { |
983 | if (pos.Z < 0f) pos.Z = 0f; | 1103 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
984 | } | 1104 | pos.Y = crossedBorder.BorderLine.Z - 1; |
1105 | } | ||
985 | 1106 | ||
986 | float localAVHeight = 1.56f; | 1107 | CheckAndAdjustLandingPoint(ref pos); |
987 | if (Appearance.AvatarHeight > 0) | ||
988 | localAVHeight = Appearance.AvatarHeight; | ||
989 | 1108 | ||
990 | float posZLimit = 0; | 1109 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
1110 | { | ||
1111 | m_log.WarnFormat( | ||
1112 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | ||
1113 | pos, Name, UUID); | ||
991 | 1114 | ||
992 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 1115 | if (pos.X < 0f) pos.X = 0f; |
993 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 1116 | if (pos.Y < 0f) pos.Y = 0f; |
994 | 1117 | if (pos.Z < 0f) pos.Z = 0f; | |
995 | float newPosZ = posZLimit + localAVHeight / 2; | 1118 | } |
996 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
997 | { | ||
998 | pos.Z = newPosZ; | ||
999 | } | ||
1000 | AbsolutePosition = pos; | ||
1001 | 1119 | ||
1002 | AddToPhysicalScene(isFlying); | 1120 | float localAVHeight = 1.56f; |
1121 | if (Appearance.AvatarHeight > 0) | ||
1122 | localAVHeight = Appearance.AvatarHeight; | ||
1003 | 1123 | ||
1004 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | 1124 | float posZLimit = 0; |
1005 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
1006 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
1007 | // the value to a negative position which does not trigger the border cross. | ||
1008 | // This may not be the best location for this. | ||
1009 | CheckForBorderCrossing(); | ||
1010 | 1125 | ||
1011 | if (ForceFly) | 1126 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
1012 | { | 1127 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
1013 | Flying = true; | 1128 | |
1014 | } | 1129 | float newPosZ = posZLimit + localAVHeight / 2; |
1015 | else if (FlyDisabled) | 1130 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
1016 | { | 1131 | { |
1017 | Flying = false; | 1132 | pos.Z = newPosZ; |
1018 | } | 1133 | } |
1134 | AbsolutePosition = pos; | ||
1135 | |||
1136 | if (m_teleportFlags == TeleportFlags.Default) | ||
1137 | { | ||
1138 | Vector3 vel = Velocity; | ||
1139 | AddToPhysicalScene(isFlying); | ||
1140 | if (PhysicsActor != null) | ||
1141 | PhysicsActor.SetMomentum(vel); | ||
1142 | } | ||
1143 | else | ||
1144 | AddToPhysicalScene(isFlying); | ||
1145 | |||
1146 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | ||
1147 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
1148 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
1149 | // the value to a negative position which does not trigger the border cross. | ||
1150 | // This may not be the best location for this. | ||
1151 | CheckForBorderCrossing(); | ||
1019 | 1152 | ||
1153 | if (ForceFly) | ||
1154 | { | ||
1155 | Flying = true; | ||
1156 | } | ||
1157 | else if (FlyDisabled) | ||
1158 | { | ||
1159 | Flying = false; | ||
1160 | } | ||
1161 | } | ||
1020 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1162 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
1021 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 1163 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
1022 | // elsewhere anyway | 1164 | // elsewhere anyway |
@@ -1048,31 +1190,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1048 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently | 1190 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently |
1049 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are | 1191 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are |
1050 | // not transporting the required data. | 1192 | // not transporting the required data. |
1051 | // | 1193 | lock (m_attachments) |
1052 | // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of | ||
1053 | // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here | ||
1054 | // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. | ||
1055 | // | ||
1056 | // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). | ||
1057 | // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing | ||
1058 | // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the | ||
1059 | // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. | ||
1060 | List<SceneObjectGroup> attachments = GetAttachments(); | ||
1061 | |||
1062 | if (attachments.Count > 0) | ||
1063 | { | 1194 | { |
1064 | m_log.DebugFormat( | 1195 | if (HasAttachments()) |
1065 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | ||
1066 | |||
1067 | // Resume scripts | ||
1068 | foreach (SceneObjectGroup sog in attachments) | ||
1069 | { | 1196 | { |
1070 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 1197 | m_log.DebugFormat( |
1071 | sog.ResumeScripts(); | 1198 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
1199 | |||
1200 | // Resume scripts | ||
1201 | Util.FireAndForget(delegate(object x) { | ||
1202 | foreach (SceneObjectGroup sog in m_attachments) | ||
1203 | { | ||
1204 | sog.ScheduleGroupForFullUpdate(); | ||
1205 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | ||
1206 | sog.ResumeScripts(); | ||
1207 | } | ||
1208 | }); | ||
1072 | } | 1209 | } |
1073 | } | 1210 | } |
1074 | } | 1211 | } |
1075 | 1212 | ||
1213 | SendAvatarDataToAllAgents(); | ||
1214 | |||
1076 | // send the animations of the other presences to me | 1215 | // send the animations of the other presences to me |
1077 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 1216 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
1078 | { | 1217 | { |
@@ -1083,6 +1222,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1083 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1222 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
1084 | // stall on the border crossing since the existing child agent will still have the last movement | 1223 | // stall on the border crossing since the existing child agent will still have the last movement |
1085 | // recorded, which stops the input from being processed. | 1224 | // recorded, which stops the input from being processed. |
1225 | |||
1086 | MovementFlag = 0; | 1226 | MovementFlag = 0; |
1087 | 1227 | ||
1088 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1228 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
@@ -1115,12 +1255,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1115 | /// </remarks> | 1255 | /// </remarks> |
1116 | public void MakeChildAgent() | 1256 | public void MakeChildAgent() |
1117 | { | 1257 | { |
1258 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1259 | |||
1118 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1260 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
1119 | 1261 | ||
1120 | // Reset these so that teleporting in and walking out isn't seen | 1262 | // Reset these so that teleporting in and walking out isn't seen |
1121 | // as teleporting back | 1263 | // as teleporting back |
1122 | TeleportFlags = TeleportFlags.Default; | 1264 | TeleportFlags = TeleportFlags.Default; |
1123 | 1265 | ||
1266 | MovementFlag = 0; | ||
1267 | |||
1124 | // It looks like Animator is set to null somewhere, and MakeChild | 1268 | // It looks like Animator is set to null somewhere, and MakeChild |
1125 | // is called after that. Probably in aborted teleports. | 1269 | // is called after that. Probably in aborted teleports. |
1126 | if (Animator == null) | 1270 | if (Animator == null) |
@@ -1128,6 +1272,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1128 | else | 1272 | else |
1129 | Animator.ResetAnimations(); | 1273 | Animator.ResetAnimations(); |
1130 | 1274 | ||
1275 | |||
1131 | // m_log.DebugFormat( | 1276 | // m_log.DebugFormat( |
1132 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1277 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
1133 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1278 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -1139,6 +1284,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1139 | IsChildAgent = true; | 1284 | IsChildAgent = true; |
1140 | m_scene.SwapRootAgentCount(true); | 1285 | m_scene.SwapRootAgentCount(true); |
1141 | RemoveFromPhysicalScene(); | 1286 | RemoveFromPhysicalScene(); |
1287 | ParentID = 0; // Child agents can't be sitting | ||
1142 | 1288 | ||
1143 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1289 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
1144 | 1290 | ||
@@ -1154,9 +1300,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1154 | { | 1300 | { |
1155 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1301 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
1156 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1302 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
1157 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1158 | PhysicsActor.UnSubscribeEvents(); | ||
1159 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1303 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1304 | PhysicsActor.UnSubscribeEvents(); | ||
1305 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1160 | PhysicsActor = null; | 1306 | PhysicsActor = null; |
1161 | } | 1307 | } |
1162 | // else | 1308 | // else |
@@ -1173,7 +1319,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1173 | /// <param name="pos"></param> | 1319 | /// <param name="pos"></param> |
1174 | public void Teleport(Vector3 pos) | 1320 | public void Teleport(Vector3 pos) |
1175 | { | 1321 | { |
1176 | TeleportWithMomentum(pos, null); | 1322 | TeleportWithMomentum(pos, Vector3.Zero); |
1177 | } | 1323 | } |
1178 | 1324 | ||
1179 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1325 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1197,6 +1343,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1197 | SendTerseUpdateToAllClients(); | 1343 | SendTerseUpdateToAllClients(); |
1198 | } | 1344 | } |
1199 | 1345 | ||
1346 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1347 | { | ||
1348 | CheckLandingPoint(ref newpos); | ||
1349 | AbsolutePosition = newpos; | ||
1350 | |||
1351 | if (newvel.HasValue) | ||
1352 | { | ||
1353 | if ((Vector3)newvel == Vector3.Zero) | ||
1354 | { | ||
1355 | if (PhysicsActor != null) | ||
1356 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1357 | m_velocity = Vector3.Zero; | ||
1358 | } | ||
1359 | else | ||
1360 | { | ||
1361 | if (PhysicsActor != null) | ||
1362 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1363 | m_velocity = (Vector3)newvel; | ||
1364 | |||
1365 | if (rotateToVelXY) | ||
1366 | { | ||
1367 | Vector3 lookAt = (Vector3)newvel; | ||
1368 | lookAt.Z = 0; | ||
1369 | lookAt.Normalize(); | ||
1370 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1371 | return; | ||
1372 | } | ||
1373 | } | ||
1374 | } | ||
1375 | |||
1376 | SendTerseUpdateToAllClients(); | ||
1377 | } | ||
1378 | |||
1379 | |||
1380 | |||
1200 | public void StopFlying() | 1381 | public void StopFlying() |
1201 | { | 1382 | { |
1202 | Vector3 pos = AbsolutePosition; | 1383 | Vector3 pos = AbsolutePosition; |
@@ -1385,6 +1566,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1385 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); | 1566 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); |
1386 | } | 1567 | } |
1387 | 1568 | ||
1569 | public void SetSize(Vector3 size, float feetoffset) | ||
1570 | { | ||
1571 | // TODO: Merge the physics bits | ||
1572 | // if (PhysicsActor != null && !IsChildAgent) | ||
1573 | // PhysicsActor.setAvatarSize(size, feetoffset); | ||
1574 | |||
1575 | } | ||
1576 | |||
1388 | private bool WaitForUpdateAgent(IClientAPI client) | 1577 | private bool WaitForUpdateAgent(IClientAPI client) |
1389 | { | 1578 | { |
1390 | // Before the source region executes UpdateAgent | 1579 | // Before the source region executes UpdateAgent |
@@ -1444,7 +1633,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1444 | 1633 | ||
1445 | Vector3 look = Velocity; | 1634 | Vector3 look = Velocity; |
1446 | 1635 | ||
1447 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1636 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1637 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1448 | { | 1638 | { |
1449 | look = new Vector3(0.99f, 0.042f, 0); | 1639 | look = new Vector3(0.99f, 0.042f, 0); |
1450 | } | 1640 | } |
@@ -1514,11 +1704,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1514 | { | 1704 | { |
1515 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1705 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1516 | if (m_agentTransfer != null) | 1706 | if (m_agentTransfer != null) |
1517 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1707 | m_agentTransfer.EnableChildAgents(this); |
1518 | 1708 | ||
1519 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1709 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1520 | if (friendsModule != null) | 1710 | if (friendsModule != null) |
1521 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1711 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1712 | |||
1522 | } | 1713 | } |
1523 | 1714 | ||
1524 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region | 1715 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region |
@@ -1544,36 +1735,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1544 | /// <param name="collisionPoint"></param> | 1735 | /// <param name="collisionPoint"></param> |
1545 | /// <param name="localid"></param> | 1736 | /// <param name="localid"></param> |
1546 | /// <param name="distance"></param> | 1737 | /// <param name="distance"></param> |
1738 | /// | ||
1739 | |||
1740 | private void UpdateCameraCollisionPlane(Vector4 plane) | ||
1741 | { | ||
1742 | if (m_lastCameraCollisionPlane != plane) | ||
1743 | { | ||
1744 | m_lastCameraCollisionPlane = plane; | ||
1745 | ControllingClient.SendCameraConstraint(plane); | ||
1746 | } | ||
1747 | } | ||
1748 | |||
1547 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) | 1749 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) |
1548 | { | 1750 | { |
1549 | const float POSITION_TOLERANCE = 0.02f; | 1751 | const float POSITION_TOLERANCE = 0.02f; |
1550 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1551 | const float ROTATION_TOLERANCE = 0.02f; | 1752 | const float ROTATION_TOLERANCE = 0.02f; |
1552 | 1753 | ||
1553 | if (m_followCamAuto) | 1754 | m_doingCamRayCast = false; |
1755 | if (hitYN && localid != LocalId) | ||
1554 | { | 1756 | { |
1555 | if (hitYN) | 1757 | SceneObjectGroup group = m_scene.GetGroupByPrim(localid); |
1758 | bool IsPrim = group != null; | ||
1759 | if (IsPrim) | ||
1556 | { | 1760 | { |
1557 | CameraConstraintActive = true; | 1761 | SceneObjectPart part = group.GetPart(localid); |
1558 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); | 1762 | if (part != null && !part.VolumeDetectActive) |
1559 | 1763 | { | |
1560 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1764 | CameraConstraintActive = true; |
1561 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1765 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1766 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); | ||
1767 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); | ||
1768 | pNormal.Normalize(); | ||
1769 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); | ||
1770 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); | ||
1771 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); | ||
1772 | |||
1773 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, | ||
1774 | Vector3.Dot(collisionPoint, pNormal)); | ||
1775 | UpdateCameraCollisionPlane(plane); | ||
1776 | } | ||
1562 | } | 1777 | } |
1563 | else | 1778 | else |
1564 | { | 1779 | { |
1565 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1780 | CameraConstraintActive = true; |
1566 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1781 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1567 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1782 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); |
1568 | { | 1783 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); |
1569 | if (CameraConstraintActive) | 1784 | pNormal.Normalize(); |
1570 | { | 1785 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); |
1571 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); | 1786 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); |
1572 | CameraConstraintActive = false; | 1787 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); |
1573 | } | 1788 | |
1574 | } | 1789 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, |
1790 | Vector3.Dot(collisionPoint, pNormal)); | ||
1791 | UpdateCameraCollisionPlane(plane); | ||
1575 | } | 1792 | } |
1576 | } | 1793 | } |
1794 | else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | ||
1795 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | ||
1796 | { | ||
1797 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... | ||
1798 | UpdateCameraCollisionPlane(plane); | ||
1799 | CameraConstraintActive = false; | ||
1800 | } | ||
1577 | } | 1801 | } |
1578 | 1802 | ||
1579 | /// <summary> | 1803 | /// <summary> |
@@ -1647,6 +1871,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1647 | StandUp(); | 1871 | StandUp(); |
1648 | } | 1872 | } |
1649 | 1873 | ||
1874 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | ||
1875 | // this exclude checks may not be complete | ||
1876 | |||
1877 | if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) | ||
1878 | { | ||
1879 | if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) | ||
1880 | { | ||
1881 | Vector3 posAdjusted = AbsolutePosition; | ||
1882 | // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; | ||
1883 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
1884 | Vector3 tocam = CameraPosition - posAdjusted; | ||
1885 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
1886 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
1887 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
1888 | |||
1889 | float distTocamlen = tocam.Length(); | ||
1890 | if (distTocamlen > 0.3f) | ||
1891 | { | ||
1892 | tocam *= (1.0f / distTocamlen); | ||
1893 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
1894 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
1895 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
1896 | |||
1897 | m_doingCamRayCast = true; | ||
1898 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
1899 | } | ||
1900 | } | ||
1901 | else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) | ||
1902 | { | ||
1903 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... | ||
1904 | UpdateCameraCollisionPlane(plane); | ||
1905 | CameraConstraintActive = false; | ||
1906 | } | ||
1907 | } | ||
1908 | |||
1650 | uint flagsForScripts = (uint)flags; | 1909 | uint flagsForScripts = (uint)flags; |
1651 | flags = RemoveIgnoredControls(flags, IgnoredControls); | 1910 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1652 | 1911 | ||
@@ -2207,7 +2466,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2207 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); | 2466 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); |
2208 | 2467 | ||
2209 | MovingToTarget = false; | 2468 | MovingToTarget = false; |
2210 | MoveToPositionTarget = Vector3.Zero; | 2469 | // MoveToPositionTarget = Vector3.Zero; |
2470 | m_forceToApply = null; // cancel possible last action | ||
2211 | 2471 | ||
2212 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct | 2472 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct |
2213 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. | 2473 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. |
@@ -2230,6 +2490,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2230 | 2490 | ||
2231 | if (satOnObject) | 2491 | if (satOnObject) |
2232 | { | 2492 | { |
2493 | PrevSitOffset = m_pos; // Save sit offset | ||
2494 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
2495 | |||
2233 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 2496 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
2234 | if (taskIDict != null) | 2497 | if (taskIDict != null) |
2235 | { | 2498 | { |
@@ -2245,6 +2508,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2245 | } | 2508 | } |
2246 | } | 2509 | } |
2247 | 2510 | ||
2511 | part.ParentGroup.DeleteAvatar(UUID); | ||
2248 | Vector3 sitPartWorldPosition = part.GetWorldPosition(); | 2512 | Vector3 sitPartWorldPosition = part.GetWorldPosition(); |
2249 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 2513 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
2250 | 2514 | ||
@@ -2305,6 +2569,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2305 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2569 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2306 | } | 2570 | } |
2307 | 2571 | ||
2572 | else if (PhysicsActor == null) | ||
2573 | AddToPhysicalScene(false); | ||
2574 | |||
2308 | Animator.TrySetMovementAnimation("STAND"); | 2575 | Animator.TrySetMovementAnimation("STAND"); |
2309 | TriggerScenePresenceUpdated(); | 2576 | TriggerScenePresenceUpdated(); |
2310 | } | 2577 | } |
@@ -2353,11 +2620,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2353 | if (part == null) | 2620 | if (part == null) |
2354 | return; | 2621 | return; |
2355 | 2622 | ||
2356 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
2357 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
2358 | |||
2359 | if (PhysicsActor != null) | 2623 | if (PhysicsActor != null) |
2360 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2624 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2361 | 2625 | ||
2362 | bool canSit = false; | 2626 | bool canSit = false; |
2363 | 2627 | ||
@@ -2384,33 +2648,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
2384 | } | 2648 | } |
2385 | else | 2649 | else |
2386 | { | 2650 | { |
2651 | if (PhysicsSit(part,offset)) // physics engine | ||
2652 | return; | ||
2653 | |||
2387 | Vector3 pos = part.AbsolutePosition + offset; | 2654 | Vector3 pos = part.AbsolutePosition + offset; |
2388 | 2655 | ||
2389 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2656 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2390 | { | 2657 | { |
2391 | // m_log.DebugFormat( | ||
2392 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | ||
2393 | // Name, part.Name, part.LocalId); | ||
2394 | |||
2395 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2658 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2396 | canSit = true; | 2659 | canSit = true; |
2397 | } | 2660 | } |
2398 | // else | ||
2399 | // { | ||
2400 | // m_log.DebugFormat( | ||
2401 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
2402 | // Name, part.Name, part.LocalId); | ||
2403 | // } | ||
2404 | } | 2661 | } |
2405 | 2662 | ||
2406 | if (canSit) | 2663 | if (canSit) |
2407 | { | 2664 | { |
2665 | |||
2408 | if (PhysicsActor != null) | 2666 | if (PhysicsActor != null) |
2409 | { | 2667 | { |
2410 | // We can remove the physicsActor until they stand up. | 2668 | // We can remove the physicsActor until they stand up. |
2411 | RemoveFromPhysicalScene(); | 2669 | RemoveFromPhysicalScene(); |
2412 | } | 2670 | } |
2413 | 2671 | ||
2672 | if (MovingToTarget) | ||
2673 | ResetMoveToTarget(); | ||
2674 | |||
2675 | Velocity = Vector3.Zero; | ||
2676 | |||
2414 | part.AddSittingAvatar(UUID); | 2677 | part.AddSittingAvatar(UUID); |
2415 | 2678 | ||
2416 | cameraAtOffset = part.GetCameraAtOffset(); | 2679 | cameraAtOffset = part.GetCameraAtOffset(); |
@@ -2454,14 +2717,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2454 | m_requestedSitTargetID = part.LocalId; | 2717 | m_requestedSitTargetID = part.LocalId; |
2455 | m_requestedSitTargetUUID = part.UUID; | 2718 | m_requestedSitTargetUUID = part.UUID; |
2456 | 2719 | ||
2457 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
2458 | |||
2459 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
2460 | { | ||
2461 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | ||
2462 | //SitRayCastAvatarPosition(part); | ||
2463 | //return; | ||
2464 | } | ||
2465 | } | 2720 | } |
2466 | else | 2721 | else |
2467 | { | 2722 | { |
@@ -2471,197 +2726,115 @@ namespace OpenSim.Region.Framework.Scenes | |||
2471 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2726 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2472 | } | 2727 | } |
2473 | 2728 | ||
2474 | /* | 2729 | // returns false if does not suport so older sit can be tried |
2475 | public void SitRayCastAvatarPosition(SceneObjectPart part) | 2730 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2476 | { | ||
2477 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2478 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
2479 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2480 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2481 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
2482 | } | ||
2483 | |||
2484 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | ||
2485 | { | 2731 | { |
2486 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2732 | // TODO: Pull in these bits |
2487 | if (part != null) | 2733 | return false; |
2488 | { | 2734 | /* |
2489 | if (hitYN) | 2735 | if (part == null || part.ParentGroup.IsAttachment) |
2490 | { | ||
2491 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2492 | { | ||
2493 | SitRaycastFindEdge(collisionPoint, normal); | ||
2494 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2495 | } | ||
2496 | else | ||
2497 | { | ||
2498 | SitRayCastAvatarPositionCameraZ(part); | ||
2499 | } | ||
2500 | } | ||
2501 | else | ||
2502 | { | ||
2503 | SitRayCastAvatarPositionCameraZ(part); | ||
2504 | } | ||
2505 | } | ||
2506 | else | ||
2507 | { | 2736 | { |
2508 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2737 | return true; |
2509 | m_requestedSitTargetUUID = UUID.Zero; | ||
2510 | m_requestedSitTargetID = 0; | ||
2511 | m_requestedSitOffset = Vector3.Zero; | ||
2512 | } | 2738 | } |
2513 | 2739 | ||
2514 | } | 2740 | if ( m_scene.PhysicsScene == null) |
2515 | 2741 | return false; | |
2516 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | ||
2517 | { | ||
2518 | // Next, try to raycast from the camera Z position | ||
2519 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2520 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2521 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2522 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2523 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2524 | } | ||
2525 | 2742 | ||
2526 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2743 | if (part.PhysActor == null) |
2527 | { | ||
2528 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2529 | if (part != null) | ||
2530 | { | 2744 | { |
2531 | if (hitYN) | 2745 | // none physcis shape |
2532 | { | 2746 | if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) |
2533 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2747 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2534 | { | ||
2535 | SitRaycastFindEdge(collisionPoint, normal); | ||
2536 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2537 | } | ||
2538 | else | ||
2539 | { | ||
2540 | SitRayCastCameraPosition(part); | ||
2541 | } | ||
2542 | } | ||
2543 | else | 2748 | else |
2544 | { | 2749 | { // non physical phantom TODO |
2545 | SitRayCastCameraPosition(part); | 2750 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2751 | return false; | ||
2546 | } | 2752 | } |
2547 | } | 2753 | return true; |
2548 | else | ||
2549 | { | ||
2550 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2551 | m_requestedSitTargetUUID = UUID.Zero; | ||
2552 | m_requestedSitTargetID = 0; | ||
2553 | m_requestedSitOffset = Vector3.Zero; | ||
2554 | } | 2754 | } |
2555 | 2755 | ||
2556 | } | ||
2557 | 2756 | ||
2558 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2757 | // not doing autopilot |
2559 | { | 2758 | m_requestedSitTargetID = 0; |
2560 | // Next, try to raycast from the camera position | ||
2561 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2562 | Vector3 StartRayCastPosition = CameraPosition; | ||
2563 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2564 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2565 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2566 | } | ||
2567 | 2759 | ||
2568 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2760 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) |
2569 | { | 2761 | return true; |
2570 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2571 | if (part != null) | ||
2572 | { | ||
2573 | if (hitYN) | ||
2574 | { | ||
2575 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2576 | { | ||
2577 | SitRaycastFindEdge(collisionPoint, normal); | ||
2578 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2579 | } | ||
2580 | else | ||
2581 | { | ||
2582 | SitRayHorizontal(part); | ||
2583 | } | ||
2584 | } | ||
2585 | else | ||
2586 | { | ||
2587 | SitRayHorizontal(part); | ||
2588 | } | ||
2589 | } | ||
2590 | else | ||
2591 | { | ||
2592 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2593 | m_requestedSitTargetUUID = UUID.Zero; | ||
2594 | m_requestedSitTargetID = 0; | ||
2595 | m_requestedSitOffset = Vector3.Zero; | ||
2596 | } | ||
2597 | 2762 | ||
2763 | return false; | ||
2764 | */ | ||
2598 | } | 2765 | } |
2599 | 2766 | ||
2600 | public void SitRayHorizontal(SceneObjectPart part) | 2767 | |
2768 | private bool CanEnterLandPosition(Vector3 testPos) | ||
2601 | { | 2769 | { |
2602 | // Next, try to raycast from the avatar position to fwd | 2770 | ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); |
2603 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2771 | |
2604 | Vector3 StartRayCastPosition = CameraPosition; | 2772 | if (land == null || land.LandData.Name == "NO_LAND") |
2605 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2773 | return true; |
2606 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2774 | |
2607 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | 2775 | return land.CanBeOnThisLand(UUID,testPos.Z); |
2608 | } | 2776 | } |
2609 | 2777 | ||
2610 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2778 | // status |
2779 | // < 0 ignore | ||
2780 | // 0 bad sit spot | ||
2781 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | ||
2611 | { | 2782 | { |
2612 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2783 | if (status < 0) |
2613 | if (part != null) | 2784 | return; |
2785 | |||
2786 | if (status == 0) | ||
2614 | { | 2787 | { |
2615 | if (hitYN) | 2788 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2616 | { | 2789 | return; |
2617 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2618 | { | ||
2619 | SitRaycastFindEdge(collisionPoint, normal); | ||
2620 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2621 | // Next, try to raycast from the camera position | ||
2622 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2623 | Vector3 StartRayCastPosition = CameraPosition; | ||
2624 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2625 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2626 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2627 | } | ||
2628 | else | ||
2629 | { | ||
2630 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2631 | m_requestedSitTargetUUID = UUID.Zero; | ||
2632 | m_requestedSitTargetID = 0; | ||
2633 | m_requestedSitOffset = Vector3.Zero; | ||
2634 | } | ||
2635 | } | ||
2636 | else | ||
2637 | { | ||
2638 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2639 | m_requestedSitTargetUUID = UUID.Zero; | ||
2640 | m_requestedSitTargetID = 0; | ||
2641 | m_requestedSitOffset = Vector3.Zero; | ||
2642 | } | ||
2643 | } | 2790 | } |
2644 | else | 2791 | |
2792 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | ||
2793 | if (part == null) | ||
2794 | return; | ||
2795 | |||
2796 | Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation(); | ||
2797 | if(!CanEnterLandPosition(targetPos)) | ||
2645 | { | 2798 | { |
2646 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2799 | ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); |
2647 | m_requestedSitTargetUUID = UUID.Zero; | 2800 | return; |
2648 | m_requestedSitTargetID = 0; | ||
2649 | m_requestedSitOffset = Vector3.Zero; | ||
2650 | } | 2801 | } |
2651 | 2802 | ||
2652 | } | 2803 | RemoveFromPhysicalScene(); |
2653 | 2804 | ||
2654 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2805 | if (MovingToTarget) |
2655 | { | 2806 | ResetMoveToTarget(); |
2656 | int i = 0; | 2807 | |
2657 | //throw new NotImplementedException(); | 2808 | Velocity = Vector3.Zero; |
2658 | //m_requestedSitTargetUUID = UUID.Zero; | 2809 | |
2659 | //m_requestedSitTargetID = 0; | 2810 | part.AddSittingAvatar(UUID); |
2660 | //m_requestedSitOffset = Vector3.Zero; | 2811 | |
2812 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); | ||
2813 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2814 | bool forceMouselook = part.GetForceMouselook(); | ||
2815 | |||
2816 | ControllingClient.SendSitResponse( | ||
2817 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2818 | |||
2819 | // not using autopilot | ||
2820 | |||
2821 | Rotation = Orientation; | ||
2822 | m_pos = offset; | ||
2823 | |||
2824 | m_requestedSitTargetID = 0; | ||
2825 | part.ParentGroup.AddAvatar(UUID); | ||
2826 | |||
2827 | ParentPart = part; | ||
2828 | ParentID = part.LocalId; | ||
2829 | if(status == 3) | ||
2830 | Animator.TrySetMovementAnimation("SIT_GROUND"); | ||
2831 | else | ||
2832 | Animator.TrySetMovementAnimation("SIT"); | ||
2833 | SendAvatarDataToAllAgents(); | ||
2661 | 2834 | ||
2662 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2835 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2663 | } | 2836 | } |
2664 | */ | 2837 | |
2665 | 2838 | ||
2666 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2839 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2667 | { | 2840 | { |
@@ -2681,6 +2854,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2681 | return; | 2854 | return; |
2682 | } | 2855 | } |
2683 | 2856 | ||
2857 | |||
2684 | if (part.SitTargetAvatar == UUID) | 2858 | if (part.SitTargetAvatar == UUID) |
2685 | { | 2859 | { |
2686 | Vector3 sitTargetPos = part.SitTargetPosition; | 2860 | Vector3 sitTargetPos = part.SitTargetPosition; |
@@ -2695,7 +2869,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2695 | 2869 | ||
2696 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2870 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2697 | 2871 | ||
2698 | Vector3 newPos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2872 | double x, y, z, m; |
2873 | |||
2874 | Quaternion r = sitTargetOrient; | ||
2875 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2876 | |||
2877 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2878 | { | ||
2879 | m = 1.0 / Math.Sqrt(m); | ||
2880 | r.X *= (float)m; | ||
2881 | r.Y *= (float)m; | ||
2882 | r.Z *= (float)m; | ||
2883 | r.W *= (float)m; | ||
2884 | } | ||
2885 | |||
2886 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2887 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2888 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2889 | |||
2890 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2891 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2892 | |||
2893 | Vector3 newPos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2699 | Quaternion newRot; | 2894 | Quaternion newRot; |
2700 | 2895 | ||
2701 | if (part.IsRoot) | 2896 | if (part.IsRoot) |
@@ -2712,6 +2907,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2712 | 2907 | ||
2713 | m_pos = newPos; | 2908 | m_pos = newPos; |
2714 | Rotation = newRot; | 2909 | Rotation = newRot; |
2910 | |||
2911 | // ParentPosition = part.AbsolutePosition; | ||
2912 | part.ParentGroup.AddAvatar(UUID); | ||
2715 | } | 2913 | } |
2716 | else | 2914 | else |
2717 | { | 2915 | { |
@@ -2719,6 +2917,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2719 | // being sat upon. | 2917 | // being sat upon. |
2720 | m_pos -= part.GroupPosition; | 2918 | m_pos -= part.GroupPosition; |
2721 | 2919 | ||
2920 | // ParentPosition = part.AbsolutePosition; | ||
2921 | part.ParentGroup.AddAvatar(UUID); | ||
2922 | |||
2722 | // m_log.DebugFormat( | 2923 | // m_log.DebugFormat( |
2723 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2924 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
2724 | // Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); | 2925 | // Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); |
@@ -2834,8 +3035,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2834 | direc.Z *= 2.6f; | 3035 | direc.Z *= 2.6f; |
2835 | 3036 | ||
2836 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 3037 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2837 | Animator.TrySetMovementAnimation("PREJUMP"); | 3038 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2838 | Animator.TrySetMovementAnimation("JUMP"); | 3039 | // Animator.TrySetMovementAnimation("JUMP"); |
2839 | } | 3040 | } |
2840 | } | 3041 | } |
2841 | } | 3042 | } |
@@ -2844,6 +3045,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2844 | 3045 | ||
2845 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 3046 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2846 | m_forceToApply = direc; | 3047 | m_forceToApply = direc; |
3048 | Animator.UpdateMovementAnimations(); | ||
2847 | } | 3049 | } |
2848 | 3050 | ||
2849 | #endregion | 3051 | #endregion |
@@ -2861,16 +3063,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2861 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 3063 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2862 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 3064 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2863 | // storing a requested force instead of an actual traveling velocity | 3065 | // storing a requested force instead of an actual traveling velocity |
3066 | if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) | ||
3067 | SendAvatarDataToAllAgents(); | ||
2864 | 3068 | ||
2865 | // Throw away duplicate or insignificant updates | 3069 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2866 | if ( | 3070 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2867 | // If the velocity has become zero, send it no matter what. | 3071 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2868 | (Velocity != m_lastVelocity && Velocity == Vector3.Zero) | ||
2869 | // otherwise, if things have changed reasonably, send the update | ||
2870 | || (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) | ||
2871 | || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) | ||
2872 | || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))) | ||
2873 | |||
2874 | { | 3072 | { |
2875 | SendTerseUpdateToAllClients(); | 3073 | SendTerseUpdateToAllClients(); |
2876 | 3074 | ||
@@ -3030,9 +3228,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3030 | // again here... this comes after the cached appearance check because the avatars | 3228 | // again here... this comes after the cached appearance check because the avatars |
3031 | // appearance goes into the avatar update packet | 3229 | // appearance goes into the avatar update packet |
3032 | SendAvatarDataToAllAgents(); | 3230 | SendAvatarDataToAllAgents(); |
3033 | 3231 | SendAppearanceToAgent(this); | |
3034 | // This invocation always shows up in the viewer logs as an error. | ||
3035 | // SendAppearanceToAgent(this); | ||
3036 | 3232 | ||
3037 | // If we are using the the cached appearance then send it out to everyone | 3233 | // If we are using the the cached appearance then send it out to everyone |
3038 | if (cachedappearance) | 3234 | if (cachedappearance) |
@@ -3063,6 +3259,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3063 | return; | 3259 | return; |
3064 | } | 3260 | } |
3065 | 3261 | ||
3262 | m_lastSize = Appearance.AvatarSize; | ||
3263 | |||
3066 | int count = 0; | 3264 | int count = 0; |
3067 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 3265 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
3068 | { | 3266 | { |
@@ -3170,6 +3368,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3170 | 3368 | ||
3171 | avatar.ControllingClient.SendAppearance( | 3369 | avatar.ControllingClient.SendAppearance( |
3172 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 3370 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
3371 | |||
3372 | |||
3173 | } | 3373 | } |
3174 | 3374 | ||
3175 | #endregion | 3375 | #endregion |
@@ -3243,8 +3443,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3243 | 3443 | ||
3244 | // If we don't have a PhysActor, we can't cross anyway | 3444 | // If we don't have a PhysActor, we can't cross anyway |
3245 | // Also don't do this while sat, sitting avatars cross with the | 3445 | // Also don't do this while sat, sitting avatars cross with the |
3246 | // object they sit on. | 3446 | // object they sit on. ParentUUID denoted a pending sit, don't |
3247 | if (ParentID != 0 || PhysicsActor == null) | 3447 | // interfere with it. |
3448 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
3248 | return; | 3449 | return; |
3249 | 3450 | ||
3250 | if (!IsInTransit) | 3451 | if (!IsInTransit) |
@@ -3588,6 +3789,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3588 | cAgent.AlwaysRun = SetAlwaysRun; | 3789 | cAgent.AlwaysRun = SetAlwaysRun; |
3589 | 3790 | ||
3590 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3791 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3792 | |||
3793 | cAgent.ParentPart = ParentUUID; | ||
3794 | cAgent.SitOffset = PrevSitOffset; | ||
3591 | 3795 | ||
3592 | lock (scriptedcontrols) | 3796 | lock (scriptedcontrols) |
3593 | { | 3797 | { |
@@ -3596,7 +3800,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3596 | 3800 | ||
3597 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3801 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3598 | { | 3802 | { |
3599 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3803 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3600 | } | 3804 | } |
3601 | cAgent.Controllers = controls; | 3805 | cAgent.Controllers = controls; |
3602 | } | 3806 | } |
@@ -3630,6 +3834,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3630 | CameraAtAxis = cAgent.AtAxis; | 3834 | CameraAtAxis = cAgent.AtAxis; |
3631 | CameraLeftAxis = cAgent.LeftAxis; | 3835 | CameraLeftAxis = cAgent.LeftAxis; |
3632 | CameraUpAxis = cAgent.UpAxis; | 3836 | CameraUpAxis = cAgent.UpAxis; |
3837 | ParentUUID = cAgent.ParentPart; | ||
3838 | PrevSitOffset = cAgent.SitOffset; | ||
3633 | 3839 | ||
3634 | // When we get to the point of re-computing neighbors everytime this | 3840 | // When we get to the point of re-computing neighbors everytime this |
3635 | // changes, then start using the agent's drawdistance rather than the | 3841 | // changes, then start using the agent's drawdistance rather than the |
@@ -3667,6 +3873,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3667 | foreach (ControllerData c in cAgent.Controllers) | 3873 | foreach (ControllerData c in cAgent.Controllers) |
3668 | { | 3874 | { |
3669 | ScriptControllers sc = new ScriptControllers(); | 3875 | ScriptControllers sc = new ScriptControllers(); |
3876 | sc.objectID = c.ObjectID; | ||
3670 | sc.itemID = c.ItemID; | 3877 | sc.itemID = c.ItemID; |
3671 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3878 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3672 | sc.eventControls = (ScriptControlled)c.EventControls; | 3879 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3732,20 +3939,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3732 | } | 3939 | } |
3733 | 3940 | ||
3734 | if (Appearance.AvatarHeight == 0) | 3941 | if (Appearance.AvatarHeight == 0) |
3735 | Appearance.SetHeight(); | 3942 | // Appearance.SetHeight(); |
3943 | Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
3736 | 3944 | ||
3737 | PhysicsScene scene = m_scene.PhysicsScene; | 3945 | PhysicsScene scene = m_scene.PhysicsScene; |
3738 | 3946 | ||
3739 | Vector3 pVec = AbsolutePosition; | 3947 | Vector3 pVec = AbsolutePosition; |
3740 | 3948 | ||
3949 | /* | ||
3950 | PhysicsActor = scene.AddAvatar( | ||
3951 | LocalId, Firstname + "." + Lastname, pVec, | ||
3952 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); | ||
3953 | */ | ||
3954 | |||
3741 | PhysicsActor = scene.AddAvatar( | 3955 | PhysicsActor = scene.AddAvatar( |
3742 | LocalId, Firstname + "." + Lastname, pVec, | 3956 | LocalId, Firstname + "." + Lastname, pVec, |
3743 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); | 3957 | Appearance.AvatarBoxSize, isFlying); |
3744 | 3958 | ||
3745 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3959 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3746 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3960 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3747 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3961 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3748 | PhysicsActor.SubscribeEvents(500); | 3962 | PhysicsActor.SubscribeEvents(100); |
3749 | PhysicsActor.LocalID = LocalId; | 3963 | PhysicsActor.LocalID = LocalId; |
3750 | } | 3964 | } |
3751 | 3965 | ||
@@ -3759,6 +3973,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3759 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3973 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3760 | } | 3974 | } |
3761 | 3975 | ||
3976 | |||
3762 | /// <summary> | 3977 | /// <summary> |
3763 | /// Event called by the physics plugin to tell the avatar about a collision. | 3978 | /// Event called by the physics plugin to tell the avatar about a collision. |
3764 | /// </summary> | 3979 | /// </summary> |
@@ -3772,7 +3987,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3772 | /// <param name="e"></param> | 3987 | /// <param name="e"></param> |
3773 | public void PhysicsCollisionUpdate(EventArgs e) | 3988 | public void PhysicsCollisionUpdate(EventArgs e) |
3774 | { | 3989 | { |
3775 | if (IsChildAgent) | 3990 | if (IsChildAgent || Animator == null) |
3776 | return; | 3991 | return; |
3777 | 3992 | ||
3778 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3993 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3789,7 +4004,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3789 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 4004 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3790 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 4005 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3791 | 4006 | ||
3792 | CollisionPlane = Vector4.UnitW; | ||
3793 | 4007 | ||
3794 | // // No collisions at all means we may be flying. Update always | 4008 | // // No collisions at all means we may be flying. Update always |
3795 | // // to make falling work | 4009 | // // to make falling work |
@@ -3799,34 +4013,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3799 | // m_lastColCount = coldata.Count; | 4013 | // m_lastColCount = coldata.Count; |
3800 | // } | 4014 | // } |
3801 | 4015 | ||
3802 | if (coldata.Count != 0) | 4016 | CollisionPlane = Vector4.UnitW; |
3803 | { | ||
3804 | switch (Animator.CurrentMovementAnimation) | ||
3805 | { | ||
3806 | case "STAND": | ||
3807 | case "WALK": | ||
3808 | case "RUN": | ||
3809 | case "CROUCH": | ||
3810 | case "CROUCHWALK": | ||
3811 | { | ||
3812 | ContactPoint lowest; | ||
3813 | lowest.SurfaceNormal = Vector3.Zero; | ||
3814 | lowest.Position = Vector3.Zero; | ||
3815 | lowest.Position.Z = Single.NaN; | ||
3816 | |||
3817 | foreach (ContactPoint contact in coldata.Values) | ||
3818 | { | ||
3819 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | ||
3820 | { | ||
3821 | lowest = contact; | ||
3822 | } | ||
3823 | } | ||
3824 | |||
3825 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3826 | } | ||
3827 | break; | ||
3828 | } | ||
3829 | } | ||
3830 | 4017 | ||
3831 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 4018 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3832 | if (Invulnerable || GodLevel > 0) | 4019 | if (Invulnerable || GodLevel > 0) |
@@ -3925,6 +4112,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3925 | // m_reprioritizationTimer.Dispose(); | 4112 | // m_reprioritizationTimer.Dispose(); |
3926 | 4113 | ||
3927 | RemoveFromPhysicalScene(); | 4114 | RemoveFromPhysicalScene(); |
4115 | |||
4116 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
4117 | |||
4118 | // if (Animator != null) | ||
4119 | // Animator.Close(); | ||
4120 | Animator = null; | ||
3928 | 4121 | ||
3929 | LifecycleState = ScenePresenceState.Removed; | 4122 | LifecycleState = ScenePresenceState.Removed; |
3930 | } | 4123 | } |
@@ -4160,10 +4353,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4160 | 4353 | ||
4161 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 4354 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
4162 | { | 4355 | { |
4356 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
4357 | if (p == null) | ||
4358 | return; | ||
4359 | |||
4360 | ControllingClient.SendTakeControls(controls, false, false); | ||
4361 | ControllingClient.SendTakeControls(controls, true, false); | ||
4362 | |||
4163 | ScriptControllers obj = new ScriptControllers(); | 4363 | ScriptControllers obj = new ScriptControllers(); |
4164 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 4364 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
4165 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 4365 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
4166 | 4366 | ||
4367 | obj.objectID = p.ParentGroup.UUID; | ||
4167 | obj.itemID = Script_item_UUID; | 4368 | obj.itemID = Script_item_UUID; |
4168 | if (pass_on == 0 && accept == 0) | 4369 | if (pass_on == 0 && accept == 0) |
4169 | { | 4370 | { |
@@ -4212,6 +4413,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4212 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 4413 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
4213 | } | 4414 | } |
4214 | 4415 | ||
4416 | private void UnRegisterSeatControls(UUID obj) | ||
4417 | { | ||
4418 | List<UUID> takers = new List<UUID>(); | ||
4419 | |||
4420 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
4421 | { | ||
4422 | if (c.objectID == obj) | ||
4423 | takers.Add(c.itemID); | ||
4424 | } | ||
4425 | foreach (UUID t in takers) | ||
4426 | { | ||
4427 | UnRegisterControlEventsToScript(0, t); | ||
4428 | } | ||
4429 | } | ||
4430 | |||
4215 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 4431 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
4216 | { | 4432 | { |
4217 | ScriptControllers takecontrols; | 4433 | ScriptControllers takecontrols; |
@@ -4541,6 +4757,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4541 | 4757 | ||
4542 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4758 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4543 | { | 4759 | { |
4760 | string reason; | ||
4761 | |||
4762 | // Honor bans | ||
4763 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4764 | return; | ||
4765 | |||
4544 | SceneObjectGroup telehub = null; | 4766 | SceneObjectGroup telehub = null; |
4545 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4767 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4546 | { | 4768 | { |
@@ -4580,11 +4802,119 @@ namespace OpenSim.Region.Framework.Scenes | |||
4580 | pos = land.LandData.UserLocation; | 4802 | pos = land.LandData.UserLocation; |
4581 | } | 4803 | } |
4582 | } | 4804 | } |
4583 | 4805 | ||
4584 | land.SendLandUpdateToClient(ControllingClient); | 4806 | land.SendLandUpdateToClient(ControllingClient); |
4585 | } | 4807 | } |
4586 | } | 4808 | } |
4587 | 4809 | ||
4810 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4811 | { | ||
4812 | DetectedObject detobj = new DetectedObject(); | ||
4813 | detobj.keyUUID = obj.UUID; | ||
4814 | detobj.nameStr = obj.Name; | ||
4815 | detobj.ownerUUID = obj.OwnerID; | ||
4816 | detobj.posVector = obj.AbsolutePosition; | ||
4817 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4818 | detobj.velVector = obj.Velocity; | ||
4819 | detobj.colliderType = 0; | ||
4820 | detobj.groupUUID = obj.GroupID; | ||
4821 | |||
4822 | return detobj; | ||
4823 | } | ||
4824 | |||
4825 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4826 | { | ||
4827 | DetectedObject detobj = new DetectedObject(); | ||
4828 | detobj.keyUUID = av.UUID; | ||
4829 | detobj.nameStr = av.ControllingClient.Name; | ||
4830 | detobj.ownerUUID = av.UUID; | ||
4831 | detobj.posVector = av.AbsolutePosition; | ||
4832 | detobj.rotQuat = av.Rotation; | ||
4833 | detobj.velVector = av.Velocity; | ||
4834 | detobj.colliderType = 0; | ||
4835 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4836 | |||
4837 | return detobj; | ||
4838 | } | ||
4839 | |||
4840 | private DetectedObject CreateDetObjectForGround() | ||
4841 | { | ||
4842 | DetectedObject detobj = new DetectedObject(); | ||
4843 | detobj.keyUUID = UUID.Zero; | ||
4844 | detobj.nameStr = ""; | ||
4845 | detobj.ownerUUID = UUID.Zero; | ||
4846 | detobj.posVector = AbsolutePosition; | ||
4847 | detobj.rotQuat = Quaternion.Identity; | ||
4848 | detobj.velVector = Vector3.Zero; | ||
4849 | detobj.colliderType = 0; | ||
4850 | detobj.groupUUID = UUID.Zero; | ||
4851 | |||
4852 | return detobj; | ||
4853 | } | ||
4854 | |||
4855 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4856 | { | ||
4857 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4858 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4859 | foreach (uint localId in colliders) | ||
4860 | { | ||
4861 | if (localId == 0) | ||
4862 | continue; | ||
4863 | |||
4864 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4865 | if (obj != null) | ||
4866 | { | ||
4867 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4868 | colliding.Add(CreateDetObject(obj)); | ||
4869 | } | ||
4870 | else | ||
4871 | { | ||
4872 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4873 | if (av != null && (!av.IsChildAgent)) | ||
4874 | { | ||
4875 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4876 | colliding.Add(CreateDetObject(av)); | ||
4877 | } | ||
4878 | } | ||
4879 | } | ||
4880 | |||
4881 | colliderArgs.Colliders = colliding; | ||
4882 | |||
4883 | return colliderArgs; | ||
4884 | } | ||
4885 | |||
4886 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4887 | |||
4888 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4889 | { | ||
4890 | ColliderArgs CollidingMessage; | ||
4891 | |||
4892 | if (colliders.Count > 0) | ||
4893 | { | ||
4894 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4895 | { | ||
4896 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4897 | |||
4898 | if (CollidingMessage.Colliders.Count > 0) | ||
4899 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4900 | } | ||
4901 | } | ||
4902 | } | ||
4903 | |||
4904 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4905 | { | ||
4906 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4907 | { | ||
4908 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4909 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4910 | |||
4911 | colliding.Add(CreateDetObjectForGround()); | ||
4912 | LandCollidingMessage.Colliders = colliding; | ||
4913 | |||
4914 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4915 | } | ||
4916 | } | ||
4917 | |||
4588 | private void TeleportFlagsDebug() { | 4918 | private void TeleportFlagsDebug() { |
4589 | 4919 | ||
4590 | // Some temporary debugging help to show all the TeleportFlags we have... | 4920 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4609,6 +4939,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4609 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4939 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4610 | 4940 | ||
4611 | } | 4941 | } |
4612 | |||
4613 | } | 4942 | } |
4614 | } | 4943 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index acaeb90..0911f00 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |||
@@ -111,15 +111,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
111 | 111 | ||
112 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; | 112 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
113 | 113 | ||
114 | // We need to preserve this here because phys actor is removed by the sit. | ||
115 | Vector3 spPhysActorSize = m_sp.PhysicsActor.Size; | ||
114 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | 116 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
115 | 117 | ||
116 | // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the | ||
117 | // default avatar. | ||
118 | // Curiously, Vector3.ToString() will not display the last two places of the float. For example, | ||
119 | // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337> | ||
120 | Assert.That( | 118 | Assert.That( |
121 | m_sp.AbsolutePosition, | 119 | m_sp.AbsolutePosition, |
122 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); | 120 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2))); |
123 | 121 | ||
124 | m_sp.StandUp(); | 122 | m_sp.StandUp(); |
125 | 123 | ||
@@ -147,9 +145,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
147 | 145 | ||
148 | Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); | 146 | Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); |
149 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); | 147 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); |
150 | Assert.That( | 148 | // Assert.That( |
151 | m_sp.AbsolutePosition, | 149 | // m_sp.AbsolutePosition, |
152 | Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); | 150 | // Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); |
153 | Assert.That(m_sp.PhysicsActor, Is.Null); | 151 | Assert.That(m_sp.PhysicsActor, Is.Null); |
154 | 152 | ||
155 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); | 153 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index dd27294..1e59e3f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -62,8 +62,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
62 | = AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero); | 62 | = AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero); |
63 | m_assetService.Store(corruptAsset); | 63 | m_assetService.Store(corruptAsset); |
64 | 64 | ||
65 | IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); | 65 | IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); |
66 | m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); | 66 | m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, (sbyte)AssetType.Object, foundAssetUuids); |
67 | 67 | ||
68 | // We count the uuid as gathered even if the asset itself is corrupt. | 68 | // We count the uuid as gathered even if the asset itself is corrupt. |
69 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | 69 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); |
@@ -78,9 +78,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
78 | TestHelpers.InMethod(); | 78 | TestHelpers.InMethod(); |
79 | 79 | ||
80 | UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | 80 | UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); |
81 | IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); | 81 | IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); |
82 | 82 | ||
83 | m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); | 83 | m_uuidGatherer.GatherAssetUuids(missingAssetUuid, (sbyte)AssetType.Object, foundAssetUuids); |
84 | 84 | ||
85 | // We count the uuid as gathered even if the asset itself is missing. | 85 | // We count the uuid as gathered even if the asset itself is missing. |
86 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | 86 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); |
@@ -103,8 +103,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
103 | AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString()); | 103 | AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString()); |
104 | m_assetService.Store(ncAsset); | 104 | m_assetService.Store(ncAsset); |
105 | 105 | ||
106 | IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); | 106 | IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); |
107 | m_uuidGatherer.GatherAssetUuids(ncAssetId, AssetType.Notecard, foundAssetUuids); | 107 | m_uuidGatherer.GatherAssetUuids(ncAssetId, (sbyte)AssetType.Notecard, foundAssetUuids); |
108 | 108 | ||
109 | // We count the uuid as gathered even if the asset itself is corrupt. | 109 | // We count the uuid as gathered even if the asset itself is corrupt. |
110 | Assert.That(foundAssetUuids.Count, Is.EqualTo(2)); | 110 | Assert.That(foundAssetUuids.Count, Is.EqualTo(2)); |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 3e074b9..75a51b5 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -38,6 +38,7 @@ using OpenMetaverse.StructuredData; | |||
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Region.Framework.Scenes.Serialization; | 39 | using OpenSim.Region.Framework.Scenes.Serialization; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; | ||
41 | 42 | ||
42 | namespace OpenSim.Region.Framework.Scenes | 43 | namespace OpenSim.Region.Framework.Scenes |
43 | { | 44 | { |
@@ -83,7 +84,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
83 | /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> | 84 | /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> |
84 | /// <param name="assetType">The type of the asset for the uuid given</param> | 85 | /// <param name="assetType">The type of the asset for the uuid given</param> |
85 | /// <param name="assetUuids">The assets gathered</param> | 86 | /// <param name="assetUuids">The assets gathered</param> |
86 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) | 87 | public void GatherAssetUuids(UUID assetUuid, sbyte assetType, IDictionary<UUID, sbyte> assetUuids) |
87 | { | 88 | { |
88 | // avoid infinite loops | 89 | // avoid infinite loops |
89 | if (assetUuids.ContainsKey(assetUuid)) | 90 | if (assetUuids.ContainsKey(assetUuid)) |
@@ -93,23 +94,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
93 | { | 94 | { |
94 | assetUuids[assetUuid] = assetType; | 95 | assetUuids[assetUuid] = assetType; |
95 | 96 | ||
96 | if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType) | 97 | if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType) |
97 | { | 98 | { |
98 | GetWearableAssetUuids(assetUuid, assetUuids); | 99 | GetWearableAssetUuids(assetUuid, assetUuids); |
99 | } | 100 | } |
100 | else if (AssetType.Gesture == assetType) | 101 | else if ((sbyte)AssetType.Gesture == assetType) |
101 | { | 102 | { |
102 | GetGestureAssetUuids(assetUuid, assetUuids); | 103 | GetGestureAssetUuids(assetUuid, assetUuids); |
103 | } | 104 | } |
104 | else if (AssetType.Notecard == assetType) | 105 | else if ((sbyte)AssetType.Notecard == assetType) |
105 | { | 106 | { |
106 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); | 107 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); |
107 | } | 108 | } |
108 | else if (AssetType.LSLText == assetType) | 109 | else if ((sbyte)AssetType.LSLText == assetType) |
109 | { | 110 | { |
110 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); | 111 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); |
111 | } | 112 | } |
112 | else if (AssetType.Object == assetType) | 113 | else if ((sbyte)OpenSimAssetType.Material == assetType) |
114 | { | ||
115 | GetMaterialAssetUuids(assetUuid, assetUuids); | ||
116 | } | ||
117 | else if ((sbyte)AssetType.Object == assetType) | ||
113 | { | 118 | { |
114 | GetSceneObjectAssetUuids(assetUuid, assetUuids); | 119 | GetSceneObjectAssetUuids(assetUuid, assetUuids); |
115 | } | 120 | } |
@@ -136,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
136 | /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset. | 141 | /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset. |
137 | /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown. | 142 | /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown. |
138 | /// </param> | 143 | /// </param> |
139 | public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids) | 144 | public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, sbyte> assetUuids) |
140 | { | 145 | { |
141 | // m_log.DebugFormat( | 146 | // m_log.DebugFormat( |
142 | // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); | 147 | // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); |
@@ -156,7 +161,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | { | 161 | { |
157 | // Get the prim's default texture. This will be used for faces which don't have their own texture | 162 | // Get the prim's default texture. This will be used for faces which don't have their own texture |
158 | if (textureEntry.DefaultTexture != null) | 163 | if (textureEntry.DefaultTexture != null) |
159 | assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; | 164 | assetUuids[textureEntry.DefaultTexture.TextureID] = (sbyte)AssetType.Texture; |
160 | 165 | ||
161 | if (textureEntry.FaceTextures != null) | 166 | if (textureEntry.FaceTextures != null) |
162 | { | 167 | { |
@@ -164,20 +169,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
164 | foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) | 169 | foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) |
165 | { | 170 | { |
166 | if (texture != null) | 171 | if (texture != null) |
167 | assetUuids[texture.TextureID] = AssetType.Texture; | 172 | assetUuids[texture.TextureID] = (sbyte)AssetType.Texture; |
168 | } | 173 | } |
169 | } | 174 | } |
170 | } | 175 | } |
171 | 176 | ||
172 | // If the prim is a sculpt then preserve this information too | 177 | // If the prim is a sculpt then preserve this information too |
173 | if (part.Shape.SculptTexture != UUID.Zero) | 178 | if (part.Shape.SculptTexture != UUID.Zero) |
174 | assetUuids[part.Shape.SculptTexture] = AssetType.Texture; | 179 | assetUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture; |
175 | 180 | ||
176 | if (part.Shape.ProjectionTextureUUID != UUID.Zero) | 181 | if (part.Shape.ProjectionTextureUUID != UUID.Zero) |
177 | assetUuids[part.Shape.ProjectionTextureUUID] = AssetType.Texture; | 182 | assetUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture; |
178 | 183 | ||
179 | if (part.CollisionSound != UUID.Zero) | 184 | if (part.CollisionSound != UUID.Zero) |
180 | assetUuids[part.CollisionSound] = AssetType.Sound; | 185 | assetUuids[part.CollisionSound] = (sbyte)AssetType.Sound; |
181 | 186 | ||
182 | if (part.ParticleSystem.Length > 0) | 187 | if (part.ParticleSystem.Length > 0) |
183 | { | 188 | { |
@@ -185,7 +190,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
185 | { | 190 | { |
186 | Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0); | 191 | Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0); |
187 | if (ps.Texture != UUID.Zero) | 192 | if (ps.Texture != UUID.Zero) |
188 | assetUuids[ps.Texture] = AssetType.Texture; | 193 | assetUuids[ps.Texture] = (sbyte)AssetType.Texture; |
189 | } | 194 | } |
190 | catch (Exception e) | 195 | catch (Exception e) |
191 | { | 196 | { |
@@ -205,7 +210,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
205 | // tii.Name, tii.Type, part.Name, part.UUID); | 210 | // tii.Name, tii.Type, part.Name, part.UUID); |
206 | 211 | ||
207 | if (!assetUuids.ContainsKey(tii.AssetID)) | 212 | if (!assetUuids.ContainsKey(tii.AssetID)) |
208 | GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); | 213 | GatherAssetUuids(tii.AssetID, (sbyte)tii.Type, assetUuids); |
209 | } | 214 | } |
210 | 215 | ||
211 | // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed | 216 | // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed |
@@ -214,7 +219,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
214 | // Scene.EventManager is present. | 219 | // Scene.EventManager is present. |
215 | // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); | 220 | // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); |
216 | 221 | ||
217 | GatherMaterialsUuids(part, assetUuids); | 222 | |
223 | // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs | ||
224 | GatherMaterialsUuids(part, assetUuids); | ||
218 | } | 225 | } |
219 | catch (Exception e) | 226 | catch (Exception e) |
220 | { | 227 | { |
@@ -225,7 +232,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
225 | } | 232 | } |
226 | } | 233 | } |
227 | } | 234 | } |
228 | 235 | ||
229 | // /// <summary> | 236 | // /// <summary> |
230 | // /// The callback made when we request the asset for an object from the asset service. | 237 | // /// The callback made when we request the asset for an object from the asset service. |
231 | // /// </summary> | 238 | // /// </summary> |
@@ -241,10 +248,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
241 | 248 | ||
242 | /// <summary> | 249 | /// <summary> |
243 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps | 250 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps |
251 | /// stored in legacy format in part.DynAttrs | ||
244 | /// </summary> | 252 | /// </summary> |
245 | /// <param name="part"></param> | 253 | /// <param name="part"></param> |
246 | /// <param name="assetUuids"></param> | 254 | /// <param name="assetUuids"></param> |
247 | public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) | 255 | //public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) |
256 | public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, sbyte> assetUuids) | ||
248 | { | 257 | { |
249 | // scan thru the dynAttrs map of this part for any textures used as materials | 258 | // scan thru the dynAttrs map of this part for any textures used as materials |
250 | OSD osdMaterials = null; | 259 | OSD osdMaterials = null; |
@@ -280,7 +289,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
280 | UUID normalMapId = mat["NormMap"].AsUUID(); | 289 | UUID normalMapId = mat["NormMap"].AsUUID(); |
281 | if (normalMapId != UUID.Zero) | 290 | if (normalMapId != UUID.Zero) |
282 | { | 291 | { |
283 | assetUuids[normalMapId] = AssetType.Texture; | 292 | assetUuids[normalMapId] = (sbyte)AssetType.Texture; |
284 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); | 293 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); |
285 | } | 294 | } |
286 | } | 295 | } |
@@ -289,7 +298,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
289 | UUID specularMapId = mat["SpecMap"].AsUUID(); | 298 | UUID specularMapId = mat["SpecMap"].AsUUID(); |
290 | if (specularMapId != UUID.Zero) | 299 | if (specularMapId != UUID.Zero) |
291 | { | 300 | { |
292 | assetUuids[specularMapId] = AssetType.Texture; | 301 | assetUuids[specularMapId] = (sbyte)AssetType.Texture; |
293 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); | 302 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); |
294 | } | 303 | } |
295 | } | 304 | } |
@@ -344,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | /// </summary> | 353 | /// </summary> |
345 | /// <param name="scriptUuid"></param> | 354 | /// <param name="scriptUuid"></param> |
346 | /// <param name="assetUuids">Dictionary in which to record the references</param> | 355 | /// <param name="assetUuids">Dictionary in which to record the references</param> |
347 | private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids) | 356 | private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, sbyte> assetUuids) |
348 | { | 357 | { |
349 | // m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId); | 358 | // m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId); |
350 | 359 | ||
@@ -364,7 +373,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
364 | 373 | ||
365 | // Embedded asset references (if not false positives) could be for many types of asset, so we will | 374 | // Embedded asset references (if not false positives) could be for many types of asset, so we will |
366 | // label these as unknown. | 375 | // label these as unknown. |
367 | assetUuids[uuid] = AssetType.Unknown; | 376 | assetUuids[uuid] = (sbyte)AssetType.Unknown; |
368 | } | 377 | } |
369 | } | 378 | } |
370 | } | 379 | } |
@@ -374,7 +383,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
374 | /// </summary> | 383 | /// </summary> |
375 | /// <param name="wearableAssetUuid"></param> | 384 | /// <param name="wearableAssetUuid"></param> |
376 | /// <param name="assetUuids">Dictionary in which to record the references</param> | 385 | /// <param name="assetUuids">Dictionary in which to record the references</param> |
377 | private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) | 386 | private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, sbyte> assetUuids) |
378 | { | 387 | { |
379 | AssetBase assetBase = GetAsset(wearableAssetUuid); | 388 | AssetBase assetBase = GetAsset(wearableAssetUuid); |
380 | 389 | ||
@@ -389,7 +398,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | 398 | ||
390 | foreach (UUID uuid in wearableAsset.Textures.Values) | 399 | foreach (UUID uuid in wearableAsset.Textures.Values) |
391 | { | 400 | { |
392 | assetUuids[uuid] = AssetType.Texture; | 401 | assetUuids[uuid] = (sbyte)AssetType.Texture; |
393 | } | 402 | } |
394 | } | 403 | } |
395 | } | 404 | } |
@@ -401,7 +410,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
401 | /// </summary> | 410 | /// </summary> |
402 | /// <param name="sceneObject"></param> | 411 | /// <param name="sceneObject"></param> |
403 | /// <param name="assetUuids"></param> | 412 | /// <param name="assetUuids"></param> |
404 | private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) | 413 | private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, sbyte> assetUuids) |
405 | { | 414 | { |
406 | AssetBase objectAsset = GetAsset(sceneObjectUuid); | 415 | AssetBase objectAsset = GetAsset(sceneObjectUuid); |
407 | 416 | ||
@@ -430,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
430 | /// </summary> | 439 | /// </summary> |
431 | /// <param name="gestureUuid"></param> | 440 | /// <param name="gestureUuid"></param> |
432 | /// <param name="assetUuids"></param> | 441 | /// <param name="assetUuids"></param> |
433 | private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) | 442 | private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, sbyte> assetUuids) |
434 | { | 443 | { |
435 | AssetBase assetBase = GetAsset(gestureUuid); | 444 | AssetBase assetBase = GetAsset(gestureUuid); |
436 | if (null == assetBase) | 445 | if (null == assetBase) |
@@ -464,9 +473,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
464 | // If it can be parsed as a UUID, it is an asset ID | 473 | // If it can be parsed as a UUID, it is an asset ID |
465 | UUID uuid; | 474 | UUID uuid; |
466 | if (UUID.TryParse(id, out uuid)) | 475 | if (UUID.TryParse(id, out uuid)) |
467 | assetUuids[uuid] = AssetType.Animation; | 476 | assetUuids[uuid] = (sbyte)AssetType.Animation; |
468 | } | 477 | } |
469 | } | 478 | } |
479 | |||
480 | /// <summary> | ||
481 | /// Get the asset uuid's referenced in a material. | ||
482 | /// </summary> | ||
483 | private void GetMaterialAssetUuids(UUID materialUuid, IDictionary<UUID, sbyte> assetUuids) | ||
484 | { | ||
485 | AssetBase assetBase = GetAsset(materialUuid); | ||
486 | if (null == assetBase) | ||
487 | return; | ||
488 | |||
489 | OSDMap mat = (OSDMap)OSDParser.DeserializeLLSDXml(assetBase.Data); | ||
490 | |||
491 | UUID normMap = mat["NormMap"].AsUUID(); | ||
492 | if (normMap != UUID.Zero) | ||
493 | assetUuids[normMap] = (sbyte)AssetType.Texture; | ||
494 | |||
495 | UUID specMap = mat["SpecMap"].AsUUID(); | ||
496 | if (specMap != UUID.Zero) | ||
497 | assetUuids[specMap] = (sbyte)AssetType.Texture; | ||
498 | } | ||
470 | } | 499 | } |
471 | 500 | ||
472 | public class HGUuidGatherer : UuidGatherer | 501 | public class HGUuidGatherer : UuidGatherer |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index a4fc4ae..b3fdd22 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -908,7 +908,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
908 | // Mimicking LLClientView which gets always set appearance from client. | 908 | // Mimicking LLClientView which gets always set appearance from client. |
909 | AvatarAppearance appearance; | 909 | AvatarAppearance appearance; |
910 | m_scene.GetAvatarAppearance(this, out appearance); | 910 | m_scene.GetAvatarAppearance(this, out appearance); |
911 | OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(), new List<CachedTextureRequestArg>()); | 911 | OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(),appearance.AvatarSize, new WearableCacheItem[0]); |
912 | } | 912 | } |
913 | 913 | ||
914 | public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) | 914 | public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) |
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs deleted file mode 100644 index d8f5563..0000000 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ /dev/null | |||
@@ -1,657 +0,0 @@ | |||
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 | using System.Security.Cryptography; // for computing md5 hash | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using Nini.Config; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | |||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | |||
46 | using Ionic.Zlib; | ||
47 | |||
48 | // You will need to uncomment these lines if you are adding a region module to some other assembly which does not already | ||
49 | // specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans | ||
50 | // the available DLLs | ||
51 | //[assembly: Addin("MaterialsDemoModule", "1.0")] | ||
52 | //[assembly: AddinDependency("OpenSim", "0.5")] | ||
53 | |||
54 | namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | ||
55 | { | ||
56 | /// <summary> | ||
57 | /// | ||
58 | // # # ## ##### # # # # # #### | ||
59 | // # # # # # # ## # # ## # # # | ||
60 | // # # # # # # # # # # # # # # | ||
61 | // # ## # ###### ##### # # # # # # # # ### | ||
62 | // ## ## # # # # # ## # # ## # # | ||
63 | // # # # # # # # # # # # #### | ||
64 | // | ||
65 | // THIS MODULE IS FOR EXPERIMENTAL USE ONLY AND MAY CAUSE REGION OR ASSET CORRUPTION! | ||
66 | // | ||
67 | ////////////// WARNING ////////////////////////////////////////////////////////////////// | ||
68 | /// This is an *Experimental* module for developing support for materials-capable viewers | ||
69 | /// This module should NOT be used in a production environment! It may cause data corruption and | ||
70 | /// viewer crashes. It should be only used to evaluate implementations of materials. | ||
71 | /// | ||
72 | /// Materials are persisted via SceneObjectPart.dynattrs. This is a relatively new feature | ||
73 | /// of OpenSimulator and is not field proven at the time this module was written. Persistence | ||
74 | /// may fail or become corrupt and this could cause viewer crashes due to erroneous materials | ||
75 | /// data being sent to viewers. Materials descriptions might survive IAR, OAR, or other means | ||
76 | /// of archiving however the texture resources used by these materials probably will not as they | ||
77 | /// may not be adequately referenced to ensure proper archiving. | ||
78 | /// | ||
79 | /// | ||
80 | /// | ||
81 | /// To enable this module, add this string at the bottom of OpenSim.ini: | ||
82 | /// [MaterialsDemoModule] | ||
83 | /// | ||
84 | /// </summary> | ||
85 | /// | ||
86 | |||
87 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsDemoModule")] | ||
88 | public class MaterialsDemoModule : INonSharedRegionModule | ||
89 | { | ||
90 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
91 | |||
92 | public string Name { get { return "MaterialsDemoModule"; } } | ||
93 | |||
94 | public Type ReplaceableInterface { get { return null; } } | ||
95 | |||
96 | private Scene m_scene = null; | ||
97 | private bool m_enabled = false; | ||
98 | |||
99 | public Dictionary<UUID, OSDMap> m_knownMaterials = new Dictionary<UUID, OSDMap>(); | ||
100 | |||
101 | public void Initialise(IConfigSource source) | ||
102 | { | ||
103 | m_enabled = (source.Configs["MaterialsDemoModule"] != null); | ||
104 | if (!m_enabled) | ||
105 | return; | ||
106 | |||
107 | m_log.DebugFormat("[MaterialsDemoModule]: INITIALIZED MODULE"); | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | if (!m_enabled) | ||
113 | return; | ||
114 | |||
115 | m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); | ||
116 | } | ||
117 | |||
118 | public void AddRegion(Scene scene) | ||
119 | { | ||
120 | if (!m_enabled) | ||
121 | return; | ||
122 | |||
123 | m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
124 | |||
125 | m_scene = scene; | ||
126 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
127 | m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; | ||
128 | // m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; | ||
129 | } | ||
130 | |||
131 | void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) | ||
132 | { | ||
133 | foreach (var part in obj.Parts) | ||
134 | if (part != null) | ||
135 | GetStoredMaterialsForPart(part); | ||
136 | } | ||
137 | |||
138 | void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) | ||
139 | { | ||
140 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
141 | |||
142 | IRequestHandler renderMaterialsPostHandler | ||
143 | = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); | ||
144 | caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); | ||
145 | |||
146 | // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET | ||
147 | // and POST handlers, (at least at the time this was originally written), so we first set up a POST | ||
148 | // handler normally and then add a GET handler via MainServer | ||
149 | |||
150 | IRequestHandler renderMaterialsGetHandler | ||
151 | = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null); | ||
152 | MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); | ||
153 | |||
154 | // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well | ||
155 | IRequestHandler renderMaterialsPutHandler | ||
156 | = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); | ||
157 | MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); | ||
158 | } | ||
159 | |||
160 | public void RemoveRegion(Scene scene) | ||
161 | { | ||
162 | if (!m_enabled) | ||
163 | return; | ||
164 | |||
165 | m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | ||
166 | m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; | ||
167 | // m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; | ||
168 | |||
169 | m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
170 | } | ||
171 | |||
172 | public void RegionLoaded(Scene scene) | ||
173 | { | ||
174 | } | ||
175 | |||
176 | OSDMap GetMaterial(UUID id) | ||
177 | { | ||
178 | OSDMap map = null; | ||
179 | lock (m_knownMaterials) | ||
180 | { | ||
181 | if (m_knownMaterials.ContainsKey(id)) | ||
182 | { | ||
183 | map = new OSDMap(); | ||
184 | map["ID"] = OSD.FromBinary(id.GetBytes()); | ||
185 | map["Material"] = m_knownMaterials[id]; | ||
186 | } | ||
187 | } | ||
188 | return map; | ||
189 | } | ||
190 | |||
191 | void GetStoredMaterialsForPart(SceneObjectPart part) | ||
192 | { | ||
193 | OSD OSMaterials = null; | ||
194 | OSDArray matsArr = null; | ||
195 | |||
196 | if (part.DynAttrs == null) | ||
197 | { | ||
198 | m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); | ||
199 | } | ||
200 | |||
201 | lock (part.DynAttrs) | ||
202 | { | ||
203 | if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) | ||
204 | { | ||
205 | OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); | ||
206 | |||
207 | if (materialsStore == null) | ||
208 | return; | ||
209 | |||
210 | materialsStore.TryGetValue("Materials", out OSMaterials); | ||
211 | } | ||
212 | |||
213 | if (OSMaterials != null && OSMaterials is OSDArray) | ||
214 | matsArr = OSMaterials as OSDArray; | ||
215 | else | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); | ||
220 | |||
221 | if (matsArr == null) | ||
222 | { | ||
223 | m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); | ||
224 | return; | ||
225 | } | ||
226 | |||
227 | foreach (OSD elemOsd in matsArr) | ||
228 | { | ||
229 | if (elemOsd != null && elemOsd is OSDMap) | ||
230 | { | ||
231 | OSDMap matMap = elemOsd as OSDMap; | ||
232 | if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) | ||
233 | { | ||
234 | try | ||
235 | { | ||
236 | lock (m_knownMaterials) | ||
237 | m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; | ||
238 | } | ||
239 | catch (Exception e) | ||
240 | { | ||
241 | m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material: " + e.ToString()); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | |||
248 | void StoreMaterialsForPart(SceneObjectPart part) | ||
249 | { | ||
250 | try | ||
251 | { | ||
252 | if (part == null || part.Shape == null) | ||
253 | return; | ||
254 | |||
255 | Dictionary<UUID, OSDMap> mats = new Dictionary<UUID, OSDMap>(); | ||
256 | |||
257 | Primitive.TextureEntry te = part.Shape.Textures; | ||
258 | |||
259 | if (te.DefaultTexture != null) | ||
260 | { | ||
261 | lock (m_knownMaterials) | ||
262 | { | ||
263 | if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) | ||
264 | mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | if (te.FaceTextures != null) | ||
269 | { | ||
270 | foreach (var face in te.FaceTextures) | ||
271 | { | ||
272 | if (face != null) | ||
273 | { | ||
274 | lock (m_knownMaterials) | ||
275 | { | ||
276 | if (m_knownMaterials.ContainsKey(face.MaterialID)) | ||
277 | mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | if (mats.Count == 0) | ||
283 | return; | ||
284 | |||
285 | OSDArray matsArr = new OSDArray(); | ||
286 | foreach (KeyValuePair<UUID, OSDMap> kvp in mats) | ||
287 | { | ||
288 | OSDMap matOsd = new OSDMap(); | ||
289 | matOsd["ID"] = OSD.FromUUID(kvp.Key); | ||
290 | matOsd["Material"] = kvp.Value; | ||
291 | matsArr.Add(matOsd); | ||
292 | } | ||
293 | |||
294 | OSDMap OSMaterials = new OSDMap(); | ||
295 | OSMaterials["Materials"] = matsArr; | ||
296 | |||
297 | lock (part.DynAttrs) | ||
298 | part.DynAttrs.SetStore("OpenSim", "Materials", OSMaterials); | ||
299 | } | ||
300 | catch (Exception e) | ||
301 | { | ||
302 | m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart(): " + e.ToString()); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | public string RenderMaterialsPostCap(string request, string path, | ||
307 | string param, IOSHttpRequest httpRequest, | ||
308 | IOSHttpResponse httpResponse) | ||
309 | { | ||
310 | m_log.Debug("[MaterialsDemoModule]: POST cap handler"); | ||
311 | |||
312 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
313 | OSDMap resp = new OSDMap(); | ||
314 | |||
315 | OSDMap materialsFromViewer = null; | ||
316 | |||
317 | OSDArray respArr = new OSDArray(); | ||
318 | |||
319 | if (req.ContainsKey("Zipped")) | ||
320 | { | ||
321 | OSD osd = null; | ||
322 | |||
323 | byte[] inBytes = req["Zipped"].AsBinary(); | ||
324 | |||
325 | try | ||
326 | { | ||
327 | osd = ZDecompressBytesToOsd(inBytes); | ||
328 | |||
329 | if (osd != null) | ||
330 | { | ||
331 | if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries | ||
332 | { | ||
333 | foreach (OSD elem in (OSDArray)osd) | ||
334 | { | ||
335 | |||
336 | try | ||
337 | { | ||
338 | UUID id = new UUID(elem.AsBinary(), 0); | ||
339 | |||
340 | lock (m_knownMaterials) | ||
341 | { | ||
342 | if (m_knownMaterials.ContainsKey(id)) | ||
343 | { | ||
344 | m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); | ||
345 | OSDMap matMap = new OSDMap(); | ||
346 | matMap["ID"] = OSD.FromBinary(id.GetBytes()); | ||
347 | |||
348 | matMap["Material"] = m_knownMaterials[id]; | ||
349 | respArr.Add(matMap); | ||
350 | } | ||
351 | else | ||
352 | m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); | ||
353 | } | ||
354 | } | ||
355 | catch (Exception e) | ||
356 | { | ||
357 | // report something here? | ||
358 | continue; | ||
359 | } | ||
360 | } | ||
361 | } | ||
362 | else if (osd is OSDMap) // reqest to assign a material | ||
363 | { | ||
364 | materialsFromViewer = osd as OSDMap; | ||
365 | |||
366 | if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) | ||
367 | { | ||
368 | OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; | ||
369 | if (matsOsd is OSDArray) | ||
370 | { | ||
371 | OSDArray matsArr = matsOsd as OSDArray; | ||
372 | |||
373 | try | ||
374 | { | ||
375 | foreach (OSDMap matsMap in matsArr) | ||
376 | { | ||
377 | m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); | ||
378 | |||
379 | uint matLocalID = 0; | ||
380 | try { matLocalID = matsMap["ID"].AsUInteger(); } | ||
381 | catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } | ||
382 | m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString()); | ||
383 | |||
384 | |||
385 | OSDMap mat = null; | ||
386 | try { mat = matsMap["Material"] as OSDMap; } | ||
387 | catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } | ||
388 | m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); | ||
389 | |||
390 | UUID id = HashOsd(mat); | ||
391 | lock (m_knownMaterials) | ||
392 | m_knownMaterials[id] = mat; | ||
393 | |||
394 | |||
395 | var sop = m_scene.GetSceneObjectPart(matLocalID); | ||
396 | if (sop == null) | ||
397 | m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); | ||
398 | else | ||
399 | { | ||
400 | var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); | ||
401 | |||
402 | if (te == null) | ||
403 | { | ||
404 | m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString()); | ||
405 | } | ||
406 | else | ||
407 | { | ||
408 | int face = -1; | ||
409 | |||
410 | if (matsMap.ContainsKey("Face")) | ||
411 | { | ||
412 | face = matsMap["Face"].AsInteger(); | ||
413 | if (te.FaceTextures == null) // && face == 0) | ||
414 | { | ||
415 | if (te.DefaultTexture == null) | ||
416 | m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); | ||
417 | else | ||
418 | te.DefaultTexture.MaterialID = id; | ||
419 | } | ||
420 | else | ||
421 | { | ||
422 | if (te.FaceTextures.Length >= face - 1) | ||
423 | { | ||
424 | if (te.FaceTextures[face] == null) | ||
425 | te.DefaultTexture.MaterialID = id; | ||
426 | else | ||
427 | te.FaceTextures[face].MaterialID = id; | ||
428 | } | ||
429 | } | ||
430 | } | ||
431 | else | ||
432 | { | ||
433 | if (te.DefaultTexture != null) | ||
434 | te.DefaultTexture.MaterialID = id; | ||
435 | } | ||
436 | |||
437 | m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString()); | ||
438 | |||
439 | //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually | ||
440 | |||
441 | if (sop.ParentGroup != null) | ||
442 | { | ||
443 | sop.Shape.TextureEntry = te.GetBytes(); | ||
444 | sop.TriggerScriptChangedEvent(Changed.TEXTURE); | ||
445 | sop.UpdateFlag = UpdateRequired.FULL; | ||
446 | sop.ParentGroup.HasGroupChanged = true; | ||
447 | |||
448 | sop.ScheduleFullUpdate(); | ||
449 | |||
450 | StoreMaterialsForPart(sop); | ||
451 | } | ||
452 | } | ||
453 | } | ||
454 | } | ||
455 | } | ||
456 | catch (Exception e) | ||
457 | { | ||
458 | m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message); | ||
459 | } | ||
460 | } | ||
461 | } | ||
462 | } | ||
463 | } | ||
464 | |||
465 | } | ||
466 | catch (Exception e) | ||
467 | { | ||
468 | m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message); | ||
469 | //return ""; | ||
470 | } | ||
471 | m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); | ||
472 | } | ||
473 | |||
474 | |||
475 | resp["Zipped"] = ZCompressOSD(respArr, false); | ||
476 | string response = OSDParser.SerializeLLSDXmlString(resp); | ||
477 | |||
478 | //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); | ||
479 | m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); | ||
480 | m_log.Debug("[MaterialsDemoModule]: cap response: " + response); | ||
481 | return response; | ||
482 | } | ||
483 | |||
484 | |||
485 | public string RenderMaterialsGetCap(string request, string path, | ||
486 | string param, IOSHttpRequest httpRequest, | ||
487 | IOSHttpResponse httpResponse) | ||
488 | { | ||
489 | m_log.Debug("[MaterialsDemoModule]: GET cap handler"); | ||
490 | |||
491 | OSDMap resp = new OSDMap(); | ||
492 | int matsCount = 0; | ||
493 | OSDArray allOsd = new OSDArray(); | ||
494 | |||
495 | lock (m_knownMaterials) | ||
496 | { | ||
497 | foreach (KeyValuePair<UUID, OSDMap> kvp in m_knownMaterials) | ||
498 | { | ||
499 | OSDMap matMap = new OSDMap(); | ||
500 | |||
501 | matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); | ||
502 | matMap["Material"] = kvp.Value; | ||
503 | allOsd.Add(matMap); | ||
504 | matsCount++; | ||
505 | } | ||
506 | } | ||
507 | |||
508 | resp["Zipped"] = ZCompressOSD(allOsd, false); | ||
509 | m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); | ||
510 | |||
511 | return OSDParser.SerializeLLSDXmlString(resp); | ||
512 | } | ||
513 | |||
514 | static string ZippedOsdBytesToString(byte[] bytes) | ||
515 | { | ||
516 | try | ||
517 | { | ||
518 | return OSDParser.SerializeJsonString(ZDecompressBytesToOsd(bytes)); | ||
519 | } | ||
520 | catch (Exception e) | ||
521 | { | ||
522 | return "ZippedOsdBytesToString caught an exception: " + e.ToString(); | ||
523 | } | ||
524 | } | ||
525 | |||
526 | /// <summary> | ||
527 | /// computes a UUID by hashing a OSD object | ||
528 | /// </summary> | ||
529 | /// <param name="osd"></param> | ||
530 | /// <returns></returns> | ||
531 | private static UUID HashOsd(OSD osd) | ||
532 | { | ||
533 | using (var md5 = MD5.Create()) | ||
534 | using (MemoryStream ms = new MemoryStream(OSDParser.SerializeLLSDBinary(osd, false))) | ||
535 | return new UUID(md5.ComputeHash(ms), 0); | ||
536 | } | ||
537 | |||
538 | public static OSD ZCompressOSD(OSD inOsd, bool useHeader) | ||
539 | { | ||
540 | OSD osd = null; | ||
541 | |||
542 | using (MemoryStream msSinkCompressed = new MemoryStream()) | ||
543 | { | ||
544 | using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, | ||
545 | Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) | ||
546 | { | ||
547 | CopyStream(new MemoryStream(OSDParser.SerializeLLSDBinary(inOsd, useHeader)), zOut); | ||
548 | zOut.Close(); | ||
549 | } | ||
550 | |||
551 | msSinkCompressed.Seek(0L, SeekOrigin.Begin); | ||
552 | osd = OSD.FromBinary( msSinkCompressed.ToArray()); | ||
553 | } | ||
554 | |||
555 | return osd; | ||
556 | } | ||
557 | |||
558 | |||
559 | public static OSD ZDecompressBytesToOsd(byte[] input) | ||
560 | { | ||
561 | OSD osd = null; | ||
562 | |||
563 | using (MemoryStream msSinkUnCompressed = new MemoryStream()) | ||
564 | { | ||
565 | using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true)) | ||
566 | { | ||
567 | CopyStream(new MemoryStream(input), zOut); | ||
568 | zOut.Close(); | ||
569 | } | ||
570 | msSinkUnCompressed.Seek(0L, SeekOrigin.Begin); | ||
571 | osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray()); | ||
572 | } | ||
573 | |||
574 | return osd; | ||
575 | } | ||
576 | |||
577 | static void CopyStream(System.IO.Stream input, System.IO.Stream output) | ||
578 | { | ||
579 | byte[] buffer = new byte[2048]; | ||
580 | int len; | ||
581 | while ((len = input.Read(buffer, 0, 2048)) > 0) | ||
582 | { | ||
583 | output.Write(buffer, 0, len); | ||
584 | } | ||
585 | |||
586 | output.Flush(); | ||
587 | } | ||
588 | |||
589 | // FIXME: This code is currently still in UuidGatherer since we cannot use Scene.EventManager as some | ||
590 | // calls to the gatherer are done for objects with no scene. | ||
591 | // /// <summary> | ||
592 | // /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps | ||
593 | // /// </summary> | ||
594 | // /// <param name="part"></param> | ||
595 | // /// <param name="assetUuids"></param> | ||
596 | // private void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) | ||
597 | // { | ||
598 | // // scan thru the dynAttrs map of this part for any textures used as materials | ||
599 | // OSD osdMaterials = null; | ||
600 | // | ||
601 | // lock (part.DynAttrs) | ||
602 | // { | ||
603 | // if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) | ||
604 | // { | ||
605 | // OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); | ||
606 | // if (materialsStore == null) | ||
607 | // return; | ||
608 | // | ||
609 | // materialsStore.TryGetValue("Materials", out osdMaterials); | ||
610 | // } | ||
611 | // | ||
612 | // if (osdMaterials != null) | ||
613 | // { | ||
614 | // //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); | ||
615 | // | ||
616 | // if (osdMaterials is OSDArray) | ||
617 | // { | ||
618 | // OSDArray matsArr = osdMaterials as OSDArray; | ||
619 | // foreach (OSDMap matMap in matsArr) | ||
620 | // { | ||
621 | // try | ||
622 | // { | ||
623 | // if (matMap.ContainsKey("Material")) | ||
624 | // { | ||
625 | // OSDMap mat = matMap["Material"] as OSDMap; | ||
626 | // if (mat.ContainsKey("NormMap")) | ||
627 | // { | ||
628 | // UUID normalMapId = mat["NormMap"].AsUUID(); | ||
629 | // if (normalMapId != UUID.Zero) | ||
630 | // { | ||
631 | // assetUuids[normalMapId] = AssetType.Texture; | ||
632 | // //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); | ||
633 | // } | ||
634 | // } | ||
635 | // if (mat.ContainsKey("SpecMap")) | ||
636 | // { | ||
637 | // UUID specularMapId = mat["SpecMap"].AsUUID(); | ||
638 | // if (specularMapId != UUID.Zero) | ||
639 | // { | ||
640 | // assetUuids[specularMapId] = AssetType.Texture; | ||
641 | // //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); | ||
642 | // } | ||
643 | // } | ||
644 | // } | ||
645 | // | ||
646 | // } | ||
647 | // catch (Exception e) | ||
648 | // { | ||
649 | // m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); | ||
650 | // } | ||
651 | // } | ||
652 | // } | ||
653 | // } | ||
654 | // } | ||
655 | // } | ||
656 | } | ||
657 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs new file mode 100644 index 0000000..afb788b --- /dev/null +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs | |||
@@ -0,0 +1,590 @@ | |||
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 | using System.Security.Cryptography; // for computing md5 hash | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using Nini.Config; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | |||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; | ||
46 | |||
47 | using Ionic.Zlib; | ||
48 | |||
49 | // You will need to uncomment these lines if you are adding a region module to some other assembly which does not already | ||
50 | // specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans | ||
51 | // the available DLLs | ||
52 | //[assembly: Addin("MaterialsModule", "1.0")] | ||
53 | //[assembly: AddinDependency("OpenSim", "0.5")] | ||
54 | |||
55 | namespace OpenSim.Region.OptionalModules.Materials | ||
56 | { | ||
57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsModule")] | ||
58 | public class MaterialsModule : INonSharedRegionModule | ||
59 | { | ||
60 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
61 | |||
62 | public string Name { get { return "MaterialsModule"; } } | ||
63 | |||
64 | public Type ReplaceableInterface { get { return null; } } | ||
65 | |||
66 | private Scene m_scene = null; | ||
67 | private bool m_enabled = false; | ||
68 | |||
69 | public Dictionary<UUID, OSDMap> m_regionMaterials = new Dictionary<UUID, OSDMap>(); | ||
70 | |||
71 | public void Initialise(IConfigSource source) | ||
72 | { | ||
73 | IConfig config = source.Configs["Materials"]; | ||
74 | if (config == null) | ||
75 | return; | ||
76 | |||
77 | m_enabled = config.GetBoolean("enable_materials", true); | ||
78 | if (!m_enabled) | ||
79 | return; | ||
80 | |||
81 | m_log.DebugFormat("[Materials]: Initialized"); | ||
82 | } | ||
83 | |||
84 | public void Close() | ||
85 | { | ||
86 | if (!m_enabled) | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | public void AddRegion(Scene scene) | ||
91 | { | ||
92 | if (!m_enabled) | ||
93 | return; | ||
94 | |||
95 | m_scene = scene; | ||
96 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
97 | m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; | ||
98 | } | ||
99 | |||
100 | private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) | ||
101 | { | ||
102 | foreach (var part in obj.Parts) | ||
103 | if (part != null) | ||
104 | GetStoredMaterialsInPart(part); | ||
105 | } | ||
106 | |||
107 | private void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) | ||
108 | { | ||
109 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
110 | |||
111 | IRequestHandler renderMaterialsPostHandler | ||
112 | = new RestStreamHandler("POST", capsBase + "/", | ||
113 | (request, path, param, httpRequest, httpResponse) | ||
114 | => RenderMaterialsPostCap(request, agentID), | ||
115 | "RenderMaterials", null); | ||
116 | caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); | ||
117 | |||
118 | // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET | ||
119 | // and POST handlers, (at least at the time this was originally written), so we first set up a POST | ||
120 | // handler normally and then add a GET handler via MainServer | ||
121 | |||
122 | IRequestHandler renderMaterialsGetHandler | ||
123 | = new RestStreamHandler("GET", capsBase + "/", | ||
124 | (request, path, param, httpRequest, httpResponse) | ||
125 | => RenderMaterialsGetCap(request), | ||
126 | "RenderMaterials", null); | ||
127 | MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); | ||
128 | |||
129 | // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well | ||
130 | IRequestHandler renderMaterialsPutHandler | ||
131 | = new RestStreamHandler("PUT", capsBase + "/", | ||
132 | (request, path, param, httpRequest, httpResponse) | ||
133 | => RenderMaterialsPostCap(request, agentID), | ||
134 | "RenderMaterials", null); | ||
135 | MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); | ||
136 | } | ||
137 | |||
138 | public void RemoveRegion(Scene scene) | ||
139 | { | ||
140 | if (!m_enabled) | ||
141 | return; | ||
142 | |||
143 | m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | ||
144 | m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; | ||
145 | } | ||
146 | |||
147 | public void RegionLoaded(Scene scene) | ||
148 | { | ||
149 | } | ||
150 | |||
151 | /// <summary> | ||
152 | /// Finds any legacy materials stored in DynAttrs that may exist for this part and add them to 'm_regionMaterials'. | ||
153 | /// </summary> | ||
154 | /// <param name="part"></param> | ||
155 | private void GetLegacyStoredMaterialsInPart(SceneObjectPart part) | ||
156 | { | ||
157 | if (part.DynAttrs == null) | ||
158 | return; | ||
159 | |||
160 | OSD OSMaterials = null; | ||
161 | OSDArray matsArr = null; | ||
162 | |||
163 | lock (part.DynAttrs) | ||
164 | { | ||
165 | if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) | ||
166 | { | ||
167 | OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); | ||
168 | |||
169 | if (materialsStore == null) | ||
170 | return; | ||
171 | |||
172 | materialsStore.TryGetValue("Materials", out OSMaterials); | ||
173 | } | ||
174 | |||
175 | if (OSMaterials != null && OSMaterials is OSDArray) | ||
176 | matsArr = OSMaterials as OSDArray; | ||
177 | else | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | if (matsArr == null) | ||
182 | return; | ||
183 | |||
184 | foreach (OSD elemOsd in matsArr) | ||
185 | { | ||
186 | if (elemOsd != null && elemOsd is OSDMap) | ||
187 | { | ||
188 | OSDMap matMap = elemOsd as OSDMap; | ||
189 | if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) | ||
190 | { | ||
191 | try | ||
192 | { | ||
193 | lock (m_regionMaterials) | ||
194 | m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; | ||
195 | } | ||
196 | catch (Exception e) | ||
197 | { | ||
198 | m_log.Warn("[Materials]: exception decoding persisted legacy material: " + e.ToString()); | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | |||
205 | /// <summary> | ||
206 | /// Find the materials used in the SOP, and add them to 'm_regionMaterials'. | ||
207 | /// </summary> | ||
208 | private void GetStoredMaterialsInPart(SceneObjectPart part) | ||
209 | { | ||
210 | if (part.Shape == null) | ||
211 | return; | ||
212 | |||
213 | var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); | ||
214 | if (te == null) | ||
215 | return; | ||
216 | |||
217 | GetLegacyStoredMaterialsInPart(part); | ||
218 | |||
219 | GetStoredMaterialInFace(part, te.DefaultTexture); | ||
220 | |||
221 | foreach (Primitive.TextureEntryFace face in te.FaceTextures) | ||
222 | { | ||
223 | if (face != null) | ||
224 | GetStoredMaterialInFace(part, face); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | /// <summary> | ||
229 | /// Find the materials used in one Face, and add them to 'm_regionMaterials'. | ||
230 | /// </summary> | ||
231 | private void GetStoredMaterialInFace(SceneObjectPart part, Primitive.TextureEntryFace face) | ||
232 | { | ||
233 | UUID id = face.MaterialID; | ||
234 | if (id == UUID.Zero) | ||
235 | return; | ||
236 | |||
237 | lock (m_regionMaterials) | ||
238 | { | ||
239 | if (m_regionMaterials.ContainsKey(id)) | ||
240 | return; | ||
241 | |||
242 | byte[] data = m_scene.AssetService.GetData(id.ToString()); | ||
243 | if (data == null) | ||
244 | { | ||
245 | m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id); | ||
246 | return; | ||
247 | } | ||
248 | |||
249 | OSDMap mat; | ||
250 | try | ||
251 | { | ||
252 | mat = (OSDMap)OSDParser.DeserializeLLSDXml(data); | ||
253 | } | ||
254 | catch (Exception e) | ||
255 | { | ||
256 | m_log.WarnFormat("[Materials]: cannot decode material asset {0}: {1}", id, e.Message); | ||
257 | return; | ||
258 | } | ||
259 | |||
260 | m_regionMaterials[id] = mat; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | public string RenderMaterialsPostCap(string request, UUID agentID) | ||
265 | { | ||
266 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
267 | OSDMap resp = new OSDMap(); | ||
268 | |||
269 | OSDMap materialsFromViewer = null; | ||
270 | |||
271 | OSDArray respArr = new OSDArray(); | ||
272 | |||
273 | if (req.ContainsKey("Zipped")) | ||
274 | { | ||
275 | OSD osd = null; | ||
276 | |||
277 | byte[] inBytes = req["Zipped"].AsBinary(); | ||
278 | |||
279 | try | ||
280 | { | ||
281 | osd = ZDecompressBytesToOsd(inBytes); | ||
282 | |||
283 | if (osd != null) | ||
284 | { | ||
285 | if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries | ||
286 | { | ||
287 | foreach (OSD elem in (OSDArray)osd) | ||
288 | { | ||
289 | try | ||
290 | { | ||
291 | UUID id = new UUID(elem.AsBinary(), 0); | ||
292 | |||
293 | lock (m_regionMaterials) | ||
294 | { | ||
295 | if (m_regionMaterials.ContainsKey(id)) | ||
296 | { | ||
297 | OSDMap matMap = new OSDMap(); | ||
298 | matMap["ID"] = OSD.FromBinary(id.GetBytes()); | ||
299 | matMap["Material"] = m_regionMaterials[id]; | ||
300 | respArr.Add(matMap); | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString()); | ||
305 | |||
306 | // Theoretically we could try to load the material from the assets service, | ||
307 | // but that shouldn't be necessary because the viewer should only request | ||
308 | // materials that exist in a prim on the region, and all of these materials | ||
309 | // are already stored in m_regionMaterials. | ||
310 | } | ||
311 | } | ||
312 | } | ||
313 | catch (Exception e) | ||
314 | { | ||
315 | m_log.Error("Error getting materials in response to viewer request", e); | ||
316 | continue; | ||
317 | } | ||
318 | } | ||
319 | } | ||
320 | else if (osd is OSDMap) // request to assign a material | ||
321 | { | ||
322 | materialsFromViewer = osd as OSDMap; | ||
323 | |||
324 | if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) | ||
325 | { | ||
326 | OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; | ||
327 | if (matsOsd is OSDArray) | ||
328 | { | ||
329 | OSDArray matsArr = matsOsd as OSDArray; | ||
330 | |||
331 | try | ||
332 | { | ||
333 | foreach (OSDMap matsMap in matsArr) | ||
334 | { | ||
335 | uint primLocalID = 0; | ||
336 | try { | ||
337 | primLocalID = matsMap["ID"].AsUInteger(); | ||
338 | } | ||
339 | catch (Exception e) { | ||
340 | m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); | ||
341 | continue; | ||
342 | } | ||
343 | |||
344 | OSDMap mat = null; | ||
345 | try | ||
346 | { | ||
347 | mat = matsMap["Material"] as OSDMap; | ||
348 | } | ||
349 | catch (Exception e) | ||
350 | { | ||
351 | m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message); | ||
352 | continue; | ||
353 | } | ||
354 | |||
355 | SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); | ||
356 | if (sop == null) | ||
357 | { | ||
358 | m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); | ||
359 | continue; | ||
360 | } | ||
361 | |||
362 | if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) | ||
363 | { | ||
364 | m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); | ||
365 | continue; | ||
366 | } | ||
367 | |||
368 | Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); | ||
369 | if (te == null) | ||
370 | { | ||
371 | m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); | ||
372 | continue; | ||
373 | } | ||
374 | |||
375 | |||
376 | UUID id; | ||
377 | if (mat == null) | ||
378 | { | ||
379 | // This happens then the user removes a material from a prim | ||
380 | id = UUID.Zero; | ||
381 | } | ||
382 | else | ||
383 | { | ||
384 | id = StoreMaterialAsAsset(agentID, mat, sop); | ||
385 | } | ||
386 | |||
387 | |||
388 | int face = -1; | ||
389 | |||
390 | if (matsMap.ContainsKey("Face")) | ||
391 | { | ||
392 | face = matsMap["Face"].AsInteger(); | ||
393 | Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face); | ||
394 | faceEntry.MaterialID = id; | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | if (te.DefaultTexture == null) | ||
399 | m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID); | ||
400 | else | ||
401 | te.DefaultTexture.MaterialID = id; | ||
402 | } | ||
403 | |||
404 | //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); | ||
405 | |||
406 | // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually | ||
407 | sop.Shape.TextureEntry = te.GetBytes(); | ||
408 | |||
409 | if (sop.ParentGroup != null) | ||
410 | { | ||
411 | sop.TriggerScriptChangedEvent(Changed.TEXTURE); | ||
412 | sop.UpdateFlag = UpdateRequired.FULL; | ||
413 | sop.ParentGroup.HasGroupChanged = true; | ||
414 | sop.ScheduleFullUpdate(); | ||
415 | } | ||
416 | } | ||
417 | } | ||
418 | catch (Exception e) | ||
419 | { | ||
420 | m_log.Warn("[Materials]: exception processing received material ", e); | ||
421 | } | ||
422 | } | ||
423 | } | ||
424 | } | ||
425 | } | ||
426 | |||
427 | } | ||
428 | catch (Exception e) | ||
429 | { | ||
430 | m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e); | ||
431 | //return ""; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | |||
436 | resp["Zipped"] = ZCompressOSD(respArr, false); | ||
437 | string response = OSDParser.SerializeLLSDXmlString(resp); | ||
438 | |||
439 | //m_log.Debug("[Materials]: cap request: " + request); | ||
440 | //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); | ||
441 | //m_log.Debug("[Materials]: cap response: " + response); | ||
442 | return response; | ||
443 | } | ||
444 | |||
445 | private UUID StoreMaterialAsAsset(UUID agentID, OSDMap mat, SceneObjectPart sop) | ||
446 | { | ||
447 | UUID id; | ||
448 | // Material UUID = hash of the material's data. | ||
449 | // This makes materials deduplicate across the entire grid (but isn't otherwise required). | ||
450 | byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat)); | ||
451 | using (var md5 = MD5.Create()) | ||
452 | id = new UUID(md5.ComputeHash(data), 0); | ||
453 | |||
454 | lock (m_regionMaterials) | ||
455 | { | ||
456 | if (!m_regionMaterials.ContainsKey(id)) | ||
457 | { | ||
458 | m_regionMaterials[id] = mat; | ||
459 | |||
460 | // This asset might exist already, but it's ok to try to store it again | ||
461 | string name = "Material " + ChooseMaterialName(mat, sop); | ||
462 | name = name.Substring(0, Math.Min(64, name.Length)).Trim(); | ||
463 | AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString()); | ||
464 | asset.Data = data; | ||
465 | m_scene.AssetService.Store(asset); | ||
466 | } | ||
467 | } | ||
468 | return id; | ||
469 | } | ||
470 | |||
471 | /// <summary> | ||
472 | /// Use heuristics to choose a good name for the material. | ||
473 | /// </summary> | ||
474 | private string ChooseMaterialName(OSDMap mat, SceneObjectPart sop) | ||
475 | { | ||
476 | UUID normMap = mat["NormMap"].AsUUID(); | ||
477 | if (normMap != UUID.Zero) | ||
478 | { | ||
479 | AssetBase asset = m_scene.AssetService.GetCached(normMap.ToString()); | ||
480 | if ((asset != null) && (asset.Name.Length > 0) && !asset.Name.Equals("From IAR")) | ||
481 | return asset.Name; | ||
482 | } | ||
483 | |||
484 | UUID specMap = mat["SpecMap"].AsUUID(); | ||
485 | if (specMap != UUID.Zero) | ||
486 | { | ||
487 | AssetBase asset = m_scene.AssetService.GetCached(specMap.ToString()); | ||
488 | if ((asset != null) && (asset.Name.Length > 0) && !asset.Name.Equals("From IAR")) | ||
489 | return asset.Name; | ||
490 | } | ||
491 | |||
492 | if (sop.Name != "Primitive") | ||
493 | return sop.Name; | ||
494 | |||
495 | if ((sop.ParentGroup != null) && (sop.ParentGroup.Name != "Primitive")) | ||
496 | return sop.ParentGroup.Name; | ||
497 | |||
498 | return ""; | ||
499 | } | ||
500 | |||
501 | |||
502 | public string RenderMaterialsGetCap(string request) | ||
503 | { | ||
504 | OSDMap resp = new OSDMap(); | ||
505 | int matsCount = 0; | ||
506 | OSDArray allOsd = new OSDArray(); | ||
507 | |||
508 | lock (m_regionMaterials) | ||
509 | { | ||
510 | foreach (KeyValuePair<UUID, OSDMap> kvp in m_regionMaterials) | ||
511 | { | ||
512 | OSDMap matMap = new OSDMap(); | ||
513 | |||
514 | matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); | ||
515 | matMap["Material"] = kvp.Value; | ||
516 | allOsd.Add(matMap); | ||
517 | matsCount++; | ||
518 | } | ||
519 | } | ||
520 | |||
521 | resp["Zipped"] = ZCompressOSD(allOsd, false); | ||
522 | |||
523 | return OSDParser.SerializeLLSDXmlString(resp); | ||
524 | } | ||
525 | |||
526 | private static string ZippedOsdBytesToString(byte[] bytes) | ||
527 | { | ||
528 | try | ||
529 | { | ||
530 | return OSDParser.SerializeJsonString(ZDecompressBytesToOsd(bytes)); | ||
531 | } | ||
532 | catch (Exception e) | ||
533 | { | ||
534 | return "ZippedOsdBytesToString caught an exception: " + e.ToString(); | ||
535 | } | ||
536 | } | ||
537 | |||
538 | /// <summary> | ||
539 | /// computes a UUID by hashing a OSD object | ||
540 | /// </summary> | ||
541 | /// <param name="osd"></param> | ||
542 | /// <returns></returns> | ||
543 | private static UUID HashOsd(OSD osd) | ||
544 | { | ||
545 | byte[] data = OSDParser.SerializeLLSDBinary(osd, false); | ||
546 | using (var md5 = MD5.Create()) | ||
547 | return new UUID(md5.ComputeHash(data), 0); | ||
548 | } | ||
549 | |||
550 | public static OSD ZCompressOSD(OSD inOsd, bool useHeader) | ||
551 | { | ||
552 | OSD osd = null; | ||
553 | |||
554 | byte[] data = OSDParser.SerializeLLSDBinary(inOsd, useHeader); | ||
555 | |||
556 | using (MemoryStream msSinkCompressed = new MemoryStream()) | ||
557 | { | ||
558 | using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, | ||
559 | Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) | ||
560 | { | ||
561 | zOut.Write(data, 0, data.Length); | ||
562 | } | ||
563 | |||
564 | msSinkCompressed.Seek(0L, SeekOrigin.Begin); | ||
565 | osd = OSD.FromBinary(msSinkCompressed.ToArray()); | ||
566 | } | ||
567 | |||
568 | return osd; | ||
569 | } | ||
570 | |||
571 | |||
572 | public static OSD ZDecompressBytesToOsd(byte[] input) | ||
573 | { | ||
574 | OSD osd = null; | ||
575 | |||
576 | using (MemoryStream msSinkUnCompressed = new MemoryStream()) | ||
577 | { | ||
578 | using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true)) | ||
579 | { | ||
580 | zOut.Write(input, 0, input.Length); | ||
581 | } | ||
582 | |||
583 | msSinkUnCompressed.Seek(0L, SeekOrigin.Begin); | ||
584 | osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray()); | ||
585 | } | ||
586 | |||
587 | return osd; | ||
588 | } | ||
589 | } | ||
590 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs new file mode 100644 index 0000000..d4b19dd --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
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 OpenSim 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 | using Mono.Addins; | ||
28 | |||
29 | using System; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using System.Text; | ||
33 | using System.Net; | ||
34 | using System.Net.Sockets; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using System.Collections.Generic; | ||
43 | using System.Text.RegularExpressions; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | ||
46 | { | ||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreCommandsModule")] | ||
48 | |||
49 | public class JsonStoreCommandsModule : INonSharedRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = | ||
52 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | private IConfig m_config = null; | ||
55 | private bool m_enabled = false; | ||
56 | |||
57 | private Scene m_scene = null; | ||
58 | //private IJsonStoreModule m_store; | ||
59 | private JsonStoreModule m_store; | ||
60 | |||
61 | #region Region Module interface | ||
62 | |||
63 | // ----------------------------------------------------------------- | ||
64 | /// <summary> | ||
65 | /// Name of this shared module is it's class name | ||
66 | /// </summary> | ||
67 | // ----------------------------------------------------------------- | ||
68 | public string Name | ||
69 | { | ||
70 | get { return this.GetType().Name; } | ||
71 | } | ||
72 | |||
73 | // ----------------------------------------------------------------- | ||
74 | /// <summary> | ||
75 | /// Initialise this shared module | ||
76 | /// </summary> | ||
77 | /// <param name="scene">this region is getting initialised</param> | ||
78 | /// <param name="source">nini config, we are not using this</param> | ||
79 | // ----------------------------------------------------------------- | ||
80 | public void Initialise(IConfigSource config) | ||
81 | { | ||
82 | try | ||
83 | { | ||
84 | if ((m_config = config.Configs["JsonStore"]) == null) | ||
85 | { | ||
86 | // There is no configuration, the module is disabled | ||
87 | // m_log.InfoFormat("[JsonStore] no configuration info"); | ||
88 | return; | ||
89 | } | ||
90 | |||
91 | m_enabled = m_config.GetBoolean("Enabled", m_enabled); | ||
92 | } | ||
93 | catch (Exception e) | ||
94 | { | ||
95 | m_log.Error("[JsonStore]: initialization error: {0}", e); | ||
96 | return; | ||
97 | } | ||
98 | |||
99 | if (m_enabled) | ||
100 | m_log.DebugFormat("[JsonStore]: module is enabled"); | ||
101 | } | ||
102 | |||
103 | // ----------------------------------------------------------------- | ||
104 | /// <summary> | ||
105 | /// everything is loaded, perform post load configuration | ||
106 | /// </summary> | ||
107 | // ----------------------------------------------------------------- | ||
108 | public void PostInitialise() | ||
109 | { | ||
110 | } | ||
111 | |||
112 | // ----------------------------------------------------------------- | ||
113 | /// <summary> | ||
114 | /// Nothing to do on close | ||
115 | /// </summary> | ||
116 | // ----------------------------------------------------------------- | ||
117 | public void Close() | ||
118 | { | ||
119 | } | ||
120 | |||
121 | // ----------------------------------------------------------------- | ||
122 | /// <summary> | ||
123 | /// </summary> | ||
124 | // ----------------------------------------------------------------- | ||
125 | public void AddRegion(Scene scene) | ||
126 | { | ||
127 | if (m_enabled) | ||
128 | { | ||
129 | m_scene = scene; | ||
130 | |||
131 | } | ||
132 | } | ||
133 | |||
134 | // ----------------------------------------------------------------- | ||
135 | /// <summary> | ||
136 | /// </summary> | ||
137 | // ----------------------------------------------------------------- | ||
138 | public void RemoveRegion(Scene scene) | ||
139 | { | ||
140 | // need to remove all references to the scene in the subscription | ||
141 | // list to enable full garbage collection of the scene object | ||
142 | } | ||
143 | |||
144 | // ----------------------------------------------------------------- | ||
145 | /// <summary> | ||
146 | /// Called when all modules have been added for a region. This is | ||
147 | /// where we hook up events | ||
148 | /// </summary> | ||
149 | // ----------------------------------------------------------------- | ||
150 | public void RegionLoaded(Scene scene) | ||
151 | { | ||
152 | if (m_enabled) | ||
153 | { | ||
154 | m_scene = scene; | ||
155 | |||
156 | m_store = (JsonStoreModule) m_scene.RequestModuleInterface<IJsonStoreModule>(); | ||
157 | if (m_store == null) | ||
158 | { | ||
159 | m_log.ErrorFormat("[JsonStoreCommands]: JsonModule interface not defined"); | ||
160 | m_enabled = false; | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | scene.AddCommand("JsonStore", this, "jsonstore stats", "jsonstore stats", | ||
165 | "Display statistics about the state of the JsonStore module", "", | ||
166 | CmdStats); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | /// ----------------------------------------------------------------- | ||
171 | /// <summary> | ||
172 | /// </summary> | ||
173 | // ----------------------------------------------------------------- | ||
174 | public Type ReplaceableInterface | ||
175 | { | ||
176 | get { return null; } | ||
177 | } | ||
178 | |||
179 | #endregion | ||
180 | |||
181 | #region Commands | ||
182 | |||
183 | private void CmdStats(string module, string[] cmd) | ||
184 | { | ||
185 | if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) | ||
186 | return; | ||
187 | |||
188 | JsonStoreStats stats = m_store.GetStoreStats(); | ||
189 | MainConsole.Instance.OutputFormat("{0}\t{1}",m_scene.RegionInfo.RegionName,stats.StoreCount); | ||
190 | } | ||
191 | |||
192 | #endregion | ||
193 | |||
194 | } | ||
195 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index 5fbfcc5..b502a55 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | |||
@@ -42,7 +42,6 @@ using OpenSim.Region.Framework.Scenes; | |||
42 | using System.Collections.Generic; | 42 | using System.Collections.Generic; |
43 | using System.Text.RegularExpressions; | 43 | using System.Text.RegularExpressions; |
44 | 44 | ||
45 | |||
46 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | 45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore |
47 | { | 46 | { |
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreModule")] | 47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreModule")] |
@@ -60,6 +59,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
60 | private Scene m_scene = null; | 59 | private Scene m_scene = null; |
61 | 60 | ||
62 | private Dictionary<UUID,JsonStore> m_JsonValueStore; | 61 | private Dictionary<UUID,JsonStore> m_JsonValueStore; |
62 | |||
63 | private UUID m_sharedStore; | 63 | private UUID m_sharedStore; |
64 | 64 | ||
65 | #region Region Module interface | 65 | #region Region Module interface |
@@ -140,6 +140,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
140 | m_sharedStore = UUID.Zero; | 140 | m_sharedStore = UUID.Zero; |
141 | m_JsonValueStore = new Dictionary<UUID,JsonStore>(); | 141 | m_JsonValueStore = new Dictionary<UUID,JsonStore>(); |
142 | m_JsonValueStore.Add(m_sharedStore,new JsonStore("")); | 142 | m_JsonValueStore.Add(m_sharedStore,new JsonStore("")); |
143 | |||
144 | scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; | ||
143 | } | 145 | } |
144 | } | 146 | } |
145 | 147 | ||
@@ -149,6 +151,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
149 | // ----------------------------------------------------------------- | 151 | // ----------------------------------------------------------------- |
150 | public void RemoveRegion(Scene scene) | 152 | public void RemoveRegion(Scene scene) |
151 | { | 153 | { |
154 | scene.EventManager.OnObjectBeingRemovedFromScene -= EventManagerOnObjectBeingRemovedFromScene; | ||
155 | |||
152 | // need to remove all references to the scene in the subscription | 156 | // need to remove all references to the scene in the subscription |
153 | // list to enable full garbage collection of the scene object | 157 | // list to enable full garbage collection of the scene object |
154 | } | 158 | } |
@@ -161,7 +165,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
161 | // ----------------------------------------------------------------- | 165 | // ----------------------------------------------------------------- |
162 | public void RegionLoaded(Scene scene) | 166 | public void RegionLoaded(Scene scene) |
163 | { | 167 | { |
164 | if (m_enabled) {} | 168 | if (m_enabled) |
169 | { | ||
170 | } | ||
165 | } | 171 | } |
166 | 172 | ||
167 | /// ----------------------------------------------------------------- | 173 | /// ----------------------------------------------------------------- |
@@ -175,8 +181,39 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
175 | 181 | ||
176 | #endregion | 182 | #endregion |
177 | 183 | ||
184 | #region SceneEvents | ||
185 | // ----------------------------------------------------------------- | ||
186 | /// <summary> | ||
187 | /// | ||
188 | /// </summary> | ||
189 | // ----------------------------------------------------------------- | ||
190 | public void EventManagerOnObjectBeingRemovedFromScene(SceneObjectGroup obj) | ||
191 | { | ||
192 | obj.ForEachPart(delegate(SceneObjectPart sop) { DestroyStore(sop.UUID); } ); | ||
193 | } | ||
194 | |||
195 | #endregion | ||
196 | |||
178 | #region ScriptInvocationInteface | 197 | #region ScriptInvocationInteface |
179 | 198 | ||
199 | |||
200 | // ----------------------------------------------------------------- | ||
201 | /// <summary> | ||
202 | /// | ||
203 | /// </summary> | ||
204 | // ----------------------------------------------------------------- | ||
205 | public JsonStoreStats GetStoreStats() | ||
206 | { | ||
207 | JsonStoreStats stats; | ||
208 | |||
209 | lock (m_JsonValueStore) | ||
210 | { | ||
211 | stats.StoreCount = m_JsonValueStore.Count; | ||
212 | } | ||
213 | |||
214 | return stats; | ||
215 | } | ||
216 | |||
180 | // ----------------------------------------------------------------- | 217 | // ----------------------------------------------------------------- |
181 | /// <summary> | 218 | /// <summary> |
182 | /// | 219 | /// |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 1bb5aee..9fbfb66 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -59,7 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
59 | 59 | ||
60 | private IScriptModuleComms m_comms; | 60 | private IScriptModuleComms m_comms; |
61 | private IJsonStoreModule m_store; | 61 | private IJsonStoreModule m_store; |
62 | 62 | ||
63 | private Dictionary<UUID,HashSet<UUID>> m_scriptStores = new Dictionary<UUID,HashSet<UUID>>(); | ||
64 | |||
63 | #region Region Module interface | 65 | #region Region Module interface |
64 | 66 | ||
65 | // ----------------------------------------------------------------- | 67 | // ----------------------------------------------------------------- |
@@ -126,6 +128,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
126 | // ----------------------------------------------------------------- | 128 | // ----------------------------------------------------------------- |
127 | public void AddRegion(Scene scene) | 129 | public void AddRegion(Scene scene) |
128 | { | 130 | { |
131 | scene.EventManager.OnScriptReset += HandleScriptReset; | ||
132 | scene.EventManager.OnRemoveScript += HandleScriptReset; | ||
129 | } | 133 | } |
130 | 134 | ||
131 | // ----------------------------------------------------------------- | 135 | // ----------------------------------------------------------------- |
@@ -134,12 +138,34 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
134 | // ----------------------------------------------------------------- | 138 | // ----------------------------------------------------------------- |
135 | public void RemoveRegion(Scene scene) | 139 | public void RemoveRegion(Scene scene) |
136 | { | 140 | { |
141 | scene.EventManager.OnScriptReset -= HandleScriptReset; | ||
142 | scene.EventManager.OnRemoveScript -= HandleScriptReset; | ||
143 | |||
137 | // need to remove all references to the scene in the subscription | 144 | // need to remove all references to the scene in the subscription |
138 | // list to enable full garbage collection of the scene object | 145 | // list to enable full garbage collection of the scene object |
139 | } | 146 | } |
140 | 147 | ||
141 | // ----------------------------------------------------------------- | 148 | // ----------------------------------------------------------------- |
142 | /// <summary> | 149 | /// <summary> |
150 | /// </summary> | ||
151 | // ----------------------------------------------------------------- | ||
152 | private void HandleScriptReset(uint localID, UUID itemID) | ||
153 | { | ||
154 | HashSet<UUID> stores; | ||
155 | |||
156 | lock (m_scriptStores) | ||
157 | { | ||
158 | if (! m_scriptStores.TryGetValue(itemID, out stores)) | ||
159 | return; | ||
160 | m_scriptStores.Remove(itemID); | ||
161 | } | ||
162 | |||
163 | foreach (UUID id in stores) | ||
164 | m_store.DestroyStore(id); | ||
165 | } | ||
166 | |||
167 | // ----------------------------------------------------------------- | ||
168 | /// <summary> | ||
143 | /// Called when all modules have been added for a region. This is | 169 | /// Called when all modules have been added for a region. This is |
144 | /// where we hook up events | 170 | /// where we hook up events |
145 | /// </summary> | 171 | /// </summary> |
@@ -250,6 +276,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
250 | if (! m_store.CreateStore(value, ref uuid)) | 276 | if (! m_store.CreateStore(value, ref uuid)) |
251 | GenerateRuntimeError("Failed to create Json store"); | 277 | GenerateRuntimeError("Failed to create Json store"); |
252 | 278 | ||
279 | lock (m_scriptStores) | ||
280 | { | ||
281 | if (! m_scriptStores.ContainsKey(scriptID)) | ||
282 | m_scriptStores[scriptID] = new HashSet<UUID>(); | ||
283 | |||
284 | m_scriptStores[scriptID].Add(uuid); | ||
285 | } | ||
253 | return uuid; | 286 | return uuid; |
254 | } | 287 | } |
255 | 288 | ||
@@ -261,6 +294,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
261 | [ScriptInvocation] | 294 | [ScriptInvocation] |
262 | public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID) | 295 | public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID) |
263 | { | 296 | { |
297 | lock(m_scriptStores) | ||
298 | { | ||
299 | if (m_scriptStores.ContainsKey(scriptID)) | ||
300 | m_scriptStores[scriptID].Remove(storeID); | ||
301 | } | ||
302 | |||
264 | return m_store.DestroyStore(storeID) ? 1 : 0; | 303 | return m_store.DestroyStore(storeID) ? 1 : 0; |
265 | } | 304 | } |
266 | 305 | ||
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index f841d5c..7f9e440 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -110,6 +110,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
110 | // ScenePresence.SendInitialData() to reset our entire appearance. | 110 | // ScenePresence.SendInitialData() to reset our entire appearance. |
111 | m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); | 111 | m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); |
112 | 112 | ||
113 | /* | ||
113 | m_afMod.SetAppearance(sp, originalTe, null); | 114 | m_afMod.SetAppearance(sp, originalTe, null); |
114 | 115 | ||
115 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); | 116 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); |
@@ -125,6 +126,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
125 | 126 | ||
126 | // Have to account for both SP and NPC. | 127 | // Have to account for both SP and NPC. |
127 | Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2)); | 128 | Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2)); |
129 | */ | ||
128 | } | 130 | } |
129 | 131 | ||
130 | [Test] | 132 | [Test] |
@@ -321,9 +323,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
321 | 323 | ||
322 | Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); | 324 | Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); |
323 | Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); | 325 | Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); |
324 | Assert.That( | 326 | // Assert.That( |
325 | npc.AbsolutePosition, | 327 | // npc.AbsolutePosition, |
326 | Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); | 328 | // Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); |
327 | 329 | ||
328 | m_npcMod.Stand(npc.UUID, m_scene); | 330 | m_npcMod.Stand(npc.UUID, m_scene); |
329 | 331 | ||
@@ -335,7 +337,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
335 | public void TestSitAndStandWithNoSitTarget() | 337 | public void TestSitAndStandWithNoSitTarget() |
336 | { | 338 | { |
337 | TestHelpers.InMethod(); | 339 | TestHelpers.InMethod(); |
338 | // log4net.Config.XmlConfigurator.Configure(); | 340 | // TestHelpers.EnableLogging(); |
339 | 341 | ||
340 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 342 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
341 | 343 | ||
@@ -353,13 +355,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
353 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); | 355 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
354 | Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); | 356 | Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); |
355 | 357 | ||
356 | // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the | 358 | // We should really be using the NPC size but this would mean preserving the physics actor since it is |
357 | // default avatar. | 359 | // removed on sit. |
358 | // Curiously, Vector3.ToString() will not display the last two places of the float. For example, | ||
359 | // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337> | ||
360 | Assert.That( | 360 | Assert.That( |
361 | npc.AbsolutePosition, | 361 | npc.AbsolutePosition, |
362 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); | 362 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, sp.PhysicsActor.Size.Z / 2))); |
363 | 363 | ||
364 | m_npcMod.Stand(npc.UUID, m_scene); | 364 | m_npcMod.Stand(npc.UUID, m_scene); |
365 | 365 | ||
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs index e43136a..0d17e0e 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs | |||
@@ -118,14 +118,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
118 | 118 | ||
119 | public override Vector3 Position { get; set; } | 119 | public override Vector3 Position { get; set; } |
120 | 120 | ||
121 | public override Vector3 Size | 121 | public override Vector3 Size { get; set; } |
122 | { | ||
123 | get { return _size; } | ||
124 | set { | ||
125 | _size = value; | ||
126 | _size.Z = _size.Z / 2.0f; | ||
127 | } | ||
128 | } | ||
129 | 122 | ||
130 | public override PrimitiveBaseShape Shape | 123 | public override PrimitiveBaseShape Shape |
131 | { | 124 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index 006a9c1..fbe320b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |||
@@ -71,7 +71,7 @@ public abstract class BSShape | |||
71 | lastReferenced = DateTime.Now; | 71 | lastReferenced = DateTime.Now; |
72 | } | 72 | } |
73 | 73 | ||
74 | // Called when this shape is being used again. | 74 | // Called when this shape is done being used. |
75 | protected virtual void DecrementReference() | 75 | protected virtual void DecrementReference() |
76 | { | 76 | { |
77 | referenceCount--; | 77 | referenceCount--; |
@@ -866,6 +866,8 @@ public class BSShapeHull : BSShape | |||
866 | public class BSShapeCompound : BSShape | 866 | public class BSShapeCompound : BSShape |
867 | { | 867 | { |
868 | private static string LogHeader = "[BULLETSIM SHAPE COMPOUND]"; | 868 | private static string LogHeader = "[BULLETSIM SHAPE COMPOUND]"; |
869 | public static Dictionary<string, BSShapeCompound> CompoundShapes = new Dictionary<string, BSShapeCompound>(); | ||
870 | |||
869 | public BSShapeCompound(BulletShape pShape) : base(pShape) | 871 | public BSShapeCompound(BulletShape pShape) : base(pShape) |
870 | { | 872 | { |
871 | } | 873 | } |
@@ -873,7 +875,9 @@ public class BSShapeCompound : BSShape | |||
873 | { | 875 | { |
874 | // Base compound shapes are not shared so this returns a raw shape. | 876 | // Base compound shapes are not shared so this returns a raw shape. |
875 | // A built compound shape can be reused in linksets. | 877 | // A built compound shape can be reused in linksets. |
876 | return new BSShapeCompound(CreatePhysicalCompoundShape(physicsScene)); | 878 | BSShapeCompound ret = new BSShapeCompound(CreatePhysicalCompoundShape(physicsScene)); |
879 | CompoundShapes.Add(ret.AddrString, ret); | ||
880 | return ret; | ||
877 | } | 881 | } |
878 | public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim) | 882 | public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim) |
879 | { | 883 | { |
@@ -911,10 +915,21 @@ public class BSShapeCompound : BSShape | |||
911 | BulletShape childShape = physicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(physShapeInfo, ii); | 915 | BulletShape childShape = physicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(physShapeInfo, ii); |
912 | DereferenceAnonCollisionShape(physicsScene, childShape); | 916 | DereferenceAnonCollisionShape(physicsScene, childShape); |
913 | } | 917 | } |
918 | |||
919 | lock (CompoundShapes) | ||
920 | CompoundShapes.Remove(physShapeInfo.AddrString); | ||
914 | physicsScene.PE.DeleteCollisionShape(physicsScene.World, physShapeInfo); | 921 | physicsScene.PE.DeleteCollisionShape(physicsScene.World, physShapeInfo); |
915 | } | 922 | } |
916 | } | 923 | } |
917 | } | 924 | } |
925 | public static bool TryGetCompoundByPtr(BulletShape pShape, out BSShapeCompound outCompound) | ||
926 | { | ||
927 | lock (CompoundShapes) | ||
928 | { | ||
929 | string addr = pShape.AddrString; | ||
930 | return CompoundShapes.TryGetValue(addr, out outCompound); | ||
931 | } | ||
932 | } | ||
918 | private static BulletShape CreatePhysicalCompoundShape(BSScene physicsScene) | 933 | private static BulletShape CreatePhysicalCompoundShape(BSScene physicsScene) |
919 | { | 934 | { |
920 | BulletShape cShape = physicsScene.PE.CreateCompoundShape(physicsScene.World, false); | 935 | BulletShape cShape = physicsScene.PE.CreateCompoundShape(physicsScene.World, false); |
@@ -926,10 +941,13 @@ public class BSShapeCompound : BSShape | |||
926 | private void DereferenceAnonCollisionShape(BSScene physicsScene, BulletShape pShape) | 941 | private void DereferenceAnonCollisionShape(BSScene physicsScene, BulletShape pShape) |
927 | { | 942 | { |
928 | // TODO: figure a better way to go through all the shape types and find a possible instance. | 943 | // TODO: figure a better way to go through all the shape types and find a possible instance. |
944 | physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,shape={1}", | ||
945 | BSScene.DetailLogZero, pShape); | ||
929 | BSShapeMesh meshDesc; | 946 | BSShapeMesh meshDesc; |
930 | if (BSShapeMesh.TryGetMeshByPtr(pShape, out meshDesc)) | 947 | if (BSShapeMesh.TryGetMeshByPtr(pShape, out meshDesc)) |
931 | { | 948 | { |
932 | meshDesc.Dereference(physicsScene); | 949 | meshDesc.Dereference(physicsScene); |
950 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundMesh,shape={1}", BSScene.DetailLogZero, pShape); | ||
933 | } | 951 | } |
934 | else | 952 | else |
935 | { | 953 | { |
@@ -937,13 +955,15 @@ public class BSShapeCompound : BSShape | |||
937 | if (BSShapeHull.TryGetHullByPtr(pShape, out hullDesc)) | 955 | if (BSShapeHull.TryGetHullByPtr(pShape, out hullDesc)) |
938 | { | 956 | { |
939 | hullDesc.Dereference(physicsScene); | 957 | hullDesc.Dereference(physicsScene); |
958 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundHull,shape={1}", BSScene.DetailLogZero, pShape); | ||
940 | } | 959 | } |
941 | else | 960 | else |
942 | { | 961 | { |
943 | BSShapeConvexHull chullDesc; | 962 | BSShapeConvexHull chullDesc; |
944 | if (BSShapeConvexHull.TryGetHullByPtr(pShape, out chullDesc)) | 963 | if (BSShapeConvexHull.TryGetConvexHullByPtr(pShape, out chullDesc)) |
945 | { | 964 | { |
946 | chullDesc.Dereference(physicsScene); | 965 | chullDesc.Dereference(physicsScene); |
966 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundConvexHull,shape={1}", BSScene.DetailLogZero, pShape); | ||
947 | } | 967 | } |
948 | else | 968 | else |
949 | { | 969 | { |
@@ -951,20 +971,23 @@ public class BSShapeCompound : BSShape | |||
951 | if (BSShapeGImpact.TryGetGImpactByPtr(pShape, out gImpactDesc)) | 971 | if (BSShapeGImpact.TryGetGImpactByPtr(pShape, out gImpactDesc)) |
952 | { | 972 | { |
953 | gImpactDesc.Dereference(physicsScene); | 973 | gImpactDesc.Dereference(physicsScene); |
974 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundgImpact,shape={1}", BSScene.DetailLogZero, pShape); | ||
954 | } | 975 | } |
955 | else | 976 | else |
956 | { | 977 | { |
957 | // Didn't find it in the lists of specific types. It could be compound. | 978 | // Didn't find it in the lists of specific types. It could be compound. |
958 | if (physicsScene.PE.IsCompound(pShape)) | 979 | BSShapeCompound compoundDesc; |
980 | if (BSShapeCompound.TryGetCompoundByPtr(pShape, out compoundDesc)) | ||
959 | { | 981 | { |
960 | BSShapeCompound recursiveCompound = new BSShapeCompound(pShape); | 982 | compoundDesc.Dereference(physicsScene); |
961 | recursiveCompound.Dereference(physicsScene); | 983 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,recursiveCompoundShape,shape={1}", BSScene.DetailLogZero, pShape); |
962 | } | 984 | } |
963 | else | 985 | else |
964 | { | 986 | { |
965 | // If none of the above, maybe it is a simple native shape. | 987 | // If none of the above, maybe it is a simple native shape. |
966 | if (physicsScene.PE.IsNativeShape(pShape)) | 988 | if (physicsScene.PE.IsNativeShape(pShape)) |
967 | { | 989 | { |
990 | // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,assumingNative,shape={1}", BSScene.DetailLogZero, pShape); | ||
968 | BSShapeNative nativeShape = new BSShapeNative(pShape); | 991 | BSShapeNative nativeShape = new BSShapeNative(pShape); |
969 | nativeShape.Dereference(physicsScene); | 992 | nativeShape.Dereference(physicsScene); |
970 | } | 993 | } |
@@ -1021,6 +1044,8 @@ public class BSShapeConvexHull : BSShape | |||
1021 | convexShape = physicsScene.PE.BuildConvexHullShapeFromMesh(physicsScene.World, baseMesh.physShapeInfo); | 1044 | convexShape = physicsScene.PE.BuildConvexHullShapeFromMesh(physicsScene.World, baseMesh.physShapeInfo); |
1022 | convexShape.shapeKey = newMeshKey; | 1045 | convexShape.shapeKey = newMeshKey; |
1023 | ConvexHulls.Add(convexShape.shapeKey, retConvexHull); | 1046 | ConvexHulls.Add(convexShape.shapeKey, retConvexHull); |
1047 | physicsScene.DetailLog("{0},BSShapeConvexHull.GetReference,addingNewlyCreatedShape,shape={1}", | ||
1048 | BSScene.DetailLogZero, convexShape); | ||
1024 | } | 1049 | } |
1025 | 1050 | ||
1026 | // Done with the base mesh | 1051 | // Done with the base mesh |
@@ -1049,7 +1074,7 @@ public class BSShapeConvexHull : BSShape | |||
1049 | } | 1074 | } |
1050 | } | 1075 | } |
1051 | // Loop through all the known hulls and return the description based on the physical address. | 1076 | // Loop through all the known hulls and return the description based on the physical address. |
1052 | public static bool TryGetHullByPtr(BulletShape pShape, out BSShapeConvexHull outHull) | 1077 | public static bool TryGetConvexHullByPtr(BulletShape pShape, out BSShapeConvexHull outHull) |
1053 | { | 1078 | { |
1054 | bool ret = false; | 1079 | bool ret = false; |
1055 | BSShapeConvexHull foundDesc = null; | 1080 | BSShapeConvexHull foundDesc = null; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index 816591b..c928f16 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | |||
@@ -443,9 +443,13 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
443 | region.RegionName = response["Name"].AsString(); | 443 | region.RegionName = response["Name"].AsString(); |
444 | 444 | ||
445 | Vector3d minPosition = response["MinPosition"].AsVector3d(); | 445 | Vector3d minPosition = response["MinPosition"].AsVector3d(); |
446 | Vector3d maxPosition = response["MaxPosition"].AsVector3d(); | ||
446 | region.RegionLocX = (int)minPosition.X; | 447 | region.RegionLocX = (int)minPosition.X; |
447 | region.RegionLocY = (int)minPosition.Y; | 448 | region.RegionLocY = (int)minPosition.Y; |
448 | 449 | ||
450 | region.RegionSizeX = (int)maxPosition.X - (int)minPosition.X; | ||
451 | region.RegionSizeY = (int)maxPosition.Y - (int)minPosition.Y; | ||
452 | |||
449 | if ( ! extraData["HyperGrid"] ) { | 453 | if ( ! extraData["HyperGrid"] ) { |
450 | Uri httpAddress = response["Address"].AsUri(); | 454 | Uri httpAddress = response["Address"].AsUri(); |
451 | region.ExternalHostName = httpAddress.Host; | 455 | region.ExternalHostName = httpAddress.Host; |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index e72b7f9..137ce04 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -313,8 +313,9 @@ namespace OpenSim.Services.GridService | |||
313 | if (region != null) | 313 | if (region != null) |
314 | { | 314 | { |
315 | // Not really? Maybe? | 315 | // Not really? Maybe? |
316 | List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1, | 316 | List<RegionData> rdatas = m_Database.Get( |
317 | region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); | 317 | region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, |
318 | region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); | ||
318 | 319 | ||
319 | foreach (RegionData rdata in rdatas) | 320 | foreach (RegionData rdata in rdatas) |
320 | { | 321 | { |
@@ -347,6 +348,11 @@ namespace OpenSim.Services.GridService | |||
347 | return null; | 348 | return null; |
348 | } | 349 | } |
349 | 350 | ||
351 | // Get a region given its base coordinates. | ||
352 | // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST | ||
353 | // be the base coordinate of the region. | ||
354 | // The snapping is technically unnecessary but is harmless because regions are always | ||
355 | // multiples of the legacy region size (256). | ||
350 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 356 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
351 | { | 357 | { |
352 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; | 358 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; |
@@ -441,6 +447,8 @@ namespace OpenSim.Services.GridService | |||
441 | RegionData rdata = new RegionData(); | 447 | RegionData rdata = new RegionData(); |
442 | rdata.posX = (int)rinfo.RegionLocX; | 448 | rdata.posX = (int)rinfo.RegionLocX; |
443 | rdata.posY = (int)rinfo.RegionLocY; | 449 | rdata.posY = (int)rinfo.RegionLocY; |
450 | rdata.sizeX = rinfo.RegionSizeX; | ||
451 | rdata.sizeY = rinfo.RegionSizeY; | ||
444 | rdata.RegionID = rinfo.RegionID; | 452 | rdata.RegionID = rinfo.RegionID; |
445 | rdata.RegionName = rinfo.RegionName; | 453 | rdata.RegionName = rinfo.RegionName; |
446 | rdata.Data = rinfo.ToKeyValuePairs(); | 454 | rdata.Data = rinfo.ToKeyValuePairs(); |
@@ -454,6 +462,8 @@ namespace OpenSim.Services.GridService | |||
454 | GridRegion rinfo = new GridRegion(rdata.Data); | 462 | GridRegion rinfo = new GridRegion(rdata.Data); |
455 | rinfo.RegionLocX = rdata.posX; | 463 | rinfo.RegionLocX = rdata.posX; |
456 | rinfo.RegionLocY = rdata.posY; | 464 | rinfo.RegionLocY = rdata.posY; |
465 | rinfo.RegionSizeX = rdata.sizeX; | ||
466 | rinfo.RegionSizeY = rdata.sizeY; | ||
457 | rinfo.RegionID = rdata.RegionID; | 467 | rinfo.RegionID = rdata.RegionID; |
458 | rinfo.RegionName = rdata.RegionName; | 468 | rinfo.RegionName = rdata.RegionName; |
459 | rinfo.ScopeID = rdata.ScopeID; | 469 | rinfo.ScopeID = rdata.ScopeID; |
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 88ac5b3..739e279 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -29,9 +29,13 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
32 | using System.Reflection; | ||
33 | |||
32 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
33 | using OpenMetaverse; | 35 | using OpenMetaverse; |
34 | 36 | ||
37 | using log4net; | ||
38 | |||
35 | namespace OpenSim.Services.Interfaces | 39 | namespace OpenSim.Services.Interfaces |
36 | { | 40 | { |
37 | public interface IGridService | 41 | public interface IGridService |
@@ -119,6 +123,9 @@ namespace OpenSim.Services.Interfaces | |||
119 | 123 | ||
120 | public class GridRegion | 124 | public class GridRegion |
121 | { | 125 | { |
126 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
127 | private static readonly string LogHeader = "[GRID REGION]"; | ||
128 | |||
122 | /// <summary> | 129 | /// <summary> |
123 | /// The port by which http communication occurs with the region | 130 | /// The port by which http communication occurs with the region |
124 | /// </summary> | 131 | /// </summary> |
@@ -177,6 +184,7 @@ namespace OpenSim.Services.Interfaces | |||
177 | 184 | ||
178 | /// <summary> | 185 | /// <summary> |
179 | /// The location of this region in meters. | 186 | /// The location of this region in meters. |
187 | /// DANGER DANGER! Note that this name means something different in RegionInfo. | ||
180 | /// </summary> | 188 | /// </summary> |
181 | public int RegionLocX | 189 | public int RegionLocX |
182 | { | 190 | { |
@@ -185,8 +193,12 @@ namespace OpenSim.Services.Interfaces | |||
185 | } | 193 | } |
186 | protected int m_regionLocX; | 194 | protected int m_regionLocX; |
187 | 195 | ||
196 | public int RegionSizeX { get; set; } | ||
197 | public int RegionSizeY { get; set; } | ||
198 | |||
188 | /// <summary> | 199 | /// <summary> |
189 | /// The location of this region in meters. | 200 | /// The location of this region in meters. |
201 | /// DANGER DANGER! Note that this name means something different in RegionInfo. | ||
190 | /// </summary> | 202 | /// </summary> |
191 | public int RegionLocY | 203 | public int RegionLocY |
192 | { | 204 | { |
@@ -215,13 +227,18 @@ namespace OpenSim.Services.Interfaces | |||
215 | 227 | ||
216 | public GridRegion() | 228 | public GridRegion() |
217 | { | 229 | { |
230 | RegionSizeX = (int)Constants.RegionSize; | ||
231 | RegionSizeY = (int)Constants.RegionSize; | ||
218 | m_serverURI = string.Empty; | 232 | m_serverURI = string.Empty; |
219 | } | 233 | } |
220 | 234 | ||
235 | /* | ||
221 | public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) | 236 | public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) |
222 | { | 237 | { |
223 | m_regionLocX = regionLocX; | 238 | m_regionLocX = regionLocX; |
224 | m_regionLocY = regionLocY; | 239 | m_regionLocY = regionLocY; |
240 | RegionSizeX = (int)Constants.RegionSize; | ||
241 | RegionSizeY = (int)Constants.RegionSize; | ||
225 | 242 | ||
226 | m_internalEndPoint = internalEndPoint; | 243 | m_internalEndPoint = internalEndPoint; |
227 | m_externalHostName = externalUri; | 244 | m_externalHostName = externalUri; |
@@ -231,16 +248,21 @@ namespace OpenSim.Services.Interfaces | |||
231 | { | 248 | { |
232 | m_regionLocX = regionLocX; | 249 | m_regionLocX = regionLocX; |
233 | m_regionLocY = regionLocY; | 250 | m_regionLocY = regionLocY; |
251 | RegionSizeX = (int)Constants.RegionSize; | ||
252 | RegionSizeY = (int)Constants.RegionSize; | ||
234 | 253 | ||
235 | m_externalHostName = externalUri; | 254 | m_externalHostName = externalUri; |
236 | 255 | ||
237 | m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); | 256 | m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); |
238 | } | 257 | } |
258 | */ | ||
239 | 259 | ||
240 | public GridRegion(uint xcell, uint ycell) | 260 | public GridRegion(uint xcell, uint ycell) |
241 | { | 261 | { |
242 | m_regionLocX = (int)(xcell * Constants.RegionSize); | 262 | m_regionLocX = (int)(xcell * Constants.RegionSize); |
243 | m_regionLocY = (int)(ycell * Constants.RegionSize); | 263 | m_regionLocY = (int)(ycell * Constants.RegionSize); |
264 | RegionSizeX = (int)Constants.RegionSize; | ||
265 | RegionSizeY = (int)Constants.RegionSize; | ||
244 | } | 266 | } |
245 | 267 | ||
246 | public GridRegion(RegionInfo ConvertFrom) | 268 | public GridRegion(RegionInfo ConvertFrom) |
@@ -248,6 +270,8 @@ namespace OpenSim.Services.Interfaces | |||
248 | m_regionName = ConvertFrom.RegionName; | 270 | m_regionName = ConvertFrom.RegionName; |
249 | m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); | 271 | m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); |
250 | m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); | 272 | m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); |
273 | RegionSizeX = (int)ConvertFrom.RegionSizeX; | ||
274 | RegionSizeY = (int)ConvertFrom.RegionSizeY; | ||
251 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | 275 | m_internalEndPoint = ConvertFrom.InternalEndPoint; |
252 | m_externalHostName = ConvertFrom.ExternalHostName; | 276 | m_externalHostName = ConvertFrom.ExternalHostName; |
253 | m_httpPort = ConvertFrom.HttpPort; | 277 | m_httpPort = ConvertFrom.HttpPort; |
@@ -266,6 +290,8 @@ namespace OpenSim.Services.Interfaces | |||
266 | m_regionName = ConvertFrom.RegionName; | 290 | m_regionName = ConvertFrom.RegionName; |
267 | m_regionLocX = ConvertFrom.RegionLocX; | 291 | m_regionLocX = ConvertFrom.RegionLocX; |
268 | m_regionLocY = ConvertFrom.RegionLocY; | 292 | m_regionLocY = ConvertFrom.RegionLocY; |
293 | RegionSizeX = ConvertFrom.RegionSizeX; | ||
294 | RegionSizeY = ConvertFrom.RegionSizeY; | ||
269 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | 295 | m_internalEndPoint = ConvertFrom.InternalEndPoint; |
270 | m_externalHostName = ConvertFrom.ExternalHostName; | 296 | m_externalHostName = ConvertFrom.ExternalHostName; |
271 | m_httpPort = ConvertFrom.HttpPort; | 297 | m_httpPort = ConvertFrom.HttpPort; |
@@ -373,6 +399,8 @@ namespace OpenSim.Services.Interfaces | |||
373 | kvp["uuid"] = RegionID.ToString(); | 399 | kvp["uuid"] = RegionID.ToString(); |
374 | kvp["locX"] = RegionLocX.ToString(); | 400 | kvp["locX"] = RegionLocX.ToString(); |
375 | kvp["locY"] = RegionLocY.ToString(); | 401 | kvp["locY"] = RegionLocY.ToString(); |
402 | kvp["sizeX"] = RegionSizeX.ToString(); | ||
403 | kvp["sizeY"] = RegionSizeY.ToString(); | ||
376 | kvp["regionName"] = RegionName; | 404 | kvp["regionName"] = RegionName; |
377 | kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); | 405 | kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); |
378 | kvp["serverHttpPort"] = HttpPort.ToString(); | 406 | kvp["serverHttpPort"] = HttpPort.ToString(); |
@@ -399,6 +427,16 @@ namespace OpenSim.Services.Interfaces | |||
399 | if (kvp.ContainsKey("locY")) | 427 | if (kvp.ContainsKey("locY")) |
400 | RegionLocY = Convert.ToInt32((string)kvp["locY"]); | 428 | RegionLocY = Convert.ToInt32((string)kvp["locY"]); |
401 | 429 | ||
430 | if (kvp.ContainsKey("sizeX")) | ||
431 | RegionSizeX = Convert.ToInt32((string)kvp["sizeX"]); | ||
432 | else | ||
433 | RegionSizeX = (int)Constants.RegionSize; | ||
434 | |||
435 | if (kvp.ContainsKey("sizeY")) | ||
436 | RegionSizeY = Convert.ToInt32((string)kvp["sizeY"]); | ||
437 | else | ||
438 | RegionSizeX = (int)Constants.RegionSize; | ||
439 | |||
402 | if (kvp.ContainsKey("regionName")) | 440 | if (kvp.ContainsKey("regionName")) |
403 | RegionName = (string)kvp["regionName"]; | 441 | RegionName = (string)kvp["regionName"]; |
404 | 442 | ||
@@ -446,6 +484,9 @@ namespace OpenSim.Services.Interfaces | |||
446 | 484 | ||
447 | if (kvp.ContainsKey("Token")) | 485 | if (kvp.ContainsKey("Token")) |
448 | Token = kvp["Token"].ToString(); | 486 | Token = kvp["Token"].ToString(); |
487 | |||
488 | // m_log.DebugFormat("{0} New GridRegion. id={1}, loc=<{2},{3}>, size=<{4},{5}>", | ||
489 | // LogHeader, RegionID, RegionLocX, RegionLocY, RegionSizeX, RegionSizeY); | ||
449 | } | 490 | } |
450 | } | 491 | } |
451 | } | 492 | } |
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 6ab5258..5256b74 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs | |||
@@ -254,11 +254,11 @@ namespace OpenSim.Services.LLLoginService | |||
254 | Currency = currency; | 254 | Currency = currency; |
255 | ClassifiedFee = classifiedFee; | 255 | ClassifiedFee = classifiedFee; |
256 | 256 | ||
257 | |||
258 | FillOutHomeData(pinfo, home); | 257 | FillOutHomeData(pinfo, home); |
259 | LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); | 258 | LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); |
260 | 259 | ||
261 | FillOutRegionData(destination); | 260 | FillOutRegionData(destination); |
261 | // m_log.DebugFormat("[LOGIN RESPONSE] LLLoginResponse create. sizeX=<{0},{1}>", RegionSizeX, RegionSizeY); | ||
262 | 262 | ||
263 | FillOutSeedCap(aCircuit, destination, clientIP); | 263 | FillOutSeedCap(aCircuit, destination, clientIP); |
264 | 264 | ||
@@ -384,6 +384,8 @@ namespace OpenSim.Services.LLLoginService | |||
384 | SimPort = (uint)endPoint.Port; | 384 | SimPort = (uint)endPoint.Port; |
385 | RegionX = (uint)destination.RegionLocX; | 385 | RegionX = (uint)destination.RegionLocX; |
386 | RegionY = (uint)destination.RegionLocY; | 386 | RegionY = (uint)destination.RegionLocY; |
387 | RegionSizeX = destination.RegionSizeX; | ||
388 | RegionSizeY = destination.RegionSizeY; | ||
387 | } | 389 | } |
388 | 390 | ||
389 | private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient) | 391 | private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient) |
@@ -529,6 +531,9 @@ namespace OpenSim.Services.LLLoginService | |||
529 | responseData["message"] = welcomeMessage; | 531 | responseData["message"] = welcomeMessage; |
530 | responseData["region_x"] = (Int32)(RegionX); | 532 | responseData["region_x"] = (Int32)(RegionX); |
531 | responseData["region_y"] = (Int32)(RegionY); | 533 | responseData["region_y"] = (Int32)(RegionY); |
534 | responseData["region_size_x"] = (Int32)RegionSizeX; | ||
535 | responseData["region_size_y"] = (Int32)RegionSizeY; | ||
536 | // m_log.DebugFormat("[LOGIN RESPONSE] returning sizeX=<{0},{1}>", RegionSizeX, RegionSizeY); | ||
532 | 537 | ||
533 | if (searchURL != String.Empty) | 538 | if (searchURL != String.Empty) |
534 | responseData["search"] = searchURL; | 539 | responseData["search"] = searchURL; |
@@ -918,6 +923,9 @@ namespace OpenSim.Services.LLLoginService | |||
918 | set { regionY = value; } | 923 | set { regionY = value; } |
919 | } | 924 | } |
920 | 925 | ||
926 | public int RegionSizeX { get; private set; } | ||
927 | public int RegionSizeY { get; private set; } | ||
928 | |||
921 | public string SunTexture | 929 | public string SunTexture |
922 | { | 930 | { |
923 | get { return sunTexture; } | 931 | get { return sunTexture; } |
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index fe43582..e2f9966 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -50,6 +50,8 @@ namespace OpenSim.Services.LLLoginService | |||
50 | public class LLLoginService : ILoginService | 50 | public class LLLoginService : ILoginService |
51 | { | 51 | { |
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
53 | private static readonly string LogHeader = "[LLOGIN SERVICE]"; | ||
54 | |||
53 | private static bool Initialized = false; | 55 | private static bool Initialized = false; |
54 | 56 | ||
55 | protected IUserAccountService m_UserAccountService; | 57 | protected IUserAccountService m_UserAccountService; |
@@ -389,6 +391,7 @@ namespace OpenSim.Services.LLLoginService | |||
389 | if (guinfo == null) | 391 | if (guinfo == null) |
390 | { | 392 | { |
391 | // something went wrong, make something up, so that we don't have to test this anywhere else | 393 | // something went wrong, make something up, so that we don't have to test this anywhere else |
394 | m_log.DebugFormat("{0} Failed to fetch GridUserInfo. Creating empty GridUserInfo as home", LogHeader); | ||
392 | guinfo = new GridUserInfo(); | 395 | guinfo = new GridUserInfo(); |
393 | guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30); | 396 | guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30); |
394 | } | 397 | } |
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs index 69c7b91..dd26cdc 100644 --- a/OpenSim/Services/UserProfilesService/UserProfilesService.cs +++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs | |||
@@ -37,6 +37,7 @@ using OpenSim.Data; | |||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenMetaverse.StructuredData; | 38 | using OpenMetaverse.StructuredData; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Services.UserAccountService; | ||
40 | 41 | ||
41 | namespace OpenSim.Services.ProfilesService | 42 | namespace OpenSim.Services.ProfilesService |
42 | { | 43 | { |
@@ -166,11 +167,71 @@ namespace OpenSim.Services.ProfilesService | |||
166 | #region User Preferences | 167 | #region User Preferences |
167 | public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result) | 168 | public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result) |
168 | { | 169 | { |
170 | if(string.IsNullOrEmpty(pref.EMail)) | ||
171 | { | ||
172 | UserAccount account = new UserAccount(); | ||
173 | if(userAccounts is UserAccountService.UserAccountService) | ||
174 | { | ||
175 | try | ||
176 | { | ||
177 | account = userAccounts.GetUserAccount(UUID.Zero, pref.UserId); | ||
178 | if(string.IsNullOrEmpty(account.Email)) | ||
179 | { | ||
180 | result = "No Email address on record!"; | ||
181 | return false; | ||
182 | } | ||
183 | else | ||
184 | pref.EMail = account.Email; | ||
185 | } | ||
186 | catch | ||
187 | { | ||
188 | m_log.Info ("[PROFILES]: UserAccountService Exception: Could not get user account"); | ||
189 | result = "Missing Email address!"; | ||
190 | return false; | ||
191 | } | ||
192 | } | ||
193 | else | ||
194 | { | ||
195 | m_log.Info ("[PROFILES]: UserAccountService: Could not get user account"); | ||
196 | result = "Missing Email address!"; | ||
197 | return false; | ||
198 | } | ||
199 | } | ||
169 | return ProfilesData.UpdateUserPreferences(ref pref, ref result); | 200 | return ProfilesData.UpdateUserPreferences(ref pref, ref result); |
170 | } | 201 | } |
171 | 202 | ||
172 | public bool UserPreferencesRequest(ref UserPreferences pref, ref string result) | 203 | public bool UserPreferencesRequest(ref UserPreferences pref, ref string result) |
173 | { | 204 | { |
205 | if(string.IsNullOrEmpty(pref.EMail)) | ||
206 | { | ||
207 | UserAccount account = new UserAccount(); | ||
208 | if(userAccounts is UserAccountService.UserAccountService) | ||
209 | { | ||
210 | try | ||
211 | { | ||
212 | account = userAccounts.GetUserAccount(UUID.Zero, pref.UserId); | ||
213 | if(string.IsNullOrEmpty(account.Email)) | ||
214 | { | ||
215 | result = "No Email address on record!"; | ||
216 | return false; | ||
217 | } | ||
218 | else | ||
219 | pref.EMail = account.Email; | ||
220 | } | ||
221 | catch | ||
222 | { | ||
223 | m_log.Info ("[PROFILES]: UserAccountService Exception: Could not get user account"); | ||
224 | result = "Missing Email address!"; | ||
225 | return false; | ||
226 | } | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | m_log.Info ("[PROFILES]: UserAccountService: Could not get user account"); | ||
231 | result = "Missing Email address!"; | ||
232 | return false; | ||
233 | } | ||
234 | } | ||
174 | return ProfilesData.GetUserPreferences(ref pref, ref result); | 235 | return ProfilesData.GetUserPreferences(ref pref, ref result); |
175 | } | 236 | } |
176 | #endregion User Preferences | 237 | #endregion User Preferences |
diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs index e666433..f2bae58 100644 --- a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs +++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs | |||
@@ -114,22 +114,25 @@ namespace OpenSim.Tests.Common | |||
114 | AddEvent(avatarID, "DisableSimulator", handle); | 114 | AddEvent(avatarID, "DisableSimulator", handle); |
115 | } | 115 | } |
116 | 116 | ||
117 | public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID) | 117 | public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) |
118 | { | 118 | { |
119 | AddEvent(avatarID, "EnableSimulator", handle); | 119 | AddEvent(avatarID, "EnableSimulator", handle); |
120 | } | 120 | } |
121 | 121 | ||
122 | public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath) | 122 | public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath, |
123 | ulong regionHandle, int regionSizeX, int regionSizeY) | ||
123 | { | 124 | { |
124 | AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath); | 125 | AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath); |
125 | } | 126 | } |
126 | 127 | ||
127 | public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, UUID agentID) | 128 | public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
129 | uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY) | ||
128 | { | 130 | { |
129 | AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL); | 131 | AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL); |
130 | } | 132 | } |
131 | 133 | ||
132 | public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL, UUID avatarID, UUID sessionID) | 134 | public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, |
135 | string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) | ||
133 | { | 136 | { |
134 | AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID); | 137 | AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID); |
135 | } | 138 | } |
diff --git a/OpenSim/Tests/Performance/NPCPerformanceTests.cs b/OpenSim/Tests/Performance/NPCPerformanceTests.cs index 2026a88..eb09061 100644 --- a/OpenSim/Tests/Performance/NPCPerformanceTests.cs +++ b/OpenSim/Tests/Performance/NPCPerformanceTests.cs | |||
@@ -144,6 +144,7 @@ namespace OpenSim.Tests.Performance | |||
144 | // ScenePresence.SendInitialData() to reset our entire appearance. | 144 | // ScenePresence.SendInitialData() to reset our entire appearance. |
145 | scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); | 145 | scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); |
146 | 146 | ||
147 | /* | ||
147 | afm.SetAppearance(sp, originalTe, null); | 148 | afm.SetAppearance(sp, originalTe, null); |
148 | 149 | ||
149 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 150 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
@@ -185,6 +186,7 @@ namespace OpenSim.Tests.Performance | |||
185 | endGcMemory / 1024 / 1024, | 186 | endGcMemory / 1024 / 1024, |
186 | startGcMemory / 1024 / 1024, | 187 | startGcMemory / 1024 / 1024, |
187 | (endGcMemory - startGcMemory) / 1024 / 1024); | 188 | (endGcMemory - startGcMemory) / 1024 / 1024); |
189 | */ | ||
188 | } | 190 | } |
189 | } | 191 | } |
190 | } \ No newline at end of file | 192 | } |
diff --git a/bin/OpenMetaverse.StructuredData.XML b/bin/OpenMetaverse.StructuredData.XML index 789ad5b..3999d99 100644 --- a/bin/OpenMetaverse.StructuredData.XML +++ b/bin/OpenMetaverse.StructuredData.XML | |||
@@ -4,123 +4,6 @@ | |||
4 | <name>OpenMetaverse.StructuredData</name> | 4 | <name>OpenMetaverse.StructuredData</name> |
5 | </assembly> | 5 | </assembly> |
6 | <members> | 6 | <members> |
7 | <member name="T:OpenMetaverse.StructuredData.OSDType"> | ||
8 | <summary> | ||
9 | |||
10 | </summary> | ||
11 | </member> | ||
12 | <member name="F:OpenMetaverse.StructuredData.OSDType.Unknown"> | ||
13 | <summary></summary> | ||
14 | </member> | ||
15 | <member name="F:OpenMetaverse.StructuredData.OSDType.Boolean"> | ||
16 | <summary></summary> | ||
17 | </member> | ||
18 | <member name="F:OpenMetaverse.StructuredData.OSDType.Integer"> | ||
19 | <summary></summary> | ||
20 | </member> | ||
21 | <member name="F:OpenMetaverse.StructuredData.OSDType.Real"> | ||
22 | <summary></summary> | ||
23 | </member> | ||
24 | <member name="F:OpenMetaverse.StructuredData.OSDType.String"> | ||
25 | <summary></summary> | ||
26 | </member> | ||
27 | <member name="F:OpenMetaverse.StructuredData.OSDType.UUID"> | ||
28 | <summary></summary> | ||
29 | </member> | ||
30 | <member name="F:OpenMetaverse.StructuredData.OSDType.Date"> | ||
31 | <summary></summary> | ||
32 | </member> | ||
33 | <member name="F:OpenMetaverse.StructuredData.OSDType.URI"> | ||
34 | <summary></summary> | ||
35 | </member> | ||
36 | <member name="F:OpenMetaverse.StructuredData.OSDType.Binary"> | ||
37 | <summary></summary> | ||
38 | </member> | ||
39 | <member name="F:OpenMetaverse.StructuredData.OSDType.Map"> | ||
40 | <summary></summary> | ||
41 | </member> | ||
42 | <member name="F:OpenMetaverse.StructuredData.OSDType.Array"> | ||
43 | <summary></summary> | ||
44 | </member> | ||
45 | <member name="T:OpenMetaverse.StructuredData.OSDException"> | ||
46 | <summary> | ||
47 | |||
48 | </summary> | ||
49 | </member> | ||
50 | <member name="T:OpenMetaverse.StructuredData.OSD"> | ||
51 | <summary> | ||
52 | |||
53 | </summary> | ||
54 | </member> | ||
55 | <member name="M:OpenMetaverse.StructuredData.OSD.SerializeMembers(System.Object)"> | ||
56 | <summary> | ||
57 | Uses reflection to create an SDMap from all of the SD | ||
58 | serializable types in an object | ||
59 | </summary> | ||
60 | <param name="obj">Class or struct containing serializable types</param> | ||
61 | <returns>An SDMap holding the serialized values from the | ||
62 | container object</returns> | ||
63 | </member> | ||
64 | <member name="M:OpenMetaverse.StructuredData.OSD.DeserializeMembers(System.Object@,OpenMetaverse.StructuredData.OSDMap)"> | ||
65 | <summary> | ||
66 | Uses reflection to deserialize member variables in an object from | ||
67 | an SDMap | ||
68 | </summary> | ||
69 | <param name="obj">Reference to an object to fill with deserialized | ||
70 | values</param> | ||
71 | <param name="serialized">Serialized values to put in the target | ||
72 | object</param> | ||
73 | </member> | ||
74 | <member name="T:OpenMetaverse.StructuredData.OSDBoolean"> | ||
75 | <summary> | ||
76 | |||
77 | </summary> | ||
78 | </member> | ||
79 | <member name="T:OpenMetaverse.StructuredData.OSDInteger"> | ||
80 | <summary> | ||
81 | |||
82 | </summary> | ||
83 | </member> | ||
84 | <member name="T:OpenMetaverse.StructuredData.OSDReal"> | ||
85 | <summary> | ||
86 | |||
87 | </summary> | ||
88 | </member> | ||
89 | <member name="T:OpenMetaverse.StructuredData.OSDString"> | ||
90 | <summary> | ||
91 | |||
92 | </summary> | ||
93 | </member> | ||
94 | <member name="T:OpenMetaverse.StructuredData.OSDUUID"> | ||
95 | <summary> | ||
96 | |||
97 | </summary> | ||
98 | </member> | ||
99 | <member name="T:OpenMetaverse.StructuredData.OSDDate"> | ||
100 | <summary> | ||
101 | |||
102 | </summary> | ||
103 | </member> | ||
104 | <member name="T:OpenMetaverse.StructuredData.OSDUri"> | ||
105 | <summary> | ||
106 | |||
107 | </summary> | ||
108 | </member> | ||
109 | <member name="T:OpenMetaverse.StructuredData.OSDBinary"> | ||
110 | <summary> | ||
111 | |||
112 | </summary> | ||
113 | </member> | ||
114 | <member name="T:OpenMetaverse.StructuredData.OSDMap"> | ||
115 | <summary> | ||
116 | |||
117 | </summary> | ||
118 | </member> | ||
119 | <member name="T:OpenMetaverse.StructuredData.OSDArray"> | ||
120 | <summary> | ||
121 | |||
122 | </summary> | ||
123 | </member> | ||
124 | <member name="T:OpenMetaverse.StructuredData.OSDParser"> | 7 | <member name="T:OpenMetaverse.StructuredData.OSDParser"> |
125 | <summary> | 8 | <summary> |
126 | 9 | ||
@@ -345,5 +228,122 @@ | |||
345 | <param name="c"></param> | 228 | <param name="c"></param> |
346 | <returns></returns> | 229 | <returns></returns> |
347 | </member> | 230 | </member> |
231 | <member name="T:OpenMetaverse.StructuredData.OSDType"> | ||
232 | <summary> | ||
233 | |||
234 | </summary> | ||
235 | </member> | ||
236 | <member name="F:OpenMetaverse.StructuredData.OSDType.Unknown"> | ||
237 | <summary></summary> | ||
238 | </member> | ||
239 | <member name="F:OpenMetaverse.StructuredData.OSDType.Boolean"> | ||
240 | <summary></summary> | ||
241 | </member> | ||
242 | <member name="F:OpenMetaverse.StructuredData.OSDType.Integer"> | ||
243 | <summary></summary> | ||
244 | </member> | ||
245 | <member name="F:OpenMetaverse.StructuredData.OSDType.Real"> | ||
246 | <summary></summary> | ||
247 | </member> | ||
248 | <member name="F:OpenMetaverse.StructuredData.OSDType.String"> | ||
249 | <summary></summary> | ||
250 | </member> | ||
251 | <member name="F:OpenMetaverse.StructuredData.OSDType.UUID"> | ||
252 | <summary></summary> | ||
253 | </member> | ||
254 | <member name="F:OpenMetaverse.StructuredData.OSDType.Date"> | ||
255 | <summary></summary> | ||
256 | </member> | ||
257 | <member name="F:OpenMetaverse.StructuredData.OSDType.URI"> | ||
258 | <summary></summary> | ||
259 | </member> | ||
260 | <member name="F:OpenMetaverse.StructuredData.OSDType.Binary"> | ||
261 | <summary></summary> | ||
262 | </member> | ||
263 | <member name="F:OpenMetaverse.StructuredData.OSDType.Map"> | ||
264 | <summary></summary> | ||
265 | </member> | ||
266 | <member name="F:OpenMetaverse.StructuredData.OSDType.Array"> | ||
267 | <summary></summary> | ||
268 | </member> | ||
269 | <member name="T:OpenMetaverse.StructuredData.OSDException"> | ||
270 | <summary> | ||
271 | |||
272 | </summary> | ||
273 | </member> | ||
274 | <member name="T:OpenMetaverse.StructuredData.OSD"> | ||
275 | <summary> | ||
276 | |||
277 | </summary> | ||
278 | </member> | ||
279 | <member name="M:OpenMetaverse.StructuredData.OSD.SerializeMembers(System.Object)"> | ||
280 | <summary> | ||
281 | Uses reflection to create an SDMap from all of the SD | ||
282 | serializable types in an object | ||
283 | </summary> | ||
284 | <param name="obj">Class or struct containing serializable types</param> | ||
285 | <returns>An SDMap holding the serialized values from the | ||
286 | container object</returns> | ||
287 | </member> | ||
288 | <member name="M:OpenMetaverse.StructuredData.OSD.DeserializeMembers(System.Object@,OpenMetaverse.StructuredData.OSDMap)"> | ||
289 | <summary> | ||
290 | Uses reflection to deserialize member variables in an object from | ||
291 | an SDMap | ||
292 | </summary> | ||
293 | <param name="obj">Reference to an object to fill with deserialized | ||
294 | values</param> | ||
295 | <param name="serialized">Serialized values to put in the target | ||
296 | object</param> | ||
297 | </member> | ||
298 | <member name="T:OpenMetaverse.StructuredData.OSDBoolean"> | ||
299 | <summary> | ||
300 | |||
301 | </summary> | ||
302 | </member> | ||
303 | <member name="T:OpenMetaverse.StructuredData.OSDInteger"> | ||
304 | <summary> | ||
305 | |||
306 | </summary> | ||
307 | </member> | ||
308 | <member name="T:OpenMetaverse.StructuredData.OSDReal"> | ||
309 | <summary> | ||
310 | |||
311 | </summary> | ||
312 | </member> | ||
313 | <member name="T:OpenMetaverse.StructuredData.OSDString"> | ||
314 | <summary> | ||
315 | |||
316 | </summary> | ||
317 | </member> | ||
318 | <member name="T:OpenMetaverse.StructuredData.OSDUUID"> | ||
319 | <summary> | ||
320 | |||
321 | </summary> | ||
322 | </member> | ||
323 | <member name="T:OpenMetaverse.StructuredData.OSDDate"> | ||
324 | <summary> | ||
325 | |||
326 | </summary> | ||
327 | </member> | ||
328 | <member name="T:OpenMetaverse.StructuredData.OSDUri"> | ||
329 | <summary> | ||
330 | |||
331 | </summary> | ||
332 | </member> | ||
333 | <member name="T:OpenMetaverse.StructuredData.OSDBinary"> | ||
334 | <summary> | ||
335 | |||
336 | </summary> | ||
337 | </member> | ||
338 | <member name="T:OpenMetaverse.StructuredData.OSDMap"> | ||
339 | <summary> | ||
340 | |||
341 | </summary> | ||
342 | </member> | ||
343 | <member name="T:OpenMetaverse.StructuredData.OSDArray"> | ||
344 | <summary> | ||
345 | |||
346 | </summary> | ||
347 | </member> | ||
348 | </members> | 348 | </members> |
349 | </doc> | 349 | </doc> |
diff --git a/bin/OpenMetaverse.StructuredData.dll b/bin/OpenMetaverse.StructuredData.dll index d980531..ed613e7 100755 --- a/bin/OpenMetaverse.StructuredData.dll +++ b/bin/OpenMetaverse.StructuredData.dll | |||
Binary files differ | |||
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 28c16cf..28369a3 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -691,6 +691,12 @@ | |||
691 | ; enable_windlight = false | 691 | ; enable_windlight = false |
692 | 692 | ||
693 | 693 | ||
694 | [Materials] | ||
695 | ;# {enable_materials} {} {Enable Materials support?} {true false} true | ||
696 | ;; This enables the use of Materials. | ||
697 | ; enable_materials = true | ||
698 | |||
699 | |||
694 | [DataSnapshot] | 700 | [DataSnapshot] |
695 | ;# {index_sims} {} {Enable data snapshotting (search)?} {true false} false | 701 | ;# {index_sims} {} {Enable data snapshotting (search)?} {true false} false |
696 | ;; The following set of configs pertains to search. | 702 | ;; The following set of configs pertains to search. |
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index ae7b794..0da99ba 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini | |||
@@ -539,6 +539,16 @@ | |||
539 | ; | 539 | ; |
540 | ;TextureSendLimit = 20 | 540 | ;TextureSendLimit = 20 |
541 | 541 | ||
542 | ; CannibalizeTextureRate allows bandwidth to be moved from the | ||
543 | ; UDP texture throttle to the task throttle. Since most viewers | ||
544 | ; use HTTP textures, this provides a means of using what is largely | ||
545 | ; unused bandwidth in the total throttle. The value is the proportion | ||
546 | ; of the texture rate to move to the task queue. It must be between | ||
547 | ; 0.0 (none of the bandwidth is cannibalized) and 0.9 (90% of the | ||
548 | ; bandwidth is grabbed) | ||
549 | ; | ||
550 | ; CannibalizeTextureRate = 0.5 | ||
551 | |||
542 | ; Quash and remove any light properties from attachments not on the | 552 | ; Quash and remove any light properties from attachments not on the |
543 | ; hands. This allows flashlights and lanterns to function, but kills | 553 | ; hands. This allows flashlights and lanterns to function, but kills |
544 | ; silly vanity "Facelights" dead. Sorry, head mounted miner's lamps | 554 | ; silly vanity "Facelights" dead. Sorry, head mounted miner's lamps |