diff options
author | Melanie | 2012-07-07 02:05:01 +0200 |
---|---|---|
committer | Melanie | 2012-07-07 02:05:01 +0200 |
commit | 6535f23e4b8fec9578dae5275db69b237a99e498 (patch) | |
tree | fcf5495a3ebc005812c377076def18d1bafa5bab /OpenSim | |
parent | added llSetVelocity. will refuse to work on vehicles and on attachments ( th... (diff) | |
download | opensim-SC-6535f23e4b8fec9578dae5275db69b237a99e498.zip opensim-SC-6535f23e4b8fec9578dae5275db69b237a99e498.tar.gz opensim-SC-6535f23e4b8fec9578dae5275db69b237a99e498.tar.bz2 opensim-SC-6535f23e4b8fec9578dae5275db69b237a99e498.tar.xz |
Add saving vehicle physics data to the database
Diffstat (limited to 'OpenSim')
4 files changed, 73 insertions, 27 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 5e4df3a..fecc329 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -175,7 +175,8 @@ namespace OpenSim.Data.MySQL | |||
175 | "PassCollisions, " + | 175 | "PassCollisions, " + |
176 | "LinkNumber, MediaURL, KeyframeMotion, " + | 176 | "LinkNumber, MediaURL, KeyframeMotion, " + |
177 | "PhysicsShapeType, Density, GravityModifier, " + | 177 | "PhysicsShapeType, Density, GravityModifier, " + |
178 | "Friction, Restitution) values (" + "?UUID, " + | 178 | "Friction, Restitution, Vehicle " + |
179 | ") values (" + "?UUID, " + | ||
179 | "?CreationDate, ?Name, ?Text, " + | 180 | "?CreationDate, ?Name, ?Text, " + |
180 | "?Description, ?SitName, ?TouchName, " + | 181 | "?Description, ?SitName, ?TouchName, " + |
181 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + | 182 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + |
@@ -209,7 +210,7 @@ namespace OpenSim.Data.MySQL | |||
209 | "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " + | 210 | "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " + |
210 | "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + | 211 | "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + |
211 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + | 212 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + |
212 | "?Friction, ?Restitution)"; | 213 | "?Friction, ?Restitution, ?Vehicle)"; |
213 | 214 | ||
214 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | 215 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); |
215 | 216 | ||
@@ -1258,6 +1259,15 @@ namespace OpenSim.Data.MySQL | |||
1258 | prim.GravityModifier = (float)(double)row["GravityModifier"]; | 1259 | prim.GravityModifier = (float)(double)row["GravityModifier"]; |
1259 | prim.Friction = (float)(double)row["Friction"]; | 1260 | prim.Friction = (float)(double)row["Friction"]; |
1260 | prim.Bounciness = (float)(double)row["Restitution"]; | 1261 | prim.Bounciness = (float)(double)row["Restitution"]; |
1262 | |||
1263 | SOPVehicle vehicle = null; | ||
1264 | |||
1265 | if (row["Vehicle"].ToString() != String.Empty) | ||
1266 | { | ||
1267 | vehicle = SOPVehicle.FromXml2(row["Vehicle"].ToString()); | ||
1268 | if (vehicle != null) | ||
1269 | prim.VehicleParams = vehicle; | ||
1270 | } | ||
1261 | 1271 | ||
1262 | return prim; | 1272 | return prim; |
1263 | } | 1273 | } |
@@ -1635,6 +1645,11 @@ namespace OpenSim.Data.MySQL | |||
1635 | cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); | 1645 | cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); |
1636 | cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); | 1646 | cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); |
1637 | cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness); | 1647 | cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness); |
1648 | |||
1649 | if (prim.VehicleParams != null) | ||
1650 | { | ||
1651 | cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2()); | ||
1652 | } | ||
1638 | } | 1653 | } |
1639 | 1654 | ||
1640 | /// <summary> | 1655 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index d3c2d27..45ca00c 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs | |||
@@ -30,6 +30,8 @@ using System.Collections.Generic; | |||
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Physics.Manager; | 32 | using OpenSim.Region.Physics.Manager; |
33 | using System.Text; | ||
34 | using System.IO; | ||
33 | using System.Xml; | 35 | using System.Xml; |
34 | using OpenSim.Framework.Serialization; | 36 | using OpenSim.Framework.Serialization; |
35 | using OpenSim.Framework.Serialization.External; | 37 | using OpenSim.Framework.Serialization.External; |
@@ -561,6 +563,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
561 | } | 563 | } |
562 | 564 | ||
563 | 565 | ||
566 | public string ToXml2() | ||
567 | { | ||
568 | MemoryStream ms = new MemoryStream(); | ||
569 | UTF8Encoding enc = new UTF8Encoding(); | ||
570 | XmlTextWriter writer = new XmlTextWriter(ms, null); | ||
571 | ToXml2(writer); | ||
572 | return enc.GetString(ms.ToArray()); | ||
573 | } | ||
574 | |||
575 | public static SOPVehicle FromXml2(string text) | ||
576 | { | ||
577 | if (text == String.Empty) | ||
578 | return null; | ||
579 | UTF8Encoding enc = new UTF8Encoding(); | ||
580 | MemoryStream ms = new MemoryStream(enc.GetBytes(text)); | ||
581 | XmlTextReader reader = new XmlTextReader(ms); | ||
582 | |||
583 | SOPVehicle v = new SOPVehicle(); | ||
584 | bool error; | ||
585 | |||
586 | v.FromXml2(reader, out error); | ||
587 | if (error) | ||
588 | { | ||
589 | v = null; | ||
590 | return null; | ||
591 | } | ||
592 | |||
593 | return v; | ||
594 | } | ||
564 | 595 | ||
565 | public void FromXml2(XmlTextReader _reader, out bool errors) | 596 | public void FromXml2(XmlTextReader _reader, out bool errors) |
566 | { | 597 | { |
@@ -739,4 +770,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
739 | vd.m_referenceFrame = XRquat(); | 770 | vd.m_referenceFrame = XRquat(); |
740 | } | 771 | } |
741 | } | 772 | } |
742 | } \ No newline at end of file | 773 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ed32adc..dd30a59 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -338,7 +338,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
338 | private int LastColSoundSentTime; | 338 | private int LastColSoundSentTime; |
339 | 339 | ||
340 | 340 | ||
341 | private SOPVehicle m_vehicle = null; | 341 | private SOPVehicle m_vehicleParams = null; |
342 | 342 | ||
343 | private KeyframeMotion m_keyframeMotion = null; | 343 | private KeyframeMotion m_keyframeMotion = null; |
344 | 344 | ||
@@ -3379,15 +3379,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3379 | Force = force; | 3379 | Force = force; |
3380 | } | 3380 | } |
3381 | 3381 | ||
3382 | public SOPVehicle sopVehicle | 3382 | public SOPVehicle VehicleParams |
3383 | { | 3383 | { |
3384 | get | 3384 | get |
3385 | { | 3385 | { |
3386 | return m_vehicle; | 3386 | return m_vehicleParams; |
3387 | } | 3387 | } |
3388 | set | 3388 | set |
3389 | { | 3389 | { |
3390 | m_vehicle = value; | 3390 | m_vehicleParams = value; |
3391 | } | 3391 | } |
3392 | } | 3392 | } |
3393 | 3393 | ||
@@ -3396,10 +3396,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3396 | { | 3396 | { |
3397 | get | 3397 | get |
3398 | { | 3398 | { |
3399 | if (m_vehicle == null) | 3399 | if (m_vehicleParams == null) |
3400 | return (int)Vehicle.TYPE_NONE; | 3400 | return (int)Vehicle.TYPE_NONE; |
3401 | else | 3401 | else |
3402 | return (int)m_vehicle.Type; | 3402 | return (int)m_vehicleParams.Type; |
3403 | } | 3403 | } |
3404 | set | 3404 | set |
3405 | { | 3405 | { |
@@ -3409,7 +3409,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3409 | 3409 | ||
3410 | public void SetVehicleType(int type) | 3410 | public void SetVehicleType(int type) |
3411 | { | 3411 | { |
3412 | m_vehicle = null; | 3412 | m_vehicleParams = null; |
3413 | 3413 | ||
3414 | if (type == (int)Vehicle.TYPE_NONE) | 3414 | if (type == (int)Vehicle.TYPE_NONE) |
3415 | { | 3415 | { |
@@ -3417,8 +3417,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3417 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | 3417 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; |
3418 | return; | 3418 | return; |
3419 | } | 3419 | } |
3420 | m_vehicle = new SOPVehicle(); | 3420 | m_vehicleParams = new SOPVehicle(); |
3421 | m_vehicle.ProcessTypeChange((Vehicle)type); | 3421 | m_vehicleParams.ProcessTypeChange((Vehicle)type); |
3422 | { | 3422 | { |
3423 | if (_parentID ==0 && PhysActor != null) | 3423 | if (_parentID ==0 && PhysActor != null) |
3424 | PhysActor.VehicleType = type; | 3424 | PhysActor.VehicleType = type; |
@@ -3428,10 +3428,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3428 | 3428 | ||
3429 | public void SetVehicleFlags(int param, bool remove) | 3429 | public void SetVehicleFlags(int param, bool remove) |
3430 | { | 3430 | { |
3431 | if (m_vehicle == null) | 3431 | if (m_vehicleParams == null) |
3432 | return; | 3432 | return; |
3433 | 3433 | ||
3434 | m_vehicle.ProcessVehicleFlags(param, remove); | 3434 | m_vehicleParams.ProcessVehicleFlags(param, remove); |
3435 | 3435 | ||
3436 | if (_parentID ==0 && PhysActor != null) | 3436 | if (_parentID ==0 && PhysActor != null) |
3437 | { | 3437 | { |
@@ -3441,10 +3441,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3441 | 3441 | ||
3442 | public void SetVehicleFloatParam(int param, float value) | 3442 | public void SetVehicleFloatParam(int param, float value) |
3443 | { | 3443 | { |
3444 | if (m_vehicle == null) | 3444 | if (m_vehicleParams == null) |
3445 | return; | 3445 | return; |
3446 | 3446 | ||
3447 | m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); | 3447 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
3448 | 3448 | ||
3449 | if (_parentID == 0 && PhysActor != null) | 3449 | if (_parentID == 0 && PhysActor != null) |
3450 | { | 3450 | { |
@@ -3454,10 +3454,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3454 | 3454 | ||
3455 | public void SetVehicleVectorParam(int param, Vector3 value) | 3455 | public void SetVehicleVectorParam(int param, Vector3 value) |
3456 | { | 3456 | { |
3457 | if (m_vehicle == null) | 3457 | if (m_vehicleParams == null) |
3458 | return; | 3458 | return; |
3459 | 3459 | ||
3460 | m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); | 3460 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
3461 | 3461 | ||
3462 | if (_parentID == 0 && PhysActor != null) | 3462 | if (_parentID == 0 && PhysActor != null) |
3463 | { | 3463 | { |
@@ -3467,10 +3467,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3467 | 3467 | ||
3468 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3468 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
3469 | { | 3469 | { |
3470 | if (m_vehicle == null) | 3470 | if (m_vehicleParams == null) |
3471 | return; | 3471 | return; |
3472 | 3472 | ||
3473 | m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); | 3473 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
3474 | 3474 | ||
3475 | if (_parentID == 0 && PhysActor != null) | 3475 | if (_parentID == 0 && PhysActor != null) |
3476 | { | 3476 | { |
@@ -4637,8 +4637,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4637 | if (VolumeDetectActive) // change if not the default only | 4637 | if (VolumeDetectActive) // change if not the default only |
4638 | pa.SetVolumeDetect(1); | 4638 | pa.SetVolumeDetect(1); |
4639 | 4639 | ||
4640 | if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) | 4640 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) |
4641 | m_vehicle.SetVehicle(pa); | 4641 | m_vehicleParams.SetVehicle(pa); |
4642 | 4642 | ||
4643 | // we are going to tell rest of code about physics so better have this here | 4643 | // we are going to tell rest of code about physics so better have this here |
4644 | PhysActor = pa; | 4644 | PhysActor = pa; |
@@ -4676,7 +4676,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4676 | pa.RotationalVelocity = rotationalVelocity; | 4676 | pa.RotationalVelocity = rotationalVelocity; |
4677 | 4677 | ||
4678 | // if not vehicle and root part apply force and torque | 4678 | // if not vehicle and root part apply force and torque |
4679 | if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) | 4679 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) |
4680 | && LocalId == ParentGroup.RootPart.LocalId) | 4680 | && LocalId == ParentGroup.RootPart.LocalId) |
4681 | { | 4681 | { |
4682 | pa.Force = Force; | 4682 | pa.Force = Force; |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 151eba2..c7e4c3e 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -630,13 +630,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
630 | 630 | ||
631 | if (errors) | 631 | if (errors) |
632 | { | 632 | { |
633 | obj.sopVehicle = null; | 633 | obj.VehicleParams = null; |
634 | m_log.DebugFormat( | 634 | m_log.DebugFormat( |
635 | "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", | 635 | "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", |
636 | obj.Name, obj.UUID); | 636 | obj.Name, obj.UUID); |
637 | } | 637 | } |
638 | else | 638 | else |
639 | obj.sopVehicle = _vehicle; | 639 | obj.VehicleParams = _vehicle; |
640 | } | 640 | } |
641 | 641 | ||
642 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | 642 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) |
@@ -1325,8 +1325,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1325 | 1325 | ||
1326 | writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); | 1326 | writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); |
1327 | 1327 | ||
1328 | if (sop.sopVehicle != null) | 1328 | if (sop.VehicleParams != null) |
1329 | sop.sopVehicle.ToXml2(writer); | 1329 | sop.VehicleParams.ToXml2(writer); |
1330 | 1330 | ||
1331 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) | 1331 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) |
1332 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | 1332 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); |