Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork

avinationmerge
ubit 2012-07-07 04:54:58 +02:00
commit 5b6d31f268
4 changed files with 73 additions and 27 deletions

View File

@ -175,7 +175,8 @@ namespace OpenSim.Data.MySQL
"PassCollisions, " + "PassCollisions, " +
"LinkNumber, MediaURL, KeyframeMotion, " + "LinkNumber, MediaURL, KeyframeMotion, " +
"PhysicsShapeType, Density, GravityModifier, " + "PhysicsShapeType, Density, GravityModifier, " +
"Friction, Restitution) values (" + "?UUID, " + "Friction, Restitution, Vehicle " +
") values (" + "?UUID, " +
"?CreationDate, ?Name, ?Text, " + "?CreationDate, ?Name, ?Text, " +
"?Description, ?SitName, ?TouchName, " + "?Description, ?SitName, ?TouchName, " +
"?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " +
@ -209,7 +210,7 @@ namespace OpenSim.Data.MySQL
"?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " + "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " +
"?LinkNumber, ?MediaURL, ?KeyframeMotion, " + "?LinkNumber, ?MediaURL, ?KeyframeMotion, " +
"?PhysicsShapeType, ?Density, ?GravityModifier, " + "?PhysicsShapeType, ?Density, ?GravityModifier, " +
"?Friction, ?Restitution)"; "?Friction, ?Restitution, ?Vehicle)";
FillPrimCommand(cmd, prim, obj.UUID, regionUUID); FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
@ -1258,6 +1259,15 @@ namespace OpenSim.Data.MySQL
prim.GravityModifier = (float)(double)row["GravityModifier"]; prim.GravityModifier = (float)(double)row["GravityModifier"];
prim.Friction = (float)(double)row["Friction"]; prim.Friction = (float)(double)row["Friction"];
prim.Bounciness = (float)(double)row["Restitution"]; prim.Bounciness = (float)(double)row["Restitution"];
SOPVehicle vehicle = null;
if (row["Vehicle"].ToString() != String.Empty)
{
vehicle = SOPVehicle.FromXml2(row["Vehicle"].ToString());
if (vehicle != null)
prim.VehicleParams = vehicle;
}
return prim; return prim;
} }
@ -1635,6 +1645,11 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier);
cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); cmd.Parameters.AddWithValue("Friction", (double)prim.Friction);
cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness); cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness);
if (prim.VehicleParams != null)
cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2());
else
cmd.Parameters.AddWithValue("Vehicle", String.Empty);
} }
/// <summary> /// <summary>

View File

@ -30,6 +30,8 @@ using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using System.Text;
using System.IO;
using System.Xml; using System.Xml;
using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization;
using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Serialization.External;
@ -561,6 +563,35 @@ namespace OpenSim.Region.Framework.Scenes
} }
public string ToXml2()
{
MemoryStream ms = new MemoryStream();
UTF8Encoding enc = new UTF8Encoding();
XmlTextWriter writer = new XmlTextWriter(ms, null);
ToXml2(writer);
return enc.GetString(ms.ToArray());
}
public static SOPVehicle FromXml2(string text)
{
if (text == String.Empty)
return null;
UTF8Encoding enc = new UTF8Encoding();
MemoryStream ms = new MemoryStream(enc.GetBytes(text));
XmlTextReader reader = new XmlTextReader(ms);
SOPVehicle v = new SOPVehicle();
bool error;
v.FromXml2(reader, out error);
if (error)
{
v = null;
return null;
}
return v;
}
public void FromXml2(XmlTextReader _reader, out bool errors) public void FromXml2(XmlTextReader _reader, out bool errors)
{ {
@ -739,4 +770,4 @@ namespace OpenSim.Region.Framework.Scenes
vd.m_referenceFrame = XRquat(); vd.m_referenceFrame = XRquat();
} }
} }
} }

View File

