* Refactor: Move the responsibility for applying physics and sending the initial client update to Scene.AddSceneObject() from some of the SceneObjectGroup constructors

* I think this has been done cleanly from inspection and testing, but if prim creation or load suddenly starts playing up more than usual, please open a mantis
* This also has the effect of stopping the archiver generating ghost in-world prims
* Some code dupliction also removed
0.6.0-stable
Justin Clarke Casey 2008-06-17 20:36:21 +00:00
parent 33d32355a1
commit 16d0a895cb
6 changed files with 16 additions and 52 deletions

View File

@ -45,7 +45,7 @@ namespace OpenSim.Region.Environment.Scenes
{
XmlDocument doc = new XmlDocument();
XmlNode rootNode;
int primCount = 0;
if (fileName.StartsWith("http:") || File.Exists(fileName))
{
XmlTextReader reader = new XmlTextReader(fileName);
@ -65,33 +65,6 @@ namespace OpenSim.Region.Environment.Scenes
//obj.RegenerateFullIDs();
scene.AddSceneObject(obj, true);
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
// Apply loadOffsets for load/import and move combinations
rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset;
bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) &&
scene.m_physicalPrim);
if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0)
{
rootPart.PhysActor = scene.PhysicsScene.AddPrimShape(
rootPart.Name,
rootPart.Shape,
new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X,
rootPart.AbsolutePosition.Y + loadOffset.Y,
rootPart.AbsolutePosition.Z + loadOffset.Z),
new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
// to quote from SceneObjectPart: Basic
// Physics returns null.. joy joy joy.
if (rootPart.PhysActor != null)
{
rootPart.PhysActor.LocalID = rootPart.LocalId;
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
}
}
primCount++;
}
}
else
@ -196,10 +169,6 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
scene.AddSceneObjectFromStorage(obj);
obj.ApplyPhysics(scene.m_physicalPrim);
obj.ScheduleGroupForFullUpdate();
}
public static void SavePrimsToXml2(Scene scene, string fileName)

View File

@ -197,15 +197,16 @@ namespace OpenSim.Region.Environment.Scenes
foreach (SceneObjectPart part in sceneObject.Children.Values)
{
part.LocalId = m_parentScene.PrimIDAllocate();
}
sceneObject.UpdateParentIDs();
AddSceneObject(sceneObject, true);
}
/// <summary>
/// Add an object to the scene.
/// Add an object to the scene. This will both update the scene, and send information about the
/// new object to all clients interested in the scene.
/// </summary>
/// <param name="sceneObject"></param>
/// <param name="attachToBackup">
@ -216,6 +217,9 @@ namespace OpenSim.Region.Environment.Scenes
/// </returns>
protected internal bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
{
sceneObject.ApplyPhysics(m_parentScene.m_physicalPrim);
sceneObject.ScheduleGroupForFullUpdate();
lock (Entities)
{
if (!Entities.ContainsKey(sceneObject.UUID))

View File

@ -1499,7 +1499,7 @@ namespace OpenSim.Region.Environment.Scenes
{
string xmlData = Helpers.FieldToUTF8String(rezAsset.Data);
SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count,remoteClient.AgentId, pos) && !attachment)
if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count, remoteClient.AgentId, pos) && !attachment)
{
return null;
}
@ -1513,8 +1513,8 @@ namespace OpenSim.Region.Environment.Scenes
if (!attachment)
{
pos = GetNewRezLocation(
RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
BypassRayCast, bRayEndIsIntersection, true, group.GroupScale(), false);
RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
BypassRayCast, bRayEndIsIntersection, true, group.GroupScale(), false);
group.AbsolutePosition = pos;
}
else

View File

@ -1460,7 +1460,6 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted;
rootPart.TrimPermissions();
group.CheckSculptAndLoad();
group.ApplyPhysics(m_physicalPrim);
//rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
}
@ -1578,9 +1577,12 @@ namespace OpenSim.Region.Environment.Scenes
public virtual SceneObjectGroup AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape)
{
//m_log.DebugFormat(
// "[SCENE]: Scene.AddNewPrim() called for agent {0} in {1}", ownerID, RegionInfo.RegionName);
SceneObjectGroup sceneOb =
new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
AddSceneObject(sceneOb, true);
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
// if grass or tree, make phantom
//rootPart.TrimPermissions();
@ -1591,9 +1593,8 @@ namespace OpenSim.Region.Environment.Scenes
if (rootPart.Shape.PCode != (byte)PCode.Grass)
AdaptTree(ref shape);
}
// if not phantom, add to physics
sceneOb.ApplyPhysics(m_physicalPrim);
m_innerScene.AddToUpdateList(sceneOb);
AddSceneObject(sceneOb, true);
return sceneOb;
}

View File

@ -350,10 +350,6 @@ namespace OpenSim.Region.Environment.Scenes
SetPartAsRoot(part);
RegionHandle = regionHandle;
ApplyPhysics(scene.m_physicalPrim);
ScheduleGroupForFullUpdate();
}
/// <summary>
@ -412,10 +408,6 @@ namespace OpenSim.Region.Environment.Scenes
m_rootPart.ParentID = 0;
m_rootPart.RegionHandle = m_regionHandle;
UpdateParentIDs();
ApplyPhysics(scene.m_physicalPrim);
ScheduleGroupForFullUpdate();
}
/// <summary>
@ -854,7 +846,6 @@ namespace OpenSim.Region.Environment.Scenes
if (part.UUID != m_rootPart.UUID)
{
part.ParentID = m_rootPart.LocalId;
}
}
}

View File

@ -77,7 +77,6 @@ namespace OpenSim.Region.Examples.SimpleModule
FileSystemObject fileObject = new FileSystemObject(m_scene, fileInfo, filePos);
m_scene.AddSceneObject(fileObject, true);
fileObject.ScheduleGroupForFullUpdate();
}
}