diff options
author | Robert Adams | 2013-06-30 13:39:58 -0700 |
---|---|---|
committer | Robert Adams | 2013-06-30 17:07:49 -0700 |
commit | 23516717e48095011c1c06d64785ef7d91754ff2 (patch) | |
tree | 706e3cb958e94d0989d2546ef07a463dc7858ff9 /OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | |
parent | BulletSim: add inTaintTime parameter to collision cache clear function. (diff) | |
download | opensim-SC_OLD-23516717e48095011c1c06d64785ef7d91754ff2.zip opensim-SC_OLD-23516717e48095011c1c06d64785ef7d91754ff2.tar.gz opensim-SC_OLD-23516717e48095011c1c06d64785ef7d91754ff2.tar.bz2 opensim-SC_OLD-23516717e48095011c1c06d64785ef7d91754ff2.tar.xz |
BulletSim: a better version of llMoveToTarget that doesn't go crazy.
There is still some overshoot but mostly fixes Mantis 6693.
Fix bug where moveToTarget was active for non-physical objects
and while selected.
Fix bug where move target was not getting changed if the script
changed the target during a move.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs index ef662b5..1214703 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | |||
@@ -144,7 +144,6 @@ public class BSVMotor : BSMotor | |||
144 | 144 | ||
145 | Vector3 correction = Vector3.Zero; | 145 | Vector3 correction = Vector3.Zero; |
146 | Vector3 error = TargetValue - CurrentValue; | 146 | Vector3 error = TargetValue - CurrentValue; |
147 | LastError = error; | ||
148 | if (!ErrorIsZero(error)) | 147 | if (!ErrorIsZero(error)) |
149 | { | 148 | { |
150 | correction = StepError(timeStep, error); | 149 | correction = StepError(timeStep, error); |
@@ -179,6 +178,7 @@ public class BSVMotor : BSMotor | |||
179 | MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}", | 178 | MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}", |
180 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue); | 179 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue); |
181 | } | 180 | } |
181 | LastError = error; | ||
182 | 182 | ||
183 | return correction; | 183 | return correction; |
184 | } | 184 | } |
@@ -293,7 +293,6 @@ public class BSFMotor : BSMotor | |||
293 | 293 | ||
294 | float correction = 0f; | 294 | float correction = 0f; |
295 | float error = TargetValue - CurrentValue; | 295 | float error = TargetValue - CurrentValue; |
296 | LastError = error; | ||
297 | if (!ErrorIsZero(error)) | 296 | if (!ErrorIsZero(error)) |
298 | { | 297 | { |
299 | correction = StepError(timeStep, error); | 298 | correction = StepError(timeStep, error); |
@@ -328,6 +327,7 @@ public class BSFMotor : BSMotor | |||
328 | MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", | 327 | MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", |
329 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); | 328 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); |
330 | } | 329 | } |
330 | LastError = error; | ||
331 | 331 | ||
332 | return CurrentValue; | 332 | return CurrentValue; |
333 | } | 333 | } |
@@ -363,7 +363,7 @@ public class BSFMotor : BSMotor | |||
363 | 363 | ||
364 | // ============================================================================ | 364 | // ============================================================================ |
365 | // ============================================================================ | 365 | // ============================================================================ |
366 | // Proportional, Integral, Derivitive Motor | 366 | // Proportional, Integral, Derivitive ("PID") Motor |
367 | // Good description at http://www.answers.com/topic/pid-controller . Includes processes for choosing p, i and d factors. | 367 | // Good description at http://www.answers.com/topic/pid-controller . Includes processes for choosing p, i and d factors. |
368 | public class BSPIDVMotor : BSVMotor | 368 | public class BSPIDVMotor : BSVMotor |
369 | { | 369 | { |
@@ -434,15 +434,14 @@ public class BSPIDVMotor : BSVMotor | |||
434 | 434 | ||
435 | // A simple derivitive is the rate of change from the last error. | 435 | // A simple derivitive is the rate of change from the last error. |
436 | Vector3 derivitive = (error - LastError) * timeStep; | 436 | Vector3 derivitive = (error - LastError) * timeStep; |
437 | LastError = error; | ||
438 | 437 | ||
439 | // Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError) | 438 | // Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError) |
440 | Vector3 ret = error * timeStep * proportionFactor * FactorMix.X | 439 | Vector3 ret = error / TimeScale * timeStep * proportionFactor * FactorMix.X |
441 | + RunningIntegration * integralFactor * FactorMix.Y | 440 | + RunningIntegration / TimeScale * integralFactor * FactorMix.Y |
442 | + derivitive * derivFactor * FactorMix.Z | 441 | + derivitive / TimeScale * derivFactor * FactorMix.Z |
443 | ; | 442 | ; |
444 | 443 | ||
445 | MDetailLog("{0},BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", | 444 | MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", |
446 | BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); | 445 | BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); |
447 | 446 | ||
448 | return ret; | 447 | return ret; |