Improve liveness by operating on list copies of SOG.Children where appropriate

prebuild-update
Justin Clark-Casey (justincc) 2010-08-28 00:40:33 +01:00
parent 4f9931ec10
commit 1c0b4457cd
9 changed files with 386 additions and 373 deletions

View File

@ -349,7 +349,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
public void TestLoadIarPathStartsWithSlash() public void TestLoadIarPathStartsWithSlash()
{ {
TestHelper.InMethod(); TestHelper.InMethod();
log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
SerialiserModule serialiserModule = new SerialiserModule(); SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);

View File

@ -243,39 +243,40 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// to the same scene (when this is possible). // to the same scene (when this is possible).
sceneObject.ResetIDs(); sceneObject.ResetIDs();
List<SceneObjectPart> partList = null;
lock (sceneObject.Children) lock (sceneObject.Children)
partList = new List<SceneObjectPart>(sceneObject.Children.Values);
foreach (SceneObjectPart part in partList)
{ {
foreach (SceneObjectPart part in sceneObject.Children.Values) if (!ResolveUserUuid(part.CreatorID))
part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
if (!ResolveUserUuid(part.OwnerID))
part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
if (!ResolveUserUuid(part.LastOwnerID))
part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
// And zap any troublesome sit target information
part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
part.SitTargetPosition = new Vector3(0, 0, 0);
// Fix ownership/creator of inventory items
// Not doing so results in inventory items
// being no copy/no mod for everyone
lock (part.TaskInventory)
{ {
if (!ResolveUserUuid(part.CreatorID)) TaskInventoryDictionary inv = part.TaskInventory;
part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
if (!ResolveUserUuid(part.OwnerID))
part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
if (!ResolveUserUuid(part.LastOwnerID))
part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
// And zap any troublesome sit target information
part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
part.SitTargetPosition = new Vector3(0, 0, 0);
// Fix ownership/creator of inventory items
// Not doing so results in inventory items
// being no copy/no mod for everyone
lock (part.TaskInventory)
{ {
TaskInventoryDictionary inv = part.TaskInventory; if (!ResolveUserUuid(kvp.Value.OwnerID))
foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
{ {
if (!ResolveUserUuid(kvp.Value.OwnerID)) kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
{ }
kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; if (!ResolveUserUuid(kvp.Value.CreatorID))
} {
if (!ResolveUserUuid(kvp.Value.CreatorID)) kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
{
kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
}
} }
} }
} }

View File

@ -229,279 +229,280 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
Color mapdotspot = Color.Gray; // Default color when prim color is white Color mapdotspot = Color.Gray; // Default color when prim color is white
// Loop over prim in group // Loop over prim in group
List<SceneObjectPart> partList = null;
lock (mapdot.Children) lock (mapdot.Children)
partList = new List<SceneObjectPart>(mapdot.Children.Values);
foreach (SceneObjectPart part in partList)
{ {
foreach (SceneObjectPart part in mapdot.Children.Values) if (part == null)
continue;
// Draw if the object is at least 1 meter wide in any direction
if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
{ {
if (part == null) // Try to get the RGBA of the default texture entry..
//
try
{
// get the null checks out of the way
// skip the ones that break
if (part == null)
continue;
if (part.Shape == null)
continue;
if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass)
continue; // eliminates trees from this since we don't really have a good tree representation
// if you want tree blocks on the map comment the above line and uncomment the below line
//mapdotspot = Color.PaleGreen;
Primitive.TextureEntry textureEntry = part.Shape.Textures;
if (textureEntry == null || textureEntry.DefaultTexture == null)
continue;
Color4 texcolor = textureEntry.DefaultTexture.RGBA;
// Not sure why some of these are null, oh well.
int colorr = 255 - (int)(texcolor.R * 255f);
int colorg = 255 - (int)(texcolor.G * 255f);
int colorb = 255 - (int)(texcolor.B * 255f);
if (!(colorr == 255 && colorg == 255 && colorb == 255))
{
//Try to set the map spot color
try
{
// If the color gets goofy somehow, skip it *shakes fist at Color4
mapdotspot = Color.FromArgb(colorr, colorg, colorb);
}
catch (ArgumentException)
{
}
}
}
catch (IndexOutOfRangeException)
{
// Windows Array
}
catch (ArgumentOutOfRangeException)
{
// Mono Array
}
Vector3 pos = part.GetWorldPosition();
// skip prim outside of retion
if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
continue; continue;
// Draw if the object is at least 1 meter wide in any direction // skip prim in non-finite position
if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
continue;
// Figure out if object is under 256m above the height of the terrain
bool isBelow256AboveTerrain = false;
try
{ {
// Try to get the RGBA of the default texture entry.. isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
// }
try catch (Exception)
{ {
// get the null checks out of the way }
// skip the ones that break
if (part == null)
continue;
if (part.Shape == null) if (isBelow256AboveTerrain)
continue; {
// Translate scale by rotation so scale is represented properly when object is rotated
Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
Vector3 scale = new Vector3();
Vector3 tScale = new Vector3();
Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) Quaternion llrot = part.GetWorldRotation();
continue; // eliminates trees from this since we don't really have a good tree representation Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
// if you want tree blocks on the map comment the above line and uncomment the below line scale = lscale * rot;
//mapdotspot = Color.PaleGreen;
Primitive.TextureEntry textureEntry = part.Shape.Textures; // negative scales don't work in this situation
scale.X = Math.Abs(scale.X);
scale.Y = Math.Abs(scale.Y);
scale.Z = Math.Abs(scale.Z);
if (textureEntry == null || textureEntry.DefaultTexture == null) // This scaling isn't very accurate and doesn't take into account the face rotation :P
continue; int mapdrawstartX = (int)(pos.X - scale.X);
int mapdrawstartY = (int)(pos.Y - scale.Y);
int mapdrawendX = (int)(pos.X + scale.X);
int mapdrawendY = (int)(pos.Y + scale.Y);
Color4 texcolor = textureEntry.DefaultTexture.RGBA; // If object is beyond the edge of the map, don't draw it to avoid errors
if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
// Not sure why some of these are null, oh well. || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
|| mapdrawendY > ((int)Constants.RegionSize - 1))
int colorr = 255 - (int)(texcolor.R * 255f);
int colorg = 255 - (int)(texcolor.G * 255f);
int colorb = 255 - (int)(texcolor.B * 255f);
if (!(colorr == 255 && colorg == 255 && colorb == 255))
{
//Try to set the map spot color
try
{
// If the color gets goofy somehow, skip it *shakes fist at Color4
mapdotspot = Color.FromArgb(colorr, colorg, colorb);
}
catch (ArgumentException)
{
}
}
}
catch (IndexOutOfRangeException)
{
// Windows Array
}
catch (ArgumentOutOfRangeException)
{
// Mono Array
}
Vector3 pos = part.GetWorldPosition();
// skip prim outside of retion
if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
continue; continue;
// skip prim in non-finite position #region obb face reconstruction part duex
if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || Vector3[] vertexes = new Vector3[8];
Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
continue;
// Figure out if object is under 256m above the height of the terrain // float[] distance = new float[6];
bool isBelow256AboveTerrain = false; Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
try tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
{ scale = ((tScale * rot));
isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
} // vertexes[0].x = pos.X + vertexes[0].x;
catch (Exception) //vertexes[0].y = pos.Y + vertexes[0].y;
//vertexes[0].z = pos.Z + vertexes[0].z;
FaceA[0] = vertexes[0];
FaceB[3] = vertexes[0];
FaceA[4] = vertexes[0];
tScale = lscale;
scale = ((tScale * rot));
vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[1].x = pos.X + vertexes[1].x;
// vertexes[1].y = pos.Y + vertexes[1].y;
//vertexes[1].z = pos.Z + vertexes[1].z;
FaceB[0] = vertexes[1];
FaceA[1] = vertexes[1];
FaceC[4] = vertexes[1];
tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[2].x = pos.X + vertexes[2].x;
//vertexes[2].y = pos.Y + vertexes[2].y;
//vertexes[2].z = pos.Z + vertexes[2].z;
FaceC[0] = vertexes[2];
FaceD[3] = vertexes[2];
FaceC[5] = vertexes[2];
tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[3].x = pos.X + vertexes[3].x;
// vertexes[3].y = pos.Y + vertexes[3].y;
// vertexes[3].z = pos.Z + vertexes[3].z;
FaceD[0] = vertexes[3];
FaceC[1] = vertexes[3];
FaceA[5] = vertexes[3];
tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[4].x = pos.X + vertexes[4].x;
// vertexes[4].y = pos.Y + vertexes[4].y;
// vertexes[4].z = pos.Z + vertexes[4].z;
FaceB[1] = vertexes[4];
FaceA[2] = vertexes[4];
FaceD[4] = vertexes[4];
tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[5].x = pos.X + vertexes[5].x;
// vertexes[5].y = pos.Y + vertexes[5].y;
// vertexes[5].z = pos.Z + vertexes[5].z;
FaceD[1] = vertexes[5];
FaceC[2] = vertexes[5];
FaceB[5] = vertexes[5];
tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[6].x = pos.X + vertexes[6].x;
// vertexes[6].y = pos.Y + vertexes[6].y;
// vertexes[6].z = pos.Z + vertexes[6].z;
FaceB[2] = vertexes[6];
FaceA[3] = vertexes[6];
FaceB[4] = vertexes[6];
tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[7].x = pos.X + vertexes[7].x;
// vertexes[7].y = pos.Y + vertexes[7].y;
// vertexes[7].z = pos.Z + vertexes[7].z;
FaceD[2] = vertexes[7];
FaceC[3] = vertexes[7];
FaceD[5] = vertexes[7];
#endregion
//int wy = 0;
//bool breakYN = false; // If we run into an error drawing, break out of the
// loop so we don't lag to death on error handling
DrawStruct ds = new DrawStruct();
ds.brush = new SolidBrush(mapdotspot);
//ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
ds.trns = new face[FaceA.Length];
for (int i = 0; i < FaceA.Length; i++)
{ {
Point[] working = new Point[5];
working[0] = project(FaceA[i], axPos);
working[1] = project(FaceB[i], axPos);
working[2] = project(FaceD[i], axPos);
working[3] = project(FaceC[i], axPos);
working[4] = project(FaceA[i], axPos);
face workingface = new face();
workingface.pts = working;
ds.trns[i] = workingface;
} }
if (isBelow256AboveTerrain) z_sort.Add(part.LocalId, ds);
{ z_localIDs.Add(part.LocalId);
// Translate scale by rotation so scale is represented properly when object is rotated z_sortheights.Add(pos.Z);
Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
Vector3 scale = new Vector3();
Vector3 tScale = new Vector3();
Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
Quaternion llrot = part.GetWorldRotation(); //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); //{
scale = lscale * rot; //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
// negative scales don't work in this situation
scale.X = Math.Abs(scale.X);
scale.Y = Math.Abs(scale.Y);
scale.Z = Math.Abs(scale.Z);
// This scaling isn't very accurate and doesn't take into account the face rotation :P
int mapdrawstartX = (int)(pos.X - scale.X);
int mapdrawstartY = (int)(pos.Y - scale.Y);
int mapdrawendX = (int)(pos.X + scale.X);
int mapdrawendY = (int)(pos.Y + scale.Y);
// If object is beyond the edge of the map, don't draw it to avoid errors
if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
|| mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
|| mapdrawendY > ((int)Constants.RegionSize - 1))
continue;
#region obb face reconstruction part duex
Vector3[] vertexes = new Vector3[8];
// float[] distance = new float[6];
Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[0].x = pos.X + vertexes[0].x;
//vertexes[0].y = pos.Y + vertexes[0].y;
//vertexes[0].z = pos.Z + vertexes[0].z;
FaceA[0] = vertexes[0];
FaceB[3] = vertexes[0];
FaceA[4] = vertexes[0];
tScale = lscale;
scale = ((tScale * rot));
vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[1].x = pos.X + vertexes[1].x;
// vertexes[1].y = pos.Y + vertexes[1].y;
//vertexes[1].z = pos.Z + vertexes[1].z;
FaceB[0] = vertexes[1];
FaceA[1] = vertexes[1];
FaceC[4] = vertexes[1];
tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[2].x = pos.X + vertexes[2].x;
//vertexes[2].y = pos.Y + vertexes[2].y;
//vertexes[2].z = pos.Z + vertexes[2].z;
FaceC[0] = vertexes[2];
FaceD[3] = vertexes[2];
FaceC[5] = vertexes[2];
tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[3].x = pos.X + vertexes[3].x;
// vertexes[3].y = pos.Y + vertexes[3].y;
// vertexes[3].z = pos.Z + vertexes[3].z;
FaceD[0] = vertexes[3];
FaceC[1] = vertexes[3];
FaceA[5] = vertexes[3];
tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[4].x = pos.X + vertexes[4].x;
// vertexes[4].y = pos.Y + vertexes[4].y;
// vertexes[4].z = pos.Z + vertexes[4].z;
FaceB[1] = vertexes[4];
FaceA[2] = vertexes[4];
FaceD[4] = vertexes[4];
tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[5].x = pos.X + vertexes[5].x;
// vertexes[5].y = pos.Y + vertexes[5].y;
// vertexes[5].z = pos.Z + vertexes[5].z;
FaceD[1] = vertexes[5];
FaceC[2] = vertexes[5];
FaceB[5] = vertexes[5];
tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[6].x = pos.X + vertexes[6].x;
// vertexes[6].y = pos.Y + vertexes[6].y;
// vertexes[6].z = pos.Z + vertexes[6].z;
FaceB[2] = vertexes[6];
FaceA[3] = vertexes[6];
FaceB[4] = vertexes[6];
tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[7].x = pos.X + vertexes[7].x;
// vertexes[7].y = pos.Y + vertexes[7].y;
// vertexes[7].z = pos.Z + vertexes[7].z;
FaceD[2] = vertexes[7];
FaceC[3] = vertexes[7];
FaceD[5] = vertexes[7];
#endregion
//int wy = 0;
//bool breakYN = false; // If we run into an error drawing, break out of the
// loop so we don't lag to death on error handling
DrawStruct ds = new DrawStruct();
ds.brush = new SolidBrush(mapdotspot);
//ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
ds.trns = new face[FaceA.Length];
for (int i = 0; i < FaceA.Length; i++)
{
Point[] working = new Point[5];
working[0] = project(FaceA[i], axPos);
working[1] = project(FaceB[i], axPos);
working[2] = project(FaceD[i], axPos);
working[3] = project(FaceC[i], axPos);
working[4] = project(FaceA[i], axPos);
face workingface = new face();
workingface.pts = working;
ds.trns[i] = workingface;
}
z_sort.Add(part.LocalId, ds);
z_localIDs.Add(part.LocalId);
z_sortheights.Add(pos.Z);
//for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
//{ //{
//for (wy = mapdrawstartY; wy < mapdrawendY; wy++) //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
//try
//{ //{
//m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); // Remember, flip the y!
//try // mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
//{ //}
// Remember, flip the y! //catch (ArgumentException)
// mapbmp.SetPixel(wx, (255 - wy), mapdotspot); //{
//} // breakYN = true;
//catch (ArgumentException)
//{
// breakYN = true;
//}
//if (breakYN)
// break;
//} //}
//if (breakYN) //if (breakYN)
// break; // break;
//} //}
} // Object is within 256m Z of terrain
} // object is at least a meter wide //if (breakYN)
} // mapdot.Children lock // break;
//}
} // Object is within 256m Z of terrain
} // object is at least a meter wide
} // loop over group children } // loop over group children
} // entitybase is sceneobject group } // entitybase is sceneobject group
} // foreach loop over entities } // foreach loop over entities

