* 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 removed0.6.0-stable
parent
33d32355a1
commit
16d0a895cb
|
@ -45,7 +45,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
XmlNode rootNode;
|
XmlNode rootNode;
|
||||||
int primCount = 0;
|
|
||||||
if (fileName.StartsWith("http:") || File.Exists(fileName))
|
if (fileName.StartsWith("http:") || File.Exists(fileName))
|
||||||
{
|
{
|
||||||
XmlTextReader reader = new XmlTextReader(fileName);
|
XmlTextReader reader = new XmlTextReader(fileName);
|
||||||
|
@ -65,33 +65,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
//obj.RegenerateFullIDs();
|
//obj.RegenerateFullIDs();
|
||||||
|
|
||||||
scene.AddSceneObject(obj, true);
|
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
|
else
|
||||||
|
@ -196,10 +169,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
|
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
|
||||||
|
|
||||||
scene.AddSceneObjectFromStorage(obj);
|
scene.AddSceneObjectFromStorage(obj);
|
||||||
|
|
||||||
obj.ApplyPhysics(scene.m_physicalPrim);
|
|
||||||
|
|
||||||
obj.ScheduleGroupForFullUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SavePrimsToXml2(Scene scene, string fileName)
|
public static void SavePrimsToXml2(Scene scene, string fileName)
|
||||||
|
|
|
@ -197,15 +197,16 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
foreach (SceneObjectPart part in sceneObject.Children.Values)
|
foreach (SceneObjectPart part in sceneObject.Children.Values)
|
||||||
{
|
{
|
||||||
part.LocalId = m_parentScene.PrimIDAllocate();
|
part.LocalId = m_parentScene.PrimIDAllocate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sceneObject.UpdateParentIDs();
|
sceneObject.UpdateParentIDs();
|
||||||
|
|
||||||
AddSceneObject(sceneObject, true);
|
AddSceneObject(sceneObject, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="sceneObject"></param>
|
/// <param name="sceneObject"></param>
|
||||||
/// <param name="attachToBackup">
|
/// <param name="attachToBackup">
|
||||||
|
@ -216,6 +217,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// </returns>
|
/// </returns>
|
||||||
protected internal bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
|
protected internal bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
|
||||||
{
|
{
|
||||||
|
sceneObject.ApplyPhysics(m_parentScene.m_physicalPrim);
|
||||||
|
sceneObject.ScheduleGroupForFullUpdate();
|
||||||
|
|
||||||
lock (Entities)
|
lock (Entities)
|
||||||
{
|
{
|
||||||
if (!Entities.ContainsKey(sceneObject.UUID))
|
if (!Entities.ContainsKey(sceneObject.UUID))
|
||||||
|
|
|
@ -1460,7 +1460,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted;
|
rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted;
|
||||||
rootPart.TrimPermissions();
|
rootPart.TrimPermissions();
|
||||||
group.CheckSculptAndLoad();
|
group.CheckSculptAndLoad();
|
||||||
group.ApplyPhysics(m_physicalPrim);
|
|
||||||
//rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
|
//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)
|
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 =
|
SceneObjectGroup sceneOb =
|
||||||
new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
|
new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
|
||||||
AddSceneObject(sceneOb, true);
|
|
||||||
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
|
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
|
||||||
// if grass or tree, make phantom
|
// if grass or tree, make phantom
|
||||||
//rootPart.TrimPermissions();
|
//rootPart.TrimPermissions();
|
||||||
|
@ -1591,9 +1593,8 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (rootPart.Shape.PCode != (byte)PCode.Grass)
|
if (rootPart.Shape.PCode != (byte)PCode.Grass)
|
||||||
AdaptTree(ref shape);
|
AdaptTree(ref shape);
|
||||||
}
|
}
|
||||||
// if not phantom, add to physics
|
|
||||||
sceneOb.ApplyPhysics(m_physicalPrim);
|
AddSceneObject(sceneOb, true);
|
||||||
m_innerScene.AddToUpdateList(sceneOb);
|
|
||||||
|
|
||||||
return sceneOb;
|
return sceneOb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,10 +350,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
SetPartAsRoot(part);
|
SetPartAsRoot(part);
|
||||||
|
|
||||||
RegionHandle = regionHandle;
|
RegionHandle = regionHandle;
|
||||||
|
|
||||||
ApplyPhysics(scene.m_physicalPrim);
|
|
||||||
|
|
||||||
ScheduleGroupForFullUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -412,10 +408,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
m_rootPart.ParentID = 0;
|
m_rootPart.ParentID = 0;
|
||||||
m_rootPart.RegionHandle = m_regionHandle;
|
m_rootPart.RegionHandle = m_regionHandle;
|
||||||
UpdateParentIDs();
|
UpdateParentIDs();
|
||||||
|
|
||||||
ApplyPhysics(scene.m_physicalPrim);
|
|
||||||
|
|
||||||
ScheduleGroupForFullUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -854,7 +846,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (part.UUID != m_rootPart.UUID)
|
if (part.UUID != m_rootPart.UUID)
|
||||||
{
|
{
|
||||||
part.ParentID = m_rootPart.LocalId;
|
part.ParentID = m_rootPart.LocalId;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,6 @@ namespace OpenSim.Region.Examples.SimpleModule
|
||||||
|
|
||||||
FileSystemObject fileObject = new FileSystemObject(m_scene, fileInfo, filePos);
|
FileSystemObject fileObject = new FileSystemObject(m_scene, fileInfo, filePos);
|
||||||
m_scene.AddSceneObject(fileObject, true);
|
m_scene.AddSceneObject(fileObject, true);
|
||||||
fileObject.ScheduleGroupForFullUpdate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue