aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs210
1 files changed, 108 insertions, 102 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index dcd02e2..d106677 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
@@ -121,6 +121,9 @@ namespace OpenSim.Region.Physics.OdePlugin
121 private float m_amEfect = 0; // current angular motor eficiency 121 private float m_amEfect = 0; // current angular motor eficiency
122 private float m_ffactor = 1.0f; 122 private float m_ffactor = 1.0f;
123 123
124 private float m_timestep = 0.02f;
125 private float m_invtimestep = 50;
126
124 public float FrictionFactor 127 public float FrictionFactor
125 { 128 {
126 get 129 get
@@ -133,14 +136,12 @@ namespace OpenSim.Region.Physics.OdePlugin
133 { 136 {
134 rootPrim = rootp; 137 rootPrim = rootp;
135 _pParentScene = rootPrim._parent_scene; 138 _pParentScene = rootPrim._parent_scene;
139 m_timestep = _pParentScene.ODE_STEPSIZE;
140 m_invtimestep = 1.0f / m_timestep;
136 } 141 }
137 142
138 public void DoSetVehicle(VehicleData vd) 143 public void DoSetVehicle(VehicleData vd)
139 { 144 {
140
141 float timestep = _pParentScene.ODE_STEPSIZE;
142 float invtimestep = 1.0f / timestep;
143
144 m_type = vd.m_type; 145 m_type = vd.m_type;
145 m_flags = vd.m_flags; 146 m_flags = vd.m_flags;
146 147
@@ -148,61 +149,60 @@ namespace OpenSim.Region.Physics.OdePlugin
148 m_linearMotorDirection = vd.m_linearMotorDirection; 149 m_linearMotorDirection = vd.m_linearMotorDirection;
149 150
150 m_linearFrictionTimescale = vd.m_linearFrictionTimescale; 151 m_linearFrictionTimescale = vd.m_linearFrictionTimescale;
151 if (m_linearFrictionTimescale.X < timestep) m_linearFrictionTimescale.X = timestep; 152 if (m_linearFrictionTimescale.X < m_timestep) m_linearFrictionTimescale.X = m_timestep;
152 if (m_linearFrictionTimescale.Y < timestep) m_linearFrictionTimescale.Y = timestep; 153 if (m_linearFrictionTimescale.Y < m_timestep) m_linearFrictionTimescale.Y = m_timestep;
153 if (m_linearFrictionTimescale.Z < timestep) m_linearFrictionTimescale.Z = timestep; 154 if (m_linearFrictionTimescale.Z < m_timestep) m_linearFrictionTimescale.Z = m_timestep;
154 155
155 m_linearMotorDecayTimescale = vd.m_linearMotorDecayTimescale; 156 m_linearMotorDecayTimescale = vd.m_linearMotorDecayTimescale;
156 if (m_linearMotorDecayTimescale < timestep) m_linearMotorDecayTimescale = timestep; 157 if (m_linearMotorDecayTimescale < m_timestep) m_linearMotorDecayTimescale = m_timestep;
157 m_linearMotorDecayTimescale *= invtimestep; 158 m_linearMotorDecayTimescale *= m_invtimestep;
158 159
159 m_linearMotorTimescale = vd.m_linearMotorTimescale; 160 m_linearMotorTimescale = vd.m_linearMotorTimescale;
160 if (m_linearMotorTimescale < timestep) m_linearMotorTimescale = timestep; 161 if (m_linearMotorTimescale < m_timestep) m_linearMotorTimescale = m_timestep;
161
162 162
163 m_linearMotorOffset = vd.m_linearMotorOffset; 163 m_linearMotorOffset = vd.m_linearMotorOffset;
164 164
165 //Angular properties 165 //Angular properties
166 m_angularMotorDirection = vd.m_angularMotorDirection; 166 m_angularMotorDirection = vd.m_angularMotorDirection;
167 m_angularMotorTimescale = vd.m_angularMotorTimescale; 167 m_angularMotorTimescale = vd.m_angularMotorTimescale;
168 if (m_angularMotorTimescale < timestep) m_angularMotorTimescale = timestep; 168 if (m_angularMotorTimescale < m_timestep) m_angularMotorTimescale = m_timestep;
169 169
170 m_angularMotorDecayTimescale = vd.m_angularMotorDecayTimescale; 170 m_angularMotorDecayTimescale = vd.m_angularMotorDecayTimescale;
171 if (m_angularMotorDecayTimescale < timestep) m_angularMotorDecayTimescale = timestep; 171 if (m_angularMotorDecayTimescale < m_timestep) m_angularMotorDecayTimescale = m_timestep;
172 m_angularMotorDecayTimescale *= invtimestep; 172 m_angularMotorDecayTimescale *= m_invtimestep;
173 173
174 m_angularFrictionTimescale = vd.m_angularFrictionTimescale; 174 m_angularFrictionTimescale = vd.m_angularFrictionTimescale;
175 if (m_angularFrictionTimescale.X < timestep) m_angularFrictionTimescale.X = timestep; 175 if (m_angularFrictionTimescale.X < m_timestep) m_angularFrictionTimescale.X = m_timestep;
176 if (m_angularFrictionTimescale.Y < timestep) m_angularFrictionTimescale.Y = timestep; 176 if (m_angularFrictionTimescale.Y < m_timestep) m_angularFrictionTimescale.Y = m_timestep;
177 if (m_angularFrictionTimescale.Z < timestep) m_angularFrictionTimescale.Z = timestep; 177 if (m_angularFrictionTimescale.Z < m_timestep) m_angularFrictionTimescale.Z = m_timestep;
178 178
179 //Deflection properties 179 //Deflection properties
180 m_angularDeflectionEfficiency = vd.m_angularDeflectionEfficiency; 180 m_angularDeflectionEfficiency = vd.m_angularDeflectionEfficiency;
181 m_angularDeflectionTimescale = vd.m_angularDeflectionTimescale; 181 m_angularDeflectionTimescale = vd.m_angularDeflectionTimescale;
182 if (m_angularDeflectionTimescale < timestep) m_angularDeflectionTimescale = timestep; 182 if (m_angularDeflectionTimescale < m_timestep) m_angularDeflectionTimescale = m_timestep;
183 183
184 m_linearDeflectionEfficiency = vd.m_linearDeflectionEfficiency; 184 m_linearDeflectionEfficiency = vd.m_linearDeflectionEfficiency;
185 m_linearDeflectionTimescale = vd.m_linearDeflectionTimescale; 185 m_linearDeflectionTimescale = vd.m_linearDeflectionTimescale;
186 if (m_linearDeflectionTimescale < timestep) m_linearDeflectionTimescale = timestep; 186 if (m_linearDeflectionTimescale < m_timestep) m_linearDeflectionTimescale = m_timestep;
187 187
188 //Banking properties 188 //Banking properties
189 m_bankingEfficiency = vd.m_bankingEfficiency; 189 m_bankingEfficiency = vd.m_bankingEfficiency;
190 m_bankingMix = vd.m_bankingMix; 190 m_bankingMix = vd.m_bankingMix;
191 m_bankingTimescale = vd.m_bankingTimescale; 191 m_bankingTimescale = vd.m_bankingTimescale;
192 if (m_bankingTimescale < timestep) m_bankingTimescale = timestep; 192 if (m_bankingTimescale < m_timestep) m_bankingTimescale = m_timestep;
193 193
194 //Hover and Buoyancy properties 194 //Hover and Buoyancy properties
195 m_VhoverHeight = vd.m_VhoverHeight; 195 m_VhoverHeight = vd.m_VhoverHeight;
196 m_VhoverEfficiency = vd.m_VhoverEfficiency; 196 m_VhoverEfficiency = vd.m_VhoverEfficiency;
197 m_VhoverTimescale = vd.m_VhoverTimescale; 197 m_VhoverTimescale = vd.m_VhoverTimescale;
198 if (m_VhoverTimescale < timestep) m_VhoverTimescale = timestep; 198 if (m_VhoverTimescale < m_timestep) m_VhoverTimescale = m_timestep;
199 199
200 m_VehicleBuoyancy = vd.m_VehicleBuoyancy; 200 m_VehicleBuoyancy = vd.m_VehicleBuoyancy;
201 201
202 //Attractor properties 202 //Attractor properties
203 m_verticalAttractionEfficiency = vd.m_verticalAttractionEfficiency; 203 m_verticalAttractionEfficiency = vd.m_verticalAttractionEfficiency;
204 m_verticalAttractionTimescale = vd.m_verticalAttractionTimescale; 204 m_verticalAttractionTimescale = vd.m_verticalAttractionTimescale;
205 if (m_verticalAttractionTimescale < timestep) m_verticalAttractionTimescale = timestep; 205 if (m_verticalAttractionTimescale < m_timestep) m_verticalAttractionTimescale = m_timestep;
206 206
207 // Axis 207 // Axis
208 m_referenceFrame = vd.m_referenceFrame; 208 m_referenceFrame = vd.m_referenceFrame;
@@ -215,8 +215,6 @@ namespace OpenSim.Region.Physics.OdePlugin
215 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) 215 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
216 { 216 {
217 float len; 217 float len;
218 float invtimestep = 1.0f / _pParentScene.ODE_STEPSIZE;
219 float timestep = _pParentScene.ODE_STEPSIZE;
220 218
221 switch (pParam) 219 switch (pParam)
222 { 220 {
@@ -226,18 +224,16 @@ namespace OpenSim.Region.Physics.OdePlugin
226 m_angularDeflectionEfficiency = pValue; 224 m_angularDeflectionEfficiency = pValue;
227 break; 225 break;
228 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: 226 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE:
229 if (pValue < timestep) pValue = timestep; 227 if (pValue < m_timestep) pValue = m_timestep;
230 m_angularDeflectionTimescale = pValue; 228 m_angularDeflectionTimescale = pValue;
231 break; 229 break;
232 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: 230 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE:
233 if (pValue < timestep) pValue = timestep; 231 if (pValue < m_timestep) pValue = m_timestep;
234 // try to make impulses to work a bit better
235// if (pValue < 0.5f) pValue = 0.5f;
236 else if (pValue > 120) pValue = 120; 232 else if (pValue > 120) pValue = 120;
237 m_angularMotorDecayTimescale = pValue * invtimestep; 233 m_angularMotorDecayTimescale = pValue * m_invtimestep;
238 break; 234 break;
239 case Vehicle.ANGULAR_MOTOR_TIMESCALE: 235 case Vehicle.ANGULAR_MOTOR_TIMESCALE:
240 if (pValue < timestep) pValue = timestep; 236 if (pValue < m_timestep) pValue = m_timestep;
241 m_angularMotorTimescale = pValue; 237 m_angularMotorTimescale = pValue;
242 break; 238 break;
243 case Vehicle.BANKING_EFFICIENCY: 239 case Vehicle.BANKING_EFFICIENCY:
@@ -251,7 +247,7 @@ namespace OpenSim.Region.Physics.OdePlugin
251 m_bankingMix = pValue; 247 m_bankingMix = pValue;
252 break; 248 break;
253 case Vehicle.BANKING_TIMESCALE: 249 case Vehicle.BANKING_TIMESCALE:
254 if (pValue < timestep) pValue = timestep; 250 if (pValue < m_timestep) pValue = m_timestep;
255 m_bankingTimescale = pValue; 251 m_bankingTimescale = pValue;
256 break; 252 break;
257 case Vehicle.BUOYANCY: 253 case Vehicle.BUOYANCY:
@@ -268,7 +264,7 @@ namespace OpenSim.Region.Physics.OdePlugin
268 m_VhoverHeight = pValue; 264 m_VhoverHeight = pValue;
269 break; 265 break;
270 case Vehicle.HOVER_TIMESCALE: 266 case Vehicle.HOVER_TIMESCALE:
271 if (pValue < timestep) pValue = timestep; 267 if (pValue < m_timestep) pValue = m_timestep;
272 m_VhoverTimescale = pValue; 268 m_VhoverTimescale = pValue;
273 break; 269 break;
274 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: 270 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
@@ -277,18 +273,16 @@ namespace OpenSim.Region.Physics.OdePlugin
277 m_linearDeflectionEfficiency = pValue; 273 m_linearDeflectionEfficiency = pValue;
278 break; 274 break;
279 case Vehicle.LINEAR_DEFLECTION_TIMESCALE: 275 case Vehicle.LINEAR_DEFLECTION_TIMESCALE:
280 if (pValue < timestep) pValue = timestep; 276 if (pValue < m_timestep) pValue = m_timestep;
281 m_linearDeflectionTimescale = pValue; 277 m_linearDeflectionTimescale = pValue;
282 break; 278 break;
283 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: 279 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
284 if (pValue < timestep) pValue = timestep; 280 if (pValue < m_timestep) pValue = m_timestep;
285 // try to make impulses to work a bit better
286 //if (pValue < 0.5f) pValue = 0.5f;
287 else if (pValue > 120) pValue = 120; 281 else if (pValue > 120) pValue = 120;
288 m_linearMotorDecayTimescale = pValue * invtimestep; 282 m_linearMotorDecayTimescale = pValue * m_invtimestep;
289 break; 283 break;
290 case Vehicle.LINEAR_MOTOR_TIMESCALE: 284 case Vehicle.LINEAR_MOTOR_TIMESCALE:
291 if (pValue < timestep) pValue = timestep; 285 if (pValue < m_timestep) pValue = m_timestep;
292 m_linearMotorTimescale = pValue; 286 m_linearMotorTimescale = pValue;
293 break; 287 break;
294 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: 288 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY:
@@ -297,14 +291,14 @@ namespace OpenSim.Region.Physics.OdePlugin
297 m_verticalAttractionEfficiency = pValue; 291 m_verticalAttractionEfficiency = pValue;
298 break; 292 break;
299 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: 293 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE:
300 if (pValue < timestep) pValue = timestep; 294 if (pValue < m_timestep) pValue = m_timestep;
301 m_verticalAttractionTimescale = pValue; 295 m_verticalAttractionTimescale = pValue;
302 break; 296 break;
303 297
304 // These are vector properties but the engine lets you use a single float value to 298 // These are vector properties but the engine lets you use a single float value to
305 // set all of the components to the same value 299 // set all of the components to the same value
306 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 300 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
307 if (pValue < timestep) pValue = timestep; 301 if (pValue < m_timestep) pValue = m_timestep;
308 m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); 302 m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue);
309 break; 303 break;
310 case Vehicle.ANGULAR_MOTOR_DIRECTION: 304 case Vehicle.ANGULAR_MOTOR_DIRECTION:
@@ -318,7 +312,7 @@ namespace OpenSim.Region.Physics.OdePlugin
318 d.BodyEnable(rootPrim.Body); 312 d.BodyEnable(rootPrim.Body);
319 break; 313 break;
320 case Vehicle.LINEAR_FRICTION_TIMESCALE: 314 case Vehicle.LINEAR_FRICTION_TIMESCALE:
321 if (pValue < timestep) pValue = timestep; 315 if (pValue < m_timestep) pValue = m_timestep;
322 m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); 316 m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue);
323 break; 317 break;
324 case Vehicle.LINEAR_MOTOR_DIRECTION: 318 case Vehicle.LINEAR_MOTOR_DIRECTION:
@@ -344,14 +338,13 @@ namespace OpenSim.Region.Physics.OdePlugin
344 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue) 338 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue)
345 { 339 {
346 float len; 340 float len;
347 float invtimestep = 1.0f / _pParentScene.ODE_STEPSIZE; 341
348 float timestep = _pParentScene.ODE_STEPSIZE;
349 switch (pParam) 342 switch (pParam)
350 { 343 {
351 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 344 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
352 if (pValue.X < timestep) pValue.X = timestep; 345 if (pValue.X < m_timestep) pValue.X = m_timestep;
353 if (pValue.Y < timestep) pValue.Y = timestep; 346 if (pValue.Y < m_timestep) pValue.Y = m_timestep;
354 if (pValue.Z < timestep) pValue.Z = timestep; 347 if (pValue.Z < m_timestep) pValue.Z = m_timestep;
355 348
356 m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); 349 m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
357 break; 350 break;
@@ -367,9 +360,9 @@ namespace OpenSim.Region.Physics.OdePlugin
367 d.BodyEnable(rootPrim.Body); 360 d.BodyEnable(rootPrim.Body);
368 break; 361 break;
369 case Vehicle.LINEAR_FRICTION_TIMESCALE: 362 case Vehicle.LINEAR_FRICTION_TIMESCALE:
370 if (pValue.X < timestep) pValue.X = timestep; 363 if (pValue.X < m_timestep) pValue.X = m_timestep;
371 if (pValue.Y < timestep) pValue.Y = timestep; 364 if (pValue.Y < m_timestep) pValue.Y = m_timestep;
372 if (pValue.Z < timestep) pValue.Z = timestep; 365 if (pValue.Z < m_timestep) pValue.Z = m_timestep;
373 m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); 366 m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
374 break; 367 break;
375 case Vehicle.LINEAR_MOTOR_DIRECTION: 368 case Vehicle.LINEAR_MOTOR_DIRECTION:
@@ -422,7 +415,6 @@ namespace OpenSim.Region.Physics.OdePlugin
422 415
423 internal void ProcessTypeChange(Vehicle pType) 416 internal void ProcessTypeChange(Vehicle pType)
424 { 417 {
425 float invtimestep = _pParentScene.ODE_STEPSIZE;
426 m_lmEfect = 0; 418 m_lmEfect = 0;
427 m_amEfect = 0; 419 m_amEfect = 0;
428 m_ffactor = 1f; 420 m_ffactor = 1f;
@@ -444,9 +436,9 @@ namespace OpenSim.Region.Physics.OdePlugin
444 m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); 436 m_linearFrictionTimescale = new Vector3(1000, 1000, 1000);
445 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); 437 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
446 m_linearMotorTimescale = 1000; 438 m_linearMotorTimescale = 1000;
447 m_linearMotorDecayTimescale = 120 * invtimestep; 439 m_linearMotorDecayTimescale = 120 * m_invtimestep;
448 m_angularMotorTimescale = 1000; 440 m_angularMotorTimescale = 1000;
449 m_angularMotorDecayTimescale = 1000 * invtimestep; 441 m_angularMotorDecayTimescale = 1000 * m_invtimestep;
450 m_VhoverHeight = 0; 442 m_VhoverHeight = 0;
451 m_VhoverEfficiency = 1; 443 m_VhoverEfficiency = 1;
452 m_VhoverTimescale = 1000; 444 m_VhoverTimescale = 1000;
@@ -468,9 +460,9 @@ namespace OpenSim.Region.Physics.OdePlugin
468 m_linearFrictionTimescale = new Vector3(30, 1, 1000); 460 m_linearFrictionTimescale = new Vector3(30, 1, 1000);
469 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); 461 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
470 m_linearMotorTimescale = 1000; 462 m_linearMotorTimescale = 1000;
471 m_linearMotorDecayTimescale = 120 * invtimestep; 463 m_linearMotorDecayTimescale = 120 * m_invtimestep;
472 m_angularMotorTimescale = 1000; 464 m_angularMotorTimescale = 1000;
473 m_angularMotorDecayTimescale = 120 * invtimestep; 465 m_angularMotorDecayTimescale = 120 * m_invtimestep;
474 m_VhoverHeight = 0; 466 m_VhoverHeight = 0;
475 m_VhoverEfficiency = 1; 467 m_VhoverEfficiency = 1;
476 m_VhoverTimescale = 10; 468 m_VhoverTimescale = 10;
@@ -491,9 +483,9 @@ namespace OpenSim.Region.Physics.OdePlugin
491 m_linearFrictionTimescale = new Vector3(100, 2, 1000); 483 m_linearFrictionTimescale = new Vector3(100, 2, 1000);
492 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); 484 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
493 m_linearMotorTimescale = 1; 485 m_linearMotorTimescale = 1;
494 m_linearMotorDecayTimescale = 60 * invtimestep; 486 m_linearMotorDecayTimescale = 60 * m_invtimestep;
495 m_angularMotorTimescale = 1; 487 m_angularMotorTimescale = 1;
496 m_angularMotorDecayTimescale = 0.8f * invtimestep; 488 m_angularMotorDecayTimescale = 0.8f * m_invtimestep;
497 m_VhoverHeight = 0; 489 m_VhoverHeight = 0;
498 m_VhoverEfficiency = 0; 490 m_VhoverEfficiency = 0;
499 m_VhoverTimescale = 1000; 491 m_VhoverTimescale = 1000;
@@ -515,9 +507,9 @@ namespace OpenSim.Region.Physics.OdePlugin
515 m_linearFrictionTimescale = new Vector3(10, 3, 2); 507 m_linearFrictionTimescale = new Vector3(10, 3, 2);
516 m_angularFrictionTimescale = new Vector3(10, 10, 10); 508 m_angularFrictionTimescale = new Vector3(10, 10, 10);
517 m_linearMotorTimescale = 5; 509 m_linearMotorTimescale = 5;
518 m_linearMotorDecayTimescale = 60 * invtimestep; 510 m_linearMotorDecayTimescale = 60 * m_invtimestep;
519 m_angularMotorTimescale = 4; 511 m_angularMotorTimescale = 4;
520 m_angularMotorDecayTimescale = 4 * invtimestep; 512 m_angularMotorDecayTimescale = 4 * m_invtimestep;
521 m_VhoverHeight = 0; 513 m_VhoverHeight = 0;
522 m_VhoverEfficiency = 0.5f; 514 m_VhoverEfficiency = 0.5f;
523 m_VhoverTimescale = 2; 515 m_VhoverTimescale = 2;
@@ -543,9 +535,9 @@ namespace OpenSim.Region.Physics.OdePlugin
543 m_linearFrictionTimescale = new Vector3(200, 10, 5); 535 m_linearFrictionTimescale = new Vector3(200, 10, 5);
544 m_angularFrictionTimescale = new Vector3(20, 20, 20); 536 m_angularFrictionTimescale = new Vector3(20, 20, 20);
545 m_linearMotorTimescale = 2; 537 m_linearMotorTimescale = 2;
546 m_linearMotorDecayTimescale = 60 * invtimestep; 538 m_linearMotorDecayTimescale = 60 * m_invtimestep;
547 m_angularMotorTimescale = 4; 539 m_angularMotorTimescale = 4;
548 m_angularMotorDecayTimescale = 8 * invtimestep; 540 m_angularMotorDecayTimescale = 8 * m_invtimestep;
549 m_VhoverHeight = 0; 541 m_VhoverHeight = 0;
550 m_VhoverEfficiency = 0.5f; 542 m_VhoverEfficiency = 0.5f;
551 m_VhoverTimescale = 1000; 543 m_VhoverTimescale = 1000;
@@ -571,15 +563,15 @@ namespace OpenSim.Region.Physics.OdePlugin
571 m_linearFrictionTimescale = new Vector3(5, 5, 5); 563 m_linearFrictionTimescale = new Vector3(5, 5, 5);
572 m_angularFrictionTimescale = new Vector3(10, 10, 10); 564 m_angularFrictionTimescale = new Vector3(10, 10, 10);
573 m_linearMotorTimescale = 5; 565 m_linearMotorTimescale = 5;
574 m_linearMotorDecayTimescale = 60 * invtimestep; 566 m_linearMotorDecayTimescale = 60 * m_invtimestep;
575 m_angularMotorTimescale = 6; 567 m_angularMotorTimescale = 6;
576 m_angularMotorDecayTimescale = 10 * invtimestep; 568 m_angularMotorDecayTimescale = 10 * m_invtimestep;
577 m_VhoverHeight = 5; 569 m_VhoverHeight = 5;
578 m_VhoverEfficiency = 0.8f; 570 m_VhoverEfficiency = 0.8f;
579 m_VhoverTimescale = 10; 571 m_VhoverTimescale = 10;
580 m_VehicleBuoyancy = 1; 572 m_VehicleBuoyancy = 1;
581 m_linearDeflectionEfficiency = 0; 573 m_linearDeflectionEfficiency = 0;
582 m_linearDeflectionTimescale = 5 * invtimestep; 574 m_linearDeflectionTimescale = 5 * m_invtimestep;
583 m_angularDeflectionEfficiency = 0; 575 m_angularDeflectionEfficiency = 0;
584 m_angularDeflectionTimescale = 5; 576 m_angularDeflectionTimescale = 5;
585 m_verticalAttractionEfficiency = 0f; 577 m_verticalAttractionEfficiency = 0f;
@@ -701,7 +693,7 @@ namespace OpenSim.Region.Physics.OdePlugin
701 return ; 693 return ;
702 } 694 }
703 695
704 internal void Step()//float pTimestep) 696 internal void Step()
705 { 697 {
706 IntPtr Body = rootPrim.Body; 698 IntPtr Body = rootPrim.Body;
707 699
@@ -780,30 +772,37 @@ namespace OpenSim.Region.Physics.OdePlugin
780 { 772 {
781 d.Vector3 pos = d.BodyGetPosition(Body); 773 d.Vector3 pos = d.BodyGetPosition(Body);
782 774
783 // default to global 775 float t = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y);
784 float perr = m_VhoverHeight - pos.Z;; 776 float perr;
785 777
786 if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) 778 // default to global but don't go underground
787 { 779 if (t < m_VhoverHeight)
788 perr += _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y); 780 perr = m_VhoverHeight - pos.Z;
789 } 781 else
790 else if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) 782 perr = t - pos.Z; ;
791 { 783
792 perr += _pParentScene.GetWaterLevel(); 784 if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) == 0)
793 }
794 else if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) == 0)
795 { 785 {
796 float t = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y); 786 if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0)
797 float w = _pParentScene.GetWaterLevel(); 787 {
798 if (t > w) 788 perr += _pParentScene.GetWaterLevel();
789 }
790 else if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
791 {
799 perr += t; 792 perr += t;
793 }
800 else 794 else
801 perr += w; 795 {
796 float w = _pParentScene.GetWaterLevel();
797 if (t > w)
798 perr += t;
799 else
800 perr += w;
801 }
802 } 802 }
803
804 if ((m_flags & VehicleFlag.HOVER_UP_ONLY) == 0 || perr > 0) 803 if ((m_flags & VehicleFlag.HOVER_UP_ONLY) == 0 || perr > 0)
805 { 804 {
806 force.Z += (perr / m_VhoverTimescale / m_VhoverTimescale - curVel.Z * m_VhoverEfficiency) / _pParentScene.ODE_STEPSIZE; 805 force.Z += (perr / m_VhoverTimescale / m_VhoverTimescale - curVel.Z * m_VhoverEfficiency) / m_timestep;
807 force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy); 806 force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy);
808 } 807 }
809 else // no buoyancy 808 else // no buoyancy
@@ -811,7 +810,7 @@ namespace OpenSim.Region.Physics.OdePlugin
811 } 810 }
812 else 811 else
813 { 812 {
814 // default gravity and buoancy 813 // default gravity and Buoyancy
815 force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy); 814 force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy);
816 } 815 }
817 816
@@ -819,24 +818,31 @@ namespace OpenSim.Region.Physics.OdePlugin
819 if (m_linearDeflectionEfficiency > 0) 818 if (m_linearDeflectionEfficiency > 0)
820 { 819 {
821 float len = curVel.Length(); 820 float len = curVel.Length();
822 Vector3 atAxis; 821 if (len > 0.01) // if moving
823 atAxis = Xrot(rotq); // where are we pointing to
824 atAxis *= len; // make it same size as world velocity vector
825 tmpV = -atAxis; // oposite direction
826 atAxis -= curVel; // error to one direction
827 len = atAxis.LengthSquared();
828 tmpV -= curVel; // error to oposite
829 float lens = tmpV.LengthSquared();
830 if (len > 0.01 || lens > 0.01) // do nothing if close enougth
831 { 822 {
832 if (len < lens)
833 tmpV = atAxis;
834 823
835 tmpV *= (m_linearDeflectionEfficiency / m_linearDeflectionTimescale); // error to correct in this timestep 824 Vector3 atAxis;
836 force.X += tmpV.X; 825 atAxis = Xrot(rotq); // where are we pointing to
837 force.Y += tmpV.Y; 826 atAxis *= len; // make it same size as world velocity vector
838 if ((m_flags & VehicleFlag.NO_DEFLECTION_UP) == 0) 827
839 force.Z += tmpV.Z; 828 tmpV = -atAxis; // oposite direction
829 atAxis -= curVel; // error to one direction
830 len = atAxis.LengthSquared();
831
832 tmpV -= curVel; // error to oposite
833 float lens = tmpV.LengthSquared();
834
835 if (len > 0.01 || lens > 0.01) // do nothing if close enougth
836 {
837 if (len < lens)
838 tmpV = atAxis;
839
840 tmpV *= (m_linearDeflectionEfficiency / m_linearDeflectionTimescale); // error to correct in this timestep
841 force.X += tmpV.X;
842 force.Y += tmpV.Y;
843 if ((m_flags & VehicleFlag.NO_DEFLECTION_UP) == 0)
844 force.Z += tmpV.Z;
845 }
840 } 846 }
841 } 847 }
842 848
@@ -900,10 +906,10 @@ namespace OpenSim.Region.Physics.OdePlugin
900 906
901 GetRollPitch(irotq, out roll, out pitch); 907 GetRollPitch(irotq, out roll, out pitch);
902 908
903 float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE; 909 float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale * m_invtimestep;
904 float ftmp2; 910 float ftmp2;
905 if (m_bankingEfficiency == 0) 911 if (m_bankingEfficiency == 0)
906 ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE; 912 ftmp2 = m_verticalAttractionEfficiency * m_invtimestep;
907 else 913 else
908 ftmp2 = 0; 914 ftmp2 = 0;
909 915
@@ -985,7 +991,7 @@ namespace OpenSim.Region.Physics.OdePlugin
985 if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) 991 if (torque.X != 0 || torque.Y != 0 || torque.Z != 0)
986 { 992 {
987 torque *= m_referenceFrame; // to object frame 993 torque *= m_referenceFrame; // to object frame
988 dtorque.X = torque.X; 994 dtorque.X = torque.X ;
989 dtorque.Y = torque.Y; 995 dtorque.Y = torque.Y;
990 dtorque.Z = torque.Z; 996 dtorque.Z = torque.Z;
991 997