View File

@ -2004,11 +2004,12 @@ namespace OpenSim.Region.Framework.Scenes
sog.SetGroup(groupID, remoteClient); sog.SetGroup(groupID, remoteClient);
sog.ScheduleGroupForFullUpdate(); sog.ScheduleGroupForFullUpdate();
List<SceneObjectPart> partList = null;
lock (sog.Children) lock (sog.Children)
{ partList = new List<SceneObjectPart>(sog.Children.Values);
foreach (SceneObjectPart child in sog.Children.Values)
child.Inventory.ChangeInventoryOwner(ownerID); foreach (SceneObjectPart child in partList)
} child.Inventory.ChangeInventoryOwner(ownerID);
} }
else else
{ {
@ -2018,13 +2019,14 @@ namespace OpenSim.Region.Framework.Scenes
if (sog.GroupID != groupID) if (sog.GroupID != groupID)
continue; continue;
List<SceneObjectPart> partList = null;
lock (sog.Children) lock (sog.Children)
partList = new List<SceneObjectPart>(sog.Children.Values);
foreach (SceneObjectPart child in partList)
{ {
foreach (SceneObjectPart child in sog.Children.Values) child.LastOwnerID = child.OwnerID;
{ child.Inventory.ChangeInventoryOwner(groupID);
child.LastOwnerID = child.OwnerID;
child.Inventory.ChangeInventoryOwner(groupID);
}
} }
sog.SetOwnerId(groupID); sog.SetOwnerId(groupID);

View File

@ -164,16 +164,17 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup sog = ent as SceneObjectGroup; SceneObjectGroup sog = ent as SceneObjectGroup;
List<SceneObjectPart> partList = null;
lock (sog.Children) lock (sog.Children)
partList = new List<SceneObjectPart>(sog.Children.Values);
foreach (SceneObjectPart part in partList)
{ {
foreach (KeyValuePair<UUID, SceneObjectPart> child in (sog.Children)) if (part.LocalId == primLocalID)
{ {
if (child.Value.LocalId == primLocalID) part.GetProperties(remoteClient);
{ foundPrim = true;
child.Value.GetProperties(remoteClient); break;
foundPrim = true;
break;
}
} }
} }

View File

@ -2065,19 +2065,20 @@ namespace OpenSim.Region.Framework.Scenes
group.RemoveScriptInstances(true); group.RemoveScriptInstances(true);
} }
List<SceneObjectPart> partList = null;
lock (group.Children) lock (group.Children)
partList = new List<SceneObjectPart>(group.Children.Values);
foreach (SceneObjectPart part in partList)
{ {
foreach (SceneObjectPart part in group.Children.Values) if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
{ {
if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
{ }
PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? else if (part.PhysActor != null)
} {
else if (part.PhysActor != null) PhysicsScene.RemovePrim(part.PhysActor);
{ part.PhysActor = null;
PhysicsScene.RemovePrim(part.PhysActor);
part.PhysActor = null;
}
} }
} }

