diff options
author | UbitUmarov | 2017-04-01 17:49:17 +0100 |
---|---|---|
committer | UbitUmarov | 2017-04-01 17:49:17 +0100 |
commit | 443fc60cdf399a49832e787ca58c2644bef7e457 (patch) | |
tree | 103b547e95ced12fbc22109b82ac692f92068002 | |
parent | add missing file. Changes of inertia data of objects running does not (diff) | |
download | opensim-SC_OLD-443fc60cdf399a49832e787ca58c2644bef7e457.zip opensim-SC_OLD-443fc60cdf399a49832e787ca58c2644bef7e457.tar.gz opensim-SC_OLD-443fc60cdf399a49832e787ca58c2644bef7e457.tar.bz2 opensim-SC_OLD-443fc60cdf399a49832e787ca58c2644bef7e457.tar.xz |
store the physics inertia override in Mysql and add it to serializer. run prebuild is required
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 17 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/RegionStore.migrations | 6 | ||||
-rw-r--r-- | OpenSim/Framework/PhysicsInertia.cs | 262 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 21 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | 22 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 3 |
8 files changed, 336 insertions, 38 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 8278c0e..97a433f 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -187,7 +187,7 @@ namespace OpenSim.Data.MySQL | |||
187 | "LinkNumber, MediaURL, KeyframeMotion, AttachedPosX, " + | 187 | "LinkNumber, MediaURL, KeyframeMotion, AttachedPosX, " + |
188 | "AttachedPosY, AttachedPosZ, " + | 188 | "AttachedPosY, AttachedPosZ, " + |
189 | "PhysicsShapeType, Density, GravityModifier, " + | 189 | "PhysicsShapeType, Density, GravityModifier, " + |
190 | "Friction, Restitution, Vehicle, DynAttrs, " + | 190 | "Friction, Restitution, Vehicle, PhysInertia, DynAttrs, " + |
191 | "RotationAxisLocks" + | 191 | "RotationAxisLocks" + |
192 | ") values (" + "?UUID, " + | 192 | ") values (" + "?UUID, " + |
193 | "?CreationDate, ?Name, ?Text, " + | 193 | "?CreationDate, ?Name, ?Text, " + |
@@ -224,7 +224,7 @@ namespace OpenSim.Data.MySQL | |||
224 | "?LinkNumber, ?MediaURL, ?KeyframeMotion, ?AttachedPosX, " + | 224 | "?LinkNumber, ?MediaURL, ?KeyframeMotion, ?AttachedPosX, " + |
225 | "?AttachedPosY, ?AttachedPosZ, " + | 225 | "?AttachedPosY, ?AttachedPosZ, " + |
226 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + | 226 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + |
227 | "?Friction, ?Restitution, ?Vehicle, ?DynAttrs," + | 227 | "?Friction, ?Restitution, ?Vehicle, ?PhysInertia, ?DynAttrs," + |
228 | "?RotationAxisLocks)"; | 228 | "?RotationAxisLocks)"; |
229 | 229 | ||
230 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | 230 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); |
@@ -1452,6 +1452,14 @@ namespace OpenSim.Data.MySQL | |||
1452 | prim.VehicleParams = vehicle; | 1452 | prim.VehicleParams = vehicle; |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | PhysicsInertiaData pdata; | ||
1456 | if (row["PhysInertia"].ToString() != String.Empty) | ||
1457 | { | ||
1458 | pdata = PhysicsInertiaData.FromXml2(row["PhysInertia"].ToString()); | ||
1459 | if (pdata != null) | ||
1460 | prim.PhysicsInertia = pdata; | ||
1461 | } | ||
1462 | |||
1455 | return prim; | 1463 | return prim; |
1456 | } | 1464 | } |
1457 | 1465 | ||
@@ -1810,6 +1818,11 @@ namespace OpenSim.Data.MySQL | |||
1810 | else | 1818 | else |
1811 | cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); | 1819 | cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); |
1812 | 1820 | ||
1821 | if (prim.PhysicsInertia != null) | ||
1822 | cmd.Parameters.AddWithValue("PhysInertia", prim.PhysicsInertia.ToXml2()); | ||
1823 | else | ||
1824 | cmd.Parameters.AddWithValue("PhysInertia", String.Empty); | ||
1825 | |||
1813 | if (prim.VehicleParams != null) | 1826 | if (prim.VehicleParams != null) |
1814 | cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2()); | 1827 | cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2()); |
1815 | else | 1828 | else |
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index c63cc95..0577392 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations | |||
@@ -461,3 +461,9 @@ BEGIN; | |||
461 | ALTER TABLE `prims` ADD COLUMN `RezzerID` char(36) DEFAULT NULL; | 461 | ALTER TABLE `prims` ADD COLUMN `RezzerID` char(36) DEFAULT NULL; |
462 | 462 | ||
463 | COMMIT; | 463 | COMMIT; |
464 | |||
465 | :VERSION 57 #----- Add physics inertia data | ||
466 | |||
467 | BEGIN; | ||
468 | ALTER TABLE `prims` ADD COLUMN `PhysInertia` TEXT default NULL; | ||
469 | COMMIT; | ||
diff --git a/OpenSim/Framework/PhysicsInertia.cs b/OpenSim/Framework/PhysicsInertia.cs new file mode 100644 index 0000000..af70634 --- /dev/null +++ b/OpenSim/Framework/PhysicsInertia.cs | |||
@@ -0,0 +1,262 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using System.Text; | ||
32 | using System.IO; | ||
33 | using System.Xml; | ||
34 | |||
35 | namespace OpenSim.Framework | ||
36 | { | ||
37 | public class PhysicsInertiaData | ||
38 | { | ||
39 | public float TotalMass; // the total mass of a linkset | ||
40 | public Vector3 CenterOfMass; // the center of mass position relative to root part position | ||
41 | public Vector3 Inertia; // (Ixx, Iyy, Izz) moment of inertia relative to center of mass and principal axis in local coords | ||
42 | public Vector4 InertiaRotation; // if principal axis don't match local axis, the principal axis rotation | ||
43 | // or the upper triangle of the inertia tensor | ||
44 | // Ixy (= Iyx), Ixz (= Izx), Iyz (= Izy)) | ||
45 | |||
46 | public PhysicsInertiaData() | ||
47 | { | ||
48 | } | ||
49 | |||
50 | public PhysicsInertiaData(PhysicsInertiaData source) | ||
51 | { | ||
52 | TotalMass = source.TotalMass; | ||
53 | CenterOfMass = source.CenterOfMass; | ||
54 | Inertia = source.Inertia; | ||
55 | InertiaRotation = source.InertiaRotation; | ||
56 | } | ||
57 | |||
58 | private XmlTextWriter writer; | ||
59 | |||
60 | private void XWint(string name, int i) | ||
61 | { | ||
62 | writer.WriteElementString(name, i.ToString()); | ||
63 | } | ||
64 | |||
65 | private void XWfloat(string name, float f) | ||
66 | { | ||
67 | writer.WriteElementString(name, f.ToString(Utils.EnUsCulture)); | ||
68 | } | ||
69 | |||
70 | private void XWVector(string name, Vector3 vec) | ||
71 | { | ||
72 | writer.WriteStartElement(name); | ||
73 | writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); | ||
74 | writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); | ||
75 | writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); | ||
76 | writer.WriteEndElement(); | ||
77 | } | ||
78 | |||
79 | private void XWVector4(string name, Vector4 quat) | ||
80 | { | ||
81 | writer.WriteStartElement(name); | ||
82 | writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); | ||
83 | writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); | ||
84 | writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); | ||
85 | writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); | ||
86 | writer.WriteEndElement(); | ||
87 | } | ||
88 | |||
89 | public void ToXml2(XmlTextWriter twriter) | ||
90 | { | ||
91 | writer = twriter; | ||
92 | writer.WriteStartElement("PhysicsInertia"); | ||
93 | |||
94 | XWfloat("MASS", TotalMass); | ||
95 | XWVector("CM", CenterOfMass); | ||
96 | XWVector("INERTIA", Inertia); | ||
97 | XWVector4("IROT", InertiaRotation); | ||
98 | |||
99 | writer.WriteEndElement(); | ||
100 | writer = null; | ||
101 | } | ||
102 | |||
103 | XmlReader reader; | ||
104 | |||
105 | private int XRint() | ||
106 | { | ||
107 | return reader.ReadElementContentAsInt(); | ||
108 | } | ||
109 | |||
110 | private float XRfloat() | ||
111 | { | ||
112 | return reader.ReadElementContentAsFloat(); | ||
113 | } | ||
114 | |||
115 | public Vector3 XRvector() | ||
116 | { | ||
117 | Vector3 vec; | ||
118 | reader.ReadStartElement(); | ||
119 | vec.X = reader.ReadElementContentAsFloat(); | ||
120 | vec.Y = reader.ReadElementContentAsFloat(); | ||
121 | vec.Z = reader.ReadElementContentAsFloat(); | ||
122 | reader.ReadEndElement(); | ||
123 | return vec; | ||
124 | } | ||
125 | |||
126 | public Vector4 XRVector4() | ||
127 | { | ||
128 | Vector4 q; | ||
129 | reader.ReadStartElement(); | ||
130 | q.X = reader.ReadElementContentAsFloat(); | ||
131 | q.Y = reader.ReadElementContentAsFloat(); | ||
132 | q.Z = reader.ReadElementContentAsFloat(); | ||
133 | q.W = reader.ReadElementContentAsFloat(); | ||
134 | reader.ReadEndElement(); | ||
135 | return q; | ||
136 | } | ||
137 | |||
138 | public static bool EReadProcessors( | ||
139 | Dictionary<string, Action> processors, | ||
140 | XmlReader xtr) | ||
141 | { | ||
142 | bool errors = false; | ||
143 | |||
144 | string nodeName = string.Empty; | ||
145 | while (xtr.NodeType != XmlNodeType.EndElement) | ||
146 | { | ||
147 | nodeName = xtr.Name; | ||
148 | |||
149 | Action p = null; | ||
150 | if (processors.TryGetValue(xtr.Name, out p)) | ||
151 | { | ||
152 | try | ||
153 | { | ||
154 | p(); | ||
155 | } | ||
156 | catch | ||
157 | { | ||
158 | errors = true; | ||
159 | if (xtr.NodeType == XmlNodeType.EndElement) | ||
160 | xtr.Read(); | ||
161 | } | ||
162 | } | ||
163 | else | ||
164 | { | ||
165 | xtr.ReadOuterXml(); // ignore | ||
166 | } | ||
167 | } | ||
168 | |||
169 | return errors; | ||
170 | } | ||
171 | |||
172 | public string ToXml2() | ||
173 | { | ||
174 | using (StringWriter sw = new StringWriter()) | ||
175 | { | ||
176 | using (XmlTextWriter xwriter = new XmlTextWriter(sw)) | ||
177 | { | ||
178 | ToXml2(xwriter); | ||
179 | } | ||
180 | |||
181 | return sw.ToString(); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | public static PhysicsInertiaData FromXml2(string text) | ||
186 | { | ||
187 | if (text == String.Empty) | ||
188 | return null; | ||
189 | |||
190 | UTF8Encoding enc = new UTF8Encoding(); | ||
191 | MemoryStream ms = new MemoryStream(enc.GetBytes(text)); | ||
192 | XmlTextReader xreader = new XmlTextReader(ms); | ||
193 | |||
194 | PhysicsInertiaData v = new PhysicsInertiaData(); | ||
195 | bool error; | ||
196 | |||
197 | v.FromXml2(xreader, out error); | ||
198 | |||
199 | xreader.Close(); | ||
200 | |||
201 | if (error) | ||
202 | return null; | ||
203 | |||
204 | return v; | ||
205 | } | ||
206 | |||
207 | public static PhysicsInertiaData FromXml2(XmlReader reader) | ||
208 | { | ||
209 | PhysicsInertiaData data = new PhysicsInertiaData(); | ||
210 | |||
211 | bool errors = false; | ||
212 | |||
213 | data.FromXml2(reader, out errors); | ||
214 | if (errors) | ||
215 | return null; | ||
216 | |||
217 | return data; | ||
218 | } | ||
219 | |||
220 | private void FromXml2(XmlReader _reader, out bool errors) | ||
221 | { | ||
222 | errors = false; | ||
223 | reader = _reader; | ||
224 | |||
225 | Dictionary<string, Action> m_XmlProcessors = new Dictionary<string, Action>(); | ||
226 | |||
227 | m_XmlProcessors.Add("MASS", ProcessXR_Mass); | ||
228 | m_XmlProcessors.Add("CM", ProcessXR_CM); | ||
229 | m_XmlProcessors.Add("INERTIA", ProcessXR_Inertia); | ||
230 | m_XmlProcessors.Add("IROT", ProcessXR_InertiaRotation); | ||
231 | |||
232 | reader.ReadStartElement("PhysicsInertia", String.Empty); | ||
233 | |||
234 | errors = EReadProcessors( | ||
235 | m_XmlProcessors, | ||
236 | reader); | ||
237 | |||
238 | reader.ReadEndElement(); | ||
239 | reader = null; | ||
240 | } | ||
241 | |||
242 | private void ProcessXR_Mass() | ||
243 | { | ||
244 | TotalMass = XRfloat(); | ||
245 | } | ||
246 | |||
247 | private void ProcessXR_CM() | ||
248 | { | ||
249 | CenterOfMass = XRvector(); | ||
250 | } | ||
251 | |||
252 | private void ProcessXR_Inertia() | ||
253 | { | ||
254 | Inertia = XRvector(); | ||
255 | } | ||
256 | |||
257 | private void ProcessXR_InertiaRotation() | ||
258 | { | ||
259 | InertiaRotation = XRVector4(); | ||
260 | } | ||
261 | } | ||
262 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 77658ef..719a5dd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -5037,20 +5037,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
5037 | 5037 | ||
5038 | public void SetInertiaData(float TotalMass, Vector3 CenterOfMass, Vector3 Inertia, Vector4 aux ) | 5038 | public void SetInertiaData(float TotalMass, Vector3 CenterOfMass, Vector3 Inertia, Vector4 aux ) |
5039 | { | 5039 | { |
5040 | PhysicsActor pa = RootPart.PhysActor; | 5040 | PhysicsInertiaData inertia = new PhysicsInertiaData(); |
5041 | inertia.TotalMass = TotalMass; | ||
5042 | inertia.CenterOfMass = CenterOfMass; | ||
5043 | inertia.Inertia = Inertia; | ||
5044 | inertia.InertiaRotation = aux; | ||
5045 | |||
5046 | if(TotalMass < 0) | ||
5047 | RootPart.PhysicsInertia = null; | ||
5048 | else | ||
5049 | RootPart.PhysicsInertia = new PhysicsInertiaData(inertia); | ||
5041 | 5050 | ||
5051 | PhysicsActor pa = RootPart.PhysActor; | ||
5042 | if(pa !=null) | 5052 | if(pa !=null) |
5043 | { | ||
5044 | PhysicsInertiaData inertia = new PhysicsInertiaData(); | ||
5045 | inertia.TotalMass = TotalMass; | ||
5046 | inertia.CenterOfMass = CenterOfMass; | ||
5047 | inertia.Inertia = Inertia; | ||
5048 | inertia.InertiaRotation = aux; | ||
5049 | pa.SetInertiaData(inertia); | 5053 | pa.SetInertiaData(inertia); |
5050 | } | ||
5051 | } | 5054 | } |
5052 | 5055 | ||
5053 | |||
5054 | /// <summary> | 5056 | /// <summary> |
5055 | /// Set the user group to which this scene object belongs. | 5057 | /// Set the user group to which this scene object belongs. |
5056 | /// </summary> | 5058 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index bf0e31b..46b7b86 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -406,6 +406,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
406 | 406 | ||
407 | private SOPVehicle m_vehicleParams = null; | 407 | private SOPVehicle m_vehicleParams = null; |
408 | 408 | ||
409 | private PhysicsInertiaData m_physicsInertia; | ||
410 | |||
409 | public KeyframeMotion KeyframeMotion | 411 | public KeyframeMotion KeyframeMotion |
410 | { | 412 | { |
411 | get; set; | 413 | get; set; |
@@ -3548,6 +3550,18 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
3548 | Force = force; | 3550 | Force = force; |
3549 | } | 3551 | } |
3550 | 3552 | ||
3553 | public PhysicsInertiaData PhysicsInertia | ||
3554 | { | ||
3555 | get | ||
3556 | { | ||
3557 | return m_physicsInertia; | ||
3558 | } | ||
3559 | set | ||
3560 | { | ||
3561 | m_physicsInertia = value; | ||
3562 | } | ||
3563 | } | ||
3564 | |||
3551 | public SOPVehicle VehicleParams | 3565 | public SOPVehicle VehicleParams |
3552 | { | 3566 | { |
3553 | get | 3567 | get |
@@ -4748,8 +4762,13 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
4748 | 4762 | ||
4749 | if (VolumeDetectActive) // change if not the default only | 4763 | if (VolumeDetectActive) // change if not the default only |
4750 | pa.SetVolumeDetect(1); | 4764 | pa.SetVolumeDetect(1); |
4765 | |||
4766 | bool isroot = (m_localId == ParentGroup.RootPart.LocalId); | ||
4767 | |||
4768 | if(isroot && m_physicsInertia != null) | ||
4769 | pa.SetInertiaData(m_physicsInertia); | ||
4751 | 4770 | ||
4752 | if (m_vehicleParams != null && m_localId == ParentGroup.RootPart.LocalId) | 4771 | if (isroot && m_vehicleParams != null ) |
4753 | { | 4772 | { |
4754 | m_vehicleParams.SetVehicle(pa); | 4773 | m_vehicleParams.SetVehicle(pa); |
4755 | if(isPhysical && !isPhantom && m_vehicleParams.CameraDecoupled) | 4774 | if(isPhysical && !isPhantom && m_vehicleParams.CameraDecoupled) |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index a12a401..87d1ace 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -453,9 +453,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
453 | m_SOPXmlProcessors.Add("Torque", ProcessTorque); | 453 | m_SOPXmlProcessors.Add("Torque", ProcessTorque); |
454 | m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); | 454 | m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); |
455 | 455 | ||
456 | |||
457 | m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); | 456 | m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); |
458 | 457 | ||
458 | m_SOPXmlProcessors.Add("PhysicsInertia", ProcessPhysicsInertia); | ||
459 | |||
459 | m_SOPXmlProcessors.Add("RotationAxisLocks", ProcessRotationAxisLocks); | 460 | m_SOPXmlProcessors.Add("RotationAxisLocks", ProcessRotationAxisLocks); |
460 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); | 461 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); |
461 | m_SOPXmlProcessors.Add("Density", ProcessDensity); | 462 | m_SOPXmlProcessors.Add("Density", ProcessDensity); |
@@ -781,6 +782,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
781 | } | 782 | } |
782 | } | 783 | } |
783 | 784 | ||
785 | private static void ProcessPhysicsInertia(SceneObjectPart obj, XmlReader reader) | ||
786 | { | ||
787 | PhysicsInertiaData pdata = PhysicsInertiaData.FromXml2(reader); | ||
788 | |||
789 | if (pdata == null) | ||
790 | { | ||
791 | obj.PhysicsInertia = null; | ||
792 | m_log.DebugFormat( | ||
793 | "[SceneObjectSerializer]: Parsing PhysicsInertiaData for object part {0} {1} encountered errors. Please see earlier log entries.", | ||
794 | obj.Name, obj.UUID); | ||
795 | } | ||
796 | else | ||
797 | { | ||
798 | obj.PhysicsInertia = pdata; | ||
799 | } | ||
800 | } | ||
801 | |||
784 | private static void ProcessShape(SceneObjectPart obj, XmlReader reader) | 802 | private static void ProcessShape(SceneObjectPart obj, XmlReader reader) |
785 | { | 803 | { |
786 | List<string> errorNodeNames; | 804 | List<string> errorNodeNames; |
@@ -1498,6 +1516,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1498 | if (sop.VehicleParams != null) | 1516 | if (sop.VehicleParams != null) |
1499 | sop.VehicleParams.ToXml2(writer); | 1517 | sop.VehicleParams.ToXml2(writer); |
1500 | 1518 | ||
1519 | if (sop.PhysicsInertia != null) | ||
1520 | sop.PhysicsInertia.ToXml2(writer); | ||
1521 | |||
1501 | if(sop.RotationAxisLocks != 0) | 1522 | if(sop.RotationAxisLocks != 0) |
1502 | writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower()); | 1523 | writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower()); |
1503 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | 1524 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); |
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs index ad9b28f..d23d9c1 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | |||
@@ -55,28 +55,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
55 | Absolute | 55 | Absolute |
56 | } | 56 | } |
57 | 57 | ||
58 | public class PhysicsInertiaData | ||
59 | { | ||
60 | public float TotalMass; // the total mass of a linkset | ||
61 | public Vector3 CenterOfMass; // the center of mass position relative to root part position | ||
62 | public Vector3 Inertia; // (Ixx, Iyy, Izz) moment of inertia relative to center of mass and principal axis in local coords | ||
63 | public Vector4 InertiaRotation; // if principal axis don't match local axis, the principal axis rotation | ||
64 | // or the upper triangle of the inertia tensor | ||
65 | // Ixy (= Iyx), Ixz (= Izx), Iyz (= Izy)) | ||
66 | |||
67 | public PhysicsInertiaData() | ||
68 | { | ||
69 | } | ||
70 | |||
71 | public PhysicsInertiaData(PhysicsInertiaData source) | ||
72 | { | ||
73 | TotalMass = source.TotalMass; | ||
74 | CenterOfMass = source.CenterOfMass; | ||
75 | Inertia = source.Inertia; | ||
76 | InertiaRotation = source.InertiaRotation; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | public struct CameraData | 58 | public struct CameraData |
81 | { | 59 | { |
82 | public Quaternion CameraRotation; | 60 | public Quaternion CameraRotation; |
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index d560b41..f784990 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | |||
@@ -568,9 +568,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
568 | { | 568 | { |
569 | get | 569 | get |
570 | { | 570 | { |
571 | if(!childPrim && m_fakeInertiaOverride != null) | ||
572 | return m_fakeInertiaOverride.CenterOfMass; | ||
573 | |||
574 | lock (_parent_scene.OdeLock) | 571 | lock (_parent_scene.OdeLock) |
575 | { | 572 | { |
576 | d.AllocateODEDataForThread(0); | 573 | d.AllocateODEDataForThread(0); |