diff options
author | Justin Clarke Casey | 2008-06-17 20:36:21 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-06-17 20:36:21 +0000 |
commit | 16d0a895cb817f96a55091fadbbd4cfb2d909204 (patch) | |
tree | 30c2c790f64284dbce988554b0bb0c1ae3417307 /OpenSim/Region | |
parent | * refactor: Remove largely duplicate code from SceneXmlLoader.CreatePrimFromX... (diff) | |
download | opensim-SC-16d0a895cb817f96a55091fadbbd4cfb2d909204.zip opensim-SC-16d0a895cb817f96a55091fadbbd4cfb2d909204.tar.gz opensim-SC-16d0a895cb817f96a55091fadbbd4cfb2d909204.tar.bz2 opensim-SC-16d0a895cb817f96a55091fadbbd4cfb2d909204.tar.xz |
* 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
Diffstat (limited to '')
6 files changed, 16 insertions, 52 deletions
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 | |||
45 | { | 45 | { |
46 | XmlDocument doc = new XmlDocument(); | 46 | XmlDocument doc = new XmlDocument(); |
47 | XmlNode rootNode; | 47 | XmlNode rootNode; |
48 | int primCount = 0; | 48 | |
49 | if (fileName.StartsWith("http:") || File.Exists(fileName)) | 49 | if (fileName.StartsWith("http:") || File.Exists(fileName)) |
50 | { | 50 | { |
51 | XmlTextReader reader = new XmlTextReader(fileName); | 51 | XmlTextReader reader = new XmlTextReader(fileName); |
@@ -65,33 +65,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
65 | //obj.RegenerateFullIDs(); | 65 | //obj.RegenerateFullIDs(); |
66 | 66 | ||
67 | scene.AddSceneObject(obj, true); | 67 | scene.AddSceneObject(obj, true); |
68 | |||
69 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | ||
70 | // Apply loadOffsets for load/import and move combinations | ||
71 | rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; | ||
72 | bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) && | ||
73 | scene.m_physicalPrim); | ||
74 | if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) | ||
75 | { | ||
76 | rootPart.PhysActor = scene.PhysicsScene.AddPrimShape( | ||
77 | rootPart.Name, | ||
78 | rootPart.Shape, | ||
79 | new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X, | ||
80 | rootPart.AbsolutePosition.Y + loadOffset.Y, | ||
81 | rootPart.AbsolutePosition.Z + loadOffset.Z), | ||
82 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), | ||
83 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, | ||
84 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); | ||
85 | |||
86 | // to quote from SceneObjectPart: Basic | ||
87 | // Physics returns null.. joy joy joy. | ||
88 | if (rootPart.PhysActor != null) | ||
89 | { | ||
90 | rootPart.PhysActor.LocalID = rootPart.LocalId; | ||
91 | rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); | ||
92 | } | ||
93 | } | ||
94 | primCount++; | ||
95 | } | 68 | } |
96 | } | 69 | } |
97 | else | 70 | else |
@@ -196,10 +169,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
196 | SceneObjectGroup obj = new SceneObjectGroup(xmlData); | 169 | SceneObjectGroup obj = new SceneObjectGroup(xmlData); |
197 | 170 | ||
198 | scene.AddSceneObjectFromStorage(obj); | 171 | scene.AddSceneObjectFromStorage(obj); |
199 | |||
200 | obj.ApplyPhysics(scene.m_physicalPrim); | ||
201 | |||
202 | obj.ScheduleGroupForFullUpdate(); | ||
203 | } | 172 | } |
204 | 173 | ||
205 | public static void SavePrimsToXml2(Scene scene, string fileName) | 174 | 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 | |||
197 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 197 | foreach (SceneObjectPart part in sceneObject.Children.Values) |
198 | { | 198 | { |
199 | part.LocalId = m_parentScene.PrimIDAllocate(); | 199 | part.LocalId = m_parentScene.PrimIDAllocate(); |
200 | |||
201 | } | 200 | } |
201 | |||
202 | sceneObject.UpdateParentIDs(); | 202 | sceneObject.UpdateParentIDs(); |
203 | 203 | ||
204 | AddSceneObject(sceneObject, true); | 204 | AddSceneObject(sceneObject, true); |
205 | } | 205 | } |
206 | 206 | ||
207 | /// <summary> | 207 | /// <summary> |
208 | /// Add an object to the scene. | 208 | /// Add an object to the scene. This will both update the scene, and send information about the |
209 | /// new object to all clients interested in the scene. | ||
209 | /// </summary> | 210 | /// </summary> |
210 | /// <param name="sceneObject"></param> | 211 | /// <param name="sceneObject"></param> |
211 | /// <param name="attachToBackup"> | 212 | /// <param name="attachToBackup"> |
@@ -216,6 +217,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
216 | /// </returns> | 217 | /// </returns> |
217 | protected internal bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) | 218 | protected internal bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) |
218 | { | 219 | { |
220 | sceneObject.ApplyPhysics(m_parentScene.m_physicalPrim); | ||
221 | sceneObject.ScheduleGroupForFullUpdate(); | ||
222 | |||
219 | lock (Entities) | 223 | lock (Entities) |
220 | { | 224 | { |
221 | if (!Entities.ContainsKey(sceneObject.UUID)) | 225 | 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 | |||
1499 | { | 1499 | { |
1500 | string xmlData = Helpers.FieldToUTF8String(rezAsset.Data); | 1500 | string xmlData = Helpers.FieldToUTF8String(rezAsset.Data); |
1501 | SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); | 1501 | SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); |
1502 | if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count,remoteClient.AgentId, pos) && !attachment) | 1502 | if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count, remoteClient.AgentId, pos) && !attachment) |
1503 | { | 1503 | { |
1504 | return null; | 1504 | return null; |
1505 | } | 1505 | } |
@@ -1513,8 +1513,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1513 | if (!attachment) | 1513 | if (!attachment) |
1514 | { | 1514 | { |
1515 | pos = GetNewRezLocation( | 1515 | pos = GetNewRezLocation( |
1516 | RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), | 1516 | RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), |
1517 | BypassRayCast, bRayEndIsIntersection, true, group.GroupScale(), false); | 1517 | BypassRayCast, bRayEndIsIntersection, true, group.GroupScale(), false); |
1518 | group.AbsolutePosition = pos; | 1518 | group.AbsolutePosition = pos; |
1519 | } | 1519 | } |
1520 | else | 1520 | 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 | |||
1460 | rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted; | 1460 | rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted; |
1461 | rootPart.TrimPermissions(); | 1461 | rootPart.TrimPermissions(); |
1462 | group.CheckSculptAndLoad(); | 1462 | group.CheckSculptAndLoad(); |
1463 | group.ApplyPhysics(m_physicalPrim); | ||
1464 | //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); | 1463 | //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); |
1465 | } | 1464 | } |
1466 | 1465 | ||
@@ -1578,9 +1577,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
1578 | 1577 | ||
1579 | public virtual SceneObjectGroup AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape) | 1578 | public virtual SceneObjectGroup AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape) |
1580 | { | 1579 | { |
1580 | //m_log.DebugFormat( | ||
1581 | // "[SCENE]: Scene.AddNewPrim() called for agent {0} in {1}", ownerID, RegionInfo.RegionName); | ||
1582 | |||
1581 | SceneObjectGroup sceneOb = | 1583 | SceneObjectGroup sceneOb = |
1582 | new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape); | 1584 | new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape); |
1583 | AddSceneObject(sceneOb, true); | 1585 | |
1584 | SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); | 1586 | SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); |
1585 | // if grass or tree, make phantom | 1587 | // if grass or tree, make phantom |
1586 | //rootPart.TrimPermissions(); | 1588 | //rootPart.TrimPermissions(); |
@@ -1591,9 +1593,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1591 | if (rootPart.Shape.PCode != (byte)PCode.Grass) | 1593 | if (rootPart.Shape.PCode != (byte)PCode.Grass) |
1592 | AdaptTree(ref shape); | 1594 | AdaptTree(ref shape); |
1593 | } | 1595 | } |
1594 | // if not phantom, add to physics | 1596 | |
1595 | sceneOb.ApplyPhysics(m_physicalPrim); | 1597 | AddSceneObject(sceneOb, true); |
1596 | m_innerScene.AddToUpdateList(sceneOb); | ||
1597 | 1598 | ||
1598 | return sceneOb; | 1599 | return sceneOb; |
1599 | } | 1600 | } |
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 | |||
350 | SetPartAsRoot(part); | 350 | SetPartAsRoot(part); |
351 | 351 | ||
352 | RegionHandle = regionHandle; | 352 | RegionHandle = regionHandle; |
353 | |||
354 | ApplyPhysics(scene.m_physicalPrim); | ||
355 | |||
356 | ScheduleGroupForFullUpdate(); | ||
357 | } | 353 | } |
358 | 354 | ||
359 | /// <summary> | 355 | /// <summary> |
@@ -412,10 +408,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
412 | m_rootPart.ParentID = 0; | 408 | m_rootPart.ParentID = 0; |
413 | m_rootPart.RegionHandle = m_regionHandle; | 409 | m_rootPart.RegionHandle = m_regionHandle; |
414 | UpdateParentIDs(); | 410 | UpdateParentIDs(); |
415 | |||
416 | ApplyPhysics(scene.m_physicalPrim); | ||
417 | |||
418 | ScheduleGroupForFullUpdate(); | ||
419 | } | 411 | } |
420 | 412 | ||
421 | /// <summary> | 413 | /// <summary> |
@@ -854,7 +846,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
854 | if (part.UUID != m_rootPart.UUID) | 846 | if (part.UUID != m_rootPart.UUID) |
855 | { | 847 | { |
856 | part.ParentID = m_rootPart.LocalId; | 848 | part.ParentID = m_rootPart.LocalId; |
857 | |||
858 | } | 849 | } |
859 | } | 850 | } |
860 | } | 851 | } |
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 | |||
77 | 77 | ||
78 | FileSystemObject fileObject = new FileSystemObject(m_scene, fileInfo, filePos); | 78 | FileSystemObject fileObject = new FileSystemObject(m_scene, fileInfo, filePos); |
79 | m_scene.AddSceneObject(fileObject, true); | 79 | m_scene.AddSceneObject(fileObject, true); |
80 | fileObject.ScheduleGroupForFullUpdate(); | ||
81 | } | 80 | } |
82 | } | 81 | } |
83 | 82 | ||