From 3de3b9e63c07bc4b8e6c76d60167f9ead8a07f49 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 17:56:32 +0000 Subject: initial suport for ExtraPhysical parts parameters. Reading from llclientView to SOP including SOPserialization (not to databases). No action on physics still. No send to viewer, etc --- OpenSim/Framework/ExtraPhysicsData.cs | 50 +++++++++ OpenSim/Framework/IClientAPI.cs | 2 +- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 29 +++++- OpenSim/Region/Framework/Scenes/SOPMaterial.cs | 95 +++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 11 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 114 ++++++++++++++++++--- 7 files changed, 281 insertions(+), 22 deletions(-) create mode 100644 OpenSim/Framework/ExtraPhysicsData.cs create mode 100644 OpenSim/Region/Framework/Scenes/SOPMaterial.cs diff --git a/OpenSim/Framework/ExtraPhysicsData.cs b/OpenSim/Framework/ExtraPhysicsData.cs new file mode 100644 index 0000000..9e7334f --- /dev/null +++ b/OpenSim/Framework/ExtraPhysicsData.cs @@ -0,0 +1,50 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; + +namespace OpenSim.Framework +{ + public enum PhysShapeType : byte + { + prim = 0, + none = 1, + convex = 2, + + invalid = 255 // use to mark invalid data in ExtraPhysicsData + } + + public struct ExtraPhysicsData + { + public float Density; + public float GravitationModifier; + public float Friction; + public float Bounce; + public PhysShapeType PhysShapeType; + + } +} diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 1bd4749..c70b2a0 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -124,7 +124,7 @@ namespace OpenSim.Framework public delegate void ObjectDrop(uint localID, IClientAPI remoteClient); public delegate void UpdatePrimFlags( - uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, IClientAPI remoteClient); + uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom,ExtraPhysicsData PhysData, IClientAPI remoteClient); public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 18af623..23beaec 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -7006,10 +7006,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP // 46,47,48 are special positions within the packet // This may change so perhaps we need a better way // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?) - bool UsePhysics = (data[46] != 0) ? true : false; - bool IsTemporary = (data[47] != 0) ? true : false; - bool IsPhantom = (data[48] != 0) ? true : false; - handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this); + /* + bool UsePhysics = (data[46] != 0) ? true : false; + bool IsTemporary = (data[47] != 0) ? true : false; + bool IsPhantom = (data[48] != 0) ? true : false; + handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this); + */ + bool UsePhysics = flags.AgentData.UsePhysics; + bool IsPhantom = flags.AgentData.IsPhantom; + bool IsTemporary = flags.AgentData.IsTemporary; + ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics; + ExtraPhysicsData physdata = new ExtraPhysicsData(); + + if (blocks == null || blocks.Length == 0) + { + physdata.PhysShapeType = PhysShapeType.invalid; + } + else + { + ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0]; + physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType; + physdata.Bounce = phsblock.Restitution; + physdata.Density = phsblock.Density; + physdata.Friction = phsblock.Friction; + } + handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this); } return true; } diff --git a/OpenSim/Region/Framework/Scenes/SOPMaterial.cs b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs new file mode 100644 index 0000000..10ac37c --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs @@ -0,0 +1,95 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Region.Framework.Scenes +{ + public static class SOPMaterialData + { + public enum SopMaterial : int // redundante and not in use for now + { + Stone = 0, + Metal = 1, + Glass = 2, + Wood = 3, + Flesh = 4, + Plastic = 5, + Rubber = 6, + light = 7 // compatibility with old viewers + } + + private struct MaterialData + { + public float friction; + public float bounce; + public MaterialData(float f, float b) + { + friction = f; + bounce = b; + } + } + + private static MaterialData[] m_materialdata = { + new MaterialData(0.8f,0.4f), // Stone + new MaterialData(0.3f,0.4f), // Metal + new MaterialData(0.2f,0.7f), // Glass + new MaterialData(0.6f,0.5f), // Wood + new MaterialData(0.9f,0.3f), // Flesh + new MaterialData(0.4f,0.7f), // Plastic + new MaterialData(0.9f,0.95f), // Rubber + new MaterialData(0.0f,0.0f) // light ?? + }; + + public static Material MaxMaterial + { + get { return (Material)(m_materialdata.Length - 1); } + } + + public static float friction(Material material) + { + int indx = (int)material; + if (indx < m_materialdata.Length) + return (m_materialdata[indx].friction); + else + return 0; + } + + public static float bounce(Material material) + { + int indx = (int)material; + if (indx < m_materialdata.Length) + return (m_materialdata[indx].bounce); + else + return 0; + } + + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a3358a5..24e6eb1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4882,7 +4882,7 @@ Environment.Exit(1); private void CheckHeartbeat() { - if (m_firstHeartbeat) +// if (m_firstHeartbeat) return; if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e6e3ad0..7b77ea0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1536,7 +1536,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// protected internal void UpdatePrimFlags( - uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, IClientAPI remoteClient) + uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) @@ -1544,7 +1544,14 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) { // VolumeDetect can't be set via UI and will always be off when a change is made there - group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false); + if (PhysData.PhysShapeType == PhysShapeType.invalid) + group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false); + else + { + SceneObjectPart part = GetSceneObjectPart(localID); + if (part != null) + part.UpdateExtraPhysics(PhysData); + } } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f647544..ace53f6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -295,7 +295,13 @@ namespace OpenSim.Region.Framework.Scenes protected float m_buoyancy = 0.0f; protected Vector3 m_force; protected Vector3 m_torque; - + + protected byte m_physicsShapeType = (byte)PhysShapeType.prim; + protected float m_density = 1000.0f; // in kg/m^3 + protected float m_gravitymod = 1.0f; + protected float m_friction = 0.6f; // wood + protected float m_bounce = 0.5f; // wood + /// /// Stores media texture data /// @@ -556,19 +562,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public byte Material - { - get { return (byte) m_material; } - set - { - m_material = (Material)value; - if (PhysActor != null) - { - PhysActor.SetMaterial((int)value); - } - } - } - public bool PassTouches { get { return m_passTouches; } @@ -1377,6 +1370,87 @@ namespace OpenSim.Region.Framework.Scenes } } + public byte Material + { + get { return (byte)m_material; } + set + { + if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) + { + m_material = (Material)value; + m_friction = SOPMaterialData.friction(m_material); + m_bounce = SOPMaterialData.bounce(m_material); + if (PhysActor != null) + { + PhysActor.SetMaterial((int)value); + } + } + } + } + + public byte PhysicsShapeType + { + get { return m_physicsShapeType; } + set + { + if (value < 0 || value >= (byte)PhysShapeType.convex) + value = (byte)PhysShapeType.prim; //convex not supported ? + + else if (value == (byte)PhysShapeType.none) + { + if (ParentGroup == null || ParentGroup.RootPart == this) + value = (byte)PhysShapeType.prim; + } + m_physicsShapeType = value; + } + } + + public float Density // in kg/m^3 + { + get { return m_density; } + set + { + if (value >=1 && value <= 22587.0) + { + m_density = value; + } + } + } + + public float GravityModifier + { + get { return m_gravitymod; } + set + { if( value >= -1 && value <=28.0f) + m_gravitymod = value; + } + } + + public float Friction + { + get { return m_friction; } + set + { + if (value >= 0 && value <= 255.0f) + { + m_friction = value; + } + } + } + + public float Bounciness + { + get { return m_bounce; } + set + { + if (value >= 0 && value <= 1.0f) + { + m_bounce = value; + } + } + } + + #endregion Public Properties with only Get private uint ApplyMask(uint val, bool set, uint mask) @@ -4334,6 +4408,18 @@ namespace OpenSim.Region.Framework.Scenes } } + + public void UpdateExtraPhysics(ExtraPhysicsData physdata) + { + if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) + return; + + PhysicsShapeType = (byte)physdata.PhysShapeType; + Density = physdata.Density; + GravityModifier = physdata.GravitationModifier; + Friction = physdata.Friction; + Bounciness = physdata.Bounce; + } /// /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. /// -- cgit v1.1 From 923db53975cd91dca86aee8c7a6c07c25b26db87 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 18:10:43 +0000 Subject: let checkheartbeat work ( bad ideia :p ) commited by mistake my local copy with it disabled... --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 24e6eb1..a3358a5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4882,7 +4882,7 @@ Environment.Exit(1); private void CheckHeartbeat() { -// if (m_firstHeartbeat) + if (m_firstHeartbeat) return; if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) -- cgit v1.1 From bf2a5508debe058cbf48fc1da52d2a6d96954f80 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 19:17:32 +0000 Subject: bug fix --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 314705e..6feb333 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2556,7 +2556,7 @@ namespace OpenSim.Region.Framework.Scenes linkPart.CreateSelected = true; // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now - linkPart.UpdatePrimFlags(grpusephys, grptemporary, IsPhantom || ((linkPart.Flags & PrimFlags.Phantom) != null), linkPart.VolumeDetectActive, true); + linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { linkPart.PhysActor.link(m_rootPart.PhysActor); @@ -2578,7 +2578,7 @@ namespace OpenSim.Region.Framework.Scenes { LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); // let physics know - part.UpdatePrimFlags(grpusephys, grptemporary, IsPhantom || ((part.Flags & PrimFlags.Phantom) != null), part.VolumeDetectActive, true); + part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) { part.PhysActor.link(m_rootPart.PhysActor); -- cgit v1.1 From 741badc4fa1da61d86fdbb2d33056fa8c6599e69 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 19:24:41 +0000 Subject: let PhysicsShapeType none remove physics remove physics on child parts **UnTested** --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 48 +++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ace53f6..a68b3eb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1657,9 +1657,13 @@ namespace OpenSim.Region.Framework.Scenes if (!ParentGroup.Scene.CollidablePrims) return; + if (PhysicsShapeType == (byte)PhysShapeType.none) + return; + bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; + if (IsJoint()) { DoPhysicsPropertyUpdate(isPhysical, true); @@ -2016,6 +2020,7 @@ namespace OpenSim.Region.Framework.Scenes if (PhysActor.Phantom != phan) PhysActor.Phantom = phan; + // If this part is a sculpt then delay the physics update until we've asynchronously loaded the // mesh data. if (Shape.SculptEntry) @@ -4414,11 +4419,34 @@ namespace OpenSim.Region.Framework.Scenes if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) return; - PhysicsShapeType = (byte)physdata.PhysShapeType; - Density = physdata.Density; - GravityModifier = physdata.GravitationModifier; - Friction = physdata.Friction; - Bounciness = physdata.Bounce; + if (PhysicsShapeType != (byte)physdata.PhysShapeType) + { + PhysicsShapeType = (byte)physdata.PhysShapeType; + + if (PhysicsShapeType == (byte)PhysShapeType.none) + { + if (PhysActor != null) + { + Velocity = new Vector3(0, 0, 0); + Acceleration = new Vector3(0, 0, 0); + if (ParentGroup.RootPart == this) + AngularVelocity = new Vector3(0, 0, 0); + ParentGroup.Scene.RemovePhysicalPrim(1); + RemoveFromPhysics(); + } + } + else if (PhysActor == null) + ApplyPhysics((uint)Flags, VolumeDetectActive, false); + } + + if(Density != physdata.Density) + Density = physdata.Density; + if(GravityModifier != physdata.GravitationModifier) + GravityModifier = physdata.GravitationModifier; + if(Friction != physdata.Friction) + Friction = physdata.Friction; + if(Bounciness != physdata.Bounce) + Bounciness = physdata.Bounce; } /// /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. @@ -4448,9 +4476,10 @@ namespace OpenSim.Region.Framework.Scenes // ... if VD is changed, all others are not. // ... if one of the others is changed, VD is not. +/* if (SetVD) // VD is active, special logic applies - /* volume detection is now independent of phantom in sl + volume detection is now independent of phantom in sl { // State machine logic for VolumeDetect @@ -4471,9 +4500,8 @@ namespace OpenSim.Region.Framework.Scenes // If volumedetect is active we don't want phantom to be applied. // If this is a new call to VD out of the state "phantom" // this will also cause the prim to be visible to physics - */ SetPhantom = false; -/* } + } } else if (wasVD) { @@ -4520,10 +4548,10 @@ namespace OpenSim.Region.Framework.Scenes else RemFlag(PrimFlags.Phantom); - if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment + if ((SetPhantom && !UsePhysics) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints { - AddFlag(PrimFlags.Phantom); +// AddFlag(PrimFlags.Phantom); Velocity = new Vector3(0, 0, 0); Acceleration = new Vector3(0, 0, 0); -- cgit v1.1 From 577d07aa44b5ba7ed4fc3a56a81eeec6c141543a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 13 Mar 2012 19:51:41 +0000 Subject: missed commit of extraphysics parameters serialization.. --- .../Scenes/Serialization/SceneObjectSerializer.cs | 52 +++++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 51a3320..dfa24e5 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -359,9 +359,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("Torque", ProcessTorque); m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); - //Ubit comented until proper testing - m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); + m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); + + m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); + m_SOPXmlProcessors.Add("Density", ProcessDensity); + m_SOPXmlProcessors.Add("Friction", ProcessFriction); + m_SOPXmlProcessors.Add("Bounce", ProcessBounce); + m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); #endregion @@ -390,7 +395,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); - + #endregion #region ShapeXmlProcessors initialization @@ -585,6 +590,31 @@ namespace OpenSim.Region.Framework.Scenes.Serialization obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); } + private static void ProcessPhysicsShapeType(SceneObjectPart obj, XmlTextReader reader) + { + obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt("PhysicsShapeType", String.Empty); + } + + private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader) + { + obj.Density = (byte)reader.ReadElementContentAsInt("Density", String.Empty); + } + + private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader) + { + obj.Friction = (byte)reader.ReadElementContentAsInt("Friction", String.Empty); + } + + private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader) + { + obj.Bounciness = (byte)reader.ReadElementContentAsInt("Bounce", String.Empty); + } + + private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader) + { + obj.GravityModifier = (byte)reader.ReadElementContentAsInt("GravityModifier", String.Empty); + } + private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) { bool errors = false; @@ -1288,9 +1318,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); - //Ubit comented until proper testing - if (sop.sopVehicle != null) - sop.sopVehicle.ToXml2(writer); + if (sop.sopVehicle != null) + sop.sopVehicle.ToXml2(writer); + + if(sop.PhysicsShapeType != (byte)PhysShapeType.prim) + writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); + if (sop.Density != 1000.0f) + writer.WriteElementString("Density", sop.Density.ToString().ToLower()); + if (sop.Friction != 0.6f) + writer.WriteElementString("Friction", sop.Friction.ToString().ToLower()); + if (sop.Bounciness != 0.5f) + writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower()); + if (sop.GravityModifier != 1.0f) + writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); writer.WriteEndElement(); } -- cgit v1.1