aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2010-08-26 00:11:07 +0100
committerMelanie2010-08-26 00:11:07 +0100
commitfc8d2be632c754338b136fe4a3d57c40b0190ce7 (patch)
tree94bb954bdf258e968e8c337ad1da57ba9fa68b91
parentMerge branch 'master' into careminster-presence-refactor (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-fc8d2be632c754338b136fe4a3d57c40b0190ce7.zip
opensim-SC-fc8d2be632c754338b136fe4a3d57c40b0190ce7.tar.gz
opensim-SC-fc8d2be632c754338b136fe4a3d57c40b0190ce7.tar.bz2
opensim-SC-fc8d2be632c754338b136fe4a3d57c40b0190ce7.tar.xz
Merge branch 'master' into careminster-presence-refactor
This was rather conflicted. Please test linking.
-rw-r--r--OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs4
-rw-r--r--OpenSim/Data/MySQL/MySQLLegacyRegionData.cs1
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs44
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs512
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs78
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs38
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs90
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs111
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs69
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/CMEntityCollection.cs19
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs35
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/CMView.cs9
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs173
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs38
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs69
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs505
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Helpers.cs11
23 files changed, 1277 insertions, 607 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
index 7d017a6..7ff8737 100644
--- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
@@ -89,7 +89,6 @@ namespace OpenSim.Data.MSSQL
89 Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); 89 Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>();
90 SceneObjectGroup grp = null; 90 SceneObjectGroup grp = null;
91 91
92
93 string sql = "SELECT *, " + 92 string sql = "SELECT *, " +
94 "sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " + 93 "sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " +
95 "FROM prims " + 94 "FROM prims " +
@@ -232,7 +231,7 @@ namespace OpenSim.Data.MSSQL
232 /// <param name="regionUUID"></param> 231 /// <param name="regionUUID"></param>
233 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 232 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
234 { 233 {
235 _Log.InfoFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count); 234 _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count);
236 235
237 using (SqlConnection conn = new SqlConnection(m_connectionString)) 236 using (SqlConnection conn = new SqlConnection(m_connectionString))
238 { 237 {
@@ -291,7 +290,6 @@ namespace OpenSim.Data.MSSQL
291 } 290 }
292 } 291 }
293 } 292 }
294
295 } 293 }
296 294
297 /// <summary> 295 /// <summary>
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
index 1edcb5d..37d7a88 100644
--- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
@@ -239,6 +239,7 @@ namespace OpenSim.Data.MySQL
239 239
240 ExecuteNonQuery(cmd); 240 ExecuteNonQuery(cmd);
241 } 241 }
242
242 cmd.Dispose(); 243 cmd.Dispose();
243 } 244 }
244 } 245 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index c802490..74784ae 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -427,7 +427,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
427 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 427 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
428 { 428 {
429 if (!m_scene.Permissions.CanRezObject( 429 if (!m_scene.Permissions.CanRezObject(
430 part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) 430 part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
431 return; 431 return;
432 432
433 presence.Appearance.DetachAttachment(itemID); 433 presence.Appearance.DetachAttachment(itemID);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index cc12df0..2a36362 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -549,7 +549,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
549 } 549 }
550 550
551 if (!m_Scene.Permissions.CanRezObject( 551 if (!m_Scene.Permissions.CanRezObject(
552 group.Children.Count, remoteClient.AgentId, pos) 552 group.PrimCount, remoteClient.AgentId, pos)
553 && !attachment) 553 && !attachment)
554 { 554 {
555 // The client operates in no fail mode. It will 555 // The client operates in no fail mode. It will
@@ -629,7 +629,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
629 rootPart.Name = item.Name; 629 rootPart.Name = item.Name;
630 rootPart.Description = item.Description; 630 rootPart.Description = item.Description;
631 631
632 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); 632 List<SceneObjectPart> partList = null;
633 lock (group.Children)
634 partList = new List<SceneObjectPart>(group.Children.Values);
633 635
634 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 636 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
635 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0) 637 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 57b7672..a402f4f 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -243,29 +243,29 @@ namespace OpenSim.Region.CoreModules.World.Archiver
243 // to the same scene (when this is possible). 243 // to the same scene (when this is possible).
244 sceneObject.ResetIDs(); 244 sceneObject.ResetIDs();
245 245
246 foreach (SceneObjectPart part in sceneObject.Children.Values) 246 lock (sceneObject.Children)
247 { 247 {
248 if (!ResolveUserUuid(part.CreatorID)) 248 foreach (SceneObjectPart part in sceneObject.Children.Values)
249 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
250
251 if (!ResolveUserUuid(part.OwnerID))
252 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
253
254 if (!ResolveUserUuid(part.LastOwnerID))
255 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
256
257 // And zap any troublesome sit target information
258 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
259 part.SitTargetPosition = new Vector3(0, 0, 0);
260
261 // Fix ownership/creator of inventory items
262 // Not doing so results in inventory items
263 // being no copy/no mod for everyone
264 part.TaskInventory.LockItemsForRead(true);
265 TaskInventoryDictionary inv = part.TaskInventory;
266 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
267 { 249 {
268 if (!ResolveUserUuid(kvp.Value.OwnerID)) 250 if (!ResolveUserUuid(part.CreatorID))
251 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
252
253 if (!ResolveUserUuid(part.OwnerID))
254 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
255
256 if (!ResolveUserUuid(part.LastOwnerID))
257 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
258
259 // And zap any troublesome sit target information
260 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
261 part.SitTargetPosition = new Vector3(0, 0, 0);
262
263 // Fix ownership/creator of inventory items
264 // Not doing so results in inventory items
265 // being no copy/no mod for everyone
266 part.TaskInventory.LockItemsForRead(true);
267 TaskInventoryDictionary inv = part.TaskInventory;
268 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
269 { 269 {
270 if (!ResolveUserUuid(kvp.Value.OwnerID)) 270 if (!ResolveUserUuid(kvp.Value.OwnerID))
271 { 271 {
@@ -276,8 +276,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
276 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; 276 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
277 } 277 }
278 } 278 }
279 part.TaskInventory.LockItemsForRead(false);
279 } 280 }
280 part.TaskInventory.LockItemsForRead(false);
281 } 281 }
282 282
283 if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) 283 if (m_scene.AddRestoredSceneObject(sceneObject, true, false))
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 62abd4c..8ce6daf 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -128,7 +128,10 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
128 group.SetOwnerId(remoteClient.AgentId); 128 group.SetOwnerId(remoteClient.AgentId);
129 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId); 129 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId);
130 130
131 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); 131 List<SceneObjectPart> partList = null;
132
133 lock (group.Children)
134 partList = new List<SceneObjectPart>(group.Children.Values);
132 135
133 if (m_scene.Permissions.PropagatePermissions()) 136 if (m_scene.Permissions.PropagatePermissions())
134 { 137 {
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
index b96d95a..2f70c0a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
@@ -227,277 +227,281 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
227 { 227 {
228 SceneObjectGroup mapdot = (SceneObjectGroup)obj; 228 SceneObjectGroup mapdot = (SceneObjectGroup)obj;
229 Color mapdotspot = Color.Gray; // Default color when prim color is white 229 Color mapdotspot = Color.Gray; // Default color when prim color is white
230
230 // Loop over prim in group 231 // Loop over prim in group
231 foreach (SceneObjectPart part in mapdot.Children.Values) 232 lock (mapdot.Children)
232 { 233 {
233 if (part == null) 234 foreach (SceneObjectPart part in mapdot.Children.Values)
234 continue;
235
236 // Draw if the object is at least 1 meter wide in any direction
237 if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
238 { 235 {
239 // Try to get the RGBA of the default texture entry.. 236 if (part == null)
240 // 237 continue;
241 try 238
239 // Draw if the object is at least 1 meter wide in any direction
240 if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
242 { 241 {
243 // get the null checks out of the way 242 // Try to get the RGBA of the default texture entry..
244 // skip the ones that break 243 //
245 if (part == null) 244 try
246 continue;
247
248 if (part.Shape == null)
249 continue;
250
251 if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass)
252 continue; // eliminates trees from this since we don't really have a good tree representation
253 // if you want tree blocks on the map comment the above line and uncomment the below line
254 //mapdotspot = Color.PaleGreen;
255
256 Primitive.TextureEntry textureEntry = part.Shape.Textures;
257
258 if (textureEntry == null || textureEntry.DefaultTexture == null)
259 continue;
260
261 Color4 texcolor = textureEntry.DefaultTexture.RGBA;
262
263 // Not sure why some of these are null, oh well.
264
265 int colorr = 255 - (int)(texcolor.R * 255f);
266 int colorg = 255 - (int)(texcolor.G * 255f);
267 int colorb = 255 - (int)(texcolor.B * 255f);
268
269 if (!(colorr == 255 && colorg == 255 && colorb == 255))
270 { 245 {
271 //Try to set the map spot color 246 // get the null checks out of the way
272 try 247 // skip the ones that break
273 { 248 if (part == null)
274 // If the color gets goofy somehow, skip it *shakes fist at Color4 249 continue;
275 mapdotspot = Color.FromArgb(colorr, colorg, colorb); 250
276 } 251 if (part.Shape == null)
277 catch (ArgumentException) 252 continue;
253
254 if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass)
255 continue; // eliminates trees from this since we don't really have a good tree representation
256 // if you want tree blocks on the map comment the above line and uncomment the below line
257 //mapdotspot = Color.PaleGreen;
258
259 Primitive.TextureEntry textureEntry = part.Shape.Textures;
260
261 if (textureEntry == null || textureEntry.DefaultTexture == null)
262 continue;
263
264 Color4 texcolor = textureEntry.DefaultTexture.RGBA;
265
266 // Not sure why some of these are null, oh well.
267
268 int colorr = 255 - (int)(texcolor.R * 255f);
269 int colorg = 255 - (int)(texcolor.G * 255f);
270 int colorb = 255 - (int)(texcolor.B * 255f);
271
272 if (!(colorr == 255 && colorg == 255 && colorb == 255))
278 { 273 {
274 //Try to set the map spot color
275 try
276 {
277 // If the color gets goofy somehow, skip it *shakes fist at Color4
278 mapdotspot = Color.FromArgb(colorr, colorg, colorb);
279 }
280 catch (ArgumentException)
281 {
282 }
279 } 283 }
280 } 284 }
281 } 285 catch (IndexOutOfRangeException)
282 catch (IndexOutOfRangeException) 286 {
283 { 287 // Windows Array
284 // Windows Array 288 }
285 } 289 catch (ArgumentOutOfRangeException)
286 catch (ArgumentOutOfRangeException) 290 {
287 { 291 // Mono Array
288 // Mono Array 292 }
289 } 293
290 294 Vector3 pos = part.GetWorldPosition();
291 Vector3 pos = part.GetWorldPosition(); 295
292 296 // skip prim outside of retion
293 // skip prim outside of retion 297 if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
294 if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
295 continue;
296
297 // skip prim in non-finite position
298 if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
299 Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
300 continue;
301
302 // Figure out if object is under 256m above the height of the terrain
303 bool isBelow256AboveTerrain = false;
304
305 try
306 {
307 isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
308 }
309 catch (Exception)
310 {
311 }
312
313 if (isBelow256AboveTerrain)
314 {
315 // Translate scale by rotation so scale is represented properly when object is rotated
316 Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
317 Vector3 scale = new Vector3();
318 Vector3 tScale = new Vector3();
319 Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
320
321 Quaternion llrot = part.GetWorldRotation();
322 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
323 scale = lscale * rot;
324
325 // negative scales don't work in this situation
326 scale.X = Math.Abs(scale.X);
327 scale.Y = Math.Abs(scale.Y);
328 scale.Z = Math.Abs(scale.Z);
329
330 // This scaling isn't very accurate and doesn't take into account the face rotation :P
331 int mapdrawstartX = (int)(pos.X - scale.X);
332 int mapdrawstartY = (int)(pos.Y - scale.Y);
333 int mapdrawendX = (int)(pos.X + scale.X);
334 int mapdrawendY = (int)(pos.Y + scale.Y);
335
336 // If object is beyond the edge of the map, don't draw it to avoid errors
337 if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
338 || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
339 || mapdrawendY > ((int)Constants.RegionSize - 1))
340 continue; 298 continue;
341 299
342#region obb face reconstruction part duex 300 // skip prim in non-finite position
343 Vector3[] vertexes = new Vector3[8]; 301 if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
344 302 Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
345 // float[] distance = new float[6]; 303 continue;
346 Vector3[] FaceA = new Vector3[6]; // vertex A for Facei 304
347 Vector3[] FaceB = new Vector3[6]; // vertex B for Facei 305 // Figure out if object is under 256m above the height of the terrain
348 Vector3[] FaceC = new Vector3[6]; // vertex C for Facei 306 bool isBelow256AboveTerrain = false;
349 Vector3[] FaceD = new Vector3[6]; // vertex D for Facei 307
350 308 try
351 tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
352 scale = ((tScale * rot));
353 vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
354 // vertexes[0].x = pos.X + vertexes[0].x;
355 //vertexes[0].y = pos.Y + vertexes[0].y;
356 //vertexes[0].z = pos.Z + vertexes[0].z;
357
358 FaceA[0] = vertexes[0];
359 FaceB[3] = vertexes[0];
360 FaceA[4] = vertexes[0];
361
362 tScale = lscale;
363 scale = ((tScale * rot));
364 vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
365
366 // vertexes[1].x = pos.X + vertexes[1].x;
367 // vertexes[1].y = pos.Y + vertexes[1].y;
368 //vertexes[1].z = pos.Z + vertexes[1].z;
369
370 FaceB[0] = vertexes[1];
371 FaceA[1] = vertexes[1];
372 FaceC[4] = vertexes[1];
373
374 tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
375 scale = ((tScale * rot));
376
377 vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
378
379 //vertexes[2].x = pos.X + vertexes[2].x;
380 //vertexes[2].y = pos.Y + vertexes[2].y;
381 //vertexes[2].z = pos.Z + vertexes[2].z;
382
383 FaceC[0] = vertexes[2];
384 FaceD[3] = vertexes[2];
385 FaceC[5] = vertexes[2];
386
387 tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
388 scale = ((tScale * rot));
389 vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
390
391 //vertexes[3].x = pos.X + vertexes[3].x;
392 // vertexes[3].y = pos.Y + vertexes[3].y;
393 // vertexes[3].z = pos.Z + vertexes[3].z;
394
395 FaceD[0] = vertexes[3];
396 FaceC[1] = vertexes[3];
397 FaceA[5] = vertexes[3];
398
399 tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
400 scale = ((tScale * rot));
401 vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
402
403 // vertexes[4].x = pos.X + vertexes[4].x;
404 // vertexes[4].y = pos.Y + vertexes[4].y;
405 // vertexes[4].z = pos.Z + vertexes[4].z;
406
407 FaceB[1] = vertexes[4];
408 FaceA[2] = vertexes[4];
409 FaceD[4] = vertexes[4];
410
411 tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
412 scale = ((tScale * rot));
413 vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
414
415 // vertexes[5].x = pos.X + vertexes[5].x;
416 // vertexes[5].y = pos.Y + vertexes[5].y;
417 // vertexes[5].z = pos.Z + vertexes[5].z;
418
419 FaceD[1] = vertexes[5];
420 FaceC[2] = vertexes[5];
421 FaceB[5] = vertexes[5];
422
423 tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
424 scale = ((tScale * rot));
425 vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
426
427 // vertexes[6].x = pos.X + vertexes[6].x;
428 // vertexes[6].y = pos.Y + vertexes[6].y;
429 // vertexes[6].z = pos.Z + vertexes[6].z;
430
431 FaceB[2] = vertexes[6];
432 FaceA[3] = vertexes[6];
433 FaceB[4] = vertexes[6];
434
435 tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
436 scale = ((tScale * rot));
437 vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
438
439 // vertexes[7].x = pos.X + vertexes[7].x;
440 // vertexes[7].y = pos.Y + vertexes[7].y;
441 // vertexes[7].z = pos.Z + vertexes[7].z;
442
443 FaceD[2] = vertexes[7];
444 FaceC[3] = vertexes[7];
445 FaceD[5] = vertexes[7];
446#endregion
447
448 //int wy = 0;
449
450 //bool breakYN = false; // If we run into an error drawing, break out of the
451 // loop so we don't lag to death on error handling
452 DrawStruct ds = new DrawStruct();
453 ds.brush = new SolidBrush(mapdotspot);
454 //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
455
456 ds.trns = new face[FaceA.Length];
457
458 for (int i = 0; i < FaceA.Length; i++)
459 { 309 {
460 Point[] working = new Point[5]; 310 isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
461 working[0] = project(FaceA[i], axPos);
462 working[1] = project(FaceB[i], axPos);
463 working[2] = project(FaceD[i], axPos);
464 working[3] = project(FaceC[i], axPos);
465 working[4] = project(FaceA[i], axPos);
466
467 face workingface = new face();
468 workingface.pts = working;
469
470 ds.trns[i] = workingface;
471 } 311 }
472 312 catch (Exception)
473 z_sort.Add(part.LocalId, ds); 313 {
474 z_localIDs.Add(part.LocalId); 314 }
475 z_sortheights.Add(pos.Z); 315
476 316 if (isBelow256AboveTerrain)
477 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) 317 {
478 //{ 318 // Translate scale by rotation so scale is represented properly when object is rotated
479 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) 319 Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
320 Vector3 scale = new Vector3();
321 Vector3 tScale = new Vector3();
322 Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
323
324 Quaternion llrot = part.GetWorldRotation();
325 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
326 scale = lscale * rot;
327
328 // negative scales don't work in this situation
329 scale.X = Math.Abs(scale.X);
330 scale.Y = Math.Abs(scale.Y);
331 scale.Z = Math.Abs(scale.Z);
332
333 // This scaling isn't very accurate and doesn't take into account the face rotation :P
334 int mapdrawstartX = (int)(pos.X - scale.X);
335 int mapdrawstartY = (int)(pos.Y - scale.Y);
336 int mapdrawendX = (int)(pos.X + scale.X);
337 int mapdrawendY = (int)(pos.Y + scale.Y);
338
339 // If object is beyond the edge of the map, don't draw it to avoid errors
340 if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
341 || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
342 || mapdrawendY > ((int)Constants.RegionSize - 1))
343 continue;
344
345 #region obb face reconstruction part duex
346 Vector3[] vertexes = new Vector3[8];
347
348 // float[] distance = new float[6];
349 Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
350 Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
351 Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
352 Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
353
354 tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
355 scale = ((tScale * rot));
356 vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
357 // vertexes[0].x = pos.X + vertexes[0].x;
358 //vertexes[0].y = pos.Y + vertexes[0].y;
359 //vertexes[0].z = pos.Z + vertexes[0].z;
360
361 FaceA[0] = vertexes[0];
362 FaceB[3] = vertexes[0];
363 FaceA[4] = vertexes[0];
364
365 tScale = lscale;
366 scale = ((tScale * rot));
367 vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
368
369 // vertexes[1].x = pos.X + vertexes[1].x;
370 // vertexes[1].y = pos.Y + vertexes[1].y;
371 //vertexes[1].z = pos.Z + vertexes[1].z;
372
373 FaceB[0] = vertexes[1];
374 FaceA[1] = vertexes[1];
375 FaceC[4] = vertexes[1];
376
377 tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
378 scale = ((tScale * rot));
379
380 vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
381
382 //vertexes[2].x = pos.X + vertexes[2].x;
383 //vertexes[2].y = pos.Y + vertexes[2].y;
384 //vertexes[2].z = pos.Z + vertexes[2].z;
385
386 FaceC[0] = vertexes[2];
387 FaceD[3] = vertexes[2];
388 FaceC[5] = vertexes[2];
389
390 tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
391 scale = ((tScale * rot));
392 vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
393
394 //vertexes[3].x = pos.X + vertexes[3].x;
395 // vertexes[3].y = pos.Y + vertexes[3].y;
396 // vertexes[3].z = pos.Z + vertexes[3].z;
397
398 FaceD[0] = vertexes[3];
399 FaceC[1] = vertexes[3];
400 FaceA[5] = vertexes[3];
401
402 tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
403 scale = ((tScale * rot));
404 vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
405
406 // vertexes[4].x = pos.X + vertexes[4].x;
407 // vertexes[4].y = pos.Y + vertexes[4].y;
408 // vertexes[4].z = pos.Z + vertexes[4].z;
409
410 FaceB[1] = vertexes[4];
411 FaceA[2] = vertexes[4];
412 FaceD[4] = vertexes[4];
413
414 tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
415 scale = ((tScale * rot));
416 vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
417
418 // vertexes[5].x = pos.X + vertexes[5].x;
419 // vertexes[5].y = pos.Y + vertexes[5].y;
420 // vertexes[5].z = pos.Z + vertexes[5].z;
421
422 FaceD[1] = vertexes[5];
423 FaceC[2] = vertexes[5];
424 FaceB[5] = vertexes[5];
425
426 tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
427 scale = ((tScale * rot));
428 vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
429
430 // vertexes[6].x = pos.X + vertexes[6].x;
431 // vertexes[6].y = pos.Y + vertexes[6].y;
432 // vertexes[6].z = pos.Z + vertexes[6].z;
433
434 FaceB[2] = vertexes[6];
435 FaceA[3] = vertexes[6];
436 FaceB[4] = vertexes[6];
437
438 tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
439 scale = ((tScale * rot));
440 vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
441
442 // vertexes[7].x = pos.X + vertexes[7].x;
443 // vertexes[7].y = pos.Y + vertexes[7].y;
444 // vertexes[7].z = pos.Z + vertexes[7].z;
445
446 FaceD[2] = vertexes[7];
447 FaceC[3] = vertexes[7];
448 FaceD[5] = vertexes[7];
449 #endregion
450
451 //int wy = 0;
452
453 //bool breakYN = false; // If we run into an error drawing, break out of the
454 // loop so we don't lag to death on error handling
455 DrawStruct ds = new DrawStruct();
456 ds.brush = new SolidBrush(mapdotspot);
457 //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
458
459 ds.trns = new face[FaceA.Length];
460
461 for (int i = 0; i < FaceA.Length; i++)
462 {
463 Point[] working = new Point[5];
464 working[0] = project(FaceA[i], axPos);
465 working[1] = project(FaceB[i], axPos);
466 working[2] = project(FaceD[i], axPos);
467 working[3] = project(FaceC[i], axPos);
468 working[4] = project(FaceA[i], axPos);
469
470 face workingface = new face();
471 workingface.pts = working;
472
473 ds.trns[i] = workingface;
474 }
475
476 z_sort.Add(part.LocalId, ds);
477 z_localIDs.Add(part.LocalId);
478 z_sortheights.Add(pos.Z);
479
480 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
480 //{ 481 //{
481 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); 482 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
482 //try
483 //{ 483 //{
484 // Remember, flip the y! 484 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
485 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); 485 //try
486 //{
487 // Remember, flip the y!
488 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
489 //}
490 //catch (ArgumentException)
491 //{
492 // breakYN = true;
493 //}
494
495 //if (breakYN)
496 // break;
486 //} 497 //}
487 //catch (ArgumentException) 498
488 //{
489 // breakYN = true;
490 //}
491
492 //if (breakYN) 499 //if (breakYN)
493 // break; 500 // break;
494 //} 501 //}
495 502 } // Object is within 256m Z of terrain
496 //if (breakYN) 503 } // object is at least a meter wide
497 // break; 504 } // mapdot.Children lock
498 //}
499 } // Object is within 256m Z of terrain
500 } // object is at least a meter wide
501 } // loop over group children 505 } // loop over group children
502 } // entitybase is sceneobject group 506 } // entitybase is sceneobject group
503 } // foreach loop over entities 507 } // foreach loop over entities
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 1e2f60b..f5cd528 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
29using System.Collections; 29using System.Collections;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
32 33
33namespace OpenSim.Region.Framework.Interfaces 34namespace OpenSim.Region.Framework.Interfaces
34{ 35{
@@ -155,6 +156,17 @@ namespace OpenSim.Region.Framework.Interfaces
155 /// If no inventory item has that name then an empty list is returned. 156 /// If no inventory item has that name then an empty list is returned.
156 /// </returns> 157 /// </returns>
157 IList<TaskInventoryItem> GetInventoryItems(string name); 158 IList<TaskInventoryItem> GetInventoryItems(string name);
159
160 /// <summary>
161 /// Get the scene object referenced by an inventory item.
162 /// </summary>
163 ///
164 /// This is returned in a 'rez ready' state. That is, name, description, permissions and other details have
165 /// been adjusted to reflect the part and item from which it originates.
166 ///
167 /// <param name="item"></param>
168 /// <returns>The scene object. Null if the scene object asset couldn't be found</returns>
169 SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item);
158 170
159 /// <summary> 171 /// <summary>
160 /// Update an existing inventory item. 172 /// Update an existing inventory item.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 012732b..48508f8 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2022,60 +2022,13 @@ namespace OpenSim.Region.Framework.Scenes
2022 if (null == item) 2022 if (null == item)
2023 return null; 2023 return null;
2024 2024
2025 UUID ownerID = item.OwnerID; 2025 SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item);
2026 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); 2026
2027 2027 if (null == group)
2028 if (null == rezAsset)
2029 return null;
2030
2031 string xmlData = Utils.BytesToString(rezAsset.Data);
2032 SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
2033
2034 if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos))
2035 return null; 2028 return null;
2036
2037 group.ResetIDs();
2038
2039 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
2040
2041 // Since renaming the item in the inventory does not affect the name stored
2042 // in the serialization, transfer the correct name from the inventory to the
2043 // object itself before we rez.
2044 rootPart.Name = item.Name;
2045 rootPart.Description = item.Description;
2046
2047 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2048
2049 group.SetGroup(sourcePart.GroupID, null);
2050
2051 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
2052 {
2053 if (Permissions.PropagatePermissions())
2054 {
2055 foreach (SceneObjectPart part in partList)
2056 {
2057 part.EveryoneMask = item.EveryonePermissions;
2058 part.NextOwnerMask = item.NextPermissions;
2059 }
2060
2061 group.ApplyNextOwnerPermissions();
2062 }
2063 }
2064
2065 foreach (SceneObjectPart part in partList)
2066 {
2067 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
2068 {
2069 part.LastOwnerID = part.OwnerID;
2070 part.OwnerID = item.OwnerID;
2071 part.Inventory.ChangeInventoryOwner(item.OwnerID);
2072 }
2073
2074 part.EveryoneMask = item.EveryonePermissions;
2075 part.NextOwnerMask = item.NextPermissions;
2076 }
2077 2029
2078 rootPart.TrimPermissions(); 2030 if (!Permissions.CanRezObject(group.PrimCount, item.OwnerID, pos))
2031 return null;
2079 2032
2080 if (!Permissions.BypassPermissions()) 2033 if (!Permissions.BypassPermissions())
2081 { 2034 {
@@ -2091,7 +2044,7 @@ namespace OpenSim.Region.Framework.Scenes
2091 2044
2092 group.ScheduleGroupForFullUpdate(); 2045 group.ScheduleGroupForFullUpdate();
2093 2046
2094 return rootPart.ParentGroup; 2047 return group;
2095 } 2048 }
2096 2049
2097 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) 2050 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId)
@@ -2151,8 +2104,11 @@ namespace OpenSim.Region.Framework.Scenes
2151 sog.SetGroup(groupID, remoteClient); 2104 sog.SetGroup(groupID, remoteClient);
2152 sog.ScheduleGroupForFullUpdate(); 2105 sog.ScheduleGroupForFullUpdate();
2153 2106
2154 foreach (SceneObjectPart child in sog.Children.Values) 2107 lock (sog.Children)
2155 child.Inventory.ChangeInventoryOwner(ownerID); 2108 {
2109 foreach (SceneObjectPart child in sog.Children.Values)
2110 child.Inventory.ChangeInventoryOwner(ownerID);
2111 }
2156 } 2112 }
2157 else 2113 else
2158 { 2114 {
@@ -2162,16 +2118,18 @@ namespace OpenSim.Region.Framework.Scenes
2162 if (sog.GroupID != groupID) 2118 if (sog.GroupID != groupID)
2163 continue; 2119 continue;
2164 2120
2165 foreach (SceneObjectPart child in sog.Children.Values) 2121 lock (sog.Children)
2166 { 2122 {
2167 child.LastOwnerID = child.OwnerID; 2123 foreach (SceneObjectPart child in sog.Children.Values)
2168 child.Inventory.ChangeInventoryOwner(groupID); 2124 {
2125 child.LastOwnerID = child.OwnerID;
2126 child.Inventory.ChangeInventoryOwner(groupID);
2127 }
2169 } 2128 }
2170 2129
2171 sog.SetOwnerId(groupID); 2130 sog.SetOwnerId(groupID);
2172 sog.ApplyNextOwnerPermissions(); 2131 sog.ApplyNextOwnerPermissions();
2173 } 2132 }
2174
2175 } 2133 }
2176 2134
2177 foreach (uint localID in localIDs) 2135 foreach (uint localID in localIDs)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index e25b1f1..9f1575d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -156,21 +156,29 @@ namespace OpenSim.Region.Framework.Scenes
156 } 156 }
157 break; 157 break;
158 } 158 }
159 else 159 else
160 { 160 {
161 // We also need to check the children of this prim as they 161 // We also need to check the children of this prim as they
162 // can be selected as well and send property information 162 // can be selected as well and send property information
163 bool foundPrim = false; 163 bool foundPrim = false;
164 foreach (KeyValuePair<UUID, SceneObjectPart> child in ((SceneObjectGroup) ent).Children) 164
165 { 165 SceneObjectGroup sog = ent as SceneObjectGroup;
166 if (child.Value.LocalId == primLocalID) 166
167 { 167 lock (sog.Children)
168 child.Value.GetProperties(remoteClient); 168 {
169 foundPrim = true; 169 foreach (KeyValuePair<UUID, SceneObjectPart> child in (sog.Children))
170 break; 170 {
171 } 171 if (child.Value.LocalId == primLocalID)
172 } 172 {
173 if (foundPrim) break; 173 child.Value.GetProperties(remoteClient);
174 foundPrim = true;
175 break;
176 }
177 }
178 }
179
180 if (foundPrim)
181 break;
174 } 182 }
175 } 183 }
176 } 184 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 520f1a1..ec97d25 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1790,8 +1790,9 @@ namespace OpenSim.Region.Framework.Scenes
1790 1790
1791 if (group.RootPart == null) 1791 if (group.RootPart == null)
1792 { 1792 {
1793 m_log.ErrorFormat("[SCENE]: Found a SceneObjectGroup with m_rootPart == null and {0} children", 1793 m_log.ErrorFormat(
1794 group.Children == null ? 0 : group.Children.Count); 1794 "[SCENE]: Found a SceneObjectGroup with m_rootPart == null and {0} children",
1795 group.Children == null ? 0 : group.PrimCount);
1795 } 1796 }
1796 1797
1797 AddRestoredSceneObject(group, true, true); 1798 AddRestoredSceneObject(group, true, true);
@@ -2130,18 +2131,22 @@ namespace OpenSim.Region.Framework.Scenes
2130 group.RemoveScriptInstances(true); 2131 group.RemoveScriptInstances(true);
2131 } 2132 }
2132 2133
2133 foreach (SceneObjectPart part in group.Children.Values) 2134 lock (group.Children)
2134 { 2135 {
2135 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) 2136 foreach (SceneObjectPart part in group.Children.Values)
2136 { 2137 {
2137 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? 2138 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
2138 } 2139 {
2139 else if (part.PhysActor != null) 2140 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
2140 { 2141 }
2141 PhysicsScene.RemovePrim(part.PhysActor); 2142 else if (part.PhysActor != null)
2142 part.PhysActor = null; 2143 {
2144 PhysicsScene.RemovePrim(part.PhysActor);
2145 part.PhysActor = null;
2146 }
2143 } 2147 }
2144 } 2148 }
2149
2145// if (rootPart.PhysActor != null) 2150// if (rootPart.PhysActor != null)
2146// { 2151// {
2147// PhysicsScene.RemovePrim(rootPart.PhysActor); 2152// PhysicsScene.RemovePrim(rootPart.PhysActor);
@@ -2498,14 +2503,16 @@ namespace OpenSim.Region.Framework.Scenes
2498 2503
2499 // Force allocation of new LocalId 2504 // Force allocation of new LocalId
2500 // 2505 //
2501 foreach (SceneObjectPart p in sceneObject.Children.Values) 2506 lock (sceneObject.Children)
2502 p.LocalId = 0; 2507 {
2508 foreach (SceneObjectPart p in sceneObject.Children.Values)
2509 p.LocalId = 0;
2510 }
2503 2511
2504 if (sceneObject.IsAttachmentCheckFull()) // Attachment 2512 if (sceneObject.IsAttachmentCheckFull()) // Attachment
2505 { 2513 {
2506 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); 2514 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
2507 sceneObject.RootPart.AddFlag(PrimFlags.Phantom); 2515 sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
2508
2509 2516
2510 // Don't sent a full update here because this will cause full updates to be sent twice for 2517 // Don't sent a full update here because this will cause full updates to be sent twice for
2511 // attachments on region crossings, resulting in viewer glitches. 2518 // attachments on region crossings, resulting in viewer glitches.
@@ -2519,7 +2526,6 @@ namespace OpenSim.Region.Framework.Scenes
2519 2526
2520 if (sp != null) 2527 if (sp != null)
2521 { 2528 {
2522
2523 SceneObjectGroup grp = sceneObject; 2529 SceneObjectGroup grp = sceneObject;
2524 2530
2525 m_log.DebugFormat( 2531 m_log.DebugFormat(
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 3a0532a..9c5ee60 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -384,34 +384,35 @@ namespace OpenSim.Region.Framework.Scenes
384// "[SCENE GRAPH]: Adding object {0} {1} to region {2}", 384// "[SCENE GRAPH]: Adding object {0} {1} to region {2}",
385// sceneObject.Name, sceneObject.UUID, m_parentScene.RegionInfo.RegionName); 385// sceneObject.Name, sceneObject.UUID, m_parentScene.RegionInfo.RegionName);
386 386
387 if (m_parentScene.m_clampPrimSize) 387 lock (sceneObject.Children)
388 { 388 {
389 foreach (SceneObjectPart part in sceneObject.Children.Values) 389 if (m_parentScene.m_clampPrimSize)
390 { 390 {
391 Vector3 scale = part.Shape.Scale; 391 foreach (SceneObjectPart part in sceneObject.Children.Values)
392 392 {
393 if (scale.X > m_parentScene.m_maxNonphys) 393 Vector3 scale = part.Shape.Scale;
394 scale.X = m_parentScene.m_maxNonphys; 394
395 if (scale.Y > m_parentScene.m_maxNonphys) 395 if (scale.X > m_parentScene.m_maxNonphys)
396 scale.Y = m_parentScene.m_maxNonphys; 396 scale.X = m_parentScene.m_maxNonphys;
397 if (scale.Z > m_parentScene.m_maxNonphys) 397 if (scale.Y > m_parentScene.m_maxNonphys)
398 scale.Z = m_parentScene.m_maxNonphys; 398 scale.Y = m_parentScene.m_maxNonphys;
399 399 if (scale.Z > m_parentScene.m_maxNonphys)
400 part.Shape.Scale = scale; 400 scale.Z = m_parentScene.m_maxNonphys;
401
402 part.Shape.Scale = scale;
403 }
401 } 404 }
402 } 405
403 406 sceneObject.AttachToScene(m_parentScene);
404 sceneObject.AttachToScene(m_parentScene);
405
406 if (sendClientUpdates)
407 sceneObject.ScheduleGroupForFullUpdate();
408
409 Entities.Add(sceneObject);
410 m_numPrim += sceneObject.Children.Count;
411 407
412 if (attachToBackup) 408 if (sendClientUpdates)
413 { 409 sceneObject.ScheduleGroupForFullUpdate();
414 sceneObject.AttachToBackup(); 410
411 Entities.Add(sceneObject);
412 m_numPrim += sceneObject.Children.Count;
413
414 if (attachToBackup)
415 sceneObject.AttachToBackup();
415 } 416 }
416 417
417 if (OnObjectCreate != null) 418 if (OnObjectCreate != null)
@@ -448,10 +449,10 @@ namespace OpenSim.Region.Framework.Scenes
448 449
449 if (!resultOfObjectLinked) 450 if (!resultOfObjectLinked)
450 { 451 {
451 m_numPrim -= ((SceneObjectGroup) Entities[uuid]).Children.Count; 452 m_numPrim -= grp.PrimCount;
452 453
453 if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) 454 if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
454 RemovePhysicalPrim(grp.Children.Count); 455 RemovePhysicalPrim(grp.PrimCount);
455 } 456 }
456 457
457 if (OnObjectRemove != null) 458 if (OnObjectRemove != null)
@@ -966,8 +967,12 @@ namespace OpenSim.Region.Framework.Scenes
966 { 967 {
967 if (SceneObjectGroupsByFullID.TryGetValue(fullID, out sog)) 968 if (SceneObjectGroupsByFullID.TryGetValue(fullID, out sog))
968 { 969 {
969 if (sog.Children.ContainsKey(fullID)) 970 lock (sog.Children)
970 return sog; 971 {
972 if (sog.Children.ContainsKey(fullID))
973 return sog;
974 }
975
971 SceneObjectGroupsByFullID.Remove(fullID); 976 SceneObjectGroupsByFullID.Remove(fullID);
972 } 977 }
973 } 978 }
@@ -1678,7 +1683,7 @@ namespace OpenSim.Region.Framework.Scenes
1678 { 1683 {
1679 if (part != null) 1684 if (part != null)
1680 { 1685 {
1681 if (part.ParentGroup.Children.Count != 1) // Skip single 1686 if (part.ParentGroup.PrimCount != 1) // Skip single
1682 { 1687 {
1683 if (part.LinkNum < 2) // Root 1688 if (part.LinkNum < 2) // Root
1684 rootParts.Add(part); 1689 rootParts.Add(part);
@@ -1717,8 +1722,15 @@ namespace OpenSim.Region.Framework.Scenes
1717 // However, editing linked parts and unlinking may be different 1722 // However, editing linked parts and unlinking may be different
1718 // 1723 //
1719 SceneObjectGroup group = root.ParentGroup; 1724 SceneObjectGroup group = root.ParentGroup;
1720 List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Children.Values); 1725
1721 int numChildren = group.Children.Count; 1726 List<SceneObjectPart> newSet = null;
1727 int numChildren = -1;
1728
1729 lock (group.Children)
1730 {
1731 newSet = new List<SceneObjectPart>(group.Children.Values);
1732 numChildren = group.PrimCount;
1733 }
1722 1734
1723 // If there are prims left in a link set, but the root is 1735 // If there are prims left in a link set, but the root is
1724 // slated for unlink, we need to do this 1736 // slated for unlink, we need to do this
@@ -1808,12 +1820,17 @@ namespace OpenSim.Region.Framework.Scenes
1808 { 1820 {
1809 if (ent is SceneObjectGroup) 1821 if (ent is SceneObjectGroup)
1810 { 1822 {
1811 foreach (KeyValuePair<UUID, SceneObjectPart> subent in ((SceneObjectGroup)ent).Children) 1823 SceneObjectGroup sog = ent as SceneObjectGroup;
1824
1825 lock (sog.Children)
1812 { 1826 {
1813 if (subent.Value.LocalId == localID) 1827 foreach (KeyValuePair<UUID, SceneObjectPart> subent in sog.Children)
1814 { 1828 {
1815 objid = subent.Key; 1829 if (subent.Value.LocalId == localID)
1816 obj = subent.Value; 1830 {
1831 objid = subent.Key;
1832 obj = subent.Value;
1833 }
1817 } 1834 }
1818 } 1835 }
1819 } 1836 }
@@ -1878,7 +1895,8 @@ namespace OpenSim.Region.Framework.Scenes
1878 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 1895 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
1879 if (original != null) 1896 if (original != null)
1880 { 1897 {
1881 if (m_parentScene.Permissions.CanDuplicateObject(original.Children.Count, original.UUID, AgentID, original.AbsolutePosition)) 1898 if (m_parentScene.Permissions.CanDuplicateObject(
1899 original.PrimCount, original.UUID, AgentID, original.AbsolutePosition))
1882 { 1900 {
1883 SceneObjectGroup copy = original.Copy(true); 1901 SceneObjectGroup copy = original.Copy(true);
1884 copy.AbsolutePosition = copy.AbsolutePosition + offset; 1902 copy.AbsolutePosition = copy.AbsolutePosition + offset;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 9b66fad..e003cf8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -360,7 +360,7 @@ namespace OpenSim.Region.Framework.Scenes
360 /// </summary> 360 /// </summary>
361 public int PrimCount 361 public int PrimCount
362 { 362 {
363 get { return m_parts.Count; } 363 get { lock (m_parts) { return m_parts.Count; } }
364 } 364 }
365 365
366 protected Quaternion m_rotation = Quaternion.Identity; 366 protected Quaternion m_rotation = Quaternion.Identity;
@@ -398,6 +398,7 @@ namespace OpenSim.Region.Framework.Scenes
398 398
399 /// <value> 399 /// <value>
400 /// The parts of this scene object group. You must lock this property before using it. 400 /// The parts of this scene object group. You must lock this property before using it.
401 /// If you want to know the number of children, consider using the PrimCount property instead
401 /// </value> 402 /// </value>
402 public Dictionary<UUID, SceneObjectPart> Children 403 public Dictionary<UUID, SceneObjectPart> Children
403 { 404 {
@@ -521,7 +522,16 @@ namespace OpenSim.Region.Framework.Scenes
521 public override UUID UUID 522 public override UUID UUID
522 { 523 {
523 get { return m_rootPart.UUID; } 524 get { return m_rootPart.UUID; }
524 set { m_rootPart.UUID = value; } 525 set
526 {
527 m_rootPart.UUID = value;
528
529 lock (m_parts)
530 {
531 m_parts.Remove(m_rootPart.UUID);
532 m_parts.Add(m_rootPart.UUID, m_rootPart);
533 }
534 }
525 } 535 }
526 536
527 public UUID OwnerID 537 public UUID OwnerID
@@ -742,21 +752,23 @@ namespace OpenSim.Region.Framework.Scenes
742 if (m_rootPart.LocalId == 0) 752 if (m_rootPart.LocalId == 0)
743 m_rootPart.LocalId = m_scene.AllocateLocalId(); 753 m_rootPart.LocalId = m_scene.AllocateLocalId();
744 754
745 // No need to lock here since the object isn't yet in a scene 755 lock (m_parts)
746 foreach (SceneObjectPart part in m_parts.Values)
747 { 756 {
748 if (Object.ReferenceEquals(part, m_rootPart)) 757 foreach (SceneObjectPart part in m_parts.Values)
749 {
750 continue;
751 }
752
753 if (part.LocalId == 0)
754 { 758 {
755 part.LocalId = m_scene.AllocateLocalId(); 759 if (Object.ReferenceEquals(part, m_rootPart))
760 {
761 continue;
762 }
763
764 if (part.LocalId == 0)
765 {
766 part.LocalId = m_scene.AllocateLocalId();
767 }
768
769 part.ParentID = m_rootPart.LocalId;
770 //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID);
756 } 771 }
757
758 part.ParentID = m_rootPart.LocalId;
759 //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID);
760 } 772 }
761 773
762 ApplyPhysics(m_scene.m_physicalPrim); 774 ApplyPhysics(m_scene.m_physicalPrim);
@@ -1238,9 +1250,12 @@ namespace OpenSim.Region.Framework.Scenes
1238 m_rootPart.AttachedAvatar = agentID; 1250 m_rootPart.AttachedAvatar = agentID;
1239 1251
1240 //Anakin Lohner bug #3839 1252 //Anakin Lohner bug #3839
1241 foreach (SceneObjectPart p in m_parts.Values) 1253 lock (m_parts)
1242 { 1254 {
1243 p.AttachedAvatar = agentID; 1255 foreach (SceneObjectPart p in m_parts.Values)
1256 {
1257 p.AttachedAvatar = agentID;
1258 }
1244 } 1259 }
1245 1260
1246 if (m_rootPart.PhysActor != null) 1261 if (m_rootPart.PhysActor != null)
@@ -1308,10 +1323,14 @@ namespace OpenSim.Region.Framework.Scenes
1308 1323
1309 AbsolutePosition = detachedpos; 1324 AbsolutePosition = detachedpos;
1310 m_rootPart.AttachedAvatar = UUID.Zero; 1325 m_rootPart.AttachedAvatar = UUID.Zero;
1311 //Anakin Lohner bug #3839 1326
1312 foreach (SceneObjectPart p in m_parts.Values) 1327 //Anakin Lohner bug #3839
1328 lock (m_parts)
1313 { 1329 {
1314 p.AttachedAvatar = UUID.Zero; 1330 foreach (SceneObjectPart p in m_parts.Values)
1331 {
1332 p.AttachedAvatar = UUID.Zero;
1333 }
1315 } 1334 }
1316 1335
1317 m_rootPart.SetParentLocalId(0); 1336 m_rootPart.SetParentLocalId(0);
@@ -1337,10 +1356,14 @@ namespace OpenSim.Region.Framework.Scenes
1337 } 1356 }
1338 1357
1339 m_rootPart.AttachedAvatar = UUID.Zero; 1358 m_rootPart.AttachedAvatar = UUID.Zero;
1359
1340 //Anakin Lohner bug #3839 1360 //Anakin Lohner bug #3839
1341 foreach (SceneObjectPart p in m_parts.Values) 1361 lock (m_parts)
1342 { 1362 {
1343 p.AttachedAvatar = UUID.Zero; 1363 foreach (SceneObjectPart p in m_parts.Values)
1364 {
1365 p.AttachedAvatar = UUID.Zero;
1366 }
1344 } 1367 }
1345 1368
1346 m_rootPart.SetParentLocalId(0); 1369 m_rootPart.SetParentLocalId(0);
@@ -1406,9 +1429,8 @@ namespace OpenSim.Region.Framework.Scenes
1406 part.ParentID = 0; 1429 part.ParentID = 0;
1407 part.LinkNum = 0; 1430 part.LinkNum = 0;
1408 1431
1409 // No locking required since the SOG should not be in the scene yet - one can't change root parts after 1432 lock (m_parts)
1410 // the scene object has been attached to the scene 1433 m_parts.Add(m_rootPart.UUID, m_rootPart);
1411 m_parts.Add(m_rootPart.UUID, m_rootPart);
1412 } 1434 }
1413 1435
1414 /// <summary> 1436 /// <summary>
@@ -1928,14 +1950,14 @@ namespace OpenSim.Region.Framework.Scenes
1928 } 1950 }
1929 1951
1930 /// <summary> 1952 /// <summary>
1931 /// 1953 /// Copy the given part as the root part of this scene object.
1932 /// </summary> 1954 /// </summary>
1933 /// <param name="part"></param> 1955 /// <param name="part"></param>
1934 /// <param name="cAgentID"></param> 1956 /// <param name="cAgentID"></param>
1935 /// <param name="cGroupID"></param> 1957 /// <param name="cGroupID"></param>
1936 public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) 1958 public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed)
1937 { 1959 {
1938 SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed)); 1960 SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
1939 } 1961 }
1940 1962
1941 public void ScriptSetPhysicsStatus(bool UsePhysics) 1963 public void ScriptSetPhysicsStatus(bool UsePhysics)
@@ -2234,14 +2256,15 @@ namespace OpenSim.Region.Framework.Scenes
2234 /// </summary> 2256 /// </summary>
2235 public void ResetIDs() 2257 public void ResetIDs()
2236 { 2258 {
2237 // As this is only ever called for prims which are not currently part of the scene (and hence 2259 lock (m_parts)
2238 // not accessible by clients), there should be no need to lock
2239 List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values);
2240 m_parts.Clear();
2241 foreach (SceneObjectPart part in partsList)
2242 { 2260 {
2243 part.ResetIDs(part.LinkNum); // Don't change link nums 2261 List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values);
2244 m_parts.Add(part.UUID, part); 2262 m_parts.Clear();
2263 foreach (SceneObjectPart part in partsList)
2264 {
2265 part.ResetIDs(part.LinkNum); // Don't change link nums
2266 m_parts.Add(part.UUID, part);
2267 }
2245 } 2268 }
2246 } 2269 }
2247 2270
@@ -2479,10 +2502,15 @@ namespace OpenSim.Region.Framework.Scenes
2479 public SceneObjectPart GetChildPart(UUID primID) 2502 public SceneObjectPart GetChildPart(UUID primID)
2480 { 2503 {
2481 SceneObjectPart childPart = null; 2504 SceneObjectPart childPart = null;
2482 if (m_parts.ContainsKey(primID)) 2505
2506 lock (m_parts)
2483 { 2507 {
2484 childPart = m_parts[primID]; 2508 if (m_parts.ContainsKey(primID))
2509 {
2510 childPart = m_parts[primID];
2511 }
2485 } 2512 }
2513
2486 return childPart; 2514 return childPart;
2487 } 2515 }
2488 2516
@@ -2519,9 +2547,10 @@ namespace OpenSim.Region.Framework.Scenes
2519 /// <returns></returns> 2547 /// <returns></returns>
2520 public bool HasChildPrim(UUID primID) 2548 public bool HasChildPrim(UUID primID)
2521 { 2549 {
2522 if (m_parts.ContainsKey(primID)) 2550 lock (m_parts)
2523 { 2551 {
2524 return true; 2552 if (m_parts.ContainsKey(primID))
2553 return true;
2525 } 2554 }
2526 2555
2527 return false; 2556 return false;
@@ -3132,9 +3161,11 @@ namespace OpenSim.Region.Framework.Scenes
3132 public void UpdatePermissions(UUID AgentID, byte field, uint localID, 3161 public void UpdatePermissions(UUID AgentID, byte field, uint localID,
3133 uint mask, byte addRemTF) 3162 uint mask, byte addRemTF)
3134 { 3163 {
3135 foreach (SceneObjectPart part in m_parts.Values) 3164 lock (m_parts)
3136 part.UpdatePermissions(AgentID, field, localID, mask, 3165 {
3137 addRemTF); 3166 foreach (SceneObjectPart part in m_parts.Values)
3167 part.UpdatePermissions(AgentID, field, localID, mask, addRemTF);
3168 }
3138 3169
3139 HasGroupChanged = true; 3170 HasGroupChanged = true;
3140 } 3171 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 8b4f0ed..10931b7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -37,6 +37,7 @@ using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes.Scripting; 39using OpenSim.Region.Framework.Scenes.Scripting;
40using OpenSim.Region.Framework.Scenes.Serialization;
40 41
41namespace OpenSim.Region.Framework.Scenes 42namespace OpenSim.Region.Framework.Scenes
42{ 43{
@@ -722,6 +723,71 @@ namespace OpenSim.Region.Framework.Scenes
722 return items; 723 return items;
723 } 724 }
724 725
726 public SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item)
727 {
728 UUID ownerID = item.OwnerID;
729 AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
730
731 if (null == rezAsset)
732 {
733 m_log.WarnFormat(
734 "[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}",
735 item.AssetID, item.Name, m_part.Name);
736 return null;
737 }
738
739 string xmlData = Utils.BytesToString(rezAsset.Data);
740 SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
741
742 group.ResetIDs();
743
744 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
745
746 // Since renaming the item in the inventory does not affect the name stored
747 // in the serialization, transfer the correct name from the inventory to the
748 // object itself before we rez.
749 rootPart.Name = item.Name;
750 rootPart.Description = item.Description;
751
752 List<SceneObjectPart> partList = null;
753
754 lock (group.Children)
755 partList = new List<SceneObjectPart>(group.Children.Values);
756
757 group.SetGroup(m_part.GroupID, null);
758
759 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
760 {
761 if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
762 {
763 foreach (SceneObjectPart part in partList)
764 {
765 part.EveryoneMask = item.EveryonePermissions;
766 part.NextOwnerMask = item.NextPermissions;
767 }
768
769 group.ApplyNextOwnerPermissions();
770 }
771 }
772
773 foreach (SceneObjectPart part in partList)
774 {
775 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
776 {
777 part.LastOwnerID = part.OwnerID;
778 part.OwnerID = item.OwnerID;
779 part.Inventory.ChangeInventoryOwner(item.OwnerID);
780 }
781
782 part.EveryoneMask = item.EveryonePermissions;
783 part.NextOwnerMask = item.NextPermissions;
784 }
785
786 rootPart.TrimPermissions();
787
788 return group;
789 }
790
725 /// <summary> 791 /// <summary>
726 /// Update an existing inventory item. 792 /// Update an existing inventory item.
727 /// </summary> 793 /// </summary>
@@ -1197,6 +1263,5 @@ namespace OpenSim.Region.Framework.Scenes
1197 1263
1198 Items.LockItemsForRead(false); 1264 Items.LockItemsForRead(false);
1199 } 1265 }
1200
1201 } 1266 }
1202} 1267} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMEntityCollection.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMEntityCollection.cs
index 56656fc..de1e01c 100644
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMEntityCollection.cs
+++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMEntityCollection.cs
@@ -121,16 +121,19 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
121 continue; 121 continue;
122 temp = (SceneObjectGroup) currObj; 122 temp = (SceneObjectGroup) currObj;
123 123
124 if (m_CMEntityHash.ContainsKey(temp.UUID)) 124 lock (temp.Children)
125 { 125 {
126 foreach (SceneObjectPart part in temp.Children.Values) 126 if (m_CMEntityHash.ContainsKey(temp.UUID))
127 if (!((ContentManagementEntity)m_CMEntityHash[temp.UUID]).HasChildPrim(part.UUID)) 127 {
128 foreach (SceneObjectPart part in temp.Children.Values)
129 if (!((ContentManagementEntity)m_CMEntityHash[temp.UUID]).HasChildPrim(part.UUID))
130 missingList.Add(part);
131 }
132 else //Entire group is missing from revision. (and is a new part in region)
133 {
134 foreach (SceneObjectPart part in temp.Children.Values)
128 missingList.Add(part); 135 missingList.Add(part);
129 } 136 }
130 else //Entire group is missing from revision. (and is a new part in region)
131 {
132 foreach (SceneObjectPart part in temp.Children.Values)
133 missingList.Add(part);
134 } 137 }
135 } 138 }
136 return missingList; 139 return missingList;
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs
index 0dc78c0..e5fcb54 100644
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs
+++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMModel.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -167,9 +167,12 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
167 public void RemoveOrUpdateDeletedEntity(SceneObjectGroup group) 167 public void RemoveOrUpdateDeletedEntity(SceneObjectGroup group)
168 { 168 {
169 // Deal with new parts not revisioned that have been deleted. 169 // Deal with new parts not revisioned that have been deleted.
170 foreach (SceneObjectPart part in group.Children.Values) 170 lock (group.Children)
171 if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID)) 171 {
172 m_MetaEntityCollection.RemoveNewlyCreatedEntityAura(part.UUID); 172 foreach (SceneObjectPart part in group.Children.Values)
173 if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID))
174 m_MetaEntityCollection.RemoveNewlyCreatedEntityAura(part.UUID);
175 }
173 } 176 }
174 177
175 /// <summary> 178 /// <summary>
@@ -207,8 +210,13 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
207 { 210 {
208 temp = SceneObjectSerializer.FromXml2Format(xml); 211 temp = SceneObjectSerializer.FromXml2Format(xml);
209 temp.SetScene(scene); 212 temp.SetScene(scene);
210 foreach (SceneObjectPart part in temp.Children.Values) 213
211 part.RegionHandle = scene.RegionInfo.RegionHandle; 214 lock (temp.Children)
215 {
216 foreach (SceneObjectPart part in temp.Children.Values)
217 part.RegionHandle = scene.RegionInfo.RegionHandle;
218 }
219
212 ReplacementList.Add(temp.UUID, (EntityBase)temp); 220 ReplacementList.Add(temp.UUID, (EntityBase)temp);
213 } 221 }
214 catch (Exception e) 222 catch (Exception e)
@@ -338,15 +346,20 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
338 System.Collections.ArrayList auraList = new System.Collections.ArrayList(); 346 System.Collections.ArrayList auraList = new System.Collections.ArrayList();
339 if (group == null) 347 if (group == null)
340 return null; 348 return null;
341 foreach (SceneObjectPart part in group.Children.Values) 349
350 lock (group.Children)
342 { 351 {
343 if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID)) 352 foreach (SceneObjectPart part in group.Children.Values)
344 { 353 {
345 ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new Vector3(0,254,0), part.Scale); 354 if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID))
346 ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition(); 355 {
347 auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]); 356 ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new Vector3(0,254,0), part.Scale);
357 ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition();
358 auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]);
359 }
348 } 360 }
349 } 361 }
362
350 return auraList; 363 return auraList;
351 } 364 }
352 365
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMView.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMView.cs
index 46fbd39..f75f40a 100644
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMView.cs
+++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMView.cs
@@ -186,9 +186,12 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
186 ((ContentManagementEntity)m_model.MetaEntityCollection.Entities[group.UUID]).SendFullDiffUpdateToAll(); 186 ((ContentManagementEntity)m_model.MetaEntityCollection.Entities[group.UUID]).SendFullDiffUpdateToAll();
187 187
188 // Deal with new parts not revisioned that have been deleted. 188 // Deal with new parts not revisioned that have been deleted.
189 foreach (SceneObjectPart part in group.Children.Values) 189 lock (group.Children)
190 if (m_model.MetaEntityCollection.Auras.ContainsKey(part.UUID)) 190 {
191 ((AuraMetaEntity)m_model.MetaEntityCollection.Auras[part.UUID]).HideFromAll(); 191 foreach (SceneObjectPart part in group.Children.Values)
192 if (m_model.MetaEntityCollection.Auras.ContainsKey(part.UUID))
193 ((AuraMetaEntity)m_model.MetaEntityCollection.Auras[part.UUID]).HideFromAll();
194 }
192 } 195 }
193 196
194 public void SendMetaEntitiesToNewClient(IClientAPI client) 197 public void SendMetaEntitiesToNewClient(IClientAPI client)
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs
index ada6701..2730eee 100644
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs
+++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/ContentManagementEntity.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -132,30 +132,33 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
132 // if group is not contained in scene's list 132 // if group is not contained in scene's list
133 if (!ContainsKey(sceneEntityList, m_UnchangedEntity.UUID)) 133 if (!ContainsKey(sceneEntityList, m_UnchangedEntity.UUID))
134 { 134 {
135 foreach (SceneObjectPart part in m_UnchangedEntity.Children.Values) 135 lock (m_UnchangedEntity.Children)
136 { 136 {
137 // if scene list no longer contains this part, display translucent part and mark with red aura 137 foreach (SceneObjectPart part in m_UnchangedEntity.Children.Values)
138 if (!ContainsKey(sceneEntityList, part.UUID))
139 { 138 {
140 // if already displaying a red aura over part, make sure its red 139 // if scene list no longer contains this part, display translucent part and mark with red aura
141 if (m_AuraEntities.ContainsKey(part.UUID)) 140 if (!ContainsKey(sceneEntityList, part.UUID))
142 {
143 m_AuraEntities[part.UUID].SetAura(new Vector3(254,0,0), part.Scale);
144 }
145 else
146 { 141 {
147 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene, 142 // if already displaying a red aura over part, make sure its red
148 part.GetWorldPosition(), 143 if (m_AuraEntities.ContainsKey(part.UUID))
149 MetaEntity.TRANSLUCENT, 144 {
150 new Vector3(254,0,0), 145 m_AuraEntities[part.UUID].SetAura(new Vector3(254,0,0), part.Scale);
151 part.Scale 146 }
152 ); 147 else
153 m_AuraEntities.Add(part.UUID, auraGroup); 148 {
149 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
150 part.GetWorldPosition(),
151 MetaEntity.TRANSLUCENT,
152 new Vector3(254,0,0),
153 part.Scale
154 );
155 m_AuraEntities.Add(part.UUID, auraGroup);
156 }
157 SceneObjectPart metaPart = m_Entity.GetLinkNumPart(part.LinkNum);
158 SetPartTransparency(metaPart, MetaEntity.TRANSLUCENT);
154 } 159 }
155 SceneObjectPart metaPart = m_Entity.GetLinkNumPart(part.LinkNum); 160 // otherwise, scene will not contain the part. note: a group can not remove a part without changing group id
156 SetPartTransparency(metaPart, MetaEntity.TRANSLUCENT);
157 } 161 }
158 // otherwise, scene will not contain the part. note: a group can not remove a part without changing group id
159 } 162 }
160 163
161 // a deleted part has no where to point a beam particle system, 164 // a deleted part has no where to point a beam particle system,
@@ -180,8 +183,10 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
180 /// </summary> 183 /// </summary>
181 public bool HasChildPrim(UUID uuid) 184 public bool HasChildPrim(UUID uuid)
182 { 185 {
183 if (m_UnchangedEntity.Children.ContainsKey(uuid)) 186 lock (m_UnchangedEntity.Children)
184 return true; 187 if (m_UnchangedEntity.Children.ContainsKey(uuid))
188 return true;
189
185 return false; 190 return false;
186 } 191 }
187 192
@@ -190,9 +195,13 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
190 /// </summary> 195 /// </summary>
191 public bool HasChildPrim(uint localID) 196 public bool HasChildPrim(uint localID)
192 { 197 {
193 foreach (SceneObjectPart part in m_UnchangedEntity.Children.Values) 198 lock (m_UnchangedEntity.Children)
194 if (part.LocalId == localID) 199 {
195 return true; 200 foreach (SceneObjectPart part in m_UnchangedEntity.Children.Values)
201 if (part.LocalId == localID)
202 return true;
203 }
204
196 return false; 205 return false;
197 } 206 }
198 207
@@ -228,37 +237,72 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
228 // Use "UnchangedEntity" to do comparisons because its text, transparency, and other attributes will be just as the user 237 // Use "UnchangedEntity" to do comparisons because its text, transparency, and other attributes will be just as the user
229 // had originally saved. 238 // had originally saved.
230 // m_Entity will NOT necessarily be the same entity as the user had saved. 239 // m_Entity will NOT necessarily be the same entity as the user had saved.
231 foreach (SceneObjectPart UnchangedPart in m_UnchangedEntity.Children.Values) 240 lock (m_UnchangedEntity.Children)
232 { 241 {
233 //This is the part that we use to show changes. 242 foreach (SceneObjectPart UnchangedPart in m_UnchangedEntity.Children.Values)
234 metaEntityPart = m_Entity.GetLinkNumPart(UnchangedPart.LinkNum);
235 if (sceneEntityGroup.Children.ContainsKey(UnchangedPart.UUID))
236 { 243 {
237 sceneEntityPart = sceneEntityGroup.Children[UnchangedPart.UUID]; 244 //This is the part that we use to show changes.
238 differences = Difference.FindDifferences(UnchangedPart, sceneEntityPart); 245 metaEntityPart = m_Entity.GetLinkNumPart(UnchangedPart.LinkNum);
239 if (differences != Diff.NONE) 246 if (sceneEntityGroup.Children.ContainsKey(UnchangedPart.UUID))
240 metaEntityPart.Text = "CHANGE: " + differences.ToString();
241 if (differences != 0)
242 { 247 {
243 // Root Part that has been modified 248 sceneEntityPart = sceneEntityGroup.Children[UnchangedPart.UUID];
244 if ((differences&Diff.POSITION) > 0) 249 differences = Difference.FindDifferences(UnchangedPart, sceneEntityPart);
250 if (differences != Diff.NONE)
251 metaEntityPart.Text = "CHANGE: " + differences.ToString();
252 if (differences != 0)
253 {
254 // Root Part that has been modified
255 if ((differences&Diff.POSITION) > 0)
256 {
257 // If the position of any part has changed, make sure the RootPart of the
258 // meta entity is pointing with a beam particle system
259 if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
260 {
261 m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
262 m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
263 }
264 BeamMetaEntity beamGroup = new BeamMetaEntity(m_Entity.Scene,
265 m_UnchangedEntity.RootPart.GetWorldPosition(),
266 MetaEntity.TRANSLUCENT,
267 sceneEntityPart,
268 new Vector3(0,0,254)
269 );
270 m_BeamEntities.Add(m_UnchangedEntity.RootPart.UUID, beamGroup);
271 }
272
273 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
274 {
275 m_AuraEntities[UnchangedPart.UUID].HideFromAll();
276 m_AuraEntities.Remove(UnchangedPart.UUID);
277 }
278 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
279 UnchangedPart.GetWorldPosition(),
280 MetaEntity.TRANSLUCENT,
281 new Vector3(0,0,254),
282 UnchangedPart.Scale
283 );
284 m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
285 SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
286
287 DiffersFromSceneGroup = true;
288 }
289 else // no differences between scene part and meta part
245 { 290 {
246 // If the position of any part has changed, make sure the RootPart of the
247 // meta entity is pointing with a beam particle system
248 if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID)) 291 if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
249 { 292 {
250 m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll(); 293 m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
251 m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID); 294 m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
252 } 295 }
253 BeamMetaEntity beamGroup = new BeamMetaEntity(m_Entity.Scene, 296 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
254 m_UnchangedEntity.RootPart.GetWorldPosition(), 297 {
255 MetaEntity.TRANSLUCENT, 298 m_AuraEntities[UnchangedPart.UUID].HideFromAll();
256 sceneEntityPart, 299 m_AuraEntities.Remove(UnchangedPart.UUID);
257 new Vector3(0,0,254) 300 }
258 ); 301 SetPartTransparency(metaEntityPart, MetaEntity.NONE);
259 m_BeamEntities.Add(m_UnchangedEntity.RootPart.UUID, beamGroup);
260 } 302 }
261 303 }
304 else //The entity currently in the scene is missing parts from the metaentity saved, so mark parts red as deleted.
305 {
262 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID)) 306 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
263 { 307 {
264 m_AuraEntities[UnchangedPart.UUID].HideFromAll(); 308 m_AuraEntities[UnchangedPart.UUID].HideFromAll();
@@ -267,48 +311,17 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
267 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene, 311 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
268 UnchangedPart.GetWorldPosition(), 312 UnchangedPart.GetWorldPosition(),
269 MetaEntity.TRANSLUCENT, 313 MetaEntity.TRANSLUCENT,
270 new Vector3(0,0,254), 314 new Vector3(254,0,0),
271 UnchangedPart.Scale 315 UnchangedPart.Scale
272 ); 316 );
273 m_AuraEntities.Add(UnchangedPart.UUID, auraGroup); 317 m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
274 SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT); 318 SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
275 319
276 DiffersFromSceneGroup = true; 320 DiffersFromSceneGroup = true;
277 } 321 }
278 else // no differences between scene part and meta part
279 {
280 if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
281 {
282 m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
283 m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
284 }
285 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
286 {
287 m_AuraEntities[UnchangedPart.UUID].HideFromAll();
288 m_AuraEntities.Remove(UnchangedPart.UUID);
289 }
290 SetPartTransparency(metaEntityPart, MetaEntity.NONE);
291 }
292 }
293 else //The entity currently in the scene is missing parts from the metaentity saved, so mark parts red as deleted.
294 {
295 if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
296 {
297 m_AuraEntities[UnchangedPart.UUID].HideFromAll();
298 m_AuraEntities.Remove(UnchangedPart.UUID);
299 }
300 AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
301 UnchangedPart.GetWorldPosition(),
302 MetaEntity.TRANSLUCENT,
303 new Vector3(254,0,0),
304 UnchangedPart.Scale
305 );
306 m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
307 SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
308
309 DiffersFromSceneGroup = true;
310 } 322 }
311 } 323 }
324
312 return changed; 325 return changed;
313 } 326 }
314 327
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs
index 841ee00..796f437 100644
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs
+++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs
@@ -150,15 +150,19 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
150 { 150 {
151 //make new uuids 151 //make new uuids
152 Dictionary<UUID, SceneObjectPart> parts = new Dictionary<UUID, SceneObjectPart>(); 152 Dictionary<UUID, SceneObjectPart> parts = new Dictionary<UUID, SceneObjectPart>();
153 foreach (SceneObjectPart part in m_Entity.Children.Values) 153
154 lock (m_Entity.Children)
154 { 155 {
155 part.ResetIDs(part.LinkNum); 156 foreach (SceneObjectPart part in m_Entity.Children.Values)
156 parts.Add(part.UUID, part); 157 {
158 part.ResetIDs(part.LinkNum);
159 parts.Add(part.UUID, part);
160 }
161
162 //finalize
163 m_Entity.RootPart.PhysActor = null;
164 m_Entity.Children = parts;
157 } 165 }
158
159 //finalize
160 m_Entity.RootPart.PhysActor = null;
161 m_Entity.Children = parts;
162 } 166 }
163 167
164 #endregion Protected Methods 168 #endregion Protected Methods
@@ -173,8 +177,11 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
173 //This deletes the group without removing from any databases. 177 //This deletes the group without removing from any databases.
174 //This is important because we are not IN any database. 178 //This is important because we are not IN any database.
175 //m_Entity.FakeDeleteGroup(); 179 //m_Entity.FakeDeleteGroup();
176 foreach (SceneObjectPart part in m_Entity.Children.Values) 180 lock (m_Entity.Children)
177 client.SendKillObject(m_Entity.RegionHandle, part.LocalId); 181 {
182 foreach (SceneObjectPart part in m_Entity.Children.Values)
183 client.SendKillObject(m_Entity.RegionHandle, part.LocalId);
184 }
178 } 185 }
179 186
180 /// <summary> 187 /// <summary>
@@ -182,12 +189,15 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
182 /// </summary> 189 /// </summary>
183 public virtual void HideFromAll() 190 public virtual void HideFromAll()
184 { 191 {
185 foreach (SceneObjectPart part in m_Entity.Children.Values) 192 lock (m_Entity.Children)
186 { 193 {
187 m_Entity.Scene.ForEachClient( 194 foreach (SceneObjectPart part in m_Entity.Children.Values)
188 delegate(IClientAPI controller) 195 {
189 { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); } 196 m_Entity.Scene.ForEachClient(
190 ); 197 delegate(IClientAPI controller)
198 { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); }
199 );
200 }
191 } 201 }
192 } 202 }
193 203
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index 96cccb7..34171b0 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -185,14 +185,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
185 get 185 get
186 { 186 {
187 SceneObjectPart my = GetSOP(); 187 SceneObjectPart my = GetSOP();
188 int total = my.ParentGroup.Children.Count; 188 IObject[] rets = null;
189 189
190 IObject[] rets = new IObject[total]; 190 lock (my.ParentGroup.Children)
191
192 int i = 0;
193 foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children)
194 { 191 {
195 rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); 192 int total = my.ParentGroup.Children.Count;
193
194 rets = new IObject[total];
195
196 int i = 0;
197 foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children)
198 {
199 rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security);
200 }
196 } 201 }
197 202
198 return rets; 203 return rets;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index a407ef3..8381efa 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -293,7 +293,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
293 { 293 {
294 case ScriptBaseClass.LINK_SET: 294 case ScriptBaseClass.LINK_SET:
295 if (m_host.ParentGroup != null) 295 if (m_host.ParentGroup != null)
296 return new List<SceneObjectPart>(m_host.ParentGroup.Children.Values); 296 {
297 lock (m_host.ParentGroup.Children)
298 return new List<SceneObjectPart>(m_host.ParentGroup.Children.Values);
299 }
297 return ret; 300 return ret;
298 301
299 case ScriptBaseClass.LINK_ROOT: 302 case ScriptBaseClass.LINK_ROOT:
@@ -308,7 +311,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
308 case ScriptBaseClass.LINK_ALL_OTHERS: 311 case ScriptBaseClass.LINK_ALL_OTHERS:
309 if (m_host.ParentGroup == null) 312 if (m_host.ParentGroup == null)
310 return new List<SceneObjectPart>(); 313 return new List<SceneObjectPart>();
311 ret = new List<SceneObjectPart>(m_host.ParentGroup.Children.Values); 314
315 lock (m_host.ParentGroup.Children)
316 ret = new List<SceneObjectPart>(m_host.ParentGroup.Children.Values);
317
312 if (ret.Contains(m_host)) 318 if (ret.Contains(m_host))
313 ret.Remove(m_host); 319 ret.Remove(m_host);
314 return ret; 320 return ret;
@@ -316,7 +322,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
316 case ScriptBaseClass.LINK_ALL_CHILDREN: 322 case ScriptBaseClass.LINK_ALL_CHILDREN:
317 if (m_host.ParentGroup == null) 323 if (m_host.ParentGroup == null)
318 return new List<SceneObjectPart>(); 324 return new List<SceneObjectPart>();
319 ret = new List<SceneObjectPart>(m_host.ParentGroup.Children.Values); 325
326 lock (m_host.ParentGroup.Children)
327 ret = new List<SceneObjectPart>(m_host.ParentGroup.Children.Values);
328
320 if (ret.Contains(m_host.ParentGroup.RootPart)) 329 if (ret.Contains(m_host.ParentGroup.RootPart))
321 ret.Remove(m_host.ParentGroup.RootPart); 330 ret.Remove(m_host.ParentGroup.RootPart);
322 return ret; 331 return ret;
@@ -1272,12 +1281,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1272 if (group == null) 1281 if (group == null)
1273 return; 1282 return;
1274 bool allow = true; 1283 bool allow = true;
1275 foreach (SceneObjectPart part in group.Children.Values) 1284
1285 lock (group.Children)
1276 { 1286 {
1277 if (part.Scale.X > World.m_maxPhys || part.Scale.Y > World.m_maxPhys || part.Scale.Z > World.m_maxPhys) 1287 foreach (SceneObjectPart part in group.Children.Values)
1278 { 1288 {
1279 allow = false; 1289 if (part.Scale.X > World.m_maxPhys || part.Scale.Y > World.m_maxPhys || part.Scale.Z > World.m_maxPhys)
1280 break; 1290 {
1291 allow = false;
1292 break;
1293 }
1281 } 1294 }
1282 } 1295 }
1283 1296
@@ -3757,7 +3770,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3757 { 3770 {
3758 m_host.AddScriptLPS(1); 3771 m_host.AddScriptLPS(1);
3759 3772
3760 if (m_host.ParentGroup.Children.Count > 1) 3773 if (m_host.ParentGroup.PrimCount > 1)
3761 { 3774 {
3762 return m_host.LinkNum; 3775 return m_host.LinkNum;
3763 } 3776 }
@@ -3878,15 +3891,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3878 case ScriptBaseClass.LINK_ALL_OTHERS: 3891 case ScriptBaseClass.LINK_ALL_OTHERS:
3879 case ScriptBaseClass.LINK_ALL_CHILDREN: 3892 case ScriptBaseClass.LINK_ALL_CHILDREN:
3880 case ScriptBaseClass.LINK_THIS: 3893 case ScriptBaseClass.LINK_THIS:
3881 foreach (SceneObjectPart part in parentPrim.Children.Values) 3894 lock (parentPrim.Children)
3882 { 3895 {
3883 if (part.UUID != m_host.UUID) 3896 foreach (SceneObjectPart part in parentPrim.Children.Values)
3884 { 3897 {
3885 childPrim = part; 3898 if (part.UUID != m_host.UUID)
3886 break; 3899 {
3900 childPrim = part;
3901 break;
3902 }
3887 } 3903 }
3904 break;
3888 } 3905 }
3889 break;
3890 default: 3906 default:
3891 childPrim = parentPrim.GetLinkNumPart(linknum); 3907 childPrim = parentPrim.GetLinkNumPart(linknum);
3892 if (childPrim.UUID == m_host.UUID) 3908 if (childPrim.UUID == m_host.UUID)
@@ -3962,26 +3978,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3962 if (parentPrim.RootPart.AttachmentPoint != 0) 3978 if (parentPrim.RootPart.AttachmentPoint != 0)
3963 return; // Fail silently if attached 3979 return; // Fail silently if attached
3964 3980
3965 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); 3981 lock (parentPrim.Children)
3966 parts.Remove(parentPrim.RootPart);
3967 if (parts.Count > 0)
3968 { 3982 {
3969 try 3983 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3970 { 3984 parts.Remove(parentPrim.RootPart);
3971 parts[0].ParentGroup.areUpdatesSuspended = true; 3985
3972 foreach (SceneObjectPart part in parts) 3986 foreach (SceneObjectPart part in parts)
3973 {
3974 parentPrim.DelinkFromGroup(part.LocalId, true);
3975 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3976 }
3977 }
3978 finally
3979 { 3987 {
3980 parts[0].ParentGroup.areUpdatesSuspended = false; 3988 parentPrim.DelinkFromGroup(part.LocalId, true);
3989 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3981 } 3990 }
3991 parentPrim.HasGroupChanged = true;
3992 parentPrim.ScheduleGroupForFullUpdate();
3982 } 3993 }
3983 parentPrim.HasGroupChanged = true;
3984 parentPrim.ScheduleGroupForFullUpdate();
3985 } 3994 }
3986 3995
3987 public LSL_String llGetLinkKey(int linknum) 3996 public LSL_String llGetLinkKey(int linknum)
@@ -4545,7 +4554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4545 { 4554 {
4546 partItemID = item.ItemID; 4555 partItemID = item.ItemID;
4547 int linkNumber = m_host.LinkNum; 4556 int linkNumber = m_host.LinkNum;
4548 if (m_host.ParentGroup.Children.Count == 1) 4557 if (m_host.ParentGroup.PrimCount == 1)
4549 linkNumber = 0; 4558 linkNumber = 0;
4550 4559
4551 object[] resobj = new object[] 4560 object[] resobj = new object[]
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index f0384f8..91e2c3b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -1,3 +1,4 @@
1<<<<<<< HEAD:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
1/* 2/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 3 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 4 * See CONTRIBUTORS.TXT for a full list of copyright holders.
@@ -505,3 +506,507 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
505 506
506 } 507 }
507} 508}
509=======
510/*
511 * Copyright (c) Contributors, http://opensimulator.org/
512 * See CONTRIBUTORS.TXT for a full list of copyright holders.
513 *
514 * Redistribution and use in source and binary forms, with or without
515 * modification, are permitted provided that the following conditions are met:
516 * * Redistributions of source code must retain the above copyright
517 * notice, this list of conditions and the following disclaimer.
518 * * Redistributions in binary form must reproduce the above copyright
519 * notice, this list of conditions and the following disclaimer in the
520 * documentation and/or other materials provided with the distribution.
521 * * Neither the name of the OpenSimulator Project nor the
522 * names of its contributors may be used to endorse or promote products
523 * derived from this software without specific prior written permission.
524 *
525 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
526 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
527 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
528 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
529 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
530 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
531 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
532 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
533 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
534 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
535 */
536
537using System;
538using System.Reflection;
539using System.Collections;
540using System.Collections.Generic;
541using System.Runtime.Remoting.Lifetime;
542using OpenMetaverse;
543using Nini.Config;
544using OpenSim;
545using OpenSim.Framework;
546using OpenSim.Region.CoreModules.World.LightShare;
547using OpenSim.Region.Framework.Interfaces;
548using OpenSim.Region.Framework.Scenes;
549using OpenSim.Region.ScriptEngine.Shared;
550using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
551using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
552using OpenSim.Region.ScriptEngine.Interfaces;
553using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
554
555using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
556using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
557using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
558using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
559using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
560using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
561using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
562
563namespace OpenSim.Region.ScriptEngine.Shared.Api
564{
565 [Serializable]
566 public class LS_Api : MarshalByRefObject, ILS_Api, IScriptApi
567 {
568 internal IScriptEngine m_ScriptEngine;
569 internal SceneObjectPart m_host;
570 internal uint m_localID;
571 internal UUID m_itemID;
572 internal bool m_LSFunctionsEnabled = false;
573 internal IScriptModuleComms m_comms = null;
574
575 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
576 {
577 m_ScriptEngine = ScriptEngine;
578 m_host = host;
579 m_localID = localID;
580 m_itemID = itemID;
581
582 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
583 m_LSFunctionsEnabled = true;
584
585 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
586 if (m_comms == null)
587 m_LSFunctionsEnabled = false;
588 }
589
590 public override Object InitializeLifetimeService()
591 {
592 ILease lease = (ILease)base.InitializeLifetimeService();
593
594 if (lease.CurrentState == LeaseState.Initial)
595 {
596 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
597 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
598 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
599 }
600 return lease;
601 }
602
603 public Scene World
604 {
605 get { return m_ScriptEngine.World; }
606 }
607
608 //
609 //Dumps an error message on the debug console.
610 //
611
612 internal void LSShoutError(string message)
613 {
614 if (message.Length > 1023)
615 message = message.Substring(0, 1023);
616
617 World.SimChat(Utils.StringToBytes(message),
618 ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
619
620 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
621 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
622 }
623
624 /// <summary>
625 /// Get the current Windlight scene
626 /// </summary>
627 /// <returns>List of windlight parameters</returns>
628 public LSL_List lsGetWindlightScene(LSL_List rules)
629 {
630 if (!m_LSFunctionsEnabled)
631 {
632 LSShoutError("LightShare functions are not enabled.");
633 return new LSL_List();
634 }
635 m_host.AddScriptLPS(1);
636 RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
637
638 LSL_List values = new LSL_List();
639 int idx = 0;
640 while (idx < rules.Length)
641 {
642 uint rule = (uint)rules.GetLSLIntegerItem(idx);
643 LSL_List toadd = new LSL_List();
644
645 switch (rule)
646 {
647 case (int)ScriptBaseClass.WL_AMBIENT:
648 toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
649 break;
650 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
651 toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
652 break;
653 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
654 toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
655 break;
656 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
657 toadd.Add(new LSL_Float(wl.blurMultiplier));
658 break;
659 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
660 toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
661 break;
662 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
663 toadd.Add(new LSL_Float(wl.cloudCoverage));
664 break;
665 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
666 toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
667 break;
668 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
669 toadd.Add(new LSL_Float(wl.cloudScale));
670 break;
671 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
672 toadd.Add(new LSL_Float(wl.cloudScrollX));
673 break;
674 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
675 toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
676 break;
677 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
678 toadd.Add(new LSL_Float(wl.cloudScrollY));
679 break;
680 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
681 toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
682 break;
683 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
684 toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
685 break;
686 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
687 toadd.Add(new LSL_Float(wl.densityMultiplier));
688 break;
689 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
690 toadd.Add(new LSL_Float(wl.distanceMultiplier));
691 break;
692 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
693 toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
694 break;
695 case (int)ScriptBaseClass.WL_EAST_ANGLE:
696 toadd.Add(new LSL_Float(wl.eastAngle));
697 break;
698 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
699 toadd.Add(new LSL_Float(wl.fresnelOffset));
700 break;
701 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
702 toadd.Add(new LSL_Float(wl.fresnelScale));
703 break;
704 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
705 toadd.Add(new LSL_Float(wl.hazeDensity));
706 break;
707 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
708 toadd.Add(new LSL_Float(wl.hazeHorizon));
709 break;
710 case (int)ScriptBaseClass.WL_HORIZON:
711 toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
712 break;
713 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
714 toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
715 break;
716 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
717 toadd.Add(new LSL_Integer(wl.maxAltitude));
718 break;
719 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
720 toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
721 break;
722 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
723 toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
724 break;
725 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
726 toadd.Add(new LSL_Float(wl.refractScaleAbove));
727 break;
728 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
729 toadd.Add(new LSL_Float(wl.refractScaleBelow));
730 break;
731 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
732 toadd.Add(new LSL_Float(wl.sceneGamma));
733 break;
734 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
735 toadd.Add(new LSL_Float(wl.starBrightness));
736 break;
737 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
738 toadd.Add(new LSL_Float(wl.sunGlowFocus));
739 break;
740 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
741 toadd.Add(new LSL_Float(wl.sunGlowSize));
742 break;
743 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
744 toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
745 break;
746 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
747 toadd.Add(new LSL_Float(wl.underwaterFogModifier));
748 break;
749 case (int)ScriptBaseClass.WL_WATER_COLOR:
750 toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
751 break;
752 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
753 toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
754 break;
755 }
756
757 if (toadd.Length > 0)
758 {
759 values.Add(rule);
760 values.Add(toadd.Data[0]);
761 }
762 idx++;
763 }
764
765 return values;
766 }
767
768 private RegionLightShareData getWindlightProfileFromRules(LSL_List rules)
769 {
770 RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
771
772// LSL_List values = new LSL_List();
773 int idx = 0;
774 while (idx < rules.Length)
775 {
776 uint rule = (uint)rules.GetLSLIntegerItem(idx);
777 LSL_Types.Quaternion iQ;
778 LSL_Types.Vector3 iV;
779 switch (rule)
780 {
781 case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
782 idx++;
783 wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
784 break;
785 case (int)ScriptBaseClass.WL_AMBIENT:
786 idx++;
787 iQ = rules.GetQuaternionItem(idx);
788 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
789 break;
790 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
791 idx++;
792 iV = rules.GetVector3Item(idx);
793 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
794 break;
795 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
796 idx++;
797 iQ = rules.GetQuaternionItem(idx);
798 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
799 break;
800 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
801 idx++;
802 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
803 break;
804 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
805 idx++;
806 iQ = rules.GetQuaternionItem(idx);
807 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
808 break;
809 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
810 idx++;
811 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
812 break;
813 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
814 idx++;
815 iV = rules.GetVector3Item(idx);
816 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
817 break;
818 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
819 idx++;
820 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
821 break;
822 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
823 idx++;
824 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
825 break;
826 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
827 idx++;
828 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
829 break;
830 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
831 idx++;
832 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
833 break;
834 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
835 idx++;
836 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
837 break;
838 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
839 idx++;
840 iV = rules.GetVector3Item(idx);
841 wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
842 break;
843 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
844 idx++;
845 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
846 break;
847 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
848 idx++;
849 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
850 break;
851 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
852 idx++;
853 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
854 break;
855 case (int)ScriptBaseClass.WL_EAST_ANGLE:
856 idx++;
857 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
858 break;
859 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
860 idx++;
861 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
862 break;
863 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
864 idx++;
865 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
866 break;
867 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
868 idx++;
869 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
870 break;
871 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
872 idx++;
873 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
874 break;
875 case (int)ScriptBaseClass.WL_HORIZON:
876 idx++;
877 iQ = rules.GetQuaternionItem(idx);
878 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
879 break;
880 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
881 idx++;
882 iV = rules.GetVector3Item(idx);
883 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
884 break;
885 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
886 idx++;
887 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
888 break;
889 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
890 idx++;
891 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
892 break;
893 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
894 idx++;
895 iV = rules.GetVector3Item(idx);
896 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
897 break;
898 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
899 idx++;
900 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
901 break;
902 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
903 idx++;
904 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
905 break;
906 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
907 idx++;
908 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
909 break;
910 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
911 idx++;
912 wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
913 break;
914 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
915 idx++;
916 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
917 break;
918 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
919 idx++;
920 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
921 break;
922 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
923 idx++;
924 iQ = rules.GetQuaternionItem(idx);
925 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
926 break;
927 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
928 idx++;
929 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
930 break;
931 case (int)ScriptBaseClass.WL_WATER_COLOR:
932 idx++;
933 iV = rules.GetVector3Item(idx);
934 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
935 break;
936 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
937 idx++;
938 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
939 break;
940 }
941 idx++;
942 }
943 return wl;
944 }
945 /// <summary>
946 /// Set the current Windlight scene
947 /// </summary>
948 /// <param name="rules"></param>
949 /// <returns>success: true or false</returns>
950 public int lsSetWindlightScene(LSL_List rules)
951 {
952 if (!m_LSFunctionsEnabled)
953 {
954 LSShoutError("LightShare functions are not enabled.");
955 return 0;
956 }
957 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
958 {
959 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
960 return 0;
961 }
962 int success = 0;
963 m_host.AddScriptLPS(1);
964 if (LightShareModule.EnableWindlight)
965 {
966 RegionLightShareData wl = getWindlightProfileFromRules(rules);
967 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
968 success = 1;
969 }
970 else
971 {
972 LSShoutError("Windlight module is disabled");
973 return 0;
974 }
975 return success;
976 }
977 /// <summary>
978 /// Set the current Windlight scene to a target avatar
979 /// </summary>
980 /// <param name="rules"></param>
981 /// <returns>success: true or false</returns>
982 public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
983 {
984 if (!m_LSFunctionsEnabled)
985 {
986 LSShoutError("LightShare functions are not enabled.");
987 return 0;
988 }
989 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
990 {
991 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
992 return 0;
993 }
994 int success = 0;
995 m_host.AddScriptLPS(1);
996 if (LightShareModule.EnableWindlight)
997 {
998 RegionLightShareData wl = getWindlightProfileFromRules(rules);
999 World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
1000 success = 1;
1001 }
1002 else
1003 {
1004 LSShoutError("Windlight module is disabled");
1005 return 0;
1006 }
1007 return success;
1008 }
1009
1010 }
1011}
1012>>>>>>> master:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
index 4855d64..41501f2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -209,12 +209,15 @@ namespace OpenSim.Region.ScriptEngine.Shared
209 else 209 else
210 Type = 0x02; // Passive 210 Type = 0x02; // Passive
211 211
212 foreach (SceneObjectPart p in part.ParentGroup.Children.Values) 212 lock (part.ParentGroup.Children)
213 { 213 {
214 if (p.Inventory.ContainsScripts()) 214 foreach (SceneObjectPart p in part.ParentGroup.Children.Values)
215 { 215 {
216 Type |= 0x08; // Scripted 216 if (p.Inventory.ContainsScripts())
217 break; 217 {
218 Type |= 0x08; // Scripted
219 break;
220 }
218 } 221 }
219 } 222 }
220 223