@ -338,7 +338,7 @@ namespace OpenSim.Region.Framework.Scenes
private int LastColSoundSentTime; private int LastColSoundSentTime;
private SOPVehicle m_vehicle = null; private SOPVehicle m_vehicleParams = null;
private KeyframeMotion m_keyframeMotion = null; private KeyframeMotion m_keyframeMotion = null;
@ -3379,15 +3379,15 @@ namespace OpenSim.Region.Framework.Scenes
Force = force; Force = force;
} }
public SOPVehicle sopVehicle public SOPVehicle VehicleParams
{ {
get get
{ {
return m_vehicle; return m_vehicleParams;
} }
set set
{ {
m_vehicle = value; m_vehicleParams = value;
} }
} }
@ -3396,10 +3396,10 @@ namespace OpenSim.Region.Framework.Scenes
{ {
get get
{ {
if (m_vehicle == null) if (m_vehicleParams == null)
return (int)Vehicle.TYPE_NONE; return (int)Vehicle.TYPE_NONE;
else else
return (int)m_vehicle.Type; return (int)m_vehicleParams.Type;
} }
set set
{ {
@ -3409,7 +3409,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SetVehicleType(int type) public void SetVehicleType(int type)
{ {
m_vehicle = null; m_vehicleParams = null;
if (type == (int)Vehicle.TYPE_NONE) if (type == (int)Vehicle.TYPE_NONE)
{ {
@ -3417,8 +3417,8 @@ namespace OpenSim.Region.Framework.Scenes
PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; PhysActor.VehicleType = (int)Vehicle.TYPE_NONE;
return; return;
} }
m_vehicle = new SOPVehicle(); m_vehicleParams = new SOPVehicle();
m_vehicle.ProcessTypeChange((Vehicle)type); m_vehicleParams.ProcessTypeChange((Vehicle)type);
{ {
if (_parentID ==0 && PhysActor != null) if (_parentID ==0 && PhysActor != null)
PhysActor.VehicleType = type; PhysActor.VehicleType = type;
@ -3428,10 +3428,10 @@ namespace OpenSim.Region.Framework.Scenes
public void SetVehicleFlags(int param, bool remove) public void SetVehicleFlags(int param, bool remove)
{ {
if (m_vehicle == null) if (m_vehicleParams == null)
return; return;
m_vehicle.ProcessVehicleFlags(param, remove); m_vehicleParams.ProcessVehicleFlags(param, remove);
if (_parentID ==0 && PhysActor != null) if (_parentID ==0 && PhysActor != null)
{ {
@ -3441,10 +3441,10 @@ namespace OpenSim.Region.Framework.Scenes
public void SetVehicleFloatParam(int param, float value) public void SetVehicleFloatParam(int param, float value)
{ {
if (m_vehicle == null) if (m_vehicleParams == null)
return; return;
m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value);
if (_parentID == 0 && PhysActor != null) if (_parentID == 0 && PhysActor != null)
{ {
@ -3454,10 +3454,10 @@ namespace OpenSim.Region.Framework.Scenes
public void SetVehicleVectorParam(int param, Vector3 value) public void SetVehicleVectorParam(int param, Vector3 value)
{ {
if (m_vehicle == null) if (m_vehicleParams == null)
return; return;
m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value);
if (_parentID == 0 && PhysActor != null) if (_parentID == 0 && PhysActor != null)
{ {
@ -3467,10 +3467,10 @@ namespace OpenSim.Region.Framework.Scenes
public void SetVehicleRotationParam(int param, Quaternion rotation) public void SetVehicleRotationParam(int param, Quaternion rotation)
{ {
if (m_vehicle == null) if (m_vehicleParams == null)
return; return;
m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation);
if (_parentID == 0 && PhysActor != null) if (_parentID == 0 && PhysActor != null)
{ {
@ -4637,8 +4637,8 @@ namespace OpenSim.Region.Framework.Scenes
if (VolumeDetectActive) // change if not the default only if (VolumeDetectActive) // change if not the default only
pa.SetVolumeDetect(1); pa.SetVolumeDetect(1);
if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId)
m_vehicle.SetVehicle(pa); m_vehicleParams.SetVehicle(pa);
// we are going to tell rest of code about physics so better have this here // we are going to tell rest of code about physics so better have this here
PhysActor = pa; PhysActor = pa;
@ -4676,7 +4676,7 @@ namespace OpenSim.Region.Framework.Scenes
pa.RotationalVelocity = rotationalVelocity; pa.RotationalVelocity = rotationalVelocity;
// if not vehicle and root part apply force and torque // if not vehicle and root part apply force and torque
if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE)
&& LocalId == ParentGroup.RootPart.LocalId) && LocalId == ParentGroup.RootPart.LocalId)
{ {
pa.Force = Force; pa.Force = Force;

View File

@ -630,13 +630,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (errors) if (errors)
{ {
obj.sopVehicle = null; obj.VehicleParams = null;
m_log.DebugFormat( m_log.DebugFormat(
"[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.",
obj.Name, obj.UUID); obj.Name, obj.UUID);
} }
else else
obj.sopVehicle = _vehicle; obj.VehicleParams = _vehicle;
} }
private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
@ -1325,8 +1325,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
if (sop.sopVehicle != null) if (sop.VehicleParams != null)
sop.sopVehicle.ToXml2(writer); sop.VehicleParams.ToXml2(writer);
if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType())
writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());