aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Serialization
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization')
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs137
1 files changed, 122 insertions, 15 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 4caa9cb..7d3a168 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
278 // Script state may, or may not, exist. Not having any, is NOT 278 // Script state may, or may not, exist. Not having any, is NOT
279 // ever a problem. 279 // ever a problem.
280 sceneObject.LoadScriptState(doc); 280 sceneObject.LoadScriptState(doc);
281 281
282 return sceneObject; 282 return sceneObject;
283 } 283 }
284 catch (Exception e) 284 catch (Exception e)
@@ -307,14 +307,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
307 } 307 }
308 } 308 }
309 309
310
311 /// <summary> 310 /// <summary>
312 /// Modifies a SceneObjectGroup. 311 /// Modifies a SceneObjectGroup.
313 /// </summary> 312 /// </summary>
314 /// <param name="sog">The object</param> 313 /// <param name="sog">The object</param>
315 /// <returns>Whether the object was actually modified</returns> 314 /// <returns>Whether the object was actually modified</returns>
316 public delegate bool SceneObjectModifier(SceneObjectGroup sog); 315 public delegate bool SceneObjectModifier(SceneObjectGroup sog);
317 316
318 /// <summary> 317 /// <summary>
319 /// Modifies an object by deserializing it; applying 'modifier' to each SceneObjectGroup; and reserializing. 318 /// Modifies an object by deserializing it; applying 'modifier' to each SceneObjectGroup; and reserializing.
320 /// </summary> 319 /// </summary>
@@ -328,7 +327,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
328 CoalescedSceneObjects coa = null; 327 CoalescedSceneObjects coa = null;
329 328
330 string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(data)); 329 string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(data));
331
332 if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa)) 330 if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa))
333 { 331 {
334 // m_log.DebugFormat("[SERIALIZER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count); 332 // m_log.DebugFormat("[SERIALIZER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count);
@@ -374,7 +372,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
374 return data; 372 return data;
375 } 373 }
376 374
377
378 #region manual serialization 375 #region manual serialization
379 376
380 private static Dictionary<string, Action<SceneObjectPart, XmlReader>> m_SOPXmlProcessors 377 private static Dictionary<string, Action<SceneObjectPart, XmlReader>> m_SOPXmlProcessors
@@ -450,11 +447,28 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
450 m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); 447 m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3);
451 m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); 448 m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4);
452 449
450 m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
451 m_SOPXmlProcessors.Add("Force", ProcessForce);
452 m_SOPXmlProcessors.Add("Torque", ProcessTorque);
453 m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
454
455
456 m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle);
457
458 m_SOPXmlProcessors.Add("RotationAxisLocks", ProcessRotationAxisLocks);
453 m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); 459 m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType);
454 m_SOPXmlProcessors.Add("Density", ProcessDensity); 460 m_SOPXmlProcessors.Add("Density", ProcessDensity);
455 m_SOPXmlProcessors.Add("Friction", ProcessFriction); 461 m_SOPXmlProcessors.Add("Friction", ProcessFriction);
456 m_SOPXmlProcessors.Add("Bounce", ProcessBounce); 462 m_SOPXmlProcessors.Add("Bounce", ProcessBounce);
457 m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); 463 m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier);
464 m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset);
465 m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset);
466
467 m_SOPXmlProcessors.Add("SoundID", ProcessSoundID);
468 m_SOPXmlProcessors.Add("SoundGain", ProcessSoundGain);
469 m_SOPXmlProcessors.Add("SoundFlags", ProcessSoundFlags);
470 m_SOPXmlProcessors.Add("SoundRadius", ProcessSoundRadius);
471 m_SOPXmlProcessors.Add("SoundQueueing", ProcessSoundQueueing);
458 472
459 #endregion 473 #endregion
460 474
@@ -483,7 +497,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
483 m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); 497 m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask);
484 m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); 498 m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType);
485 m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); 499 m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged);
486 500
487 #endregion 501 #endregion
488 502
489 #region ShapeXmlProcessors initialization 503 #region ShapeXmlProcessors initialization
@@ -684,6 +698,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
684 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); 698 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
685 } 699 }
686 700
701 private static void ProcessRotationAxisLocks(SceneObjectPart obj, XmlReader reader)
702 {
703 obj.RotationAxisLocks = (byte)reader.ReadElementContentAsInt("RotationAxisLocks", String.Empty);
704 }
705
687 private static void ProcessPhysicsShapeType(SceneObjectPart obj, XmlReader reader) 706 private static void ProcessPhysicsShapeType(SceneObjectPart obj, XmlReader reader)
688 { 707 {
689 obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt("PhysicsShapeType", String.Empty); 708 obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt("PhysicsShapeType", String.Empty);
@@ -709,6 +728,58 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
709 obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); 728 obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty);
710 } 729 }
711 730
731 private static void ProcessCameraEyeOffset(SceneObjectPart obj, XmlReader reader)
732 {
733 obj.SetCameraEyeOffset(Util.ReadVector(reader, "CameraEyeOffset"));
734 }
735
736 private static void ProcessCameraAtOffset(SceneObjectPart obj, XmlReader reader)
737 {
738 obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset"));
739 }
740
741 private static void ProcessSoundID(SceneObjectPart obj, XmlReader reader)
742 {
743 obj.Sound = Util.ReadUUID(reader, "SoundID");
744 }
745
746 private static void ProcessSoundGain(SceneObjectPart obj, XmlReader reader)
747 {
748 obj.SoundGain = reader.ReadElementContentAsDouble("SoundGain", String.Empty);
749 }
750
751 private static void ProcessSoundFlags(SceneObjectPart obj, XmlReader reader)
752 {
753 obj.SoundFlags = (byte)reader.ReadElementContentAsInt("SoundFlags", String.Empty);
754 }
755
756 private static void ProcessSoundRadius(SceneObjectPart obj, XmlReader reader)
757 {
758 obj.SoundRadius = reader.ReadElementContentAsDouble("SoundRadius", String.Empty);
759 }
760
761 private static void ProcessSoundQueueing(SceneObjectPart obj, XmlReader reader)
762 {
763 obj.SoundQueueing = Util.ReadBoolean(reader);
764 }
765
766 private static void ProcessVehicle(SceneObjectPart obj, XmlReader reader)
767 {
768 SOPVehicle vehicle = SOPVehicle.FromXml2(reader);
769
770 if (vehicle == null)
771 {
772 obj.VehicleParams = null;
773 m_log.DebugFormat(
774 "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.",
775 obj.Name, obj.UUID);
776 }
777 else
778 {
779 obj.VehicleParams = vehicle;
780 }
781 }
782
712 private static void ProcessShape(SceneObjectPart obj, XmlReader reader) 783 private static void ProcessShape(SceneObjectPart obj, XmlReader reader)
713 { 784 {
714 List<string> errorNodeNames; 785 List<string> errorNodeNames;
@@ -883,6 +954,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
883 obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); 954 obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty);
884 } 955 }
885 956
957 private static void ProcessBuoyancy(SceneObjectPart obj, XmlReader reader)
958 {
959 obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty);
960 }
961
962 private static void ProcessForce(SceneObjectPart obj, XmlReader reader)
963 {
964 obj.Force = Util.ReadVector(reader, "Force");
965 }
966 private static void ProcessTorque(SceneObjectPart obj, XmlReader reader)
967 {
968 obj.Torque = Util.ReadVector(reader, "Torque");
969 }
970
971 private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlReader reader)
972 {
973 obj.VolumeDetectActive = Util.ReadBoolean(reader);
974 }
975
886 #endregion 976 #endregion
887 977
888 #region TaskInventoryXmlProcessors 978 #region TaskInventoryXmlProcessors
@@ -1271,12 +1361,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1271 1361
1272 if (sog.RootPart.KeyframeMotion != null) 1362 if (sog.RootPart.KeyframeMotion != null)
1273 { 1363 {
1274 Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); 1364 Byte[] data = sog.RootPart.KeyframeMotion.Serialize();
1275 1365
1276 writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); 1366 writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty);
1277 writer.WriteBase64(data, 0, data.Length); 1367 writer.WriteBase64(data, 0, data.Length);
1278 writer.WriteEndElement(); 1368 writer.WriteEndElement();
1279 } 1369 }
1370
1280 1371
1281 writer.WriteEndElement(); 1372 writer.WriteEndElement();
1282 } 1373 }
@@ -1388,8 +1479,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1388 writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); 1479 writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString());
1389 writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); 1480 writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString());
1390 1481
1391 if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) 1482 writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString());
1392 writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); 1483
1484 WriteVector(writer, "Force", sop.Force);
1485 WriteVector(writer, "Torque", sop.Torque);
1486
1487 writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
1488
1489 if (sop.VehicleParams != null)
1490 sop.VehicleParams.ToXml2(writer);
1491
1492 if(sop.RotationAxisLocks != 0)
1493 writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower());
1494 writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());
1393 if (sop.Density != 1000.0f) 1495 if (sop.Density != 1000.0f)
1394 writer.WriteElementString("Density", sop.Density.ToString().ToLower()); 1496 writer.WriteElementString("Density", sop.Density.ToString().ToLower());
1395 if (sop.Friction != 0.6f) 1497 if (sop.Friction != 0.6f)
@@ -1398,7 +1500,18 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1398 writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); 1500 writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower());
1399 if (sop.GravityModifier != 1.0f) 1501 if (sop.GravityModifier != 1.0f)
1400 writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); 1502 writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower());
1503 WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset());
1504 WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset());
1401 1505
1506 // if (sop.Sound != UUID.Zero) force it till sop crossing does clear it on child prim
1507 {
1508 WriteUUID(writer, "SoundID", sop.Sound, options);
1509 writer.WriteElementString("SoundGain", sop.SoundGain.ToString().ToLower());
1510 writer.WriteElementString("SoundFlags", sop.SoundFlags.ToString().ToLower());
1511 writer.WriteElementString("SoundRadius", sop.SoundRadius.ToString().ToLower());
1512 }
1513 writer.WriteElementString("SoundQueueing", sop.SoundQueueing.ToString().ToLower());
1514
1402 writer.WriteEndElement(); 1515 writer.WriteEndElement();
1403 } 1516 }
1404 1517
@@ -1625,12 +1738,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1625 { 1738 {
1626 TaskInventoryDictionary tinv = new TaskInventoryDictionary(); 1739 TaskInventoryDictionary tinv = new TaskInventoryDictionary();
1627 1740
1628 if (reader.IsEmptyElement)
1629 {
1630 reader.Read();
1631 return tinv;
1632 }
1633
1634 reader.ReadStartElement(name, String.Empty); 1741 reader.ReadStartElement(name, String.Empty);
1635 1742
1636 while (reader.Name == "TaskInventoryItem") 1743 while (reader.Name == "TaskInventoryItem")