aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJohn Hurliman2009-09-16 15:06:08 -0700
committerJohn Hurliman2009-09-16 15:06:08 -0700
commitf42d085ab17098709bcba0c816c9742a213d3c01 (patch)
treecdf3af0cf5e65ad949f07afc80d28a29954bfa42 /OpenSim/Region
parentAdd the Null storage implementation for the RegionData service. Standalones (diff)
downloadopensim-SC_OLD-f42d085ab17098709bcba0c816c9742a213d3c01.zip
opensim-SC_OLD-f42d085ab17098709bcba0c816c9742a213d3c01.tar.gz
opensim-SC_OLD-f42d085ab17098709bcba0c816c9742a213d3c01.tar.bz2
opensim-SC_OLD-f42d085ab17098709bcba0c816c9742a213d3c01.tar.xz
SceneObjectGroup cleanup. Removes the default constructor and unnecessary null checks on m_rootPart
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Examples/SimpleModule/ComplexObject.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs110
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs53
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs3
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs3
6 files changed, 53 insertions, 124 deletions
diff --git a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
index f9c3fa6..3809749 100644
--- a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
+++ b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
@@ -73,10 +73,6 @@ namespace OpenSim.Region.Examples.SimpleModule
73 base.UpdateMovement(); 73 base.UpdateMovement();
74 } 74 }
75 75
76 public ComplexObject()
77 {
78 }
79
80 public ComplexObject(Scene scene, ulong regionHandle, UUID ownerID, uint localID, Vector3 pos) 76 public ComplexObject(Scene scene, ulong regionHandle, UUID ownerID, uint localID, Vector3 pos)
81 : base(ownerID, pos, PrimitiveBaseShape.Default) 77 : base(ownerID, pos, PrimitiveBaseShape.Default)
82 { 78 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 6ba7e41..3c17bbe 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -250,16 +250,7 @@ namespace OpenSim.Region.Framework.Scenes
250 /// </summary> 250 /// </summary>
251 public override Vector3 AbsolutePosition 251 public override Vector3 AbsolutePosition
252 { 252 {
253 get 253 get { return m_rootPart.GroupPosition; }
254 {
255 if (m_rootPart == null)
256 {
257 throw new NullReferenceException(
258 string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid));
259 }
260
261 return m_rootPart.GroupPosition;
262 }
263 set 254 set
264 { 255 {
265 Vector3 val = value; 256 Vector3 val = value;
@@ -291,41 +282,19 @@ namespace OpenSim.Region.Framework.Scenes
291 282
292 public override uint LocalId 283 public override uint LocalId
293 { 284 {
294 get 285 get { return m_rootPart.LocalId; }
295 {
296 if (m_rootPart == null)
297 {
298 m_log.Error("[SCENE OBJECT GROUP]: Unable to find the rootpart for a LocalId Request!");
299 return 0;
300 }
301
302 return m_rootPart.LocalId;
303 }
304 set { m_rootPart.LocalId = value; } 286 set { m_rootPart.LocalId = value; }
305 } 287 }
306 288
307 public override UUID UUID 289 public override UUID UUID
308 { 290 {
309 get { 291 get { return m_rootPart.UUID; }
310 if (m_rootPart == null)
311 {
312 m_log.Error("Got a null rootpart while requesting UUID. Called from: ", new Exception());
313 return UUID.Zero;
314 }
315 else return m_rootPart.UUID;
316 }
317 set { m_rootPart.UUID = value; } 292 set { m_rootPart.UUID = value; }
318 } 293 }
319 294
320 public UUID OwnerID 295 public UUID OwnerID
321 { 296 {
322 get 297 get { return m_rootPart.OwnerID; }
323 {
324 if (m_rootPart == null)
325 return UUID.Zero;
326
327 return m_rootPart.OwnerID;
328 }
329 set { m_rootPart.OwnerID = value; } 298 set { m_rootPart.OwnerID = value; }
330 } 299 }
331 300
@@ -366,7 +335,7 @@ namespace OpenSim.Region.Framework.Scenes
366 { 335 {
367 m_isSelected = value; 336 m_isSelected = value;
368 // Tell physics engine that group is selected 337 // Tell physics engine that group is selected
369 if (m_rootPart != null && m_rootPart.PhysActor != null) 338 if (m_rootPart.PhysActor != null)
370 { 339 {
371 m_rootPart.PhysActor.Selected = value; 340 m_rootPart.PhysActor.Selected = value;
372 // Pass it on to the children. 341 // Pass it on to the children.
@@ -399,13 +368,6 @@ namespace OpenSim.Region.Framework.Scenes
399 #region Constructors 368 #region Constructors
400 369
401 /// <summary> 370 /// <summary>
402 /// Constructor
403 /// </summary>
404 public SceneObjectGroup()
405 {
406 }
407
408 /// <summary>
409 /// This constructor creates a SceneObjectGroup using a pre-existing SceneObjectPart. 371 /// This constructor creates a SceneObjectGroup using a pre-existing SceneObjectPart.
410 /// The original SceneObjectPart will be used rather than a copy, preserving 372 /// The original SceneObjectPart will be used rather than a copy, preserving
411 /// its existing localID and UUID. 373 /// its existing localID and UUID.
@@ -419,9 +381,8 @@ namespace OpenSim.Region.Framework.Scenes
419 /// Constructor. This object is added to the scene later via AttachToScene() 381 /// Constructor. This object is added to the scene later via AttachToScene()
420 /// </summary> 382 /// </summary>
421 public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) 383 public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
422 { 384 {
423 Vector3 rootOffset = new Vector3(0, 0, 0); 385 SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero));
424 SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, rootOffset));
425 } 386 }
426 387
427 /// <summary> 388 /// <summary>
@@ -462,11 +423,7 @@ namespace OpenSim.Region.Framework.Scenes
462 423
463 public UUID GetFromItemID() 424 public UUID GetFromItemID()
464 { 425 {
465 if (m_rootPart != null) 426 return m_rootPart.FromItemID;
466 {
467 return m_rootPart.FromItemID;
468 }
469 return UUID.Zero;
470 } 427 }
471 428
472 /// <summary> 429 /// <summary>
@@ -958,11 +915,7 @@ namespace OpenSim.Region.Framework.Scenes
958 915
959 public byte GetAttachmentPoint() 916 public byte GetAttachmentPoint()
960 { 917 {
961 if (m_rootPart != null) 918 return m_rootPart.Shape.State;
962 {
963 return m_rootPart.Shape.State;
964 }
965 return (byte)0;
966 } 919 }
967 920
968 public void ClearPartAttachmentData() 921 public void ClearPartAttachmentData()
@@ -1071,7 +1024,10 @@ namespace OpenSim.Region.Framework.Scenes
1071 /// </summary> 1024 /// </summary>
1072 /// <param name="part"></param> 1025 /// <param name="part"></param>
1073 public void SetRootPart(SceneObjectPart part) 1026 public void SetRootPart(SceneObjectPart part)
1074 { 1027 {
1028 if (part == null)
1029 throw new ArgumentNullException("Cannot give SceneObjectGroup a null root SceneObjectPart");
1030
1075 part.SetParent(this); 1031 part.SetParent(this);
1076 m_rootPart = part; 1032 m_rootPart = part;
1077 if (!IsAttachment) 1033 if (!IsAttachment)
@@ -1224,7 +1180,7 @@ namespace OpenSim.Region.Framework.Scenes
1224 1180
1225 if (!silent) 1181 if (!silent)
1226 { 1182 {
1227 if (m_rootPart != null && part == m_rootPart) 1183 if (part == m_rootPart)
1228 avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); 1184 avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
1229 } 1185 }
1230 } 1186 }
@@ -1447,7 +1403,7 @@ namespace OpenSim.Region.Framework.Scenes
1447 /// <param name="part"></param> 1403 /// <param name="part"></param>
1448 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) 1404 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
1449 { 1405 {
1450 if (m_rootPart != null && m_rootPart.UUID == part.UUID) 1406 if (m_rootPart.UUID == part.UUID)
1451 { 1407 {
1452 if (IsAttachment) 1408 if (IsAttachment)
1453 { 1409 {
@@ -1881,12 +1837,6 @@ namespace OpenSim.Region.Framework.Scenes
1881 if (m_isDeleted) 1837 if (m_isDeleted)
1882 return; 1838 return;
1883 1839
1884 // This is what happens when an orphanced link set child prim's
1885 // group was queued when it was linked
1886 //
1887 if (m_rootPart == null)
1888 return;
1889
1890 // Even temporary objects take part in physics (e.g. temp-on-rez bullets) 1840 // Even temporary objects take part in physics (e.g. temp-on-rez bullets)
1891 //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 1841 //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
1892 // return; 1842 // return;
@@ -3129,26 +3079,22 @@ namespace OpenSim.Region.Framework.Scenes
3129 int yaxis = 4; 3079 int yaxis = 4;
3130 int zaxis = 8; 3080 int zaxis = 8;
3131 3081
3132 if (m_rootPart != null) 3082 setX = ((axis & xaxis) != 0) ? true : false;
3133 { 3083 setY = ((axis & yaxis) != 0) ? true : false;
3134 setX = ((axis & xaxis) != 0) ? true : false; 3084 setZ = ((axis & zaxis) != 0) ? true : false;
3135 setY = ((axis & yaxis) != 0) ? true : false;
3136 setZ = ((axis & zaxis) != 0) ? true : false;
3137 3085
3138 float setval = (rotate10 > 0) ? 1f : 0f; 3086 float setval = (rotate10 > 0) ? 1f : 0f;
3139 3087
3140 if (setX) 3088 if (setX)
3141 m_rootPart.RotationAxis.X = setval; 3089 m_rootPart.RotationAxis.X = setval;
3142 if (setY) 3090 if (setY)
3143 m_rootPart.RotationAxis.Y = setval; 3091 m_rootPart.RotationAxis.Y = setval;
3144 if (setZ) 3092 if (setZ)
3145 m_rootPart.RotationAxis.Z = setval; 3093 m_rootPart.RotationAxis.Z = setval;
3146
3147 if (setX || setY || setZ)
3148 {
3149 m_rootPart.SetPhysicsAxisRotation();
3150 }
3151 3094
3095 if (setX || setY || setZ)
3096 {
3097 m_rootPart.SetPhysicsAxisRotation();
3152 } 3098 }
3153 } 3099 }
3154 3100
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 5ae81cd..fe74158 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -65,8 +65,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
65 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 65 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
66 //int time = System.Environment.TickCount; 66 //int time = System.Environment.TickCount;
67 67
68 SceneObjectGroup sceneObject = new SceneObjectGroup();
69
70 // libomv.types changes UUID to Guid 68 // libomv.types changes UUID to Guid
71 xmlData = xmlData.Replace("<UUID>", "<Guid>"); 69 xmlData = xmlData.Replace("<UUID>", "<Guid>");
72 xmlData = xmlData.Replace("</UUID>", "</Guid>"); 70 xmlData = xmlData.Replace("</UUID>", "</Guid>");
@@ -88,17 +86,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
88 parts = doc.GetElementsByTagName("RootPart"); 86 parts = doc.GetElementsByTagName("RootPart");
89 87
90 if (parts.Count == 0) 88 if (parts.Count == 0)
91 {
92 throw new Exception("Invalid Xml format - no root part"); 89 throw new Exception("Invalid Xml format - no root part");
93 } 90
94 else 91 sr = new StringReader(parts[0].InnerXml);
95 { 92 reader = new XmlTextReader(sr);
96 sr = new StringReader(parts[0].InnerXml); 93 SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(fromUserInventoryItemID, reader));
97 reader = new XmlTextReader(sr); 94 reader.Close();
98 sceneObject.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader)); 95 sr.Close();
99 reader.Close();
100 sr.Close();
101 }
102 96
103 parts = doc.GetElementsByTagName("Part"); 97 parts = doc.GetElementsByTagName("Part");
104 98
@@ -119,16 +113,15 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
119 // Script state may, or may not, exist. Not having any, is NOT 113 // Script state may, or may not, exist. Not having any, is NOT
120 // ever a problem. 114 // ever a problem.
121 sceneObject.LoadScriptState(doc); 115 sceneObject.LoadScriptState(doc);
116
117 return sceneObject;
122 } 118 }
123 catch (Exception e) 119 catch (Exception e)
124 { 120 {
125 m_log.ErrorFormat( 121 m_log.ErrorFormat(
126 "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); 122 "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
123 return null;
127 } 124 }
128
129 //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
130
131 return sceneObject;
132 } 125 }
133 126
134 /// <summary> 127 /// <summary>
@@ -194,8 +187,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
194 { 187 {
195 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 188 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
196 //int time = System.Environment.TickCount; 189 //int time = System.Environment.TickCount;
197
198 SceneObjectGroup sceneObject = new SceneObjectGroup();
199 190
200 // libomv.types changes UUID to Guid 191 // libomv.types changes UUID to Guid
201 xmlData = xmlData.Replace("<UUID>", "<Guid>"); 192 xmlData = xmlData.Replace("<UUID>", "<Guid>");
@@ -212,21 +203,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
212 203
213 XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart"); 204 XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart");
214 205
215 // Process the root part first 206 if (parts.Count == 0)
216 if (parts.Count > 0)
217 { 207 {
218 StringReader sr = new StringReader(parts[0].OuterXml); 208 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed: No SceneObjectPart nodes. xml was " + xmlData);
219 XmlTextReader reader = new XmlTextReader(sr); 209 return null;
220 sceneObject.SetRootPart(SceneObjectPart.FromXml(reader));
221 reader.Close();
222 sr.Close();
223 } 210 }
224 211
212 StringReader sr = new StringReader(parts[0].OuterXml);
213 XmlTextReader reader = new XmlTextReader(sr);
214 SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
215 reader.Close();
216 sr.Close();
217
225 // Then deal with the rest 218 // Then deal with the rest
226 for (int i = 1; i < parts.Count; i++) 219 for (int i = 1; i < parts.Count; i++)
227 { 220 {
228 StringReader sr = new StringReader(parts[i].OuterXml); 221 sr = new StringReader(parts[i].OuterXml);
229 XmlTextReader reader = new XmlTextReader(sr); 222 reader = new XmlTextReader(sr);
230 SceneObjectPart part = SceneObjectPart.FromXml(reader); 223 SceneObjectPart part = SceneObjectPart.FromXml(reader);
231 sceneObject.AddPart(part); 224 sceneObject.AddPart(part);
232 part.StoreUndoState(); 225 part.StoreUndoState();
@@ -238,15 +231,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
238 // ever a problem. 231 // ever a problem.
239 232
240 sceneObject.LoadScriptState(doc); 233 sceneObject.LoadScriptState(doc);
234 return sceneObject;
241 } 235 }
242 catch (Exception e) 236 catch (Exception e)
243 { 237 {
244 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); 238 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
239 return null;
245 } 240 }
246
247 //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
248
249 return sceneObject;
250 } 241 }
251 242
252 /// <summary> 243 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index bb8f27d..3b0e77f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -128,7 +128,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
128 128
129 private SceneObjectGroup NewSOG() 129 private SceneObjectGroup NewSOG()
130 { 130 {
131 SceneObjectGroup sog = new SceneObjectGroup();
132 SceneObjectPart sop = new SceneObjectPart(UUID.Random(), PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); 131 SceneObjectPart sop = new SceneObjectPart(UUID.Random(), PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
133 sop.Name = RandomName(); 132 sop.Name = RandomName();
134 sop.Description = sop.Name; 133 sop.Description = sop.Name;
@@ -136,9 +135,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
136 sop.SitName = RandomName(); 135 sop.SitName = RandomName();
137 sop.TouchName = RandomName(); 136 sop.TouchName = RandomName();
138 sop.ObjectFlags |= (uint)PrimFlags.Phantom; 137 sop.ObjectFlags |= (uint)PrimFlags.Phantom;
139
140 sog.SetRootPart(sop);
141 138
139 SceneObjectGroup sog = new SceneObjectGroup(sop);
142 scene.AddNewSceneObject(sog, false); 140 scene.AddNewSceneObject(sog, false);
143 141
144 return sog; 142 return sog;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index 7fb2d25..19c0fea 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -407,9 +407,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
407 sop.Shape.State = 1; 407 sop.Shape.State = 1;
408 sop.OwnerID = agent; 408 sop.OwnerID = agent;
409 409
410 SceneObjectGroup sog = new SceneObjectGroup(); 410 SceneObjectGroup sog = new SceneObjectGroup(sop);
411 sog.SetScene(scene); 411 sog.SetScene(scene);
412 sog.SetRootPart(sop);
413 412
414 return sog; 413 return sog;
415 } 414 }
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs
index 59b7289..fbe43d6 100644
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs
+++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs
@@ -66,7 +66,6 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
66 66
67 private void CreatePointEntity(Scene scene, UUID uuid, Vector3 groupPos) 67 private void CreatePointEntity(Scene scene, UUID uuid, Vector3 groupPos)
68 { 68 {
69 SceneObjectGroup x = new SceneObjectGroup();
70 SceneObjectPart y = new SceneObjectPart(); 69 SceneObjectPart y = new SceneObjectPart();
71 70
72 //Initialize part 71 //Initialize part
@@ -93,8 +92,8 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
93 y.TrimPermissions(); 92 y.TrimPermissions();
94 93
95 //Initialize group and add part as root part 94 //Initialize group and add part as root part
95 SceneObjectGroup x = new SceneObjectGroup(y);
96 x.SetScene(scene); 96 x.SetScene(scene);
97 x.SetRootPart(y);
98 x.RegionHandle = scene.RegionInfo.RegionHandle; 97 x.RegionHandle = scene.RegionInfo.RegionHandle;
99 x.SetScene(scene); 98 x.SetScene(scene);
100 99