aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs147
1 files changed, 73 insertions, 74 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 65b38d6..4ba2f62 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -92,7 +92,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
92 private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate 92 private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate
93 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate 93 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
94 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body 94 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
95 // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body 95 private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body
96 96
97 //Deflection properties 97 //Deflection properties
98 // private float m_angularDeflectionEfficiency = 0; 98 // private float m_angularDeflectionEfficiency = 0;
@@ -138,74 +138,55 @@ namespace OpenSim.Region.Physics.BulletSPlugin
138 switch (pParam) 138 switch (pParam)
139 { 139 {
140 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: 140 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
141 if (pValue < 0.01f) pValue = 0.01f; 141 // m_angularDeflectionEfficiency = Math.Max(pValue, 0.01f);
142 // m_angularDeflectionEfficiency = pValue;
143 break; 142 break;
144 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: 143 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE:
145 if (pValue < 0.01f) pValue = 0.01f; 144 // m_angularDeflectionTimescale = Math.Max(pValue, 0.01f);
146 // m_angularDeflectionTimescale = pValue;
147 break; 145 break;
148 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: 146 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE:
149 if (pValue < 0.01f) pValue = 0.01f; 147 m_angularMotorDecayTimescale = Math.Max(pValue, 0.01f);
150 m_angularMotorDecayTimescale = pValue;
151 break; 148 break;
152 case Vehicle.ANGULAR_MOTOR_TIMESCALE: 149 case Vehicle.ANGULAR_MOTOR_TIMESCALE:
153 if (pValue < 0.01f) pValue = 0.01f; 150 m_angularMotorTimescale = Math.Max(pValue, 0.01f);
154 m_angularMotorTimescale = pValue;
155 break; 151 break;
156 case Vehicle.BANKING_EFFICIENCY: 152 case Vehicle.BANKING_EFFICIENCY:
157 if (pValue < 0.01f) pValue = 0.01f; 153 // m_bankingEfficiency = Math.Max(pValue, 0.01f);
158 // m_bankingEfficiency = pValue;
159 break; 154 break;
160 case Vehicle.BANKING_MIX: 155 case Vehicle.BANKING_MIX:
161 if (pValue < 0.01f) pValue = 0.01f; 156 // m_bankingMix = Math.Max(pValue, 0.01f);
162 // m_bankingMix = pValue;
163 break; 157 break;
164 case Vehicle.BANKING_TIMESCALE: 158 case Vehicle.BANKING_TIMESCALE:
165 if (pValue < 0.01f) pValue = 0.01f; 159 // m_bankingTimescale = Math.Max(pValue, 0.01f);
166 // m_bankingTimescale = pValue;
167 break; 160 break;
168 case Vehicle.BUOYANCY: 161 case Vehicle.BUOYANCY:
169 if (pValue < -1f) pValue = -1f; 162 m_VehicleBuoyancy = Math.Max(-1f, Math.Min(pValue, 1f));
170 if (pValue > 1f) pValue = 1f;
171 m_VehicleBuoyancy = pValue;
172 break; 163 break;
173// case Vehicle.HOVER_EFFICIENCY: 164// case Vehicle.HOVER_EFFICIENCY:
174// if (pValue < 0f) pValue = 0f; 165// m_VhoverEfficiency = Math.Max(0f, Math.Min(pValue, 1f));
175// if (pValue > 1f) pValue = 1f;
176// m_VhoverEfficiency = pValue;
177// break; 166// break;
178 case Vehicle.HOVER_HEIGHT: 167 case Vehicle.HOVER_HEIGHT:
179 m_VhoverHeight = pValue; 168 m_VhoverHeight = pValue;
180 break; 169 break;
181 case Vehicle.HOVER_TIMESCALE: 170 case Vehicle.HOVER_TIMESCALE:
182 if (pValue < 0.01f) pValue = 0.01f; 171 m_VhoverTimescale = Math.Max(pValue, 0.01f);
183 m_VhoverTimescale = pValue;
184 break; 172 break;
185 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: 173 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
186 if (pValue < 0.01f) pValue = 0.01f; 174 // m_linearDeflectionEfficiency = Math.Max(pValue, 0.01f);
187 // m_linearDeflectionEfficiency = pValue;
188 break; 175 break;
189 case Vehicle.LINEAR_DEFLECTION_TIMESCALE: 176 case Vehicle.LINEAR_DEFLECTION_TIMESCALE:
190 if (pValue < 0.01f) pValue = 0.01f; 177 // m_linearDeflectionTimescale = Math.Max(pValue, 0.01f);
191 // m_linearDeflectionTimescale = pValue;
192 break; 178 break;
193 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: 179 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
194 if (pValue < 0.01f) pValue = 0.01f; 180 m_linearMotorDecayTimescale = Math.Max(pValue, 0.01f);
195 m_linearMotorDecayTimescale = pValue;
196 break; 181 break;
197 case Vehicle.LINEAR_MOTOR_TIMESCALE: 182 case Vehicle.LINEAR_MOTOR_TIMESCALE:
198 if (pValue < 0.01f) pValue = 0.01f; 183 m_linearMotorTimescale = Math.Max(pValue, 0.01f);
199 m_linearMotorTimescale = pValue;
200 break; 184 break;
201 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: 185 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY:
202 if (pValue < 0.1f) pValue = 0.1f; // Less goes unstable 186 m_verticalAttractionEfficiency = Math.Max(0.1f, Math.Min(pValue, 1f));
203 if (pValue > 1.0f) pValue = 1.0f;
204 m_verticalAttractionEfficiency = pValue;
205 break; 187 break;
206 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: 188 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE:
207 if (pValue < 0.01f) pValue = 0.01f; 189 m_verticalAttractionTimescale = Math.Max(pValue, 0.01f);
208 m_verticalAttractionTimescale = pValue;
209 break; 190 break;
210 191
211 // These are vector properties but the engine lets you use a single float value to 192 // These are vector properties but the engine lets you use a single float value to
@@ -371,8 +352,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
371 // m_bankingMix = 1; 352 // m_bankingMix = 1;
372 // m_bankingTimescale = 1; 353 // m_bankingTimescale = 1;
373 // m_referenceFrame = Quaternion.Identity; 354 // m_referenceFrame = Quaternion.Identity;
374 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | 355 m_flags |= (VehicleFlag.NO_DEFLECTION_UP
375 VehicleFlag.LIMIT_MOTOR_UP); 356 | VehicleFlag.LIMIT_ROLL_ONLY
357 | VehicleFlag.LIMIT_MOTOR_UP);
376 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); 358 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
377 m_flags |= (VehicleFlag.HOVER_UP_ONLY); 359 m_flags |= (VehicleFlag.HOVER_UP_ONLY);
378 break; 360 break;
@@ -399,12 +381,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
399 // m_bankingMix = 0.8f; 381 // m_bankingMix = 0.8f;
400 // m_bankingTimescale = 1; 382 // m_bankingTimescale = 1;
401 // m_referenceFrame = Quaternion.Identity; 383 // m_referenceFrame = Quaternion.Identity;
402 m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | 384 m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY
403 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); 385 | VehicleFlag.HOVER_GLOBAL_HEIGHT
404 m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); 386 | VehicleFlag.LIMIT_ROLL_ONLY
405 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | 387 | VehicleFlag.HOVER_UP_ONLY);
406 VehicleFlag.LIMIT_MOTOR_UP); 388 m_flags |= (VehicleFlag.NO_DEFLECTION_UP
407 m_flags |= (VehicleFlag.HOVER_WATER_ONLY); 389 | VehicleFlag.LIMIT_MOTOR_UP
390 | VehicleFlag.HOVER_WATER_ONLY);
408 break; 391 break;
409 case Vehicle.TYPE_AIRPLANE: 392 case Vehicle.TYPE_AIRPLANE:
410 m_linearFrictionTimescale = new Vector3(200, 10, 5); 393 m_linearFrictionTimescale = new Vector3(200, 10, 5);
@@ -429,9 +412,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
429 // m_bankingMix = 0.7f; 412 // m_bankingMix = 0.7f;
430 // m_bankingTimescale = 2; 413 // m_bankingTimescale = 2;
431 // m_referenceFrame = Quaternion.Identity; 414 // m_referenceFrame = Quaternion.Identity;
432 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | 415 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY
433 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); 416 | VehicleFlag.HOVER_TERRAIN_ONLY
434 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); 417 | VehicleFlag.HOVER_GLOBAL_HEIGHT
418 | VehicleFlag.HOVER_UP_ONLY
419 | VehicleFlag.NO_DEFLECTION_UP
420 | VehicleFlag.LIMIT_MOTOR_UP);
435 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); 421 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
436 break; 422 break;
437 case Vehicle.TYPE_BALLOON: 423 case Vehicle.TYPE_BALLOON:
@@ -457,11 +443,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
457 // m_bankingMix = 0.7f; 443 // m_bankingMix = 0.7f;
458 // m_bankingTimescale = 5; 444 // m_bankingTimescale = 5;
459 // m_referenceFrame = Quaternion.Identity; 445 // m_referenceFrame = Quaternion.Identity;
460 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | 446 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY
461 VehicleFlag.HOVER_UP_ONLY); 447 | VehicleFlag.HOVER_TERRAIN_ONLY
462 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); 448 | VehicleFlag.HOVER_UP_ONLY
463 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); 449 | VehicleFlag.NO_DEFLECTION_UP
464 m_flags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT); 450 | VehicleFlag.LIMIT_MOTOR_UP);
451 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY
452 | VehicleFlag.HOVER_GLOBAL_HEIGHT);
465 break; 453 break;
466 } 454 }
467 }//end SetDefaultsForType 455 }//end SetDefaultsForType
@@ -470,7 +458,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
470 // Do any updating needed for a vehicle 458 // Do any updating needed for a vehicle
471 public void Refresh() 459 public void Refresh()
472 { 460 {
473 if (Type == Vehicle.TYPE_NONE) return; 461 if (!IsActive)
462 return;
474 463
475 // Set the prim's inertia to zero. The vehicle code handles that and this 464 // Set the prim's inertia to zero. The vehicle code handles that and this
476 // removes the torque action introduced by Bullet. 465 // removes the torque action introduced by Bullet.
@@ -489,7 +478,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
489 LimitRotation(pTimestep); 478 LimitRotation(pTimestep);
490 479
491 // remember the position so next step we can limit absolute movement effects 480 // remember the position so next step we can limit absolute movement effects
492 m_lastPositionVector = Prim.Position; 481 m_lastPositionVector = Prim.ForcePosition;
493 482
494 VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", 483 VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}",
495 Prim.LocalID, Prim.Position, Prim.Force, Prim.Velocity, Prim.RotationalVelocity); 484 Prim.LocalID, Prim.Position, Prim.Force, Prim.Velocity, Prim.RotationalVelocity);
@@ -543,7 +532,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
543 } 532 }
544 533
545 // convert requested object velocity to object relative vector 534 // convert requested object velocity to object relative vector
546 Quaternion rotq = Prim.Orientation; 535 Quaternion rotq = Prim.ForceOrientation;
547 m_newVelocity = m_lastLinearVelocityVector * rotq; 536 m_newVelocity = m_lastLinearVelocityVector * rotq;
548 537
549 // Add the various forces into m_dir which will be our new direction vector (velocity) 538 // Add the various forces into m_dir which will be our new direction vector (velocity)
@@ -560,19 +549,19 @@ namespace OpenSim.Region.Physics.BulletSPlugin
560 m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity 549 m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity
561 */ 550 */
562 551
563 Vector3 pos = Prim.Position; 552 Vector3 pos = Prim.ForcePosition;
564// 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); 553// 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);
565 554
566 // If below the terrain, move us above the ground a little. 555 // If below the terrain, move us above the ground a little.
567 float terrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos); 556 float terrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos);
568 // Taking the rotated size doesn't work here because m_prim.Size is the size of the root prim and not the linkset. 557 // Taking the rotated size doesn't work here because m_prim.Size is the size of the root prim and not the linkset.
569 // Need to add a m_prim.LinkSet.Size similar to m_prim.LinkSet.Mass. 558 // Need to add a m_prim.LinkSet.Size similar to m_prim.LinkSet.Mass.
570 // Vector3 rotatedSize = m_prim.Size * m_prim.Orientation; 559 // Vector3 rotatedSize = m_prim.Size * m_prim.ForceOrientation;
571 // if (rotatedSize.Z < terrainHeight) 560 // if (rotatedSize.Z < terrainHeight)
572 if (pos.Z < terrainHeight) 561 if (pos.Z < terrainHeight)
573 { 562 {
574 pos.Z = terrainHeight + 2; 563 pos.Z = terrainHeight + 2;
575 Prim.Position = pos; 564 Prim.ForcePosition = pos;
576 VDetailLog("{0},MoveLinear,terrainHeight,terrainHeight={1},pos={2}", Prim.LocalID, terrainHeight, pos); 565 VDetailLog("{0},MoveLinear,terrainHeight,terrainHeight={1},pos={2}", Prim.LocalID, terrainHeight, pos);
577 } 566 }
578 567
@@ -602,7 +591,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
602 { 591 {
603 if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) 592 if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2)
604 { 593 {
605 Prim.Position = pos; 594 Prim.ForcePosition = pos;
606 } 595 }
607 } 596 }
608 else 597 else
@@ -654,12 +643,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
654 } 643 }
655 if (changed) 644 if (changed)
656 { 645 {
657 Prim.Position = pos; 646 Prim.ForcePosition = pos;
658 VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", 647 VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}",
659 Prim.LocalID, m_BlockingEndPoint, posChange, pos); 648 Prim.LocalID, m_BlockingEndPoint, posChange, pos);
660 } 649 }
661 } 650 }
662 651
652 // Limit absolute vertical change
663 float Zchange = Math.Abs(posChange.Z); 653 float Zchange = Math.Abs(posChange.Z);
664 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) 654 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
665 { 655 {
@@ -678,6 +668,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
678 grav.Z = (float)(grav.Z * 1.037125); 668 grav.Z = (float)(grav.Z * 1.037125);
679 VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", Prim.LocalID, grav); 669 VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", Prim.LocalID, grav);
680 } 670 }
671
672 // If not changing some axis, reduce out velocity
681 if ((m_flags & (VehicleFlag.NO_X)) != 0) 673 if ((m_flags & (VehicleFlag.NO_X)) != 0)
682 m_newVelocity.X = 0; 674 m_newVelocity.X = 0;
683 if ((m_flags & (VehicleFlag.NO_Y)) != 0) 675 if ((m_flags & (VehicleFlag.NO_Y)) != 0)
@@ -720,19 +712,19 @@ namespace OpenSim.Region.Physics.BulletSPlugin
720 // a newly set velocity, this routine steps the value from the previous 712 // a newly set velocity, this routine steps the value from the previous
721 // value (m_angularMotorVelocity) to the requested value (m_angularMotorDirection). 713 // value (m_angularMotorVelocity) to the requested value (m_angularMotorDirection).
722 // There are m_angularMotorApply steps. 714 // There are m_angularMotorApply steps.
723 Vector3 origAngularVelocity = m_angularMotorVelocity; 715 Vector3 origVel = m_angularMotorVelocity;
716 Vector3 origDir = m_angularMotorDirection;
717
724 // ramp up to new value 718 // ramp up to new value
725 // current velocity += error / ( time to get there / step interval) 719 // new velocity += error / ( time to get there / step interval)
726 // requested speed - last motor speed 720 // requested speed - last motor speed
727 m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); 721 m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep);
728 m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); 722 m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep);
729 m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); 723 m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep);
730 724
731 VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},angTScale={2},timeStep={3},origvel={4},dir={5},vel={6}", 725 VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},angTScale={2},timeStep={3},origvel={4},origDir={5},vel={6}",
732 Prim.LocalID, m_angularMotorApply, m_angularMotorTimescale, pTimestep, origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); 726 Prim.LocalID, m_angularMotorApply, m_angularMotorTimescale, pTimestep, origVel, origDir, m_angularMotorVelocity);
733 727
734 // This is done so that if script request rate is less than phys frame rate the expected
735 // velocity may still be acheived.
736 m_angularMotorApply--; 728 m_angularMotorApply--;
737 } 729 }
738 else 730 else
@@ -746,25 +738,32 @@ namespace OpenSim.Region.Physics.BulletSPlugin
746 738
747 // Vertical attractor section 739 // Vertical attractor section
748 Vector3 vertattr = Vector3.Zero; 740 Vector3 vertattr = Vector3.Zero;
749 if (m_verticalAttractionTimescale < 300) 741 Vector3 deflection = Vector3.Zero;
742 Vector3 banking = Vector3.Zero;
743
744 if (m_verticalAttractionTimescale < 300 && m_lastAngularVelocity != Vector3.Zero)
750 { 745 {
751 float VAservo = 0.2f / (m_verticalAttractionTimescale / pTimestep); 746 float VAservo = 0.2f / (m_verticalAttractionTimescale / pTimestep);
747 VAservo *= (m_verticalAttractionEfficiency * m_verticalAttractionEfficiency);
748
752 // get present body rotation 749 // get present body rotation
753 Quaternion rotq = Prim.Orientation; 750 Quaternion rotq = Prim.ForceOrientation;
754 // make a vector pointing up 751 // vector pointing up
755 Vector3 verterr = Vector3.Zero; 752 Vector3 verterr = Vector3.Zero;
756 verterr.Z = 1.0f; 753 verterr.Z = 1.0f;
754
757 // rotate it to Body Angle 755 // rotate it to Body Angle
758 verterr = verterr * rotq; 756 verterr = verterr * rotq;
759 // verterr.X and .Y are the World error ammounts. They are 0 when there is no error (Vehicle Body is 'vertical'), and .Z will be 1. 757 // verterr.X and .Y are the World error amounts. They are 0 when there is no error (Vehicle Body is 'vertical'), and .Z will be 1.
760 // As the body leans to its side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall and .Z will go 758 // As the body leans to its side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall and .Z will go
761 // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body. 759 // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body.
760
761 // Error is 0 (no error) to +/- 2 (max error)
762 if (verterr.Z < 0.0f) 762 if (verterr.Z < 0.0f)
763 { 763 {
764 verterr.X = 2.0f - verterr.X; 764 verterr.X = 2.0f - verterr.X;
765 verterr.Y = 2.0f - verterr.Y; 765 verterr.Y = 2.0f - verterr.Y;
766 } 766 }
767 // Error is 0 (no error) to +/- 2 (max error)
768 // scale it by VAservo 767 // scale it by VAservo
769 verterr = verterr * VAservo; 768 verterr = verterr * VAservo;
770 769
@@ -784,7 +783,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
784 783
785 } // else vertical attractor is off 784 } // else vertical attractor is off
786 785
787 // m_lastVertAttractor = vertattr; 786 m_lastVertAttractor = vertattr;
788 787
789 // Bank section tba 788 // Bank section tba
790 789
@@ -818,7 +817,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
818 817
819 internal void LimitRotation(float timestep) 818 internal void LimitRotation(float timestep)
820 { 819 {
821 Quaternion rotq = Prim.Orientation; 820 Quaternion rotq = Prim.ForceOrientation;
822 Quaternion m_rot = rotq; 821 Quaternion m_rot = rotq;
823 bool changed = false; 822 bool changed = false;
824 if (m_RollreferenceFrame != Quaternion.Identity) 823 if (m_RollreferenceFrame != Quaternion.Identity)
@@ -853,7 +852,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
853 } 852 }
854 if (changed) 853 if (changed)
855 { 854 {
856 Prim.Orientation = m_rot; 855 Prim.ForceOrientation = m_rot;
857 VDetailLog("{0},LimitRotation,done,orig={1},new={2}", Prim.LocalID, rotq, m_rot); 856 VDetailLog("{0},LimitRotation,done,orig={1},new={2}", Prim.LocalID, rotq, m_rot);
858 } 857 }
859 858