diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 218 |
1 files changed, 96 insertions, 122 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 8169e99..098fea7 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
80 | // Linear properties | 80 | // Linear properties |
81 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time | 81 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time |
82 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL | 82 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL |
83 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body | 83 | private Vector3 m_newVelocity = Vector3.Zero; // velocity computed to be applied to body |
84 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; | 84 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; |
85 | private float m_linearMotorDecayTimescale = 0; | 85 | private float m_linearMotorDecayTimescale = 0; |
86 | private float m_linearMotorTimescale = 0; | 86 | private float m_linearMotorTimescale = 0; |
@@ -475,32 +475,33 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
475 | frcount = 0; | 475 | frcount = 0; |
476 | 476 | ||
477 | MoveLinear(pTimestep); | 477 | MoveLinear(pTimestep); |
478 | MoveAngular(pTimestep); | 478 | // MoveAngular(pTimestep); |
479 | LimitRotation(pTimestep); | 479 | LimitRotation(pTimestep); |
480 | 480 | ||
481 | // remember the position so next step we can limit absolute movement effects | ||
482 | m_lastPositionVector = m_prim.Position; | ||
483 | |||
481 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", | 484 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", |
482 | m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity); | 485 | m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity); |
483 | }// end Step | 486 | }// end Step |
484 | 487 | ||
485 | private void MoveLinear(float pTimestep) | 488 | private void MoveLinear(float pTimestep) |
486 | { | 489 | { |
487 | // requested m_linearMotorDirection is significant | 490 | // m_linearMotorDirection is the direction we are moving relative to the vehicle coordinates |
488 | // if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) | 491 | // m_lastLinearVelocityVector is the speed we are moving in that direction |
489 | if (m_linearMotorDirection.LengthSquared() > 0.0001f) | 492 | if (m_linearMotorDirection.LengthSquared() > 0.001f) |
490 | { | 493 | { |
491 | Vector3 origDir = m_linearMotorDirection; | 494 | Vector3 origDir = m_linearMotorDirection; |
492 | Vector3 origVel = m_lastLinearVelocityVector; | 495 | Vector3 origVel = m_lastLinearVelocityVector; |
493 | 496 | ||
494 | // add drive to body | 497 | // add drive to body |
495 | // Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep); | 498 | // Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale / pTimestep); |
496 | Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale); | 499 | Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/(m_linearMotorTimescale / pTimestep); |
497 | // lastLinearVelocityVector is the current body velocity vector? | 500 | // lastLinearVelocityVector is the current body velocity vector |
498 | // RA: Not sure what the *10 is for. A correction for pTimestep? | 501 | // RA: Not sure what the *10 is for. A correction for pTimestep? |
499 | // m_lastLinearVelocityVector += (addAmount*10); | 502 | // m_lastLinearVelocityVector += (addAmount*10); |
500 | m_lastLinearVelocityVector += addAmount; | 503 | m_lastLinearVelocityVector += addAmount; |
501 | 504 | ||
502 | // This will work temporarily, but we really need to compare speed on an axis | ||
503 | // KF: Limit body velocity to applied velocity? | ||
504 | // Limit the velocity vector to less than the last set linear motor direction | 505 | // Limit the velocity vector to less than the last set linear motor direction |
505 | if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X)) | 506 | if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X)) |
506 | m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X; | 507 | m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X; |
@@ -509,34 +510,29 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
509 | if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z)) | 510 | if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z)) |
510 | m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z; | 511 | m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z; |
511 | 512 | ||
513 | /* | ||
512 | // decay applied velocity | 514 | // decay applied velocity |
513 | Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep))); | 515 | Vector3 decayfraction = Vector3.One/(m_linearMotorDecayTimescale / pTimestep); |
516 | // (RA: do not know where the 0.5f comes from) | ||
514 | m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f; | 517 | m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f; |
515 | |||
516 | /* | ||
517 | Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/m_linearMotorTimescale; | ||
518 | m_lastLinearVelocityVector += addAmount; | ||
519 | |||
520 | float decayfraction = (1.0f - 1.0f / m_linearMotorDecayTimescale); | ||
521 | m_linearMotorDirection *= decayfraction; | ||
522 | |||
523 | */ | 518 | */ |
519 | float keepfraction = 1.0f - (1.0f / (m_linearMotorDecayTimescale / pTimestep)); | ||
520 | m_linearMotorDirection *= keepfraction; | ||
524 | 521 | ||
525 | VDetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}", | 522 | VDetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},notDecay={4},dir={5},vel={6}", |
526 | m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector); | 523 | m_prim.LocalID, origDir, origVel, addAmount, keepfraction, m_linearMotorDirection, m_lastLinearVelocityVector); |
527 | } | 524 | } |
528 | else | 525 | else |
529 | { | 526 | { |
530 | // if what remains of applied is small, zero it. | 527 | // if what remains of direction is very small, zero it. |
531 | // if (m_lastLinearVelocityVector.ApproxEquals(Vector3.Zero, 0.01f)) | ||
532 | // m_lastLinearVelocityVector = Vector3.Zero; | ||
533 | m_linearMotorDirection = Vector3.Zero; | 528 | m_linearMotorDirection = Vector3.Zero; |
534 | m_lastLinearVelocityVector = Vector3.Zero; | 529 | m_lastLinearVelocityVector = Vector3.Zero; |
530 | VDetailLog("{0},MoveLinear,zeroed", m_prim.LocalID); | ||
535 | } | 531 | } |
536 | 532 | ||
537 | // convert requested object velocity to object relative vector | 533 | // convert requested object velocity to object relative vector |
538 | Quaternion rotq = m_prim.Orientation; | 534 | Quaternion rotq = m_prim.Orientation; |
539 | m_dir = m_lastLinearVelocityVector * rotq; | 535 | m_newVelocity = m_lastLinearVelocityVector * rotq; |
540 | 536 | ||
541 | // Add the various forces into m_dir which will be our new direction vector (velocity) | 537 | // Add the various forces into m_dir which will be our new direction vector (velocity) |
542 | 538 | ||
@@ -544,60 +540,31 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
544 | // KF: So far I have found no good method to combine a script-requested | 540 | // KF: So far I have found no good method to combine a script-requested |
545 | // .Z velocity and gravity. Therefore only 0g will used script-requested | 541 | // .Z velocity and gravity. Therefore only 0g will used script-requested |
546 | // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. | 542 | // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. |
547 | Vector3 grav = Vector3.Zero; | ||
548 | // There is some gravity, make a gravity force vector that is applied after object velocity. | 543 | // There is some gravity, make a gravity force vector that is applied after object velocity. |
549 | // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; | 544 | // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; |
550 | grav.Z = m_prim.Scene.DefaultGravity.Z * m_prim.Mass * (1f - m_VehicleBuoyancy); | 545 | Vector3 grav = m_prim.Scene.DefaultGravity * (m_prim.Mass * (1f - m_VehicleBuoyancy)); |
546 | |||
547 | /* | ||
548 | * RA: Not sure why one would do this | ||
551 | // Preserve the current Z velocity | 549 | // Preserve the current Z velocity |
552 | Vector3 vel_now = m_prim.Velocity; | 550 | Vector3 vel_now = m_prim.Velocity; |
553 | m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity | 551 | m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity |
552 | */ | ||
554 | 553 | ||
555 | Vector3 pos = m_prim.Position; | 554 | Vector3 pos = m_prim.Position; |
556 | Vector3 posChange = pos; | ||
557 | // Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f); | 555 | // Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f); |
558 | double Zchange = Math.Abs(posChange.Z); | ||
559 | if (m_BlockingEndPoint != Vector3.Zero) | ||
560 | { | ||
561 | bool changed = false; | ||
562 | if (pos.X >= (m_BlockingEndPoint.X - (float)1)) | ||
563 | { | ||
564 | pos.X -= posChange.X + 1; | ||
565 | changed = true; | ||
566 | } | ||
567 | if (pos.Y >= (m_BlockingEndPoint.Y - (float)1)) | ||
568 | { | ||
569 | pos.Y -= posChange.Y + 1; | ||
570 | changed = true; | ||
571 | } | ||
572 | if (pos.Z >= (m_BlockingEndPoint.Z - (float)1)) | ||
573 | { | ||
574 | pos.Z -= posChange.Z + 1; | ||
575 | changed = true; | ||
576 | } | ||
577 | if (pos.X <= 0) | ||
578 | { | ||
579 | pos.X += posChange.X + 1; | ||
580 | changed = true; | ||
581 | } | ||
582 | if (pos.Y <= 0) | ||
583 | { | ||
584 | pos.Y += posChange.Y + 1; | ||
585 | changed = true; | ||
586 | } | ||
587 | if (changed) | ||
588 | { | ||
589 | m_prim.Position = pos; | ||
590 | VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", | ||
591 | m_prim.LocalID, m_BlockingEndPoint, posChange, pos); | ||
592 | } | ||
593 | } | ||
594 | 556 | ||
595 | // If below the terrain, move us above the ground a little. | 557 | // If below the terrain, move us above the ground a little. |
596 | if (pos.Z < m_prim.Scene.TerrainManager.GetTerrainHeightAtXYZ(pos)) | 558 | float terrainHeight = m_prim.Scene.TerrainManager.GetTerrainHeightAtXYZ(pos); |
559 | // Taking the rotated size doesn't work here because m_prim.Size is the size of the root prim and not the linkset. | ||
560 | // Need to add a m_prim.LinkSet.Size similar to m_prim.LinkSet.Mass. | ||
561 | // Vector3 rotatedSize = m_prim.Size * m_prim.Orientation; | ||
562 | // if (rotatedSize.Z < terrainHeight) | ||
563 | if (pos.Z < terrainHeight) | ||
597 | { | 564 | { |
598 | pos.Z = m_prim.Scene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 2; | 565 | pos.Z = terrainHeight + 2; |
599 | m_prim.Position = pos; | 566 | m_prim.Position = pos; |
600 | VDetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos); | 567 | VDetailLog("{0},MoveLinear,terrainHeight,terrainHeight={1},pos={2}", m_prim.LocalID, terrainHeight, pos); |
601 | } | 568 | } |
602 | 569 | ||
603 | // Check if hovering | 570 | // Check if hovering |
@@ -606,11 +573,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
606 | // We should hover, get the target height | 573 | // We should hover, get the target height |
607 | if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) | 574 | if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) |
608 | { | 575 | { |
609 | m_VhoverTargetHeight = m_prim.Scene.GetWaterLevel() + m_VhoverHeight; | 576 | m_VhoverTargetHeight = m_prim.Scene.GetWaterLevelAtXYZ(pos) + m_VhoverHeight; |
610 | } | 577 | } |
611 | if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) | 578 | if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) |
612 | { | 579 | { |
613 | m_VhoverTargetHeight = m_prim.Scene.TerrainManager.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight; | 580 | m_VhoverTargetHeight = terrainHeight + m_VhoverHeight; |
614 | } | 581 | } |
615 | if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) | 582 | if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) |
616 | { | 583 | { |
@@ -635,82 +602,92 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
635 | // Replace Vertical speed with correction figure if significant | 602 | // Replace Vertical speed with correction figure if significant |
636 | if (Math.Abs(herr0) > 0.01f) | 603 | if (Math.Abs(herr0) > 0.01f) |
637 | { | 604 | { |
638 | m_dir.Z = -((herr0 * pTimestep * 50.0f) / m_VhoverTimescale); | 605 | m_newVelocity.Z = -((herr0 * pTimestep * 50.0f) / m_VhoverTimescale); |
639 | //KF: m_VhoverEfficiency is not yet implemented | 606 | //KF: m_VhoverEfficiency is not yet implemented |
640 | } | 607 | } |
641 | else | 608 | else |
642 | { | 609 | { |
643 | m_dir.Z = 0f; | 610 | m_newVelocity.Z = 0f; |
644 | } | 611 | } |
645 | } | 612 | } |
646 | 613 | ||
647 | VDetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight); | 614 | VDetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_newVelocity, m_VhoverHeight, m_VhoverTargetHeight); |
615 | } | ||
648 | 616 | ||
649 | // m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped | 617 | Vector3 posChange = pos - m_lastPositionVector; |
650 | // m_VhoverTimescale = 0f; // time to acheive height | 618 | if (m_BlockingEndPoint != Vector3.Zero) |
651 | // pTimestep is time since last frame,in secs | 619 | { |
620 | bool changed = false; | ||
621 | if (pos.X >= (m_BlockingEndPoint.X - (float)1)) | ||
622 | { | ||
623 | pos.X -= posChange.X + 1; | ||
624 | changed = true; | ||
625 | } | ||
626 | if (pos.Y >= (m_BlockingEndPoint.Y - (float)1)) | ||
627 | { | ||
628 | pos.Y -= posChange.Y + 1; | ||
629 | changed = true; | ||
630 | } | ||
631 | if (pos.Z >= (m_BlockingEndPoint.Z - (float)1)) | ||
632 | { | ||
633 | pos.Z -= posChange.Z + 1; | ||
634 | changed = true; | ||
635 | } | ||
636 | if (pos.X <= 0) | ||
637 | { | ||
638 | pos.X += posChange.X + 1; | ||
639 | changed = true; | ||
640 | } | ||
641 | if (pos.Y <= 0) | ||
642 | { | ||
643 | pos.Y += posChange.Y + 1; | ||
644 | changed = true; | ||
645 | } | ||
646 | if (changed) | ||
647 | { | ||
648 | m_prim.Position = pos; | ||
649 | VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", | ||
650 | m_prim.LocalID, m_BlockingEndPoint, posChange, pos); | ||
651 | } | ||
652 | } | 652 | } |
653 | 653 | ||
654 | float Zchange = Math.Abs(posChange.Z); | ||
654 | if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) | 655 | if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) |
655 | { | 656 | { |
656 | //Start Experimental Values | ||
657 | if (Zchange > .3) | 657 | if (Zchange > .3) |
658 | { | ||
659 | grav.Z = (float)(grav.Z * 3); | 658 | grav.Z = (float)(grav.Z * 3); |
660 | } | ||
661 | if (Zchange > .15) | 659 | if (Zchange > .15) |
662 | { | ||
663 | grav.Z = (float)(grav.Z * 2); | 660 | grav.Z = (float)(grav.Z * 2); |
664 | } | ||
665 | if (Zchange > .75) | 661 | if (Zchange > .75) |
666 | { | ||
667 | grav.Z = (float)(grav.Z * 1.5); | 662 | grav.Z = (float)(grav.Z * 1.5); |
668 | } | ||
669 | if (Zchange > .05) | 663 | if (Zchange > .05) |
670 | { | ||
671 | grav.Z = (float)(grav.Z * 1.25); | 664 | grav.Z = (float)(grav.Z * 1.25); |
672 | } | ||
673 | if (Zchange > .025) | 665 | if (Zchange > .025) |
674 | { | ||
675 | grav.Z = (float)(grav.Z * 1.125); | 666 | grav.Z = (float)(grav.Z * 1.125); |
676 | } | 667 | float postemp = (pos.Z - terrainHeight); |
677 | float terraintemp = m_prim.Scene.TerrainManager.GetTerrainHeightAtXYZ(pos); | ||
678 | float postemp = (pos.Z - terraintemp); | ||
679 | if (postemp > 2.5f) | 668 | if (postemp > 2.5f) |
680 | { | ||
681 | grav.Z = (float)(grav.Z * 1.037125); | 669 | grav.Z = (float)(grav.Z * 1.037125); |
682 | } | ||
683 | VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav); | 670 | VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav); |
684 | //End Experimental Values | ||
685 | } | 671 | } |
686 | if ((m_flags & (VehicleFlag.NO_X)) != 0) | 672 | if ((m_flags & (VehicleFlag.NO_X)) != 0) |
687 | { | 673 | m_newVelocity.X = 0; |
688 | m_dir.X = 0; | ||
689 | } | ||
690 | if ((m_flags & (VehicleFlag.NO_Y)) != 0) | 674 | if ((m_flags & (VehicleFlag.NO_Y)) != 0) |
691 | { | 675 | m_newVelocity.Y = 0; |
692 | m_dir.Y = 0; | ||
693 | } | ||
694 | if ((m_flags & (VehicleFlag.NO_Z)) != 0) | 676 | if ((m_flags & (VehicleFlag.NO_Z)) != 0) |
695 | { | 677 | m_newVelocity.Z = 0; |
696 | m_dir.Z = 0; | ||
697 | } | ||
698 | |||
699 | m_lastPositionVector = m_prim.Position; | ||
700 | 678 | ||
701 | // Apply velocity | 679 | // Apply velocity |
702 | m_prim.Velocity = m_dir; | 680 | m_prim.Velocity = m_newVelocity; |
703 | // apply gravity force | 681 | // apply gravity force |
704 | // Why is this set here? The physics engine already does gravity. | 682 | // Why is this set here? The physics engine already does gravity. |
705 | // m_prim.AddForce(grav, false); | 683 | // m_prim.AddForce(grav, false); |
706 | // m_prim.Force = grav; | ||
707 | 684 | ||
708 | // Apply friction | 685 | // Apply friction |
709 | Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep); | 686 | Vector3 keepFraction = Vector3.One - (Vector3.One / (m_linearFrictionTimescale / pTimestep)); |
710 | m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount; | 687 | m_lastLinearVelocityVector *= keepFraction; |
711 | 688 | ||
712 | VDetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}", | 689 | VDetailLog("{0},MoveLinear,done,lmDir={1},lmVel={2},newVel={3},grav={4},1Mdecay={5}", |
713 | m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount); | 690 | m_prim.LocalID, m_linearMotorDirection, m_lastLinearVelocityVector, m_newVelocity, grav, keepFraction); |
714 | 691 | ||
715 | } // end MoveLinear() | 692 | } // end MoveLinear() |
716 | 693 | ||
@@ -735,17 +712,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
735 | // There are m_angularMotorApply steps. | 712 | // There are m_angularMotorApply steps. |
736 | Vector3 origAngularVelocity = m_angularMotorVelocity; | 713 | Vector3 origAngularVelocity = m_angularMotorVelocity; |
737 | // ramp up to new value | 714 | // ramp up to new value |
738 | // current velocity += error / (time to get there / step interval) | 715 | // current velocity += error / ( time to get there / step interval) |
739 | // requested speed - last motor speed | 716 | // requested speed - last motor speed |
740 | m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); | 717 | m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); |
741 | m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); | 718 | m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); |
742 | m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); | 719 | m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); |
743 | 720 | ||
744 | VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}", | 721 | VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},angTScale={2},timeStep={3},origvel={4},dir={5},vel={6}", |
745 | m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); | 722 | m_prim.LocalID, m_angularMotorApply, m_angularMotorTimescale, pTimestep, origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); |
746 | 723 | ||
747 | m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected | 724 | // This is done so that if script request rate is less than phys frame rate the expected |
748 | // velocity may still be acheived. | 725 | // velocity may still be acheived. |
726 | m_angularMotorApply--; | ||
749 | } | 727 | } |
750 | else | 728 | else |
751 | { | 729 | { |
@@ -760,7 +738,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
760 | Vector3 vertattr = Vector3.Zero; | 738 | Vector3 vertattr = Vector3.Zero; |
761 | if (m_verticalAttractionTimescale < 300) | 739 | if (m_verticalAttractionTimescale < 300) |
762 | { | 740 | { |
763 | float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep); | 741 | float VAservo = 0.2f / (m_verticalAttractionTimescale / pTimestep); |
764 | // get present body rotation | 742 | // get present body rotation |
765 | Quaternion rotq = m_prim.Orientation; | 743 | Quaternion rotq = m_prim.Orientation; |
766 | // make a vector pointing up | 744 | // make a vector pointing up |
@@ -863,16 +841,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
863 | m_rot.Y = 0; | 841 | m_rot.Y = 0; |
864 | changed = true; | 842 | changed = true; |
865 | } | 843 | } |
866 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0) | ||
867 | { | ||
868 | m_rot.X = 0; | ||
869 | m_rot.Y = 0; | ||
870 | changed = true; | ||
871 | } | ||
872 | if (changed) | 844 | if (changed) |
845 | { | ||
873 | m_prim.Orientation = m_rot; | 846 | m_prim.Orientation = m_rot; |
847 | VDetailLog("{0},LimitRotation,done,orig={1},new={2}", m_prim.LocalID, rotq, m_rot); | ||
848 | } | ||
874 | 849 | ||
875 | VDetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot); | ||
876 | } | 850 | } |
877 | 851 | ||
878 | // Invoke the detailed logger and output something if it's enabled. | 852 | // Invoke the detailed logger and output something if it's enabled. |