View File

@ -381,33 +381,34 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
sceneObject.AttachToScene(m_parentScene);
if (sendClientUpdates)
sceneObject.ScheduleGroupForFullUpdate();
Entities.Add(sceneObject);
m_numPrim += sceneObject.Children.Count; m_numPrim += sceneObject.Children.Count;
}
if (attachToBackup) sceneObject.AttachToScene(m_parentScene);
sceneObject.AttachToBackup();
if (OnObjectCreate != null) if (sendClientUpdates)
OnObjectCreate(sceneObject); sceneObject.ScheduleGroupForFullUpdate();
lock (SceneObjectGroupsByFullID) Entities.Add(sceneObject);
{
SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
foreach (SceneObjectPart part in sceneObject.Children.Values)
SceneObjectGroupsByFullID[part.UUID] = sceneObject;
}
lock (SceneObjectGroupsByLocalID) if (attachToBackup)
{ sceneObject.AttachToBackup();
SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject;
foreach (SceneObjectPart part in sceneObject.Children.Values) if (OnObjectCreate != null)
SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; OnObjectCreate(sceneObject);
}
lock (SceneObjectGroupsByFullID)
{
SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
foreach (SceneObjectPart part in sceneObject.Children.Values)
SceneObjectGroupsByFullID[part.UUID] = sceneObject;
}
lock (SceneObjectGroupsByLocalID)
{
SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject;
foreach (SceneObjectPart part in sceneObject.Children.Values)
SceneObjectGroupsByLocalID[part.LocalId] = sceneObject;
} }
} }

