aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/ChOdePlugin
diff options
context:
space:
mode:
authorUbitUmarov2012-02-18 17:42:14 +0000
committerUbitUmarov2012-02-18 17:42:14 +0000
commit3aee642190add7045f78e522ae7b2221b3566f1e (patch)
treea390b28dce297bde43aa216332d217b2b28ea03a /OpenSim/Region/Physics/ChOdePlugin
parent vehicle parameters do cross (i hope) on regions in same instance ( others ne... (diff)
downloadopensim-SC-3aee642190add7045f78e522ae7b2221b3566f1e.zip
opensim-SC-3aee642190add7045f78e522ae7b2221b3566f1e.tar.gz
opensim-SC-3aee642190add7045f78e522ae7b2221b3566f1e.tar.bz2
opensim-SC-3aee642190add7045f78e522ae7b2221b3566f1e.tar.xz
changed how vehicle data is stored and passed to physics. use unsafe in serializer, tried to control m_dupeInProgress
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs62
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/OdeUtils.cs294
2 files changed, 300 insertions, 56 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 6e28bfa..2306309 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -22,7 +22,8 @@
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 * 24 *
25 * Revised March 5th 2010 by Kitto Flora. ODEDynamics.cs 25 * Revised March 5th 2010 by Kitto Flora. ODEDynamics.cs
26 * Ubit 2012
26 * rolled into ODEPrim.cs 27 * rolled into ODEPrim.cs
27 */ 28 */
28 29
@@ -38,7 +39,6 @@ using Ode.NET;
38using OpenSim.Framework; 39using OpenSim.Framework;
39using OpenSim.Region.Physics.Manager; 40using OpenSim.Region.Physics.Manager;
40 41
41
42namespace OpenSim.Region.Physics.OdePlugin 42namespace OpenSim.Region.Physics.OdePlugin
43{ 43{
44 /// <summary> 44 /// <summary>
@@ -254,6 +254,61 @@ namespace OpenSim.Region.Physics.OdePlugin
254 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. 254 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor.
255 255
256 SerialControl m_taintserial = null; 256 SerialControl m_taintserial = null;
257 object m_taintvehicledata = null;
258
259 public void DoSetVehicle()
260 {
261 VehicleData vd = (VehicleData)m_taintvehicledata;
262
263 m_type = vd.m_type;
264 m_flags = vd.m_flags;
265
266 // Linear properties
267 m_linearMotorDirection = vd.m_linearMotorDirection;
268 m_linearFrictionTimescale = vd.m_linearFrictionTimescale;
269 m_linearMotorDecayTimescale = vd.m_linearMotorDecayTimescale;
270 m_linearMotorTimescale = vd.m_linearMotorTimescale;
271// m_linearMotorOffset = vd.m_linearMotorOffset;
272
273 //Angular properties
274 m_angularMotorDirection = vd.m_angularMotorDirection;
275 m_angularMotorTimescale = vd.m_angularMotorTimescale;
276 m_angularMotorDecayTimescale = vd.m_angularMotorDecayTimescale;
277 m_angularFrictionTimescale = vd.m_angularFrictionTimescale;
278
279 //Deflection properties
280// m_angularDeflectionEfficiency = vd.m_angularDeflectionEfficiency;
281// m_angularDeflectionTimescale = vd.m_angularDeflectionTimescale;
282// m_linearDeflectionEfficiency = vd.m_linearDeflectionEfficiency;
283// m_linearDeflectionTimescale = vd.m_linearDeflectionTimescale;
284
285 //Banking properties
286// m_bankingEfficiency = vd.m_bankingEfficiency;
287// m_bankingMix = vd.m_bankingMix;
288// m_bankingTimescale = vd.m_bankingTimescale;
289
290 //Hover and Buoyancy properties
291 m_VhoverHeight = vd.m_VhoverHeight;
292// m_VhoverEfficiency = vd.m_VhoverEfficiency;
293 m_VhoverTimescale = vd.m_VhoverTimescale;
294 m_VehicleBuoyancy = vd.m_VehicleBuoyancy;
295
296 //Attractor properties
297 m_verticalAttractionEfficiency = vd.m_verticalAttractionEfficiency;
298 m_verticalAttractionTimescale = vd.m_verticalAttractionTimescale;
299
300 // Axis
301// m_referenceFrame = vd.m_referenceFrame;
302
303
304 m_taintvehicledata = null;
305 }
306
307 public override void SetVehicle(object vdata)
308 {
309 m_taintvehicledata = vdata;
310 _parent_scene.AddPhysicsActorTaint(this);
311 }
257 312
258 public override byte[] Serialize(bool PhysIsRunning) 313 public override byte[] Serialize(bool PhysIsRunning)
259 { 314 {
@@ -1843,6 +1898,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1843 if (m_taintCollidesWater != m_collidesWater) 1898 if (m_taintCollidesWater != m_collidesWater)
1844 changefloatonwater(timestep); 1899 changefloatonwater(timestep);
1845 1900
1901 if (m_taintvehicledata != null)
1902 DoSetVehicle();
1903
1846 if (m_taintserial != null) 1904 if (m_taintserial != null)
1847 DoSerialize(m_taintserial); 1905 DoSerialize(m_taintserial);
1848 1906
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdeUtils.cs b/OpenSim/Region/Physics/ChOdePlugin/OdeUtils.cs
index edd58d3..e7e7bb3 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/OdeUtils.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/OdeUtils.cs
@@ -1,5 +1,17 @@
1// adapted from libomv removing cpu endian adjust 1/* Ubit 2012
2// for prims lowlevel serialization 2 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
3 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
4 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
6 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
7 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
8 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
9 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
11 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12*/
13
14// no endian conversion. So can't be use to pass information around diferent cpus with diferent endian
3 15
4using System; 16using System;
5using System.IO; 17using System.IO;
@@ -7,77 +19,168 @@ using OpenMetaverse;
7 19
8namespace OpenSim.Region.Physics.OdePlugin 20namespace OpenSim.Region.Physics.OdePlugin
9{ 21{
10 public class wstreamer 22
23 unsafe public class wstreamer
11 { 24 {
12 private MemoryStream st; 25 byte[] buf;
26 int index;
27 byte* src;
13 28
14 public wstreamer() 29 public wstreamer()
15 { 30 {
16 st = new MemoryStream(); 31 buf = new byte[1024];
32 index = 0;
33 }
34 public wstreamer(int size)
35 {
36 buf = new byte[size];
37 index = 0;
17 } 38 }
18 39
19 public byte[] close() 40 public byte[] close()
20 { 41 {
21 byte[] data = st.ToArray(); 42 byte[] data = new byte[index];
22 st.Close(); 43 Buffer.BlockCopy(buf, 0, data, 0, index);
23 return data; 44 return data;
24 } 45 }
25 46
47 public void Seek(int pos)
48 {
49 index = pos;
50 }
51
52 public void Seekrel(int pos)
53 {
54 index += pos;
55 }
56
57 public void Wbyte(byte value)
58 {
59 buf[index++] = value;
60 }
26 public void Wshort(short value) 61 public void Wshort(short value)
27 { 62 {
28 st.Write(BitConverter.GetBytes(value), 0, 2); 63 src = (byte*)&value;
64 buf[index++] = *src++;
65 buf[index++] = *src;
29 } 66 }
30 public void Wushort(ushort value) 67 public void Wushort(ushort value)
31 { 68 {
32 byte[] t = BitConverter.GetBytes(value); 69 src = (byte*)&value;
33 st.Write(BitConverter.GetBytes(value), 0, 2); 70 buf[index++] = *src++;
71 buf[index++] = *src;
34 } 72 }
35 public void Wint(int value) 73 public void Wint(int value)
36 { 74 {
37 st.Write(BitConverter.GetBytes(value), 0, 4); 75 src = (byte*)&value;
76 buf[index++] = *src++;
77 buf[index++] = *src++;
78 buf[index++] = *src++;
79 buf[index++] = *src;
38 } 80 }
39 public void Wuint(uint value) 81 public void Wuint(uint value)
40 { 82 {
41 st.Write(BitConverter.GetBytes(value), 0, 4); 83 src = (byte*)&value;
84 buf[index++] = *src++;
85 buf[index++] = *src++;
86 buf[index++] = *src++;
87 buf[index++] = *src;
42 } 88 }
43 public void Wlong(long value) 89 public void Wlong(long value)
44 { 90 {
45 st.Write(BitConverter.GetBytes(value), 0, 8); 91 src = (byte*)&value;
92 buf[index++] = *src++;
93 buf[index++] = *src++;
94 buf[index++] = *src++;
95 buf[index++] = *src++;
96 buf[index++] = *src++;
97 buf[index++] = *src++;
98 buf[index++] = *src++;
99 buf[index++] = *src;
46 } 100 }
47 public void Wulong(ulong value) 101 public void Wulong(ulong value)
48 { 102 {
49 st.Write(BitConverter.GetBytes(value), 0, 8); 103 src = (byte*)&value;
104 buf[index++] = *src++;
105 buf[index++] = *src++;
106 buf[index++] = *src++;
107 buf[index++] = *src++;
108 buf[index++] = *src++;
109 buf[index++] = *src++;
110 buf[index++] = *src++;
111 buf[index++] = *src;
50 } 112 }
51 113
52 public void Wfloat(float value) 114 public void Wfloat(float value)
53 { 115 {
54 st.Write(BitConverter.GetBytes(value), 0, 4); 116 src = (byte*)&value;
117 buf[index++] = *src++;
118 buf[index++] = *src++;
119 buf[index++] = *src++;
120 buf[index++] = *src;
55 } 121 }
56 122
57 public void Wdouble(double value) 123 public void Wdouble(double value)
58 { 124 {
59 st.Write(BitConverter.GetBytes(value), 0, 8); 125 src = (byte*)&value;
126 buf[index++] = *src++;
127 buf[index++] = *src++;
128 buf[index++] = *src++;
129 buf[index++] = *src++;
130 buf[index++] = *src++;
131 buf[index++] = *src++;
132 buf[index++] = *src++;
133 buf[index++] = *src;
60 } 134 }
61 135
62 public void Wvector3(Vector3 value) 136 public void Wvector3(Vector3 value)
63 { 137 {
64 st.Write(BitConverter.GetBytes(value.X), 0, 4); 138 src = (byte*)&value.X;
65 st.Write(BitConverter.GetBytes(value.Y), 0, 4); 139 buf[index++] = *src++;
66 st.Write(BitConverter.GetBytes(value.Z), 0, 4); 140 buf[index++] = *src++;
141 buf[index++] = *src++;
142 buf[index++] = *src;
143 src = (byte*)&value.Y; // it may have padding ??
144 buf[index++] = *src++;
145 buf[index++] = *src++;
146 buf[index++] = *src++;
147 buf[index++] = *src;
148 src = (byte*)&value.Z;
149 buf[index++] = *src++;
150 buf[index++] = *src++;
151 buf[index++] = *src++;
152 buf[index++] = *src;
67 } 153 }
68 public void Wquat(Quaternion value) 154 public void Wquat(Quaternion value)
69 { 155 {
70 st.Write(BitConverter.GetBytes(value.X), 0, 4); 156 src = (byte*)&value.X;
71 st.Write(BitConverter.GetBytes(value.Y), 0, 4); 157 buf[index++] = *src++;
72 st.Write(BitConverter.GetBytes(value.Z), 0, 4); 158 buf[index++] = *src++;
73 st.Write(BitConverter.GetBytes(value.W), 0, 4); 159 buf[index++] = *src++;
160 buf[index++] = *src;
161 src = (byte*)&value.Y; // it may have padding ??
162 buf[index++] = *src++;
163 buf[index++] = *src++;
164 buf[index++] = *src++;
165 buf[index++] = *src;
166 src = (byte*)&value.Z;
167 buf[index++] = *src++;
168 buf[index++] = *src++;
169 buf[index++] = *src++;
170 buf[index++] = *src;
171 src = (byte*)&value.W;
172 buf[index++] = *src++;
173 buf[index++] = *src++;
174 buf[index++] = *src++;
175 buf[index++] = *src;
74 } 176 }
75 } 177 }
76 178
77 public class rstreamer 179 unsafe public class rstreamer
78 { 180 {
79 private byte[] rbuf; 181 private byte[] rbuf;
80 private int ptr; 182 private int ptr;
183 private byte* dst;
81 184
82 public rstreamer(byte[] data) 185 public rstreamer(byte[] data)
83 { 186 {
@@ -89,78 +192,161 @@ namespace OpenSim.Region.Physics.OdePlugin
89 { 192 {
90 } 193 }
91 194
195 public void Seek(int pos)
196 {
197 ptr = pos;
198 }
199
200 public void Seekrel(int pos)
201 {
202 ptr += pos;
203 }
204
205 public byte Rbyte()
206 {
207 return (byte)rbuf[ptr++];
208 }
209
92 public short Rshort() 210 public short Rshort()
93 { 211 {
94 short v = BitConverter.ToInt16(rbuf, ptr); 212 short v;
95 ptr += 2; 213 dst = (byte*)&v;
214 *dst++ = rbuf[ptr++];
215 *dst = rbuf[ptr++];
96 return v; 216 return v;
97 } 217 }
98 public ushort Rushort() 218 public ushort Rushort()
99 { 219 {
100 ushort v = BitConverter.ToUInt16(rbuf, ptr); 220 ushort v;
101 ptr += 2; 221 dst = (byte*)&v;
222 *dst++ = rbuf[ptr++];
223 *dst = rbuf[ptr++];
102 return v; 224 return v;
103 } 225 }
104 public int Rint() 226 public int Rint()
105 { 227 {
106 int v = BitConverter.ToInt32(rbuf, ptr); 228 int v;
107 ptr += 4; 229 dst = (byte*)&v;
230 *dst++ = rbuf[ptr++];
231 *dst++ = rbuf[ptr++];
232 *dst++ = rbuf[ptr++];
233 *dst = rbuf[ptr++];
108 return v; 234 return v;
109 } 235 }
110 public uint Ruint() 236 public uint Ruint()
111 { 237 {
112 uint v = BitConverter.ToUInt32(rbuf, ptr); 238 uint v;
113 ptr += 4; 239 dst = (byte*)&v;
240 *dst++ = rbuf[ptr++];
241 *dst++ = rbuf[ptr++];
242 *dst++ = rbuf[ptr++];
243 *dst = rbuf[ptr++];
114 return v; 244 return v;
115 } 245 }
116 public long Rlong() 246 public long Rlong()
117 { 247 {
118 long v = BitConverter.ToInt64(rbuf, ptr); 248 long v;
119 ptr += 8; 249 dst = (byte*)&v;
250 *dst++ = rbuf[ptr++];
251 *dst++ = rbuf[ptr++];
252 *dst++ = rbuf[ptr++];
253 *dst++ = rbuf[ptr++];
254 *dst++ = rbuf[ptr++];
255 *dst++ = rbuf[ptr++];
256 *dst++ = rbuf[ptr++];
257 *dst = rbuf[ptr++];
120 return v; 258 return v;
121 } 259 }
122 public ulong Rulong() 260 public ulong Rulong()
123 { 261 {
124 ulong v = BitConverter.ToUInt64(rbuf, ptr); 262 ulong v;
125 ptr += 8; 263 dst = (byte*)&v;
264 *dst++ = rbuf[ptr++];
265 *dst++ = rbuf[ptr++];
266 *dst++ = rbuf[ptr++];
267 *dst++ = rbuf[ptr++];
268 *dst++ = rbuf[ptr++];
269 *dst++ = rbuf[ptr++];
270 *dst++ = rbuf[ptr++];
271 *dst = rbuf[ptr++];
126 return v; 272 return v;
127 } 273 }
128 public float Rfloat() 274 public float Rfloat()
129 { 275 {
130 float v = BitConverter.ToSingle(rbuf, ptr); 276 float v;
131 ptr += 4; 277 dst = (byte*)&v;
278 *dst++ = rbuf[ptr++];
279 *dst++ = rbuf[ptr++];
280 *dst++ = rbuf[ptr++];
281 *dst = rbuf[ptr++];
132 return v; 282 return v;
133 } 283 }
134 284
135 public double Rdouble() 285 public double Rdouble()
136 { 286 {
137 double v = BitConverter.ToDouble(rbuf, ptr); 287 double v;
138 ptr += 8; 288 dst = (byte*)&v;
289 *dst++ = rbuf[ptr++];
290 *dst++ = rbuf[ptr++];
291 *dst++ = rbuf[ptr++];
292 *dst++ = rbuf[ptr++];
293 *dst++ = rbuf[ptr++];
294 *dst++ = rbuf[ptr++];
295 *dst++ = rbuf[ptr++];
296 *dst = rbuf[ptr++];
139 return v; 297 return v;
140 } 298 }
141 299
142 public Vector3 Rvector3() 300 public Vector3 Rvector3()
143 { 301 {
144 Vector3 v; 302 Vector3 v;
145 v.X = BitConverter.ToSingle(rbuf, ptr); 303 dst = (byte*)&v.X;
146 ptr += 4; 304 *dst++ = rbuf[ptr++];
147 v.Y = BitConverter.ToSingle(rbuf, ptr); 305 *dst++ = rbuf[ptr++];
148 ptr += 4; 306 *dst++ = rbuf[ptr++];
149 v.Z = BitConverter.ToSingle(rbuf, ptr); 307 *dst = rbuf[ptr++];
150 ptr += 4; 308
309 dst = (byte*)&v.Y;
310 *dst++ = rbuf[ptr++];
311 *dst++ = rbuf[ptr++];
312 *dst++ = rbuf[ptr++];
313 *dst = rbuf[ptr++];
314
315 dst = (byte*)&v.Z;
316 *dst++ = rbuf[ptr++];
317 *dst++ = rbuf[ptr++];
318 *dst++ = rbuf[ptr++];
319 *dst = rbuf[ptr++];
151 return v; 320 return v;
152 } 321 }
322
153 public Quaternion Rquat() 323 public Quaternion Rquat()
154 { 324 {
155 Quaternion v; 325 Quaternion v;
156 v.X = BitConverter.ToSingle(rbuf, ptr); 326 dst = (byte*)&v.X;
157 ptr += 4; 327 *dst++ = rbuf[ptr++];
158 v.Y = BitConverter.ToSingle(rbuf, ptr); 328 *dst++ = rbuf[ptr++];
159 ptr += 4; 329 *dst++ = rbuf[ptr++];
160 v.Z = BitConverter.ToSingle(rbuf, ptr); 330 *dst = rbuf[ptr++];
161 ptr += 4; 331
162 v.W = BitConverter.ToSingle(rbuf, ptr); 332 dst = (byte*)&v.Y;
163 ptr += 4; 333 *dst++ = rbuf[ptr++];
334 *dst++ = rbuf[ptr++];
335 *dst++ = rbuf[ptr++];
336 *dst = rbuf[ptr++];
337
338 dst = (byte*)&v.Z;
339 *dst++ = rbuf[ptr++];
340 *dst++ = rbuf[ptr++];
341 *dst++ = rbuf[ptr++];
342 *dst = rbuf[ptr++];
343
344 dst = (byte*)&v.W;
345 *dst++ = rbuf[ptr++];
346 *dst++ = rbuf[ptr++];
347 *dst++ = rbuf[ptr++];
348 *dst = rbuf[ptr++];
349
164 return v; 350 return v;
165 } 351 }
166 } 352 }