diff options
author | Melanie | 2012-08-18 13:17:39 +0100 |
---|---|---|
committer | Melanie | 2012-08-18 13:17:39 +0100 |
commit | aee7a31bc3b5348c883e0d750bab991d853db642 (patch) | |
tree | 9d38c2ec7cc62019ab3ea95a3716d28e1451c397 /OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC-aee7a31bc3b5348c883e0d750bab991d853db642.zip opensim-SC-aee7a31bc3b5348c883e0d750bab991d853db642.tar.gz opensim-SC-aee7a31bc3b5348c883e0d750bab991d853db642.tar.bz2 opensim-SC-aee7a31bc3b5348c883e0d750bab991d853db642.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/Scene.cs
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 228 |
1 files changed, 47 insertions, 181 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 5a9f135..d7213fc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -57,6 +57,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
57 | private int frcount = 0; // Used to limit dynamics debug output to | 57 | private int frcount = 0; // Used to limit dynamics debug output to |
58 | // every 100th frame | 58 | // every 100th frame |
59 | 59 | ||
60 | private BSScene m_physicsScene; | ||
60 | private BSPrim m_prim; // the prim this dynamic controller belongs to | 61 | private BSPrim m_prim; // the prim this dynamic controller belongs to |
61 | 62 | ||
62 | // Vehicle properties | 63 | // Vehicle properties |
@@ -74,7 +75,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
74 | // HOVER_UP_ONLY | 75 | // HOVER_UP_ONLY |
75 | // LIMIT_MOTOR_UP | 76 | // LIMIT_MOTOR_UP |
76 | // LIMIT_ROLL_ONLY | 77 | // LIMIT_ROLL_ONLY |
77 | private VehicleFlag m_Hoverflags = (VehicleFlag)0; | ||
78 | private Vector3 m_BlockingEndPoint = Vector3.Zero; | 78 | private Vector3 m_BlockingEndPoint = Vector3.Zero; |
79 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; | 79 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; |
80 | // Linear properties | 80 | // Linear properties |
@@ -124,15 +124,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
124 | private float m_verticalAttractionEfficiency = 1.0f; // damped | 124 | private float m_verticalAttractionEfficiency = 1.0f; // damped |
125 | private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. | 125 | private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. |
126 | 126 | ||
127 | public BSDynamics(BSPrim myPrim) | 127 | public BSDynamics(BSScene myScene, BSPrim myPrim) |
128 | { | 128 | { |
129 | m_physicsScene = myScene; | ||
129 | m_prim = myPrim; | 130 | m_prim = myPrim; |
130 | m_type = Vehicle.TYPE_NONE; | 131 | m_type = Vehicle.TYPE_NONE; |
131 | } | 132 | } |
132 | 133 | ||
133 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep) | 134 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep) |
134 | { | 135 | { |
135 | DetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); | 136 | VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); |
136 | switch (pParam) | 137 | switch (pParam) |
137 | { | 138 | { |
138 | case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: | 139 | case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: |
@@ -231,7 +232,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
231 | 232 | ||
232 | internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep) | 233 | internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep) |
233 | { | 234 | { |
234 | DetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); | 235 | VDetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); |
235 | switch (pParam) | 236 | switch (pParam) |
236 | { | 237 | { |
237 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: | 238 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: |
@@ -266,7 +267,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
266 | 267 | ||
267 | internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) | 268 | internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) |
268 | { | 269 | { |
269 | DetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); | 270 | VDetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); |
270 | switch (pParam) | 271 | switch (pParam) |
271 | { | 272 | { |
272 | case Vehicle.REFERENCE_FRAME: | 273 | case Vehicle.REFERENCE_FRAME: |
@@ -280,164 +281,27 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
280 | 281 | ||
281 | internal void ProcessVehicleFlags(int pParam, bool remove) | 282 | internal void ProcessVehicleFlags(int pParam, bool remove) |
282 | { | 283 | { |
283 | DetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove); | 284 | VDetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove); |
285 | VehicleFlag parm = (VehicleFlag)pParam; | ||
284 | if (remove) | 286 | if (remove) |
285 | { | 287 | { |
286 | if (pParam == -1) | 288 | if (pParam == -1) |
287 | { | 289 | { |
288 | m_flags = (VehicleFlag)0; | 290 | m_flags = (VehicleFlag)0; |
289 | m_Hoverflags = (VehicleFlag)0; | ||
290 | return; | ||
291 | } | 291 | } |
292 | if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) | 292 | else |
293 | { | ||
294 | if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != (VehicleFlag)0) | ||
295 | m_Hoverflags &= ~(VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
296 | } | ||
297 | if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY) | ||
298 | { | ||
299 | if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != (VehicleFlag)0) | ||
300 | m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY); | ||
301 | } | ||
302 | if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY) | ||
303 | { | ||
304 | if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != (VehicleFlag)0) | ||
305 | m_Hoverflags &= ~(VehicleFlag.HOVER_UP_ONLY); | ||
306 | } | ||
307 | if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY) | ||
308 | { | ||
309 | if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != (VehicleFlag)0) | ||
310 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY); | ||
311 | } | ||
312 | if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP) | ||
313 | { | ||
314 | if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != (VehicleFlag)0) | ||
315 | m_flags &= ~(VehicleFlag.LIMIT_MOTOR_UP); | ||
316 | } | ||
317 | if ((pParam & (int)VehicleFlag.LIMIT_ROLL_ONLY) == (int)VehicleFlag.LIMIT_ROLL_ONLY) | ||
318 | { | ||
319 | if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) != (VehicleFlag)0) | ||
320 | m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); | ||
321 | } | ||
322 | if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK) | ||
323 | { | ||
324 | if ((m_flags & VehicleFlag.MOUSELOOK_BANK) != (VehicleFlag)0) | ||
325 | m_flags &= ~(VehicleFlag.MOUSELOOK_BANK); | ||
326 | } | ||
327 | if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER) | ||
328 | { | ||
329 | if ((m_flags & VehicleFlag.MOUSELOOK_STEER) != (VehicleFlag)0) | ||
330 | m_flags &= ~(VehicleFlag.MOUSELOOK_STEER); | ||
331 | } | ||
332 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP) | ||
333 | { | ||
334 | if ((m_flags & VehicleFlag.NO_DEFLECTION_UP) != (VehicleFlag)0) | ||
335 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP); | ||
336 | } | ||
337 | if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED) | ||
338 | { | ||
339 | if ((m_flags & VehicleFlag.CAMERA_DECOUPLED) != (VehicleFlag)0) | ||
340 | m_flags &= ~(VehicleFlag.CAMERA_DECOUPLED); | ||
341 | } | ||
342 | if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X) | ||
343 | { | ||
344 | if ((m_flags & VehicleFlag.NO_X) != (VehicleFlag)0) | ||
345 | m_flags &= ~(VehicleFlag.NO_X); | ||
346 | } | ||
347 | if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y) | ||
348 | { | ||
349 | if ((m_flags & VehicleFlag.NO_Y) != (VehicleFlag)0) | ||
350 | m_flags &= ~(VehicleFlag.NO_Y); | ||
351 | } | ||
352 | if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z) | ||
353 | { | ||
354 | if ((m_flags & VehicleFlag.NO_Z) != (VehicleFlag)0) | ||
355 | m_flags &= ~(VehicleFlag.NO_Z); | ||
356 | } | ||
357 | if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT) | ||
358 | { | ||
359 | if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != (VehicleFlag)0) | ||
360 | m_Hoverflags &= ~(VehicleFlag.LOCK_HOVER_HEIGHT); | ||
361 | } | ||
362 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION) | ||
363 | { | ||
364 | if ((m_flags & VehicleFlag.NO_DEFLECTION) != (VehicleFlag)0) | ||
365 | m_flags &= ~(VehicleFlag.NO_DEFLECTION); | ||
366 | } | ||
367 | if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION) | ||
368 | { | 293 | { |
369 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != (VehicleFlag)0) | 294 | m_flags &= ~parm; |
370 | m_flags &= ~(VehicleFlag.LOCK_ROTATION); | ||
371 | } | 295 | } |
372 | } | 296 | } |
373 | else | 297 | else { |
374 | { | 298 | m_flags |= parm; |
375 | if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) | ||
376 | { | ||
377 | m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT | m_flags); | ||
378 | } | ||
379 | if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY) | ||
380 | { | ||
381 | m_Hoverflags |= (VehicleFlag.HOVER_TERRAIN_ONLY | m_flags); | ||
382 | } | ||
383 | if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY) | ||
384 | { | ||
385 | m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY | m_flags); | ||
386 | } | ||
387 | if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY) | ||
388 | { | ||
389 | m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY | m_flags); | ||
390 | } | ||
391 | if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP) | ||
392 | { | ||
393 | m_flags |= (VehicleFlag.LIMIT_MOTOR_UP | m_flags); | ||
394 | } | ||
395 | if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK) | ||
396 | { | ||
397 | m_flags |= (VehicleFlag.MOUSELOOK_BANK | m_flags); | ||
398 | } | ||
399 | if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER) | ||
400 | { | ||
401 | m_flags |= (VehicleFlag.MOUSELOOK_STEER | m_flags); | ||
402 | } | ||
403 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP) | ||
404 | { | ||
405 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | m_flags); | ||
406 | } | ||
407 | if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED) | ||
408 | { | ||
409 | m_flags |= (VehicleFlag.CAMERA_DECOUPLED | m_flags); | ||
410 | } | ||
411 | if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X) | ||
412 | { | ||
413 | m_flags |= (VehicleFlag.NO_X); | ||
414 | } | ||
415 | if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y) | ||
416 | { | ||
417 | m_flags |= (VehicleFlag.NO_Y); | ||
418 | } | ||
419 | if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z) | ||
420 | { | ||
421 | m_flags |= (VehicleFlag.NO_Z); | ||
422 | } | ||
423 | if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT) | ||
424 | { | ||
425 | m_Hoverflags |= (VehicleFlag.LOCK_HOVER_HEIGHT); | ||
426 | } | ||
427 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION) | ||
428 | { | ||
429 | m_flags |= (VehicleFlag.NO_DEFLECTION); | ||
430 | } | ||
431 | if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION) | ||
432 | { | ||
433 | m_flags |= (VehicleFlag.LOCK_ROTATION); | ||
434 | } | ||
435 | } | 299 | } |
436 | }//end ProcessVehicleFlags | 300 | }//end ProcessVehicleFlags |
437 | 301 | ||
438 | internal void ProcessTypeChange(Vehicle pType) | 302 | internal void ProcessTypeChange(Vehicle pType, float stepSize) |
439 | { | 303 | { |
440 | DetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType); | 304 | VDetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType); |
441 | // Set Defaults For Type | 305 | // Set Defaults For Type |
442 | m_type = pType; | 306 | m_type = pType; |
443 | switch (pType) | 307 | switch (pType) |
@@ -478,10 +342,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
478 | // m_bankingMix = 1; | 342 | // m_bankingMix = 1; |
479 | // m_bankingTimescale = 10; | 343 | // m_bankingTimescale = 10; |
480 | // m_referenceFrame = Quaternion.Identity; | 344 | // m_referenceFrame = Quaternion.Identity; |
481 | m_Hoverflags &= | 345 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); |
346 | m_flags &= | ||
482 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 347 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | |
483 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 348 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); |
484 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); | ||
485 | break; | 349 | break; |
486 | case Vehicle.TYPE_CAR: | 350 | case Vehicle.TYPE_CAR: |
487 | m_linearFrictionTimescale = new Vector3(100, 2, 1000); | 351 | m_linearFrictionTimescale = new Vector3(100, 2, 1000); |
@@ -506,10 +370,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
506 | // m_bankingMix = 1; | 370 | // m_bankingMix = 1; |
507 | // m_bankingTimescale = 1; | 371 | // m_bankingTimescale = 1; |
508 | // m_referenceFrame = Quaternion.Identity; | 372 | // m_referenceFrame = Quaternion.Identity; |
509 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
510 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | | 373 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | |
511 | VehicleFlag.LIMIT_MOTOR_UP); | 374 | VehicleFlag.LIMIT_MOTOR_UP); |
512 | m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY); | 375 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); |
376 | m_flags |= (VehicleFlag.HOVER_UP_ONLY); | ||
513 | break; | 377 | break; |
514 | case Vehicle.TYPE_BOAT: | 378 | case Vehicle.TYPE_BOAT: |
515 | m_linearFrictionTimescale = new Vector3(10, 3, 2); | 379 | m_linearFrictionTimescale = new Vector3(10, 3, 2); |
@@ -534,12 +398,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
534 | // m_bankingMix = 0.8f; | 398 | // m_bankingMix = 0.8f; |
535 | // m_bankingTimescale = 1; | 399 | // m_bankingTimescale = 1; |
536 | // m_referenceFrame = Quaternion.Identity; | 400 | // m_referenceFrame = Quaternion.Identity; |
537 | m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | | 401 | m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | |
538 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 402 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); |
539 | m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); | 403 | m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); |
540 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | | 404 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | |
541 | VehicleFlag.LIMIT_MOTOR_UP); | 405 | VehicleFlag.LIMIT_MOTOR_UP); |
542 | m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY); | 406 | m_flags |= (VehicleFlag.HOVER_WATER_ONLY); |
543 | break; | 407 | break; |
544 | case Vehicle.TYPE_AIRPLANE: | 408 | case Vehicle.TYPE_AIRPLANE: |
545 | m_linearFrictionTimescale = new Vector3(200, 10, 5); | 409 | m_linearFrictionTimescale = new Vector3(200, 10, 5); |
@@ -564,7 +428,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
564 | // m_bankingMix = 0.7f; | 428 | // m_bankingMix = 0.7f; |
565 | // m_bankingTimescale = 2; | 429 | // m_bankingTimescale = 2; |
566 | // m_referenceFrame = Quaternion.Identity; | 430 | // m_referenceFrame = Quaternion.Identity; |
567 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 431 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | |
568 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 432 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); |
569 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); | 433 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); |
570 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | 434 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); |
@@ -592,11 +456,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
592 | // m_bankingMix = 0.7f; | 456 | // m_bankingMix = 0.7f; |
593 | // m_bankingTimescale = 5; | 457 | // m_bankingTimescale = 5; |
594 | // m_referenceFrame = Quaternion.Identity; | 458 | // m_referenceFrame = Quaternion.Identity; |
595 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 459 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | |
596 | VehicleFlag.HOVER_UP_ONLY); | 460 | VehicleFlag.HOVER_UP_ONLY); |
597 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); | 461 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); |
598 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | 462 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); |
599 | m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT); | 463 | m_flags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT); |
600 | break; | 464 | break; |
601 | } | 465 | } |
602 | }//end SetDefaultsForType | 466 | }//end SetDefaultsForType |
@@ -613,7 +477,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
613 | MoveAngular(pTimestep); | 477 | MoveAngular(pTimestep); |
614 | LimitRotation(pTimestep); | 478 | LimitRotation(pTimestep); |
615 | 479 | ||
616 | DetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", | 480 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", |
617 | m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity); | 481 | m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity); |
618 | }// end Step | 482 | }// end Step |
619 | 483 | ||
@@ -657,7 +521,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
657 | 521 | ||
658 | */ | 522 | */ |
659 | 523 | ||
660 | DetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}", | 524 | VDetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}", |
661 | m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector); | 525 | m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector); |
662 | } | 526 | } |
663 | else | 527 | else |
@@ -669,7 +533,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
669 | m_lastLinearVelocityVector = Vector3.Zero; | 533 | m_lastLinearVelocityVector = Vector3.Zero; |
670 | } | 534 | } |
671 | 535 | ||
672 | // convert requested object velocity to world-referenced vector | 536 | // convert requested object velocity to object relative vector |
673 | Quaternion rotq = m_prim.Orientation; | 537 | Quaternion rotq = m_prim.Orientation; |
674 | m_dir = m_lastLinearVelocityVector * rotq; | 538 | m_dir = m_lastLinearVelocityVector * rotq; |
675 | 539 | ||
@@ -722,7 +586,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
722 | if (changed) | 586 | if (changed) |
723 | { | 587 | { |
724 | m_prim.Position = pos; | 588 | m_prim.Position = pos; |
725 | DetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", | 589 | VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", |
726 | m_prim.LocalID, m_BlockingEndPoint, posChange, pos); | 590 | m_prim.LocalID, m_BlockingEndPoint, posChange, pos); |
727 | } | 591 | } |
728 | } | 592 | } |
@@ -732,32 +596,32 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
732 | { | 596 | { |
733 | pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2; | 597 | pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2; |
734 | m_prim.Position = pos; | 598 | m_prim.Position = pos; |
735 | DetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos); | 599 | VDetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos); |
736 | } | 600 | } |
737 | 601 | ||
738 | // Check if hovering | 602 | // Check if hovering |
739 | if ((m_Hoverflags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) | 603 | if ((m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) |
740 | { | 604 | { |
741 | // We should hover, get the target height | 605 | // We should hover, get the target height |
742 | if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != 0) | 606 | if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) |
743 | { | 607 | { |
744 | m_VhoverTargetHeight = m_prim.Scene.GetWaterLevel() + m_VhoverHeight; | 608 | m_VhoverTargetHeight = m_prim.Scene.GetWaterLevel() + m_VhoverHeight; |
745 | } | 609 | } |
746 | if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) | 610 | if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) |
747 | { | 611 | { |
748 | m_VhoverTargetHeight = m_prim.Scene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight; | 612 | m_VhoverTargetHeight = m_prim.Scene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight; |
749 | } | 613 | } |
750 | if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) | 614 | if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) |
751 | { | 615 | { |
752 | m_VhoverTargetHeight = m_VhoverHeight; | 616 | m_VhoverTargetHeight = m_VhoverHeight; |
753 | } | 617 | } |
754 | 618 | ||
755 | if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != 0) | 619 | if ((m_flags & VehicleFlag.HOVER_UP_ONLY) != 0) |
756 | { | 620 | { |
757 | // If body is aready heigher, use its height as target height | 621 | // If body is aready heigher, use its height as target height |
758 | if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; | 622 | if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; |
759 | } | 623 | } |
760 | if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) | 624 | if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) |
761 | { | 625 | { |
762 | if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) | 626 | if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) |
763 | { | 627 | { |
@@ -779,7 +643,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
779 | } | 643 | } |
780 | } | 644 | } |
781 | 645 | ||
782 | DetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight); | 646 | VDetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight); |
783 | 647 | ||
784 | // m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped | 648 | // m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped |
785 | // m_VhoverTimescale = 0f; // time to acheive height | 649 | // m_VhoverTimescale = 0f; // time to acheive height |
@@ -815,7 +679,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
815 | { | 679 | { |
816 | grav.Z = (float)(grav.Z * 1.037125); | 680 | grav.Z = (float)(grav.Z * 1.037125); |
817 | } | 681 | } |
818 | DetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav); | 682 | VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav); |
819 | //End Experimental Values | 683 | //End Experimental Values |
820 | } | 684 | } |
821 | if ((m_flags & (VehicleFlag.NO_X)) != 0) | 685 | if ((m_flags & (VehicleFlag.NO_X)) != 0) |
@@ -844,7 +708,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
844 | Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep); | 708 | Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep); |
845 | m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount; | 709 | m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount; |
846 | 710 | ||
847 | DetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}", | 711 | VDetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}", |
848 | m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount); | 712 | m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount); |
849 | 713 | ||
850 | } // end MoveLinear() | 714 | } // end MoveLinear() |
@@ -870,13 +734,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
870 | // There are m_angularMotorApply steps. | 734 | // There are m_angularMotorApply steps. |
871 | Vector3 origAngularVelocity = m_angularMotorVelocity; | 735 | Vector3 origAngularVelocity = m_angularMotorVelocity; |
872 | // ramp up to new value | 736 | // ramp up to new value |
873 | // current velocity += error / (time to get there / step interval) | 737 | // current velocity += error / (time to get there / step interval) |
874 | // requested speed - last motor speed | 738 | // requested speed - last motor speed |
875 | m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); | 739 | m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); |
876 | m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); | 740 | m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); |
877 | m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); | 741 | m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); |
878 | 742 | ||
879 | DetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}", | 743 | VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}", |
880 | m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); | 744 | m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); |
881 | 745 | ||
882 | m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected | 746 | m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected |
@@ -887,6 +751,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
887 | // No motor recently applied, keep the body velocity | 751 | // No motor recently applied, keep the body velocity |
888 | // and decay the velocity | 752 | // and decay the velocity |
889 | m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep); | 753 | m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep); |
754 | if (m_angularMotorVelocity.LengthSquared() < 0.00001) | ||
755 | m_angularMotorVelocity = Vector3.Zero; | ||
890 | } // end motor section | 756 | } // end motor section |
891 | 757 | ||
892 | // Vertical attractor section | 758 | // Vertical attractor section |
@@ -924,7 +790,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
924 | vertattr.X += bounce * angularVelocity.X; | 790 | vertattr.X += bounce * angularVelocity.X; |
925 | vertattr.Y += bounce * angularVelocity.Y; | 791 | vertattr.Y += bounce * angularVelocity.Y; |
926 | 792 | ||
927 | DetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}", | 793 | VDetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}", |
928 | m_prim.LocalID, verterr, bounce, vertattr); | 794 | m_prim.LocalID, verterr, bounce, vertattr); |
929 | 795 | ||
930 | } // else vertical attractor is off | 796 | } // else vertical attractor is off |
@@ -942,13 +808,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
942 | { | 808 | { |
943 | m_lastAngularVelocity.X = 0; | 809 | m_lastAngularVelocity.X = 0; |
944 | m_lastAngularVelocity.Y = 0; | 810 | m_lastAngularVelocity.Y = 0; |
945 | DetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); | 811 | VDetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); |
946 | } | 812 | } |
947 | 813 | ||
948 | if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) | 814 | if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) |
949 | { | 815 | { |
950 | m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. | 816 | m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. |
951 | DetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); | 817 | VDetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); |
952 | } | 818 | } |
953 | 819 | ||
954 | // apply friction | 820 | // apply friction |
@@ -958,7 +824,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
958 | // Apply to the body | 824 | // Apply to the body |
959 | m_prim.RotationalVelocity = m_lastAngularVelocity; | 825 | m_prim.RotationalVelocity = m_lastAngularVelocity; |
960 | 826 | ||
961 | DetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity); | 827 | VDetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity); |
962 | } //end MoveAngular | 828 | } //end MoveAngular |
963 | 829 | ||
964 | internal void LimitRotation(float timestep) | 830 | internal void LimitRotation(float timestep) |
@@ -1005,11 +871,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1005 | if (changed) | 871 | if (changed) |
1006 | m_prim.Orientation = m_rot; | 872 | m_prim.Orientation = m_rot; |
1007 | 873 | ||
1008 | DetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot); | 874 | VDetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot); |
1009 | } | 875 | } |
1010 | 876 | ||
1011 | // Invoke the detailed logger and output something if it's enabled. | 877 | // Invoke the detailed logger and output something if it's enabled. |
1012 | private void DetailLog(string msg, params Object[] args) | 878 | private void VDetailLog(string msg, params Object[] args) |
1013 | { | 879 | { |
1014 | if (m_prim.Scene.VehicleLoggingEnabled) | 880 | if (m_prim.Scene.VehicleLoggingEnabled) |
1015 | m_prim.Scene.PhysicsLogging.Write(msg, args); | 881 | m_prim.Scene.PhysicsLogging.Write(msg, args); |