View File

@ -237,6 +237,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <value> /// <value>
/// The parts of this scene object group. You must lock this property before using it. /// The parts of this scene object group. You must lock this property before using it.
/// If you're doing anything other than reading values, please take a copy of the values rather than locking
/// the dictionary for the entirety of the operation. This increases liveness and reduces the danger of deadlock
/// If you want to know the number of children, consider using the PrimCount property instead /// If you want to know the number of children, consider using the PrimCount property instead
/// </value> /// </value>
public Dictionary<UUID, SceneObjectPart> Children public Dictionary<UUID, SceneObjectPart> Children
@ -1968,28 +1970,29 @@ namespace OpenSim.Region.Framework.Scenes
//if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
// return; // return;
lock (m_parts) bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f))
{ {
bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); m_rootPart.UpdateFlag = 1;
lastPhysGroupPos = AbsolutePosition;
}
if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f))
{ {
m_rootPart.UpdateFlag = 1; m_rootPart.UpdateFlag = 1;
lastPhysGroupPos = AbsolutePosition; lastPhysGroupRot = GroupRotation;
} }
if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) List<SceneObjectPart> partList = null;
{ lock (m_parts)
m_rootPart.UpdateFlag = 1; partList = new List<SceneObjectPart>(m_parts.Values);
lastPhysGroupRot = GroupRotation;
}
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in partList)
{ {
if (!IsSelected) if (!IsSelected)
part.UpdateLookAt(); part.UpdateLookAt();
part.SendScheduledUpdates(); part.SendScheduledUpdates();
}
} }
} }
@ -2787,11 +2790,12 @@ namespace OpenSim.Region.Framework.Scenes
public void UpdatePermissions(UUID AgentID, byte field, uint localID, public void UpdatePermissions(UUID AgentID, byte field, uint localID,
uint mask, byte addRemTF) uint mask, byte addRemTF)
{ {
List<SceneObjectPart> partList = null;
lock (m_parts) lock (m_parts)
{ partList = new List<SceneObjectPart>(m_parts.Values);
foreach (SceneObjectPart part in m_parts.Values)
part.UpdatePermissions(AgentID, field, localID, mask, addRemTF); foreach (SceneObjectPart part in partList)
} part.UpdatePermissions(AgentID, field, localID, mask, addRemTF);
HasGroupChanged = true; HasGroupChanged = true;
} }

View File

@ -187,17 +187,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
SceneObjectPart my = GetSOP(); SceneObjectPart my = GetSOP();
IObject[] rets = null; IObject[] rets = null;
int total = my.ParentGroup.PrimCount;
rets = new IObject[total];
int i = 0;
List<SceneObjectPart> partList = null;
lock (my.ParentGroup.Children) lock (my.ParentGroup.Children)
partList = new List<SceneObjectPart>(my.ParentGroup.Children.Values);
foreach (SceneObjectPart part in partList)
{ {
int total = my.ParentGroup.Children.Count; rets[i++] = new SOPObject(m_rootScene, part.LocalId, m_security);
rets = new IObject[total];
int i = 0;
foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children)
{
rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security);
}
} }
return rets; return rets;