From 16d0a895cb817f96a55091fadbbd4cfb2d909204 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Tue, 17 Jun 2008 20:36:21 +0000
Subject: * 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
---
.../Modules/World/Serialiser/SceneXmlLoader.cs | 33 +---------------------
OpenSim/Region/Environment/Scenes/InnerScene.cs | 8 ++++--
.../Region/Environment/Scenes/Scene.Inventory.cs | 6 ++--
OpenSim/Region/Environment/Scenes/Scene.cs | 11 ++++----
.../Region/Environment/Scenes/SceneObjectGroup.cs | 9 ------
.../Region/Examples/SimpleModule/RegionModule.cs | 1 -
6 files changed, 16 insertions(+), 52 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
index 5591ddc..db16601 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
@@ -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)
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 9bbfc3d..e803122 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -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);
}
///
- /// 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.
///
///
///
@@ -216,6 +217,9 @@ namespace OpenSim.Region.Environment.Scenes
///
protected internal bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
{
+ sceneObject.ApplyPhysics(m_parentScene.m_physicalPrim);
+ sceneObject.ScheduleGroupForFullUpdate();
+
lock (Entities)
{
if (!Entities.ContainsKey(sceneObject.UUID))
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index ebc721f..ff62a3b 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -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
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index b39e08d..7adfeca 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -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;
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 877f196..f94830e 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -350,10 +350,6 @@ namespace OpenSim.Region.Environment.Scenes
SetPartAsRoot(part);
RegionHandle = regionHandle;
-
- ApplyPhysics(scene.m_physicalPrim);
-
- ScheduleGroupForFullUpdate();
}
///
@@ -412,10 +408,6 @@ namespace OpenSim.Region.Environment.Scenes
m_rootPart.ParentID = 0;
m_rootPart.RegionHandle = m_regionHandle;
UpdateParentIDs();
-
- ApplyPhysics(scene.m_physicalPrim);
-
- ScheduleGroupForFullUpdate();
}
///
@@ -854,7 +846,6 @@ namespace OpenSim.Region.Environment.Scenes
if (part.UUID != m_rootPart.UUID)
{
part.ParentID = m_rootPart.LocalId;
-
}
}
}
diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
index ab643a2..2e6ed42 100644
--- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
+++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
@@ -77,7 +77,6 @@ namespace OpenSim.Region.Examples.SimpleModule
FileSystemObject fileObject = new FileSystemObject(m_scene, fileInfo, filePos);
m_scene.AddSceneObject(fileObject, true);
- fileObject.ScheduleGroupForFullUpdate();
}
}
--
cgit v1.1